Skip to content

Commit

Permalink
CLIENT-GAME: Fix escape key handling
Browse files Browse the repository at this point in the history
PATCH
  • Loading branch information
romainpanno committed Nov 5, 2023
1 parent 4596392 commit 38ef77b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Client/Systems/Menus/Menu/MenuSystems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,23 @@ namespace Systems {

void quitScene(std::size_t /*unused*/, std::size_t /*unused*/)
{
static std::size_t clockId = Registry::getInstance().getClock().create();

if (Raylib::KeyboardInput::isKeyPressed(Raylib::KeyboardKey::KB_ESCAPE)) {
if (Registry::getInstance().getClock().elapsedMillisecondsSince(clockId) < 300) {
return;
}
Registry::getInstance().getClock().restart(clockId);
switch (Scene::SceneManager::getInstance().getCurrentScene()) {
case MENU: Scene::SceneManager::getInstance().stop(); break;
case MENU: Logger::fatal("in menu"); Scene::SceneManager::getInstance().stop(); break;
case CREATE_LOBBY_SCENE:
Logger::fatal("in select create lobby");
Scene::SceneManager::getInstance().changeScene(SELECT_LOBBY);
break;
case SELECT_LOBBY: Scene::SceneManager::getInstance().changeScene(MENU); break;
case CREATE_SERVER_SCENE: Scene::SceneManager::getInstance().changeScene(MENU); break;
case SELECT_LOBBY: Logger::fatal("in select lobby"); Scene::SceneManager::getInstance().changeScene(MENU); break;
case CREATE_SERVER_SCENE: Logger::fatal("in create server"); Scene::SceneManager::getInstance().changeScene(MENU); break;
case GAME:
Logger::fatal("in game");
Nitwork::NitworkClient::getInstance().disconnectLobby();
Types::WaveInfos::getInstance().reset();
Scene::SceneManager::getInstance().changeScene(SELECT_LOBBY);
Expand Down

0 comments on commit 38ef77b

Please sign in to comment.