This commit is contained in:
2025-03-19 18:19:35 +01:00
parent c85b335478
commit db921e3390
2 changed files with 31 additions and 35 deletions

View File

@@ -5,9 +5,9 @@
#include <random> #include <random>
#include <string> #include <string>
#define DISABLED_COND(code, cond) \ #define DISABLED_COND(cond, code...) \
{ \ { \
bool Disabled = cond; \ bool Disabled = (cond); \
if (Disabled) \ if (Disabled) \
ImGui::BeginDisabled(); \ ImGui::BeginDisabled(); \
code if (Disabled) ImGui::EndDisabled(); \ code if (Disabled) ImGui::EndDisabled(); \
@@ -65,11 +65,10 @@ static void RenderGameWindow() {
ImGui::Text("Quelle est la note ?"); ImGui::Text("Quelle est la note ?");
DISABLED_COND( DISABLED_COND(
if (ImGui::Button("Réécouter")) { !Hint, if (ImGui::Button("Réécouter")) {
audio::PlayNote(Answer); audio::PlayNote(Answer);
Hint = false; Hint = false;
}, })
!Hint)
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button("Voir la réponse")) { if (ImGui::Button("Voir la réponse")) {
@@ -84,10 +83,8 @@ static void RenderGameWindow() {
Right = false; Right = false;
} }
if (Cooldown > 0.0) DISABLED_COND(
ImGui::BeginDisabled(); Cooldown > 0.0f, for (int i = 0; i < NoteCount; i++) {
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}; 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); ImGui::PushStyleColor(ImGuiCol_Button, color);
bool green = (ShowAnswer && i == Answer); bool green = (ShowAnswer && i == Answer);
@@ -107,10 +104,7 @@ static void RenderGameWindow() {
ImGui::PopStyleColor(); ImGui::PopStyleColor();
ImGui::PopStyleColor(); ImGui::PopStyleColor();
ImGui::SameLine(); ImGui::SameLine();
} })
if (Cooldown > 0.0)
ImGui::EndDisabled();
} }
static void RenderMainWindow() { static void RenderMainWindow() {
@@ -118,7 +112,9 @@ static void RenderMainWindow() {
InGame = true; InGame = true;
Right = true; Right = true;
} }
if (ImGui::Button("Quitter")) {} if (ImGui::Button("Quitter")) {
// TODO
}
} }
void Render() { void Render() {

View File

@@ -1,15 +1,15 @@
add_rules("mode.debug", "mode.release") add_rules("mode.debug", "mode.release")
add_requires("libsdl") add_requires("libsdl2 2.30.10")
add_requires("libsdl_mixer", {system = true}) add_requires("libsdl2_mixer 2.8.1")
add_requires("imgui", {configs = {sdl2 = true, opengl3 = true}}) add_requires("imgui v1.91.8", {configs = {sdl2 = true, opengl3 = true}})
target("PerfectHear") target("PerfectHear")
set_kind("binary") set_kind("binary")
add_files("src/*.cpp") add_files("src/*.cpp")
add_includedirs("include") add_includedirs("include")
add_packages("libsdl", "libsdl_mixer", "imgui") add_packages("libsdl2", "libsdl2_mixer", "imgui")
if is_os("windows") then if is_os("windows") then
add_ldflags("-static") add_ldflags("-static")