diff --git a/src/openrct2-ui/UiContext.cpp b/src/openrct2-ui/UiContext.cpp index 319e9de9a7..ed3924fd73 100644 --- a/src/openrct2-ui/UiContext.cpp +++ b/src/openrct2-ui/UiContext.cpp @@ -439,7 +439,7 @@ public: ie.modifiers = SDL_GetModState(); ie.button = e.button.button; ie.state = InputEventState::down; - _inputManager.QueueInputEvent(std::move(ie)); + _inputManager.queueInputEvent(std::move(ie)); } break; } @@ -475,7 +475,7 @@ public: ie.modifiers = SDL_GetModState(); ie.button = e.button.button; ie.state = InputEventState::release; - _inputManager.QueueInputEvent(std::move(ie)); + _inputManager.queueInputEvent(std::move(ie)); } break; } @@ -545,14 +545,14 @@ public: _textComposition.HandleMessage(&e); auto ie = GetInputEventFromSDLEvent(e); ie.state = InputEventState::down; - _inputManager.QueueInputEvent(std::move(ie)); + _inputManager.queueInputEvent(std::move(ie)); break; } case SDL_KEYUP: { auto ie = GetInputEventFromSDLEvent(e); ie.state = InputEventState::release; - _inputManager.QueueInputEvent(std::move(ie)); + _inputManager.queueInputEvent(std::move(ie)); break; } case SDL_MULTIGESTURE: @@ -583,7 +583,7 @@ public: break; default: { - _inputManager.QueueInputEvent(e); + _inputManager.queueInputEvent(e); break; } } diff --git a/src/openrct2-ui/WindowManager.cpp b/src/openrct2-ui/WindowManager.cpp index 382f7798d3..678ce8630f 100644 --- a/src/openrct2-ui/WindowManager.cpp +++ b/src/openrct2-ui/WindowManager.cpp @@ -615,7 +615,7 @@ public: void HandleKeyboard(bool isTitle) override { auto& inputManager = GetInputManager(); - inputManager.Process(); + inputManager.process(); } std::string GetKeyboardShortcutString(std::string_view shortcutId) override diff --git a/src/openrct2-ui/input/InputManager.cpp b/src/openrct2-ui/input/InputManager.cpp index 02a0b43243..6da38dd5b8 100644 --- a/src/openrct2-ui/input/InputManager.cpp +++ b/src/openrct2-ui/input/InputManager.cpp @@ -37,7 +37,7 @@ InputManager::InputManager() _modifierKeyState = EnumValue(ModifierKey::none); } -void InputManager::QueueInputEvent(const SDL_Event& e) +void InputManager::queueInputEvent(const SDL_Event& e) { switch (e.type) { @@ -53,7 +53,7 @@ void InputManager::QueueInputEvent(const SDL_Event& e) ie.button = e.caxis.axis; ie.state = InputEventState::down; ie.axisValue = e.caxis.value; - QueueInputEvent(std::move(ie)); + queueInputEvent(std::move(ie)); } break; } @@ -67,7 +67,7 @@ void InputManager::QueueInputEvent(const SDL_Event& e) ie.button = e.jhat.value; ie.state = InputEventState::down; ie.axisValue = 0; - QueueInputEvent(std::move(ie)); + queueInputEvent(std::move(ie)); } break; } @@ -80,7 +80,7 @@ void InputManager::QueueInputEvent(const SDL_Event& e) ie.button = e.cbutton.button; ie.state = InputEventState::down; ie.axisValue = 0; - QueueInputEvent(std::move(ie)); + queueInputEvent(std::move(ie)); break; } case SDL_CONTROLLERBUTTONUP: @@ -92,7 +92,7 @@ void InputManager::QueueInputEvent(const SDL_Event& e) ie.button = e.cbutton.button; ie.state = InputEventState::release; ie.axisValue = 0; - QueueInputEvent(std::move(ie)); + queueInputEvent(std::move(ie)); break; } case SDL_CONTROLLERDEVICEADDED: @@ -107,12 +107,12 @@ void InputManager::QueueInputEvent(const SDL_Event& e) } } -void InputManager::QueueInputEvent(InputEvent&& e) +void InputManager::queueInputEvent(InputEvent&& e) { _events.push(e); } -void InputManager::CheckJoysticks() +void InputManager::checkJoysticks() { constexpr uint32_t kCheckInternalMs = 5000; @@ -197,17 +197,17 @@ void InputManager::updateAnalogueScroll() _viewScroll.y += _analogueScroll.y; } -void InputManager::Process() +void InputManager::process() { - CheckJoysticks(); + checkJoysticks(); processAnalogueInput(); - HandleModifiers(); - ProcessEvents(); - ProcessHoldEvents(); - HandleViewScrolling(); + handleModifiers(); + processEvents(); + processHoldEvents(); + handleViewScrolling(); } -void InputManager::HandleViewScrolling() +void InputManager::handleViewScrolling() { if (gLegacyScene == LegacyScene::titleSequence) return; @@ -268,14 +268,14 @@ void InputManager::HandleViewScrolling() if (InputGetState() != InputState::Normal) return; - if (IsModifierKeyPressed(ModifierKey::shift) || IsModifierKeyPressed(ModifierKey::ctrl)) + if (isModifierKeyPressed(ModifierKey::shift) || isModifierKeyPressed(ModifierKey::ctrl)) return; GameHandleEdgeScroll(); } } -void InputManager::HandleModifiers() +void InputManager::handleModifiers() { _modifierKeyState = EnumValue(ModifierKey::none); @@ -301,29 +301,29 @@ void InputManager::HandleModifiers() if (Config::Get().general.VirtualFloorStyle != VirtualFloorStyles::Off) { - if (IsModifierKeyPressed(ModifierKey::ctrl) || IsModifierKeyPressed(ModifierKey::shift)) + if (isModifierKeyPressed(ModifierKey::ctrl) || isModifierKeyPressed(ModifierKey::shift)) VirtualFloorEnable(); else VirtualFloorDisable(); } } -bool InputManager::IsModifierKeyPressed(ModifierKey modifier) const +bool InputManager::isModifierKeyPressed(ModifierKey modifier) const { return _modifierKeyState & EnumValue(modifier); } -void InputManager::ProcessEvents() +void InputManager::processEvents() { while (!_events.empty()) { const auto& e = _events.front(); - Process(e); + process(e); _events.pop(); } } -void InputManager::Process(const InputEvent& e) +void InputManager::process(const InputEvent& e) { auto& shortcutManager = GetShortcutManager(); if (e.deviceKind == InputDeviceKind::keyboard) @@ -333,14 +333,14 @@ void InputManager::Process(const InputEvent& e) { if (!shortcutManager.ProcessEventForSpecificShortcut(e, ShortcutId::kDebugToggleConsole)) { - ProcessInGameConsole(e); + processInGameConsole(e); } return; } if (gChatOpen) { - ProcessChat(e); + processChat(e); return; } @@ -390,7 +390,7 @@ void InputManager::Process(const InputEvent& e) shortcutManager.ProcessEvent(e); } -void InputManager::ProcessInGameConsole(const InputEvent& e) +void InputManager::processInGameConsole(const InputEvent& e) { if (e.deviceKind == InputDeviceKind::keyboard && e.state == InputEventState::release) { @@ -425,7 +425,7 @@ void InputManager::ProcessInGameConsole(const InputEvent& e) } } -void InputManager::ProcessChat(const InputEvent& e) +void InputManager::processChat(const InputEvent& e) { if (e.deviceKind == InputDeviceKind::keyboard && e.state == InputEventState::down) { @@ -447,7 +447,7 @@ void InputManager::ProcessChat(const InputEvent& e) } } -void InputManager::ProcessHoldEvents() +void InputManager::processHoldEvents() { // Get mouse state _mouseState = SDL_GetMouseState(nullptr, nullptr); @@ -462,37 +462,37 @@ void InputManager::ProcessHoldEvents() _viewScroll.x = 0; _viewScroll.y = 0; - if (!HasTextInputFocus()) + if (!hasTextInputFocus()) { auto& shortcutManager = GetShortcutManager(); if (!shortcutManager.IsPendingShortcutChange()) { - ProcessViewScrollEvent(ShortcutId::kViewScrollUp, { 0, -1 }); - ProcessViewScrollEvent(ShortcutId::kViewScrollDown, { 0, 1 }); - ProcessViewScrollEvent(ShortcutId::kViewScrollLeft, { -1, 0 }); - ProcessViewScrollEvent(ShortcutId::kViewScrollRight, { 1, 0 }); + processViewScrollEvent(ShortcutId::kViewScrollUp, { 0, -1 }); + processViewScrollEvent(ShortcutId::kViewScrollDown, { 0, 1 }); + processViewScrollEvent(ShortcutId::kViewScrollLeft, { -1, 0 }); + processViewScrollEvent(ShortcutId::kViewScrollRight, { 1, 0 }); } updateAnalogueScroll(); } } -void InputManager::ProcessViewScrollEvent(std::string_view shortcutId, const ScreenCoordsXY& delta) +void InputManager::processViewScrollEvent(std::string_view shortcutId, const ScreenCoordsXY& delta) { auto& shortcutManager = GetShortcutManager(); auto shortcut = shortcutManager.GetShortcut(shortcutId); - if (shortcut != nullptr && GetState(*shortcut)) + if (shortcut != nullptr && getState(*shortcut)) { _viewScroll.x += delta.x; _viewScroll.y += delta.y; } } -bool InputManager::GetState(const RegisteredShortcut& shortcut) const +bool InputManager::getState(const RegisteredShortcut& shortcut) const { for (const auto& i : shortcut.Current) { - if (GetState(i)) + if (getState(i)) { return true; } @@ -500,7 +500,7 @@ bool InputManager::GetState(const RegisteredShortcut& shortcut) const return false; } -bool InputManager::GetState(const ShortcutInput& shortcut) const +bool InputManager::getState(const ShortcutInput& shortcut) const { constexpr uint32_t kUsefulModifiers = KMOD_SHIFT | KMOD_CTRL | KMOD_ALT | KMOD_GUI; auto modifiers = SDL_GetModState() & kUsefulModifiers; @@ -570,7 +570,7 @@ bool InputManager::GetState(const ShortcutInput& shortcut) const return false; } -bool InputManager::HasTextInputFocus() const +bool InputManager::hasTextInputFocus() const { if (OpenRCT2::Ui::Windows::IsUsingWidgetTextBox() || gChatOpen) return true; diff --git a/src/openrct2-ui/input/InputManager.h b/src/openrct2-ui/input/InputManager.h index 12dbc769ef..dd0a20d912 100644 --- a/src/openrct2-ui/input/InputManager.h +++ b/src/openrct2-ui/input/InputManager.h @@ -68,30 +68,30 @@ namespace OpenRCT2::Ui std::vector _keyboardState; uint8_t _modifierKeyState; - void CheckJoysticks(); + void checkJoysticks(); void processAnalogueInput(); void updateAnalogueScroll(); - void HandleViewScrolling(); - void HandleModifiers(); - void ProcessEvents(); - void Process(const InputEvent& e); - void ProcessInGameConsole(const InputEvent& e); - void ProcessChat(const InputEvent& e); - void ProcessHoldEvents(); - void ProcessViewScrollEvent(std::string_view shortcutId, const ScreenCoordsXY& delta); + void handleViewScrolling(); + void handleModifiers(); + void processEvents(); + void process(const InputEvent& e); + void processInGameConsole(const InputEvent& e); + void processChat(const InputEvent& e); + void processHoldEvents(); + void processViewScrollEvent(std::string_view shortcutId, const ScreenCoordsXY& delta); - bool GetState(const RegisteredShortcut& shortcut) const; - bool GetState(const ShortcutInput& shortcut) const; + bool getState(const RegisteredShortcut& shortcut) const; + bool getState(const ShortcutInput& shortcut) const; - bool HasTextInputFocus() const; + bool hasTextInputFocus() const; public: InputManager(); - bool IsModifierKeyPressed(ModifierKey modifier) const; - void QueueInputEvent(const SDL_Event& e); - void QueueInputEvent(InputEvent&& e); - void Process(); + bool isModifierKeyPressed(ModifierKey modifier) const; + void queueInputEvent(const SDL_Event& e); + void queueInputEvent(InputEvent&& e); + void process(); }; } // namespace OpenRCT2::Ui diff --git a/src/openrct2-ui/input/MouseInput.cpp b/src/openrct2-ui/input/MouseInput.cpp index 6718a33c8c..6878ad7561 100644 --- a/src/openrct2-ui/input/MouseInput.cpp +++ b/src/openrct2-ui/input/MouseInput.cpp @@ -1265,13 +1265,13 @@ namespace OpenRCT2 && cursor_w_number == w->number && widgetIndex == cursor_widgetIndex) { auto& im = GetInputManager(); - if (im.IsModifierKeyPressed(ModifierKey::shift)) + if (im.isModifierKeyPressed(ModifierKey::shift)) { gLastCloseModifier.window.number = w->number; gLastCloseModifier.window.classification = w->classification; gLastCloseModifier.modifier = CloseWindowModifier::shift; } - else if (im.IsModifierKeyPressed(ModifierKey::ctrl)) + else if (im.isModifierKeyPressed(ModifierKey::ctrl)) { gLastCloseModifier.window.number = w->number; gLastCloseModifier.window.classification = w->classification; diff --git a/src/openrct2-ui/windows/Footpath.cpp b/src/openrct2-ui/windows/Footpath.cpp index 81cde06c1a..f4f4c4b35d 100644 --- a/src/openrct2-ui/windows/Footpath.cpp +++ b/src/openrct2-ui/windows/Footpath.cpp @@ -808,7 +808,7 @@ namespace OpenRCT2::Ui::Windows auto& im = GetInputManager(); // First, store the initial copy/ctrl state - if (!_footpathPlaceCtrlState && im.IsModifierKeyPressed(ModifierKey::ctrl)) + if (!_footpathPlaceCtrlState && im.isModifierKeyPressed(ModifierKey::ctrl)) { constexpr auto interactionFlags = EnumsToFlags( ViewportInteractionItem::terrain, ViewportInteractionItem::ride, ViewportInteractionItem::scenery, @@ -824,20 +824,20 @@ namespace OpenRCT2::Ui::Windows _footpathPlaceCtrlState = true; } } - else if (!im.IsModifierKeyPressed(ModifierKey::ctrl)) + else if (!im.isModifierKeyPressed(ModifierKey::ctrl)) { _footpathPlaceCtrlState = false; _footpathPlaceCtrlZ = 0; } // In addition, vertical shifting on top of the base (copy) placement? - if (!_footpathPlaceShiftState && im.IsModifierKeyPressed(ModifierKey::shift)) + if (!_footpathPlaceShiftState && im.isModifierKeyPressed(ModifierKey::shift)) { _footpathPlaceShiftState = true; _footpathPlaceShiftStart = screenCoords; _footpathPlaceShiftZ = 0; } - else if (im.IsModifierKeyPressed(ModifierKey::shift)) + else if (im.isModifierKeyPressed(ModifierKey::shift)) { uint16_t maxPathHeight = ZoomLevel::max().ApplyTo( std::numeric_limits::max() - 32); diff --git a/src/openrct2-ui/windows/Land.cpp b/src/openrct2-ui/windows/Land.cpp index 441ca812d6..0d08c94711 100644 --- a/src/openrct2-ui/windows/Land.cpp +++ b/src/openrct2-ui/windows/Land.cpp @@ -606,7 +606,7 @@ namespace OpenRCT2::Ui::Windows */ void ToolUpdateLand(const ScreenCoordsXY& screenPos) { - const bool mapCtrlPressed = GetInputManager().IsModifierKeyPressed(ModifierKey::ctrl); + const bool mapCtrlPressed = GetInputManager().isModifierKeyPressed(ModifierKey::ctrl); auto* windowMgr = Ui::GetWindowManager(); MapInvalidateSelectionRect(); diff --git a/src/openrct2-ui/windows/MapTooltip.cpp b/src/openrct2-ui/windows/MapTooltip.cpp index 41c30aca06..0f5e356e61 100644 --- a/src/openrct2-ui/windows/MapTooltip.cpp +++ b/src/openrct2-ui/windows/MapTooltip.cpp @@ -98,8 +98,8 @@ namespace OpenRCT2::Ui::Windows auto& im = GetInputManager(); auto* wm = GetWindowManager(); - if (_cursorHoldDuration < 25 || stringId == kStringIdNone || im.IsModifierKeyPressed(ModifierKey::ctrl) - || im.IsModifierKeyPressed(ModifierKey::shift) || wm->FindByClass(WindowClass::error) != nullptr) + if (_cursorHoldDuration < 25 || stringId == kStringIdNone || im.isModifierKeyPressed(ModifierKey::ctrl) + || im.isModifierKeyPressed(ModifierKey::shift) || wm->FindByClass(WindowClass::error) != nullptr) { auto* windowMgr = Ui::GetWindowManager(); windowMgr->CloseByClass(WindowClass::mapTooltip); diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index 48bf20b93a..96f2bff5b5 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -3054,7 +3054,7 @@ namespace OpenRCT2::Ui::Windows if (!_trackPlaceCtrlState) { - if (im.IsModifierKeyPressed(ModifierKey::ctrl)) + if (im.isModifierKeyPressed(ModifierKey::ctrl)) { constexpr auto interactionFlags = EnumsToFlags( ViewportInteractionItem::terrain, ViewportInteractionItem::ride, ViewportInteractionItem::footpath, @@ -3071,7 +3071,7 @@ namespace OpenRCT2::Ui::Windows } else { - if (!(im.IsModifierKeyPressed(ModifierKey::ctrl))) + if (!(im.isModifierKeyPressed(ModifierKey::ctrl))) { _trackPlaceCtrlState = false; } @@ -3079,7 +3079,7 @@ namespace OpenRCT2::Ui::Windows if (!_trackPlaceShiftState) { - if (im.IsModifierKeyPressed(ModifierKey::shift)) + if (im.isModifierKeyPressed(ModifierKey::shift)) { _trackPlaceShiftState = true; _trackPlaceShiftStart = screenCoords; @@ -3088,7 +3088,7 @@ namespace OpenRCT2::Ui::Windows } else { - if (im.IsModifierKeyPressed(ModifierKey::shift)) + if (im.isModifierKeyPressed(ModifierKey::shift)) { uint16_t maxHeight = ZoomLevel::max().ApplyTo( std::numeric_limits::max() - 32); diff --git a/src/openrct2-ui/windows/Scenery.cpp b/src/openrct2-ui/windows/Scenery.cpp index 84d67aa1f8..952de74eb9 100644 --- a/src/openrct2-ui/windows/Scenery.cpp +++ b/src/openrct2-ui/windows/Scenery.cpp @@ -2405,7 +2405,7 @@ namespace OpenRCT2::Ui::Windows auto& im = GetInputManager(); if (!gSceneryCtrlPressed) { - if (im.IsModifierKeyPressed(ModifierKey::ctrl)) + if (im.isModifierKeyPressed(ModifierKey::ctrl)) { // CTRL pressed constexpr auto flag = EnumsToFlags( @@ -2423,7 +2423,7 @@ namespace OpenRCT2::Ui::Windows } else { - if (!(im.IsModifierKeyPressed(ModifierKey::ctrl))) + if (!(im.isModifierKeyPressed(ModifierKey::ctrl))) { // CTRL not pressed gSceneryCtrlPressed = false; @@ -2432,7 +2432,7 @@ namespace OpenRCT2::Ui::Windows if (!gSceneryShiftPressed) { - if (im.IsModifierKeyPressed(ModifierKey::shift)) + if (im.isModifierKeyPressed(ModifierKey::shift)) { // SHIFT pressed gSceneryShiftPressed = true; @@ -2443,7 +2443,7 @@ namespace OpenRCT2::Ui::Windows } else { - if (im.IsModifierKeyPressed(ModifierKey::shift)) + if (im.isModifierKeyPressed(ModifierKey::shift)) { // SHIFT pressed gSceneryShiftPressZOffset = (gSceneryShiftPressY - screenPos.y + 4); diff --git a/src/openrct2-ui/windows/StaffList.cpp b/src/openrct2-ui/windows/StaffList.cpp index 2a5b980852..499ee6a73e 100644 --- a/src/openrct2-ui/windows/StaffList.cpp +++ b/src/openrct2-ui/windows/StaffList.cpp @@ -512,7 +512,7 @@ namespace OpenRCT2::Ui::Windows void HireNewMember(StaffType staffType) { bool autoPosition = Config::Get().general.AutoStaffPlacement; - if (GetInputManager().IsModifierKeyPressed(ModifierKey::shift)) + if (GetInputManager().isModifierKeyPressed(ModifierKey::shift)) { autoPosition = autoPosition ^ 1; } diff --git a/src/openrct2-ui/windows/TileInspector.cpp b/src/openrct2-ui/windows/TileInspector.cpp index d9321d4e82..10dec74619 100644 --- a/src/openrct2-ui/windows/TileInspector.cpp +++ b/src/openrct2-ui/windows/TileInspector.cpp @@ -972,7 +972,7 @@ static uint64_t PageDisabledWidgets[] = { CoordsXY mapCoords; TileElement* clickedElement = nullptr; bool mouseOnViewport = false; - if (GetInputManager().IsModifierKeyPressed(ModifierKey::ctrl)) + if (GetInputManager().isModifierKeyPressed(ModifierKey::ctrl)) { auto info = GetMapCoordinatesFromPos(screenCoords, ViewportInteractionFlags); clickedElement = info.Element; @@ -1787,7 +1787,7 @@ static uint64_t PageDisabledWidgets[] = { void UpdateSelectedTile(const ScreenCoordsXY& screenCoords) { - const bool ctrlIsHeldDown = GetInputManager().IsModifierKeyPressed(ModifierKey::ctrl); + const bool ctrlIsHeldDown = GetInputManager().isModifierKeyPressed(ModifierKey::ctrl); // Mouse hasn't moved if (screenCoords.x == _toolMouseX && screenCoords.y == _toolMouseY && _toolCtrlDown == ctrlIsHeldDown) return; diff --git a/src/openrct2-ui/windows/TrackDesignPlace.cpp b/src/openrct2-ui/windows/TrackDesignPlace.cpp index b506bf8c5d..4cac2be601 100644 --- a/src/openrct2-ui/windows/TrackDesignPlace.cpp +++ b/src/openrct2-ui/windows/TrackDesignPlace.cpp @@ -455,7 +455,7 @@ namespace OpenRCT2::Ui::Windows auto& im = GetInputManager(); - if (!_trackPlaceCtrlState && im.IsModifierKeyPressed(ModifierKey::ctrl)) + if (!_trackPlaceCtrlState && im.isModifierKeyPressed(ModifierKey::ctrl)) { constexpr auto interactionFlags = EnumsToFlags( ViewportInteractionItem::terrain, ViewportInteractionItem::ride, ViewportInteractionItem::scenery, @@ -477,19 +477,19 @@ namespace OpenRCT2::Ui::Windows _trackPlaceCtrlState = true; } - else if (!im.IsModifierKeyPressed(ModifierKey::ctrl)) + else if (!im.isModifierKeyPressed(ModifierKey::ctrl)) { _trackPlaceCtrlState = false; _trackPlaceCtrlZ = 0; } - if (!_trackPlaceShiftState && im.IsModifierKeyPressed(ModifierKey::shift)) + if (!_trackPlaceShiftState && im.isModifierKeyPressed(ModifierKey::shift)) { _trackPlaceShiftState = true; _trackPlaceShiftStart = screenCoords; _trackPlaceShiftZ = 0; } - else if (im.IsModifierKeyPressed(ModifierKey::shift)) + else if (im.isModifierKeyPressed(ModifierKey::shift)) { uint16_t newMaxHeight = ZoomLevel::max().ApplyTo( std::numeric_limits::max() - 32);