diff options
| author | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2021-10-31 15:57:44 +0700 |
|---|---|---|
| committer | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2021-10-31 15:57:44 +0700 |
| commit | a5ce40c28821b738dda4abfb2c174b028aa58e5d (patch) | |
| tree | 8de11819d4399e85d7ca0bf766614cfdf224656e /src/GameTick.cpp | |
| parent | daa4b6c673d3327a5c64e2bd180bb02593eb8c81 (diff) | |
| download | blackshades-a5ce40c28821b738dda4abfb2c174b028aa58e5d.tar.gz | |
Restore menu buttons behavior
Diffstat (limited to 'src/GameTick.cpp')
| -rw-r--r-- | src/GameTick.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
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; } |
