From a5ce40c28821b738dda4abfb2c174b028aa58e5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Gia=20Phong?= Date: Sun, 31 Oct 2021 15:57:44 +0700 Subject: Restore menu buttons behavior --- src/GameTick.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/GameTick.cpp') diff --git a/src/GameTick.cpp b/src/GameTick.cpp index 4182c71..9630a1b 100644 --- a/src/GameTick.cpp +++ b/src/GameTick.cpp @@ -108,7 +108,7 @@ void Game::updateSong() void click(Game* game, int button, int action, int mods) { if (game->menu) { - if (button != GLFW_MOUSE_BUTTON_LEFT || action != GLFW_PRESS) + if (button != GLFW_MOUSE_BUTTON_LEFT) return; double xpos, ypos; auto window = glfwGetCurrentContext(); @@ -116,12 +116,18 @@ void click(Game* game, int button, int action, int mods) double mousex = xpos * 640 / game->screenwidth; double mousey = 480 - ypos * 480 / game->screenheight; - game->mouseoverbutton = 0; + auto button = 0; if (mousex > 120 && mousex < 560) { if (mousey > 235 && mousey < 305) - game->mouseoverbutton = 1; + button = 1; else if (mousey > 112 && mousey < 182) - game->mouseoverbutton = 2; + button = 2; + } + if (action == GLFW_PRESS) { + game->mouseoverbutton = button; + return; + } else if (button != game->mouseoverbutton) { + game->mouseoverbutton = 0; } switch (game->mouseoverbutton) { @@ -156,6 +162,7 @@ void click(Game* game, int button, int action, int mods) alSourcePlay(gSourceID[losesound]); break; } + game->mouseoverbutton = 0; return; } -- cgit v1.2.3