Compare commits

...

5 Commits

Author SHA1 Message Date
e2a787ab2f fix variadic macro 2025-03-29 16:53:51 +01:00
7ecd47f20c make text bigger 2025-03-29 16:49:45 +01:00
095dbfb0b9 static for mingw only 2025-03-29 16:47:23 +01:00
2f0c9ad012 make quit button useful 2025-03-29 16:46:57 +01:00
6fa0475acf remove implicit libsdl2 require 2025-03-29 16:34:19 +01:00
4 changed files with 21 additions and 12 deletions

View File

@@ -3,7 +3,7 @@
namespace ph { namespace ph {
namespace gui { namespace gui {
void Render(); bool Render();
void Init(); void Init();
} // namespace gui } // namespace gui

View File

@@ -5,12 +5,12 @@
#include <random> #include <random>
#include <string> #include <string>
#define DISABLED_COND(cond, code...) \ #define DISABLED_COND(cond, ...) \
{ \ { \
bool Disabled = (cond); \ bool Disabled = (cond); \
if (Disabled) \ if (Disabled) \
ImGui::BeginDisabled(); \ ImGui::BeginDisabled(); \
code if (Disabled) ImGui::EndDisabled(); \ __VA_ARGS__ if (Disabled) ImGui::EndDisabled(); \
} }
@@ -107,24 +107,29 @@ static void RenderGameWindow() {
}) })
} }
static void RenderMainWindow() { static bool RenderMainWindow() {
if (ImGui::Button("Nouvelle Partie")) { if (ImGui::Button("Nouvelle Partie")) {
InGame = true; InGame = true;
Right = true; Right = true;
} }
if (ImGui::Button("Quitter")) { if (ImGui::Button("Quitter")) {
// TODO return false;
} }
return true;
} }
void Render() { bool Render() {
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
ImGui::SetNextWindowPos(ImVec2(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.5f), ImGuiCond_Always, ImVec2(0.5f, 0.5f)); ImGui::SetNextWindowPos(ImVec2(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.5f), ImGuiCond_Always, ImVec2(0.5f, 0.5f));
ImGui::Begin("MainWindow", nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoDecoration); ImGui::Begin("MainWindow", nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoDecoration);
if (InGame) if (InGame)
RenderGameWindow(); RenderGameWindow();
else else {
RenderMainWindow(); if (!RenderMainWindow()) {
ImGui::End();
return false;
}
}
if (Cooldown > 0.0f) { if (Cooldown > 0.0f) {
ImGui::NewLine(); ImGui::NewLine();
@@ -139,6 +144,8 @@ void Render() {
#ifndef NDEBUG #ifndef NDEBUG
ImGui::ShowDemoWindow(); ImGui::ShowDemoWindow();
#endif #endif
return true;
} }
void Init() {} void Init() {}

View File

@@ -102,7 +102,7 @@ int main(int, char**) {
// io.Fonts->GetGlyphRangesJapanese()); IM_ASSERT(font != nullptr); // io.Fonts->GetGlyphRangesJapanese()); IM_ASSERT(font != nullptr);
ImFontConfig cfg; ImFontConfig cfg;
cfg.SizePixels = 30; cfg.SizePixels = 40;
io.Fonts->AddFontDefault(&cfg); io.Fonts->AddFontDefault(&cfg);
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
@@ -146,7 +146,10 @@ int main(int, char**) {
ImGui_ImplSDL2_NewFrame(); ImGui_ImplSDL2_NewFrame();
ImGui::NewFrame(); ImGui::NewFrame();
ph::gui::Render(); if (!done && !ph::gui::Render()) {
done = true;
}
// Rendering // Rendering
ImGui::Render(); ImGui::Render();

View File

@@ -1,6 +1,5 @@
add_rules("mode.debug", "mode.release") add_rules("mode.debug", "mode.release")
add_requires("libsdl2 2.30.10")
add_requires("libsdl2_mixer 2.8.1") add_requires("libsdl2_mixer 2.8.1")
add_requires("imgui v1.91.8", {configs = {sdl2 = true, opengl3 = true}}) add_requires("imgui v1.91.8", {configs = {sdl2 = true, opengl3 = true}})
@@ -11,6 +10,6 @@ target("PerfectHear")
add_packages("libsdl2", "libsdl2_mixer", "imgui") add_packages("libsdl2", "libsdl2_mixer", "imgui")
if is_os("windows") then if is_plat("mingw") then
add_ldflags("-static") add_ldflags("-static")
end end