move oddly placed player input code

This commit is contained in:
Kae 2024-02-22 17:38:47 +11:00
parent 9485aff8b8
commit 7d9c9d3b32

View File

@ -345,12 +345,18 @@ bool MainInterface::handleInputEvent(InputEvent const& event) {
return false; return false;
} else if (auto mouseDown = event.ptr<MouseButtonDownEvent>()) { } else if (auto mouseDown = event.ptr<MouseButtonDownEvent>()) {
if (mouseDown->mouseButton == MouseButton::Left || mouseDown->mouseButton == MouseButton::Right auto mouseButton = mouseDown->mouseButton;
|| mouseDown->mouseButton == MouseButton::Middle) if (mouseButton >= MouseButton::Left && mouseButton <= MouseButton::Right
return overlayClick(mouseDown->mousePosition, mouseDown->mouseButton); && overlayClick(mouseDown->mousePosition, mouseDown->mouseButton)) {
else return true;
return false; } 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>()) { } else if (auto mouseUp = event.ptr<MouseButtonUpEvent>()) {
if (mouseUp->mouseButton == MouseButton::Left) if (mouseUp->mouseButton == MouseButton::Left)
player->endPrimaryFire(); player->endPrimaryFire();
@ -360,10 +366,12 @@ bool MainInterface::handleInputEvent(InputEvent const& event) {
player->endTrigger(); player->endTrigger();
} }
for (auto& pair : m_canvases) bool captured = false;
pair.second->sendEvent(event);
return true; for (auto& pair : m_canvases)
captured |= pair.second->sendEvent(event);
return captured;
} }
bool MainInterface::inputFocus() const { bool MainInterface::inputFocus() const {
@ -1558,13 +1566,6 @@ bool MainInterface::overlayClick(Vec2I const& mousePos, MouseButton mouseButton)
return true; 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; return false;
} }