diff --git a/sources/Runner/Runner.cpp b/sources/Runner/Runner.cpp index 65b3d118..e455e30a 100644 --- a/sources/Runner/Runner.cpp +++ b/sources/Runner/Runner.cpp @@ -48,12 +48,21 @@ namespace BBM void Runner::updateState(WAL::Wal &engine, GameState &state) { + auto &view = engine.scene->view(); // You can change the scene here or update the game state based on entities values. // If you want to keep a scene loaded but not running, store it in the state.loadedScenes. // If you don't need the scene anymore, remember to remove it from the loadedScene array. if (RAY::Window::getInstance().shouldClose()) engine.shouldClose = true; + if (gameState.currentScene == GameState::SceneID::GameScene) { + for (auto &[_, component]: view) { + if (component.pause) { + gameState.nextScene = GameState::SceneID::PauseMenuScene; + break; + } + } + } if (gameState.nextScene == gameState.currentScene) return; gameState._loadedScenes[gameState.currentScene] = engine.scene; diff --git a/sources/System/MenuControllable/MenuControllableSystem.cpp b/sources/System/MenuControllable/MenuControllableSystem.cpp index e0fbe28d..81fff19e 100644 --- a/sources/System/MenuControllable/MenuControllableSystem.cpp +++ b/sources/System/MenuControllable/MenuControllableSystem.cpp @@ -33,7 +33,7 @@ namespace BBM { auto lastTick = std::chrono::steady_clock::now(); auto &controllable = entity.get(); - auto &buttons = _wal.scene->view(); + auto &buttons = _wal.scene->view(); if (lastTick - this->_now < std::chrono::milliseconds(100)) return; @@ -48,14 +48,14 @@ namespace BBM if (!currentButton) return; this->updateCurrentButton(); - for (auto &[buttonEntity, clickComponent]: buttons) { + for (auto &[buttonEntity, clickComponent, hoverComponent, idleComponent]: buttons) { if (buttonEntity == *currentButton) { - buttonEntity.getComponent().onEvent(buttonEntity, wal); + hoverComponent.onEvent(buttonEntity, wal); if (select) clickComponent.onEvent(buttonEntity, wal); continue; } - buttonEntity.getComponent().onEvent(buttonEntity, wal); + idleComponent.onEvent(buttonEntity, wal); } }