Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/frontend/StarMainInterface.cpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2024-02-22 17:38:47 +1100
committerKae <80987908+Novaenia@users.noreply.github.com>2024-02-22 17:38:47 +1100
commit7d9c9d3b32bd0eef5115a1ba02aa8939f292b212 (patch)
tree2c452002d4963fafaa4426ab7fa95ef36783f0d3 /source/frontend/StarMainInterface.cpp
parent9485aff8b83bfab642b8f99581b3c6d85778e5a2 (diff)
move oddly placed player input code
Diffstat (limited to 'source/frontend/StarMainInterface.cpp')
-rw-r--r--source/frontend/StarMainInterface.cpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/source/frontend/StarMainInterface.cpp b/source/frontend/StarMainInterface.cpp
index 21cba33..aa06dc7 100644
--- a/source/frontend/StarMainInterface.cpp
+++ b/source/frontend/StarMainInterface.cpp
@@ -345,12 +345,18 @@ bool MainInterface::handleInputEvent(InputEvent const& event) {
return false;
} else if (auto mouseDown = event.ptr<MouseButtonDownEvent>()) {
- if (mouseDown->mouseButton == MouseButton::Left || mouseDown->mouseButton == MouseButton::Right
- || mouseDown->mouseButton == MouseButton::Middle)
- return overlayClick(mouseDown->mousePosition, mouseDown->mouseButton);
- else
- return false;
-
+ auto mouseButton = mouseDown->mouseButton;
+ if (mouseButton >= MouseButton::Left && mouseButton <= MouseButton::Right
+ && overlayClick(mouseDown->mousePosition, mouseDown->mouseButton)) {
+ return true;
+ } else {
+ if (mouseButton == MouseButton::Left)
+ player->beginPrimaryFire();
+ if (mouseButton == MouseButton::Right)
+ player->beginAltFire();
+ if (mouseButton == MouseButton::Middle)
+ player->beginTrigger();
+ }
} else if (auto mouseUp = event.ptr<MouseButtonUpEvent>()) {
if (mouseUp->mouseButton == MouseButton::Left)
player->endPrimaryFire();
@@ -360,10 +366,12 @@ bool MainInterface::handleInputEvent(InputEvent const& event) {
player->endTrigger();
}
+ bool captured = false;
+
for (auto& pair : m_canvases)
- pair.second->sendEvent(event);
+ captured |= pair.second->sendEvent(event);
- return true;
+ return captured;
}
bool MainInterface::inputFocus() const {
@@ -1558,13 +1566,6 @@ bool MainInterface::overlayClick(Vec2I const& mousePos, MouseButton mouseButton)
return true;
}
- if (mouseButton == MouseButton::Left)
- m_client->mainPlayer()->beginPrimaryFire();
- if (mouseButton == MouseButton::Right)
- m_client->mainPlayer()->beginAltFire();
- if (mouseButton == MouseButton::Middle)
- m_client->mainPlayer()->beginTrigger();
-
return false;
}