diff --git a/src/openrct2-ui/input/MouseInput.cpp b/src/openrct2-ui/input/MouseInput.cpp index 5dba72b2da..c7f3ae6d3f 100644 --- a/src/openrct2-ui/input/MouseInput.cpp +++ b/src/openrct2-ui/input/MouseInput.cpp @@ -122,7 +122,7 @@ namespace OpenRCT2 GameHandleInputMouse(screenCoords, state); } - if (_inputFlags & INPUT_FLAG_5) + if (gInputFlags.has(InputFlag::unk5)) { GameHandleInputMouse(screenCoords, state); } @@ -392,11 +392,11 @@ namespace OpenRCT2 break; } - if (!InputTestFlag(INPUT_FLAG_4)) + if (!gInputFlags.has(InputFlag::unk4)) break; if (w->classification != _dragWidget.window_classification || w->number != _dragWidget.window_number - || !(_inputFlags & INPUT_FLAG_TOOL_ACTIVE)) + || !(gInputFlags.has(InputFlag::toolActive))) { break; } @@ -413,7 +413,7 @@ namespace OpenRCT2 _inputState = InputState::Reset; if (_dragWidget.window_number == w->number) { - if ((_inputFlags & INPUT_FLAG_TOOL_ACTIVE)) + if (gInputFlags.has(InputFlag::toolActive)) { w = windowMgr->FindByNumber( gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number); @@ -422,7 +422,7 @@ namespace OpenRCT2 w->OnToolUp(gCurrentToolWidget.widget_index, screenCoords); } } - else if (!(_inputFlags & INPUT_FLAG_4)) + else if (!gInputFlags.has(InputFlag::unk4)) { ViewportInteractionLeftClick(screenCoords); } @@ -552,7 +552,7 @@ namespace OpenRCT2 } WindowUnfollowSprite(w); - // gInputFlags |= INPUT_FLAG_5; + // gInputFlags.set(InputFlag::unk5); } static void InputViewportDragContinue() @@ -1084,12 +1084,12 @@ namespace OpenRCT2 gInputDragLast = screenCoords; _dragWidget.window_classification = windowClass; _dragWidget.window_number = windowNumber; - if (_inputFlags & INPUT_FLAG_TOOL_ACTIVE) + if (gInputFlags.has(InputFlag::toolActive)) { w = windowMgr->FindByNumber(gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number); if (w != nullptr) { - InputSetFlag(INPUT_FLAG_4, true); + gInputFlags.set(InputFlag::unk4); w->OnToolDown(gCurrentToolWidget.widget_index, screenCoords); } } @@ -1130,7 +1130,7 @@ namespace OpenRCT2 gPressedWidget.window_classification = windowClass; gPressedWidget.window_number = windowNumber; gPressedWidget.widget_index = widgetIndex; - _inputFlags |= INPUT_FLAG_WIDGET_PRESSED; + gInputFlags.set(InputFlag::widgetPressed); _inputState = InputState::WidgetPressed; _clickRepeatTicks = gCurrentRealTimeTicks; @@ -1163,7 +1163,7 @@ namespace OpenRCT2 switch (window->widgets[widgetId].type) { case WindowWidgetType::Viewport: - if (!(_inputFlags & INPUT_FLAG_TOOL_ACTIVE)) + if (!gInputFlags.has(InputFlag::toolActive)) { if (ViewportInteractionLeftOver(screenCoords)) { @@ -1225,7 +1225,7 @@ namespace OpenRCT2 */ void ProcessMouseTool(const ScreenCoordsXY& screenCoords) { - if (_inputFlags & INPUT_FLAG_TOOL_ACTIVE) + if (gInputFlags.has(InputFlag::toolActive)) { auto* windowMgr = GetWindowManager(); WindowBase* w = windowMgr->FindByNumber(gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number); @@ -1314,7 +1314,7 @@ namespace OpenRCT2 } } - if (_inputFlags & INPUT_FLAG_WIDGET_PRESSED) + if (gInputFlags.has(InputFlag::widgetPressed)) { if (_inputState == InputState::DropdownActive) { @@ -1324,7 +1324,7 @@ namespace OpenRCT2 return; } - _inputFlags |= INPUT_FLAG_WIDGET_PRESSED; + gInputFlags.set(InputFlag::widgetPressed); windowMgr->InvalidateWidgetByNumber(cursor_w_class, cursor_w_number, widgetIndex); return; case MouseState::LeftRelease: @@ -1356,11 +1356,11 @@ namespace OpenRCT2 else { dropdown_index = -1; - if (_inputFlags & INPUT_FLAG_DROPDOWN_STAY_OPEN) + if (gInputFlags.has(InputFlag::dropdownStayOpen)) { - if (!(_inputFlags & INPUT_FLAG_DROPDOWN_MOUSE_UP)) + if (!gInputFlags.has(InputFlag::dropdownMouseUp)) { - _inputFlags |= INPUT_FLAG_DROPDOWN_MOUSE_UP; + gInputFlags.set(InputFlag::dropdownMouseUp); return; } } @@ -1377,9 +1377,9 @@ namespace OpenRCT2 else { cursor_w = windowMgr->FindByNumber(cursor_w_class, cursor_w_number); - if (_inputFlags & INPUT_FLAG_WIDGET_PRESSED) + if (gInputFlags.has(InputFlag::widgetPressed)) { - _inputFlags &= ~INPUT_FLAG_WIDGET_PRESSED; + gInputFlags.unset(InputFlag::widgetPressed); windowMgr->InvalidateWidgetByNumber(cursor_w_class, cursor_w_number, cursor_widgetIndex); } @@ -1439,9 +1439,9 @@ namespace OpenRCT2 if (_inputState != InputState::DropdownActive) { // Hold down widget and drag outside of area?? - if (_inputFlags & INPUT_FLAG_WIDGET_PRESSED) + if (gInputFlags.has(InputFlag::widgetPressed)) { - _inputFlags &= ~INPUT_FLAG_WIDGET_PRESSED; + gInputFlags.unset(InputFlag::widgetPressed); windowMgr->InvalidateWidgetByNumber(cursor_w_class, cursor_w_number, cursor_widgetIndex); } return; @@ -1681,12 +1681,12 @@ namespace OpenRCT2 } mainWindow->savedViewPos.x += dx; - _inputFlags |= INPUT_FLAG_VIEWPORT_SCROLLING; + gInputFlags.set(InputFlag::viewportScrolling); } if (scrollScreenCoords.y != 0) { mainWindow->savedViewPos.y += dy; - _inputFlags |= INPUT_FLAG_VIEWPORT_SCROLLING; + gInputFlags.set(InputFlag::viewportScrolling); } } } // namespace OpenRCT2 diff --git a/src/openrct2-ui/input/Shortcuts.cpp b/src/openrct2-ui/input/Shortcuts.cpp index df53ad6828..0b40dd0c9c 100644 --- a/src/openrct2-ui/input/Shortcuts.cpp +++ b/src/openrct2-ui/input/Shortcuts.cpp @@ -773,7 +773,7 @@ void ShortcutManager::RegisterDefaultShortcuts() { windowMgr->Close(*window); } - else if (InputTestFlag(INPUT_FLAG_TOOL_ACTIVE)) + else if (gInputFlags.has(InputFlag::toolActive)) { ToolCancel(); } diff --git a/src/openrct2-ui/interface/ViewportInteraction.cpp b/src/openrct2-ui/interface/ViewportInteraction.cpp index 81e8cb811b..54fffb09a6 100644 --- a/src/openrct2-ui/interface/ViewportInteraction.cpp +++ b/src/openrct2-ui/interface/ViewportInteraction.cpp @@ -465,7 +465,7 @@ namespace OpenRCT2::Ui break; } - if (!(InputTestFlag(INPUT_FLAG_6)) || !(InputTestFlag(INPUT_FLAG_TOOL_ACTIVE))) + if (!gInputFlags.has(InputFlag::unk6) || !gInputFlags.has(InputFlag::toolActive)) { auto* windowMgr = GetWindowManager(); if (windowMgr->FindByClass(WindowClass::RideConstruction) == nullptr diff --git a/src/openrct2-ui/interface/Widget.cpp b/src/openrct2-ui/interface/Widget.cpp index 9b52cb7898..bdc0442523 100644 --- a/src/openrct2-ui/interface/Widget.cpp +++ b/src/openrct2-ui/interface/Widget.cpp @@ -900,7 +900,7 @@ namespace OpenRCT2::Ui if (InputGetState() == InputState::WidgetPressed || InputGetState() == InputState::DropdownActive) { - if (!(InputTestFlag(INPUT_FLAG_WIDGET_PRESSED))) + if (!gInputFlags.has(InputFlag::widgetPressed)) return false; if (gPressedWidget.window_classification != w.classification) return false; diff --git a/src/openrct2-ui/interface/Window.cpp b/src/openrct2-ui/interface/Window.cpp index b5ede76681..828f84f970 100644 --- a/src/openrct2-ui/interface/Window.cpp +++ b/src/openrct2-ui/interface/Window.cpp @@ -273,7 +273,7 @@ namespace OpenRCT2 return; // Check window cursor is over - if (!(InputTestFlag(INPUT_FLAG_5))) + if (!gInputFlags.has(InputFlag::unk5)) { auto* windowMgr = GetWindowManager(); WindowBase* w = windowMgr->FindFromPoint(cursorState->position); diff --git a/src/openrct2-ui/scripting/ScUi.hpp b/src/openrct2-ui/scripting/ScUi.hpp index 8f4b559ff5..49611c99c2 100644 --- a/src/openrct2-ui/scripting/ScUi.hpp +++ b/src/openrct2-ui/scripting/ScUi.hpp @@ -153,7 +153,7 @@ namespace OpenRCT2::Scripting std::shared_ptr tool_get() const { - if (InputTestFlag(INPUT_FLAG_TOOL_ACTIVE)) + if (gInputFlags.has(InputFlag::toolActive)) { return std::make_shared(_scriptEngine.GetContext()); } diff --git a/src/openrct2-ui/windows/ClearScenery.cpp b/src/openrct2-ui/windows/ClearScenery.cpp index 1f6795b31d..ab6d1eeb6c 100644 --- a/src/openrct2-ui/windows/ClearScenery.cpp +++ b/src/openrct2-ui/windows/ClearScenery.cpp @@ -401,7 +401,7 @@ namespace OpenRCT2::Ui::Windows ShowGridlines(); auto* toolWindow = ContextOpenWindow(WindowClass::ClearScenery); ToolSet(*toolWindow, WIDX_BACKGROUND, Tool::bulldozer); - InputSetFlag(INPUT_FLAG_6, true); + gInputFlags.set(InputFlag::unk6); } } } // namespace OpenRCT2::Ui::Windows diff --git a/src/openrct2-ui/windows/Dropdown.cpp b/src/openrct2-ui/windows/Dropdown.cpp index 40873f5b5d..4da833836b 100644 --- a/src/openrct2-ui/windows/Dropdown.cpp +++ b/src/openrct2-ui/windows/Dropdown.cpp @@ -357,9 +357,9 @@ namespace OpenRCT2::Ui::Windows const ScreenCoordsXY& screenPos, int32_t extray, ColourWithFlags colour, uint8_t customItemHeight, uint8_t flags, size_t num_items, int32_t width, size_t prefRowsPerColumn) { - InputSetFlag(static_cast(INPUT_FLAG_DROPDOWN_STAY_OPEN | INPUT_FLAG_DROPDOWN_MOUSE_UP), false); + gInputFlags.unset(InputFlag::dropdownStayOpen, InputFlag::dropdownMouseUp); if (flags & Dropdown::Flag::StayOpen || Config::Get().interface.TouchEnhancements) - InputSetFlag(INPUT_FLAG_DROPDOWN_STAY_OPEN, true); + gInputFlags.set(InputFlag::dropdownStayOpen); WindowDropdownClose(); @@ -392,9 +392,9 @@ namespace OpenRCT2::Ui::Windows int32_t x, int32_t y, int32_t extray, ColourWithFlags colour, uint8_t flags, int32_t numItems, int32_t itemWidth, int32_t itemHeight, int32_t numColumns) { - InputSetFlag(static_cast(INPUT_FLAG_DROPDOWN_STAY_OPEN | INPUT_FLAG_DROPDOWN_MOUSE_UP), false); + gInputFlags.unset(InputFlag::dropdownStayOpen, InputFlag::dropdownMouseUp); if (flags & Dropdown::Flag::StayOpen || Config::Get().interface.TouchEnhancements) - InputSetFlag(INPUT_FLAG_DROPDOWN_STAY_OPEN, true); + gInputFlags.set(InputFlag::dropdownStayOpen); // Close existing dropdown WindowDropdownClose(); diff --git a/src/openrct2-ui/windows/EditorParkEntrance.cpp b/src/openrct2-ui/windows/EditorParkEntrance.cpp index e1d3ac1923..a1cd5a40e0 100644 --- a/src/openrct2-ui/windows/EditorParkEntrance.cpp +++ b/src/openrct2-ui/windows/EditorParkEntrance.cpp @@ -253,7 +253,7 @@ namespace OpenRCT2::Ui::Windows pressed_widgets |= 1LL << WIDX_TAB; ToolSet(*this, WIDX_LIST, Tool::entranceDown); - InputSetFlag(INPUT_FLAG_6, true); + gInputFlags.set(InputFlag::unk6); } void OnMouseUp(WidgetIndex widgetIndex) override diff --git a/src/openrct2-ui/windows/Footpath.cpp b/src/openrct2-ui/windows/Footpath.cpp index a53e317b7a..ee18a0d9d2 100644 --- a/src/openrct2-ui/windows/Footpath.cpp +++ b/src/openrct2-ui/windows/Footpath.cpp @@ -222,7 +222,7 @@ namespace OpenRCT2::Ui::Windows ToolCancel(); _footpathConstructionMode = PATH_CONSTRUCTION_MODE_LAND; ToolSet(*this, WIDX_CONSTRUCT_ON_LAND, Tool::pathDown); - InputSetFlag(INPUT_FLAG_6, true); + gInputFlags.set(InputFlag::unk6); _footpathErrorOccured = false; WindowFootpathSetEnabledAndPressedWidgets(); @@ -333,7 +333,7 @@ namespace OpenRCT2::Ui::Windows gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; _footpathConstructionMode = PATH_CONSTRUCTION_MODE_LAND; ToolSet(*this, WIDX_CONSTRUCT_ON_LAND, Tool::pathDown); - InputSetFlag(INPUT_FLAG_6, true); + gInputFlags.set(InputFlag::unk6); _footpathErrorOccured = false; WindowFootpathSetEnabledAndPressedWidgets(); break; @@ -350,7 +350,7 @@ namespace OpenRCT2::Ui::Windows gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; _footpathConstructionMode = PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL_TOOL; ToolSet(*this, WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL, Tool::crosshair); - InputSetFlag(INPUT_FLAG_6, true); + gInputFlags.set(InputFlag::unk6); _footpathErrorOccured = false; WindowFootpathSetEnabledAndPressedWidgets(); break; diff --git a/src/openrct2-ui/windows/Land.cpp b/src/openrct2-ui/windows/Land.cpp index 1168440eb4..3bdd367d89 100644 --- a/src/openrct2-ui/windows/Land.cpp +++ b/src/openrct2-ui/windows/Land.cpp @@ -890,7 +890,7 @@ namespace OpenRCT2::Ui::Windows ShowGridlines(); auto* toolWindow = ContextOpenWindow(WindowClass::Land); ToolSet(*toolWindow, WIDX_BACKGROUND, Tool::digDown); - InputSetFlag(INPUT_FLAG_6, true); + gInputFlags.set(InputFlag::unk6); } } } // namespace OpenRCT2::Ui::Windows diff --git a/src/openrct2-ui/windows/LandRights.cpp b/src/openrct2-ui/windows/LandRights.cpp index b41f2e864e..5b718aa651 100644 --- a/src/openrct2-ui/windows/LandRights.cpp +++ b/src/openrct2-ui/windows/LandRights.cpp @@ -108,7 +108,7 @@ namespace OpenRCT2::Ui::Windows _landRightsMode = mode; ToolSet(*this, widgetIndex, Tool::upArrow); - InputSetFlag(INPUT_FLAG_6, true); + gInputFlags.set(InputFlag::unk6); if (kLandRightsVisibleByMode[EnumValue(mode)]) ShowLandRights(); diff --git a/src/openrct2-ui/windows/MapTooltip.cpp b/src/openrct2-ui/windows/MapTooltip.cpp index c491508f58..0d6e24e928 100644 --- a/src/openrct2-ui/windows/MapTooltip.cpp +++ b/src/openrct2-ui/windows/MapTooltip.cpp @@ -86,7 +86,7 @@ namespace OpenRCT2::Ui::Windows // Check for cursor movement _cursorHoldDuration++; - if (abs(cursorChange.x) > 5 || abs(cursorChange.y) > 5 || (InputTestFlag(INPUT_FLAG_5)) + if (abs(cursorChange.x) > 5 || abs(cursorChange.y) > 5 || (gInputFlags.has(InputFlag::unk5)) || InputGetState() == InputState::ViewportRight) _cursorHoldDuration = 0; diff --git a/src/openrct2-ui/windows/MazeConstruction.cpp b/src/openrct2-ui/windows/MazeConstruction.cpp index 88a2418002..3a2720e5d7 100644 --- a/src/openrct2-ui/windows/MazeConstruction.cpp +++ b/src/openrct2-ui/windows/MazeConstruction.cpp @@ -316,7 +316,7 @@ namespace OpenRCT2::Ui::Windows : ENTRANCE_TYPE_RIDE_EXIT; gRideEntranceExitPlaceRideIndex = rideId; gRideEntranceExitPlaceStationIndex = StationIndex::FromUnderlying(0); - InputSetFlag(INPUT_FLAG_6, true); + gInputFlags.set(InputFlag::unk6); RideConstructionInvalidateCurrentTrack(); diff --git a/src/openrct2-ui/windows/PatrolArea.cpp b/src/openrct2-ui/windows/PatrolArea.cpp index 23ef15726b..137b74098a 100644 --- a/src/openrct2-ui/windows/PatrolArea.cpp +++ b/src/openrct2-ui/windows/PatrolArea.cpp @@ -251,7 +251,7 @@ namespace OpenRCT2::Ui::Windows if (!ToolSet(*this, 0, Tool::walkDown)) { ShowGridlines(); - InputSetFlag(INPUT_FLAG_6, true); + gInputFlags.set(InputFlag::unk6); SetPatrolAreaToRender(_staffId); GfxInvalidateScreen(); } diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index b334dce23b..05013d5f2b 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -2444,7 +2444,7 @@ namespace OpenRCT2::Ui::Windows gRideEntranceExitPlaceType = ENTRANCE_TYPE_RIDE_ENTRANCE; gRideEntranceExitPlaceRideIndex = _currentRideIndex; gRideEntranceExitPlaceStationIndex = StationIndex::FromUnderlying(0); - InputSetFlag(INPUT_FLAG_6, true); + gInputFlags.set(InputFlag::unk6); RideConstructionInvalidateCurrentTrack(); if (_rideConstructionState != RideConstructionState::EntranceExit) { @@ -2470,7 +2470,7 @@ namespace OpenRCT2::Ui::Windows gRideEntranceExitPlaceType = ENTRANCE_TYPE_RIDE_EXIT; gRideEntranceExitPlaceRideIndex = _currentRideIndex; gRideEntranceExitPlaceStationIndex = StationIndex::FromUnderlying(0); - InputSetFlag(INPUT_FLAG_6, true); + gInputFlags.set(InputFlag::unk6); RideConstructionInvalidateCurrentTrack(); if (_rideConstructionState != RideConstructionState::EntranceExit) { @@ -3671,7 +3671,7 @@ namespace OpenRCT2::Ui::Windows if (w != nullptr) { ToolSet(*w, WIDX_CONSTRUCT, Tool::crosshair); - InputSetFlag(INPUT_FLAG_6, true); + gInputFlags.set(InputFlag::unk6); _trackPlaceCtrlState = false; _trackPlaceShiftState = false; } diff --git a/src/openrct2-ui/windows/Scenery.cpp b/src/openrct2-ui/windows/Scenery.cpp index ecf4644810..56bb99659b 100644 --- a/src/openrct2-ui/windows/Scenery.cpp +++ b/src/openrct2-ui/windows/Scenery.cpp @@ -3300,7 +3300,7 @@ namespace OpenRCT2::Ui::Windows { auto* toolWindow = ContextOpenWindow(WindowClass::Scenery); ToolSet(*toolWindow, WIDX_SCENERY_BACKGROUND, Tool::arrow); - InputSetFlag(INPUT_FLAG_6, true); + gInputFlags.set(InputFlag::unk6); } } } // namespace OpenRCT2::Ui::Windows diff --git a/src/openrct2-ui/windows/Tooltip.cpp b/src/openrct2-ui/windows/Tooltip.cpp index da176f8831..e802b2f374 100644 --- a/src/openrct2-ui/windows/Tooltip.cpp +++ b/src/openrct2-ui/windows/Tooltip.cpp @@ -150,7 +150,7 @@ namespace OpenRCT2::Ui::Windows gTooltipCloseTimeout = 0; gTooltipWidget.window_classification = WindowClass::Null; InputSetState(InputState::Normal); - InputSetFlag(INPUT_FLAG_4, false); + gInputFlags.unset(InputFlag::unk4); } void WindowTooltipShow(const OpenRCT2String& message, ScreenCoordsXY screenCoords) diff --git a/src/openrct2-ui/windows/TrackDesignPlace.cpp b/src/openrct2-ui/windows/TrackDesignPlace.cpp index 1da514951c..95b06490e3 100644 --- a/src/openrct2-ui/windows/TrackDesignPlace.cpp +++ b/src/openrct2-ui/windows/TrackDesignPlace.cpp @@ -104,7 +104,7 @@ namespace OpenRCT2::Ui::Windows SetWidgets(_trackPlaceWidgets); WindowInitScrollWidgets(*this); ToolSet(*this, WIDX_PRICE, Tool::crosshair); - InputSetFlag(INPUT_FLAG_6, true); + gInputFlags.set(InputFlag::unk6); WindowPushOthersRight(*this); ShowGridlines(); _miniPreview.resize(TRACK_MINI_PREVIEW_SIZE); diff --git a/src/openrct2-ui/windows/Water.cpp b/src/openrct2-ui/windows/Water.cpp index 47abbc450f..48d67d6fa7 100644 --- a/src/openrct2-ui/windows/Water.cpp +++ b/src/openrct2-ui/windows/Water.cpp @@ -447,7 +447,7 @@ namespace OpenRCT2::Ui::Windows ShowGridlines(); auto* toolWindow = ContextOpenWindow(WindowClass::Water); ToolSet(*toolWindow, WIDX_BACKGROUND, Tool::waterDown); - InputSetFlag(INPUT_FLAG_6, true); + gInputFlags.set(InputFlag::unk6); } } } // namespace OpenRCT2::Ui::Windows diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index b164b81ff4..3799c3fc8a 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -677,9 +677,9 @@ void GameLoadOrQuitNoSavePrompt() auto loadOrQuitAction = LoadOrQuitAction(LoadOrQuitModes::CloseSavePrompt); GameActions::Execute(&loadOrQuitAction); ToolCancel(); - if (InputTestFlag(INPUT_FLAG_5)) + if (gInputFlags.has(InputFlag::unk5)) { - InputSetFlag(INPUT_FLAG_5, false); + gInputFlags.unset(InputFlag::unk5); } GameResetSpeed(); gFirstTimeSaving = true; diff --git a/src/openrct2/GameState.cpp b/src/openrct2/GameState.cpp index 9c97818b20..d2ef701adc 100644 --- a/src/openrct2/GameState.cpp +++ b/src/openrct2/GameState.cpp @@ -190,9 +190,9 @@ namespace OpenRCT2 { if (InputGetState() == InputState::Reset || InputGetState() == InputState::Normal) { - if (InputTestFlag(INPUT_FLAG_VIEWPORT_SCROLLING)) + if (gInputFlags.has(InputFlag::viewportScrolling)) { - InputSetFlag(INPUT_FLAG_VIEWPORT_SCROLLING, false); + gInputFlags.unset(InputFlag::viewportScrolling); break; } } @@ -211,7 +211,7 @@ namespace OpenRCT2 if (!gOpenRCT2Headless) { - InputSetFlag(INPUT_FLAG_VIEWPORT_SCROLLING, false); + gInputFlags.unset(InputFlag::viewportScrolling); } // Always perform autosave check, even when paused diff --git a/src/openrct2/Input.cpp b/src/openrct2/Input.cpp index 2f85b6a3a2..da023b9816 100644 --- a/src/openrct2/Input.cpp +++ b/src/openrct2/Input.cpp @@ -15,7 +15,7 @@ namespace OpenRCT2 { InputState _inputState; - uint8_t _inputFlags; + InputFlags gInputFlags; WidgetRef gHoverWidget; WidgetRef gPressedWidget; @@ -40,28 +40,6 @@ namespace OpenRCT2 ContextInputHandleKeyboard(false); } - void InputSetFlag(INPUT_FLAGS flag, bool on) - { - if (on) - { - _inputFlags |= flag; - } - else - { - _inputFlags &= ~flag; - } - } - - bool InputTestFlag(INPUT_FLAGS flag) - { - return _inputFlags & flag; - } - - void InputResetFlags() - { - _inputFlags = 0; - } - void InputSetState(InputState state) { _inputState = state; diff --git a/src/openrct2/Input.h b/src/openrct2/Input.h index 8189e18926..624aa36482 100644 --- a/src/openrct2/Input.h +++ b/src/openrct2/Input.h @@ -9,34 +9,36 @@ #pragma once +#include "core/FlagHolder.hpp" #include "interface/Window.h" namespace OpenRCT2 { - enum INPUT_FLAGS + enum InputFlag { - INPUT_FLAG_WIDGET_PRESSED = (1 << 0), + widgetPressed, - // The dropdown can stay open if the mouse is released, set on flag Dropdown::Flag::StayOpen - INPUT_FLAG_DROPDOWN_STAY_OPEN = (1 << 1), + // The dropdown can stay open if the mouse is released, set on flag Dropdown::Flag::StayOpen. + dropdownStayOpen, - // The mouse has been released and the dropdown is still open - // INPUT_FLAG_DROPDOWN_STAY_OPEN is already set if this happens - INPUT_FLAG_DROPDOWN_MOUSE_UP = (1 << 2), + // The mouse has been released and the dropdown is still open. + // InputFlag::dropdownStayOpen is already set if this happens. + dropdownMouseUp, - INPUT_FLAG_TOOL_ACTIVE = (1 << 3), + toolActive, // Left click on a viewport - INPUT_FLAG_4 = (1 << 4), + unk4, - INPUT_FLAG_5 = (1 << 5), + unk5, // Some of the map tools (clear, footpath, scenery) // never read as far as I know. - INPUT_FLAG_6 = (1 << 6), + unk6, - INPUT_FLAG_VIEWPORT_SCROLLING = (1 << 7) + viewportScrolling, }; + using InputFlags = FlagHolder; enum class InputState { @@ -61,16 +63,12 @@ namespace OpenRCT2 // TODO: Move to openrct2-ui and make static again extern InputState _inputState; - extern uint8_t _inputFlags; + extern InputFlags gInputFlags; extern uint32_t _tooltipNotShownTimeout; void TitleHandleKeyboardInput(); void GameHandleKeyboardInput(); - void InputSetFlag(INPUT_FLAGS flag, bool on); - bool InputTestFlag(INPUT_FLAGS flag); - void InputResetFlags(); - void InputSetState(InputState state); InputState InputGetState(); diff --git a/src/openrct2/actions/PeepPickupAction.cpp b/src/openrct2/actions/PeepPickupAction.cpp index 6123a24692..68930945e3 100644 --- a/src/openrct2/actions/PeepPickupAction.cpp +++ b/src/openrct2/actions/PeepPickupAction.cpp @@ -147,7 +147,7 @@ GameActions::Result PeepPickupAction::Execute() const if (_owner == NetworkGetCurrentPlayerId()) { // prevent tool_cancel() - InputSetFlag(INPUT_FLAG_TOOL_ACTIVE, false); + gInputFlags.unset(InputFlag::toolActive); } } diff --git a/src/openrct2/interface/Viewport.cpp b/src/openrct2/interface/Viewport.cpp index 7ed5167fcb..7c7c1a8431 100644 --- a/src/openrct2/interface/Viewport.cpp +++ b/src/openrct2/interface/Viewport.cpp @@ -102,7 +102,7 @@ namespace OpenRCT2 WindowInitAll(); // ? - InputResetFlags(); + gInputFlags.clearAll(); InputSetState(InputState::Reset); gPressedWidget.window_classification = WindowClass::Null; gPickupPeepImage = ImageId(); diff --git a/src/openrct2/interface/Window.cpp b/src/openrct2/interface/Window.cpp index 161c065ec8..bc696678b0 100644 --- a/src/openrct2/interface/Window.cpp +++ b/src/openrct2/interface/Window.cpp @@ -629,7 +629,7 @@ static constexpr float kWindowScrollLocations[][2] = { bool isToolActive(WindowClass cls) { - return InputTestFlag(INPUT_FLAG_TOOL_ACTIVE) && gCurrentToolWidget.window_classification == cls; + return gInputFlags.has(InputFlag::toolActive) && gCurrentToolWidget.window_classification == cls; } bool isToolActive(WindowClass cls, rct_windownumber number) @@ -662,7 +662,7 @@ static constexpr float kWindowScrollLocations[][2] = { */ bool ToolSet(const WindowBase& w, WidgetIndex widgetIndex, Tool tool) { - if (InputTestFlag(INPUT_FLAG_TOOL_ACTIVE)) + if (gInputFlags.has(InputFlag::toolActive)) { if (w.classification == gCurrentToolWidget.window_classification && w.number == gCurrentToolWidget.window_number && widgetIndex == gCurrentToolWidget.widget_index) @@ -674,9 +674,9 @@ static constexpr float kWindowScrollLocations[][2] = { ToolCancel(); } - InputSetFlag(INPUT_FLAG_TOOL_ACTIVE, true); - InputSetFlag(INPUT_FLAG_4, false); - InputSetFlag(INPUT_FLAG_6, false); + gInputFlags.set(InputFlag::toolActive); + gInputFlags.unset(InputFlag::unk4); + gInputFlags.unset(InputFlag::unk6); gCurrentToolId = tool; gCurrentToolWidget.window_classification = w.classification; gCurrentToolWidget.window_number = w.number; @@ -690,9 +690,9 @@ static constexpr float kWindowScrollLocations[][2] = { */ void ToolCancel() { - if (InputTestFlag(INPUT_FLAG_TOOL_ACTIVE)) + if (gInputFlags.has(InputFlag::toolActive)) { - InputSetFlag(INPUT_FLAG_TOOL_ACTIVE, false); + gInputFlags.unset(InputFlag::toolActive); MapInvalidateSelectionRect(); MapInvalidateMapSelectionTiles(); diff --git a/src/openrct2/ride/RideConstruction.cpp b/src/openrct2/ride/RideConstruction.cpp index 42e9e49b8e..a9762f22d6 100644 --- a/src/openrct2/ride/RideConstruction.cpp +++ b/src/openrct2/ride/RideConstruction.cpp @@ -883,7 +883,7 @@ static bool ride_modify_entrance_or_exit(const CoordsXYE& tileElement) gRideEntranceExitPlaceType = entranceType; gRideEntranceExitPlaceRideIndex = rideIndex; gRideEntranceExitPlaceStationIndex = stationIndex; - InputSetFlag(INPUT_FLAG_6, true); + gInputFlags.set(InputFlag::unk6); if (_rideConstructionState != RideConstructionState::EntranceExit) { gRideEntranceExitPlacePreviousRideConstructionState = _rideConstructionState; @@ -1073,7 +1073,7 @@ int32_t RideInitialiseConstructionWindow(Ride& ride) w = ride_create_or_find_construction_window(ride.id); ToolSet(*w, WC_RIDE_CONSTRUCTION__WIDX_CONSTRUCT, Tool::crosshair); - InputSetFlag(INPUT_FLAG_6, true); + gInputFlags.set(InputFlag::unk6); _currentlySelectedTrack = ride.getRideTypeDescriptor().StartTrackPiece; _currentTrackPitchEnd = TrackPitch::None; diff --git a/src/openrct2/scenes/title/TitleScene.cpp b/src/openrct2/scenes/title/TitleScene.cpp index 48a3448729..05a5db29ce 100644 --- a/src/openrct2/scenes/title/TitleScene.cpp +++ b/src/openrct2/scenes/title/TitleScene.cpp @@ -158,7 +158,7 @@ void TitleScene::Tick() // update_weather_animation(); } - InputSetFlag(INPUT_FLAG_VIEWPORT_SCROLLING, false); + gInputFlags.unset(InputFlag::viewportScrolling); ContextHandleInput();