From db921e33904d32bb20a2a14cbeb7408161af9828 Mon Sep 17 00:00:00 2001 From: Persson-dev Date: Wed, 19 Mar 2025 18:19:35 +0100 Subject: [PATCH] fix deps --- src/PhGui.cpp | 58 ++++++++++++++++++++++++--------------------------- xmake.lua | 8 +++---- 2 files changed, 31 insertions(+), 35 deletions(-) diff --git a/src/PhGui.cpp b/src/PhGui.cpp index 731f1f9..c088c07 100644 --- a/src/PhGui.cpp +++ b/src/PhGui.cpp @@ -5,9 +5,9 @@ #include #include -#define DISABLED_COND(code, cond) \ +#define DISABLED_COND(cond, code...) \ { \ - bool Disabled = cond; \ + bool Disabled = (cond); \ if (Disabled) \ ImGui::BeginDisabled(); \ code if (Disabled) ImGui::EndDisabled(); \ @@ -65,11 +65,10 @@ static void RenderGameWindow() { ImGui::Text("Quelle est la note ?"); DISABLED_COND( - if (ImGui::Button("Réécouter")) { + !Hint, if (ImGui::Button("Réécouter")) { audio::PlayNote(Answer); Hint = false; - }, - !Hint) + }) ImGui::SameLine(); if (ImGui::Button("Voir la réponse")) { @@ -84,33 +83,28 @@ static void RenderGameWindow() { Right = false; } - if (Cooldown > 0.0) - ImGui::BeginDisabled(); - - for (int i = 0; i < NoteCount; i++) { - ImVec4 color = (i == Ab || i == Bb || i == Db || i == Eb || i == Gb) ? ImVec4{0, 0, 0, 1} : ImVec4{0.5, .5, .5, 1}; - ImGui::PushStyleColor(ImGuiCol_Button, color); - bool green = (ShowAnswer && i == Answer); - if (green) - ImGui::PushStyleColor(ImGuiCol_Button, {0, 1, 0, 1}); - if (ImGui::Button(Notes[i].c_str())) { - Cooldown = audio::NoteDuration(); - Right = (i == Answer); - if (Right && !ShowAnswer) { - audio::PlayNote(Answer); - Score++; - } else { - Score = 0; + DISABLED_COND( + Cooldown > 0.0f, for (int i = 0; i < NoteCount; i++) { + ImVec4 color = (i == Ab || i == Bb || i == Db || i == Eb || i == Gb) ? ImVec4{0, 0, 0, 1} : ImVec4{0.5, .5, .5, 1}; + ImGui::PushStyleColor(ImGuiCol_Button, color); + bool green = (ShowAnswer && i == Answer); + if (green) + ImGui::PushStyleColor(ImGuiCol_Button, {0, 1, 0, 1}); + if (ImGui::Button(Notes[i].c_str())) { + Cooldown = audio::NoteDuration(); + Right = (i == Answer); + if (Right && !ShowAnswer) { + audio::PlayNote(Answer); + Score++; + } else { + Score = 0; + } } - } - if (green) + if (green) + ImGui::PopStyleColor(); ImGui::PopStyleColor(); - ImGui::PopStyleColor(); - ImGui::SameLine(); - } - - if (Cooldown > 0.0) - ImGui::EndDisabled(); + ImGui::SameLine(); + }) } static void RenderMainWindow() { @@ -118,7 +112,9 @@ static void RenderMainWindow() { InGame = true; Right = true; } - if (ImGui::Button("Quitter")) {} + if (ImGui::Button("Quitter")) { + // TODO + } } void Render() { diff --git a/xmake.lua b/xmake.lua index 243de8f..fd06670 100644 --- a/xmake.lua +++ b/xmake.lua @@ -1,15 +1,15 @@ add_rules("mode.debug", "mode.release") -add_requires("libsdl") -add_requires("libsdl_mixer", {system = true}) -add_requires("imgui", {configs = {sdl2 = true, opengl3 = true}}) +add_requires("libsdl2 2.30.10") +add_requires("libsdl2_mixer 2.8.1") +add_requires("imgui v1.91.8", {configs = {sdl2 = true, opengl3 = true}}) target("PerfectHear") set_kind("binary") add_files("src/*.cpp") add_includedirs("include") - add_packages("libsdl", "libsdl_mixer", "imgui") + add_packages("libsdl2", "libsdl2_mixer", "imgui") if is_os("windows") then add_ldflags("-static")