From 0e9c124d6ee480e20be07f955dd0ffe486091a1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Gia=20Phong?= Date: Tue, 14 Sep 2021 23:58:50 +0700 Subject: Force menu and hardware cursor --- src/GameLoop.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/GameLoop.cpp') diff --git a/src/GameLoop.cpp b/src/GameLoop.cpp index 1691157..a927f2f 100644 --- a/src/GameLoop.cpp +++ b/src/GameLoop.cpp @@ -39,16 +39,16 @@ void handleKey(Game* game, int key, int action, int mods) { if (action != GLFW_PRESS) return; - if (game->mainmenu) { + if (game->menu) { if (key == GLFW_KEY_SPACE) - game->mainmenu = 0; + setMenu(game, false); return; } auto& player = game->person[0]; if (key == GLFW_KEY_ESCAPE) { alSourcePause(gSourceID[rainsound]); - game->mainmenu = 1; + setMenu(game, true); alSourcePlay(gSourceID[souloutsound]); game->flashamount = 1.0f; game->flashr = game->flashg = game->flashb = 1.0f; @@ -198,6 +198,12 @@ void handleKey(Game* game, int key, int action, int mods) } } +void setMenu(Game* game, bool val) +{ + glfwSetInputMode(glfwGetCurrentContext(), GLFW_CURSOR, + (game->menu = val) ? GLFW_CURSOR_NORMAL : GLFW_CURSOR_DISABLED); +} + void eventLoop(Game* game) { auto start = glfwGetTime(); @@ -206,7 +212,7 @@ void eventLoop(Game* game) do multiplier = glfwGetTime() - start; while (multiplier < 1.0f / 69); - if (visions == 1 && !game->mainmenu) + if (visions == 1 && !game->menu) multiplier /= 3; if (slomo) multiplier /= 5; -- cgit v1.2.3