diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/inventory.cpp | 2 | ||||
-rw-r--r-- | src/systems/dialog.cpp | 16 | ||||
-rw-r--r-- | src/ui.cpp | 4 | ||||
-rw-r--r-- | src/ui_menu.cpp | 18 |
4 files changed, 24 insertions, 16 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp index b96d5cf..1fdaf63 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -251,7 +251,7 @@ bool InventorySystem::receive(const MouseClickEvent &mce) game::events.emit<UseItemEvent>(mce.position, items[0].item, &attack->second); } } - return false; + return true; } bool InventorySystem::receive(const MouseReleaseEvent &mre) diff --git a/src/systems/dialog.cpp b/src/systems/dialog.cpp index ee7c834..f4f479f 100644 --- a/src/systems/dialog.cpp +++ b/src/systems/dialog.cpp @@ -27,15 +27,17 @@ void DialogSystem::configure(entityx::EventManager &ev) bool DialogSystem::receive(const MouseClickEvent &mce) { + static bool continueEvent; + + continueEvent = true; game::entities.each<Position, Solid, Dialog, Name>( [&](entityx::Entity e, Position &pos, Solid &dim, Dialog &d, Name &name) { static std::atomic_bool dialogRun; - (void)e; - (void)d; if (((mce.position.x > pos.x) & (mce.position.x < pos.x + dim.width)) && ((mce.position.y > pos.y) & (mce.position.y < pos.y + dim.height))) { + continueEvent = false; e.replace<Flash>(Color(0, 255, 255)); if (!dialogRun.load()) { @@ -141,10 +143,12 @@ bool DialogSystem::receive(const MouseClickEvent &mce) d.talking = false; dialogRun.store(false); }).detach(); - } - } - }); - return false; + } // dialogRun check + + } // mouse check + } // .each + ); + return continueEvent; } void DialogSystem::update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt) @@ -665,11 +665,11 @@ bool InputSystem::receive(const MainSDLEvent& event) break; case SDL_MOUSEBUTTONDOWN: - ev.emit<MouseClickEvent>(mouse, e.button.button); - if (UISystem::isDialog() || pageTexReady) { if ((e.button.button & SDL_BUTTON_RIGHT)) UISystem::advanceDialog(); + } else { + ev.emit<MouseClickEvent>(mouse, e.button.button); } break; diff --git a/src/ui_menu.cpp b/src/ui_menu.cpp index a48182b..fd316ce 100644 --- a/src/ui_menu.cpp +++ b/src/ui_menu.cpp @@ -13,19 +13,19 @@ static Menu* currentMenu = nullptr; bool SDLReceiver::receive(const MainSDLEvent& mse) { + if (currentMenu == nullptr) + return true; + switch (mse.event.type) { case SDL_QUIT: game::endGame(); - return true; - break; - case SDL_MOUSEMOTION: - //ui::premouse.x = e.motion.x; - //ui::premouse.y = e.motion.y; break; case SDL_MOUSEBUTTONUP: if (mse.event.button.button & SDL_BUTTON_LEFT) clicked = true; - break; + break; + case SDL_MOUSEBUTTONDOWN: + break; // consume events case SDL_KEYUP: if (currentMenu != nullptr && mse.event.key.keysym.sym == SDLK_ESCAPE) { currentMenu->gotoParent(); @@ -33,10 +33,14 @@ bool SDLReceiver::receive(const MainSDLEvent& mse) clicked = false; } break; + case SDL_KEYDOWN: + break; // consume events default: + return true; break; } - return true; + + return false; } bool SDLReceiver::clicked = false; |