mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-21 14:53:02 +01:00
Refactor INPUT_FLAGS into FlagHolder
This commit is contained in:
@@ -122,7 +122,7 @@ namespace OpenRCT2
|
|||||||
GameHandleInputMouse(screenCoords, state);
|
GameHandleInputMouse(screenCoords, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_inputFlags & INPUT_FLAG_5)
|
if (gInputFlags.has(InputFlag::unk5))
|
||||||
{
|
{
|
||||||
GameHandleInputMouse(screenCoords, state);
|
GameHandleInputMouse(screenCoords, state);
|
||||||
}
|
}
|
||||||
@@ -392,11 +392,11 @@ namespace OpenRCT2
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!InputTestFlag(INPUT_FLAG_4))
|
if (!gInputFlags.has(InputFlag::unk4))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (w->classification != _dragWidget.window_classification || w->number != _dragWidget.window_number
|
if (w->classification != _dragWidget.window_classification || w->number != _dragWidget.window_number
|
||||||
|| !(_inputFlags & INPUT_FLAG_TOOL_ACTIVE))
|
|| !(gInputFlags.has(InputFlag::toolActive)))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -413,7 +413,7 @@ namespace OpenRCT2
|
|||||||
_inputState = InputState::Reset;
|
_inputState = InputState::Reset;
|
||||||
if (_dragWidget.window_number == w->number)
|
if (_dragWidget.window_number == w->number)
|
||||||
{
|
{
|
||||||
if ((_inputFlags & INPUT_FLAG_TOOL_ACTIVE))
|
if (gInputFlags.has(InputFlag::toolActive))
|
||||||
{
|
{
|
||||||
w = windowMgr->FindByNumber(
|
w = windowMgr->FindByNumber(
|
||||||
gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number);
|
gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number);
|
||||||
@@ -422,7 +422,7 @@ namespace OpenRCT2
|
|||||||
w->OnToolUp(gCurrentToolWidget.widget_index, screenCoords);
|
w->OnToolUp(gCurrentToolWidget.widget_index, screenCoords);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!(_inputFlags & INPUT_FLAG_4))
|
else if (!gInputFlags.has(InputFlag::unk4))
|
||||||
{
|
{
|
||||||
ViewportInteractionLeftClick(screenCoords);
|
ViewportInteractionLeftClick(screenCoords);
|
||||||
}
|
}
|
||||||
@@ -552,7 +552,7 @@ namespace OpenRCT2
|
|||||||
}
|
}
|
||||||
|
|
||||||
WindowUnfollowSprite(w);
|
WindowUnfollowSprite(w);
|
||||||
// gInputFlags |= INPUT_FLAG_5;
|
// gInputFlags.set(InputFlag::unk5);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void InputViewportDragContinue()
|
static void InputViewportDragContinue()
|
||||||
@@ -1084,12 +1084,12 @@ namespace OpenRCT2
|
|||||||
gInputDragLast = screenCoords;
|
gInputDragLast = screenCoords;
|
||||||
_dragWidget.window_classification = windowClass;
|
_dragWidget.window_classification = windowClass;
|
||||||
_dragWidget.window_number = windowNumber;
|
_dragWidget.window_number = windowNumber;
|
||||||
if (_inputFlags & INPUT_FLAG_TOOL_ACTIVE)
|
if (gInputFlags.has(InputFlag::toolActive))
|
||||||
{
|
{
|
||||||
w = windowMgr->FindByNumber(gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number);
|
w = windowMgr->FindByNumber(gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number);
|
||||||
if (w != nullptr)
|
if (w != nullptr)
|
||||||
{
|
{
|
||||||
InputSetFlag(INPUT_FLAG_4, true);
|
gInputFlags.set(InputFlag::unk4);
|
||||||
w->OnToolDown(gCurrentToolWidget.widget_index, screenCoords);
|
w->OnToolDown(gCurrentToolWidget.widget_index, screenCoords);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1130,7 +1130,7 @@ namespace OpenRCT2
|
|||||||
gPressedWidget.window_classification = windowClass;
|
gPressedWidget.window_classification = windowClass;
|
||||||
gPressedWidget.window_number = windowNumber;
|
gPressedWidget.window_number = windowNumber;
|
||||||
gPressedWidget.widget_index = widgetIndex;
|
gPressedWidget.widget_index = widgetIndex;
|
||||||
_inputFlags |= INPUT_FLAG_WIDGET_PRESSED;
|
gInputFlags.set(InputFlag::widgetPressed);
|
||||||
_inputState = InputState::WidgetPressed;
|
_inputState = InputState::WidgetPressed;
|
||||||
_clickRepeatTicks = gCurrentRealTimeTicks;
|
_clickRepeatTicks = gCurrentRealTimeTicks;
|
||||||
|
|
||||||
@@ -1163,7 +1163,7 @@ namespace OpenRCT2
|
|||||||
switch (window->widgets[widgetId].type)
|
switch (window->widgets[widgetId].type)
|
||||||
{
|
{
|
||||||
case WindowWidgetType::Viewport:
|
case WindowWidgetType::Viewport:
|
||||||
if (!(_inputFlags & INPUT_FLAG_TOOL_ACTIVE))
|
if (!gInputFlags.has(InputFlag::toolActive))
|
||||||
{
|
{
|
||||||
if (ViewportInteractionLeftOver(screenCoords))
|
if (ViewportInteractionLeftOver(screenCoords))
|
||||||
{
|
{
|
||||||
@@ -1225,7 +1225,7 @@ namespace OpenRCT2
|
|||||||
*/
|
*/
|
||||||
void ProcessMouseTool(const ScreenCoordsXY& screenCoords)
|
void ProcessMouseTool(const ScreenCoordsXY& screenCoords)
|
||||||
{
|
{
|
||||||
if (_inputFlags & INPUT_FLAG_TOOL_ACTIVE)
|
if (gInputFlags.has(InputFlag::toolActive))
|
||||||
{
|
{
|
||||||
auto* windowMgr = GetWindowManager();
|
auto* windowMgr = GetWindowManager();
|
||||||
WindowBase* w = windowMgr->FindByNumber(gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number);
|
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)
|
if (_inputState == InputState::DropdownActive)
|
||||||
{
|
{
|
||||||
@@ -1324,7 +1324,7 @@ namespace OpenRCT2
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_inputFlags |= INPUT_FLAG_WIDGET_PRESSED;
|
gInputFlags.set(InputFlag::widgetPressed);
|
||||||
windowMgr->InvalidateWidgetByNumber(cursor_w_class, cursor_w_number, widgetIndex);
|
windowMgr->InvalidateWidgetByNumber(cursor_w_class, cursor_w_number, widgetIndex);
|
||||||
return;
|
return;
|
||||||
case MouseState::LeftRelease:
|
case MouseState::LeftRelease:
|
||||||
@@ -1356,11 +1356,11 @@ namespace OpenRCT2
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
dropdown_index = -1;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1377,9 +1377,9 @@ namespace OpenRCT2
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
cursor_w = windowMgr->FindByNumber(cursor_w_class, cursor_w_number);
|
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);
|
windowMgr->InvalidateWidgetByNumber(cursor_w_class, cursor_w_number, cursor_widgetIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1439,9 +1439,9 @@ namespace OpenRCT2
|
|||||||
if (_inputState != InputState::DropdownActive)
|
if (_inputState != InputState::DropdownActive)
|
||||||
{
|
{
|
||||||
// Hold down widget and drag outside of area??
|
// 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);
|
windowMgr->InvalidateWidgetByNumber(cursor_w_class, cursor_w_number, cursor_widgetIndex);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -1681,12 +1681,12 @@ namespace OpenRCT2
|
|||||||
}
|
}
|
||||||
|
|
||||||
mainWindow->savedViewPos.x += dx;
|
mainWindow->savedViewPos.x += dx;
|
||||||
_inputFlags |= INPUT_FLAG_VIEWPORT_SCROLLING;
|
gInputFlags.set(InputFlag::viewportScrolling);
|
||||||
}
|
}
|
||||||
if (scrollScreenCoords.y != 0)
|
if (scrollScreenCoords.y != 0)
|
||||||
{
|
{
|
||||||
mainWindow->savedViewPos.y += dy;
|
mainWindow->savedViewPos.y += dy;
|
||||||
_inputFlags |= INPUT_FLAG_VIEWPORT_SCROLLING;
|
gInputFlags.set(InputFlag::viewportScrolling);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace OpenRCT2
|
} // namespace OpenRCT2
|
||||||
|
|||||||
@@ -773,7 +773,7 @@ void ShortcutManager::RegisterDefaultShortcuts()
|
|||||||
{
|
{
|
||||||
windowMgr->Close(*window);
|
windowMgr->Close(*window);
|
||||||
}
|
}
|
||||||
else if (InputTestFlag(INPUT_FLAG_TOOL_ACTIVE))
|
else if (gInputFlags.has(InputFlag::toolActive))
|
||||||
{
|
{
|
||||||
ToolCancel();
|
ToolCancel();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -465,7 +465,7 @@ namespace OpenRCT2::Ui
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(InputTestFlag(INPUT_FLAG_6)) || !(InputTestFlag(INPUT_FLAG_TOOL_ACTIVE)))
|
if (!gInputFlags.has(InputFlag::unk6) || !gInputFlags.has(InputFlag::toolActive))
|
||||||
{
|
{
|
||||||
auto* windowMgr = GetWindowManager();
|
auto* windowMgr = GetWindowManager();
|
||||||
if (windowMgr->FindByClass(WindowClass::RideConstruction) == nullptr
|
if (windowMgr->FindByClass(WindowClass::RideConstruction) == nullptr
|
||||||
|
|||||||
@@ -900,7 +900,7 @@ namespace OpenRCT2::Ui
|
|||||||
|
|
||||||
if (InputGetState() == InputState::WidgetPressed || InputGetState() == InputState::DropdownActive)
|
if (InputGetState() == InputState::WidgetPressed || InputGetState() == InputState::DropdownActive)
|
||||||
{
|
{
|
||||||
if (!(InputTestFlag(INPUT_FLAG_WIDGET_PRESSED)))
|
if (!gInputFlags.has(InputFlag::widgetPressed))
|
||||||
return false;
|
return false;
|
||||||
if (gPressedWidget.window_classification != w.classification)
|
if (gPressedWidget.window_classification != w.classification)
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ namespace OpenRCT2
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Check window cursor is over
|
// Check window cursor is over
|
||||||
if (!(InputTestFlag(INPUT_FLAG_5)))
|
if (!gInputFlags.has(InputFlag::unk5))
|
||||||
{
|
{
|
||||||
auto* windowMgr = GetWindowManager();
|
auto* windowMgr = GetWindowManager();
|
||||||
WindowBase* w = windowMgr->FindFromPoint(cursorState->position);
|
WindowBase* w = windowMgr->FindFromPoint(cursorState->position);
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ namespace OpenRCT2::Scripting
|
|||||||
|
|
||||||
std::shared_ptr<ScTool> tool_get() const
|
std::shared_ptr<ScTool> tool_get() const
|
||||||
{
|
{
|
||||||
if (InputTestFlag(INPUT_FLAG_TOOL_ACTIVE))
|
if (gInputFlags.has(InputFlag::toolActive))
|
||||||
{
|
{
|
||||||
return std::make_shared<ScTool>(_scriptEngine.GetContext());
|
return std::make_shared<ScTool>(_scriptEngine.GetContext());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -401,7 +401,7 @@ namespace OpenRCT2::Ui::Windows
|
|||||||
ShowGridlines();
|
ShowGridlines();
|
||||||
auto* toolWindow = ContextOpenWindow(WindowClass::ClearScenery);
|
auto* toolWindow = ContextOpenWindow(WindowClass::ClearScenery);
|
||||||
ToolSet(*toolWindow, WIDX_BACKGROUND, Tool::bulldozer);
|
ToolSet(*toolWindow, WIDX_BACKGROUND, Tool::bulldozer);
|
||||||
InputSetFlag(INPUT_FLAG_6, true);
|
gInputFlags.set(InputFlag::unk6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace OpenRCT2::Ui::Windows
|
} // namespace OpenRCT2::Ui::Windows
|
||||||
|
|||||||
@@ -357,9 +357,9 @@ namespace OpenRCT2::Ui::Windows
|
|||||||
const ScreenCoordsXY& screenPos, int32_t extray, ColourWithFlags colour, uint8_t customItemHeight, uint8_t flags,
|
const ScreenCoordsXY& screenPos, int32_t extray, ColourWithFlags colour, uint8_t customItemHeight, uint8_t flags,
|
||||||
size_t num_items, int32_t width, size_t prefRowsPerColumn)
|
size_t num_items, int32_t width, size_t prefRowsPerColumn)
|
||||||
{
|
{
|
||||||
InputSetFlag(static_cast<INPUT_FLAGS>(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)
|
if (flags & Dropdown::Flag::StayOpen || Config::Get().interface.TouchEnhancements)
|
||||||
InputSetFlag(INPUT_FLAG_DROPDOWN_STAY_OPEN, true);
|
gInputFlags.set(InputFlag::dropdownStayOpen);
|
||||||
|
|
||||||
WindowDropdownClose();
|
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 x, int32_t y, int32_t extray, ColourWithFlags colour, uint8_t flags, int32_t numItems, int32_t itemWidth,
|
||||||
int32_t itemHeight, int32_t numColumns)
|
int32_t itemHeight, int32_t numColumns)
|
||||||
{
|
{
|
||||||
InputSetFlag(static_cast<INPUT_FLAGS>(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)
|
if (flags & Dropdown::Flag::StayOpen || Config::Get().interface.TouchEnhancements)
|
||||||
InputSetFlag(INPUT_FLAG_DROPDOWN_STAY_OPEN, true);
|
gInputFlags.set(InputFlag::dropdownStayOpen);
|
||||||
|
|
||||||
// Close existing dropdown
|
// Close existing dropdown
|
||||||
WindowDropdownClose();
|
WindowDropdownClose();
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ namespace OpenRCT2::Ui::Windows
|
|||||||
pressed_widgets |= 1LL << WIDX_TAB;
|
pressed_widgets |= 1LL << WIDX_TAB;
|
||||||
|
|
||||||
ToolSet(*this, WIDX_LIST, Tool::entranceDown);
|
ToolSet(*this, WIDX_LIST, Tool::entranceDown);
|
||||||
InputSetFlag(INPUT_FLAG_6, true);
|
gInputFlags.set(InputFlag::unk6);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnMouseUp(WidgetIndex widgetIndex) override
|
void OnMouseUp(WidgetIndex widgetIndex) override
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ namespace OpenRCT2::Ui::Windows
|
|||||||
ToolCancel();
|
ToolCancel();
|
||||||
_footpathConstructionMode = PATH_CONSTRUCTION_MODE_LAND;
|
_footpathConstructionMode = PATH_CONSTRUCTION_MODE_LAND;
|
||||||
ToolSet(*this, WIDX_CONSTRUCT_ON_LAND, Tool::pathDown);
|
ToolSet(*this, WIDX_CONSTRUCT_ON_LAND, Tool::pathDown);
|
||||||
InputSetFlag(INPUT_FLAG_6, true);
|
gInputFlags.set(InputFlag::unk6);
|
||||||
_footpathErrorOccured = false;
|
_footpathErrorOccured = false;
|
||||||
WindowFootpathSetEnabledAndPressedWidgets();
|
WindowFootpathSetEnabledAndPressedWidgets();
|
||||||
|
|
||||||
@@ -333,7 +333,7 @@ namespace OpenRCT2::Ui::Windows
|
|||||||
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
|
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
|
||||||
_footpathConstructionMode = PATH_CONSTRUCTION_MODE_LAND;
|
_footpathConstructionMode = PATH_CONSTRUCTION_MODE_LAND;
|
||||||
ToolSet(*this, WIDX_CONSTRUCT_ON_LAND, Tool::pathDown);
|
ToolSet(*this, WIDX_CONSTRUCT_ON_LAND, Tool::pathDown);
|
||||||
InputSetFlag(INPUT_FLAG_6, true);
|
gInputFlags.set(InputFlag::unk6);
|
||||||
_footpathErrorOccured = false;
|
_footpathErrorOccured = false;
|
||||||
WindowFootpathSetEnabledAndPressedWidgets();
|
WindowFootpathSetEnabledAndPressedWidgets();
|
||||||
break;
|
break;
|
||||||
@@ -350,7 +350,7 @@ namespace OpenRCT2::Ui::Windows
|
|||||||
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
|
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
|
||||||
_footpathConstructionMode = PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL_TOOL;
|
_footpathConstructionMode = PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL_TOOL;
|
||||||
ToolSet(*this, WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL, Tool::crosshair);
|
ToolSet(*this, WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL, Tool::crosshair);
|
||||||
InputSetFlag(INPUT_FLAG_6, true);
|
gInputFlags.set(InputFlag::unk6);
|
||||||
_footpathErrorOccured = false;
|
_footpathErrorOccured = false;
|
||||||
WindowFootpathSetEnabledAndPressedWidgets();
|
WindowFootpathSetEnabledAndPressedWidgets();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -890,7 +890,7 @@ namespace OpenRCT2::Ui::Windows
|
|||||||
ShowGridlines();
|
ShowGridlines();
|
||||||
auto* toolWindow = ContextOpenWindow(WindowClass::Land);
|
auto* toolWindow = ContextOpenWindow(WindowClass::Land);
|
||||||
ToolSet(*toolWindow, WIDX_BACKGROUND, Tool::digDown);
|
ToolSet(*toolWindow, WIDX_BACKGROUND, Tool::digDown);
|
||||||
InputSetFlag(INPUT_FLAG_6, true);
|
gInputFlags.set(InputFlag::unk6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace OpenRCT2::Ui::Windows
|
} // namespace OpenRCT2::Ui::Windows
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ namespace OpenRCT2::Ui::Windows
|
|||||||
_landRightsMode = mode;
|
_landRightsMode = mode;
|
||||||
|
|
||||||
ToolSet(*this, widgetIndex, Tool::upArrow);
|
ToolSet(*this, widgetIndex, Tool::upArrow);
|
||||||
InputSetFlag(INPUT_FLAG_6, true);
|
gInputFlags.set(InputFlag::unk6);
|
||||||
|
|
||||||
if (kLandRightsVisibleByMode[EnumValue(mode)])
|
if (kLandRightsVisibleByMode[EnumValue(mode)])
|
||||||
ShowLandRights();
|
ShowLandRights();
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ namespace OpenRCT2::Ui::Windows
|
|||||||
|
|
||||||
// Check for cursor movement
|
// Check for cursor movement
|
||||||
_cursorHoldDuration++;
|
_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)
|
|| InputGetState() == InputState::ViewportRight)
|
||||||
_cursorHoldDuration = 0;
|
_cursorHoldDuration = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -316,7 +316,7 @@ namespace OpenRCT2::Ui::Windows
|
|||||||
: ENTRANCE_TYPE_RIDE_EXIT;
|
: ENTRANCE_TYPE_RIDE_EXIT;
|
||||||
gRideEntranceExitPlaceRideIndex = rideId;
|
gRideEntranceExitPlaceRideIndex = rideId;
|
||||||
gRideEntranceExitPlaceStationIndex = StationIndex::FromUnderlying(0);
|
gRideEntranceExitPlaceStationIndex = StationIndex::FromUnderlying(0);
|
||||||
InputSetFlag(INPUT_FLAG_6, true);
|
gInputFlags.set(InputFlag::unk6);
|
||||||
|
|
||||||
RideConstructionInvalidateCurrentTrack();
|
RideConstructionInvalidateCurrentTrack();
|
||||||
|
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ namespace OpenRCT2::Ui::Windows
|
|||||||
if (!ToolSet(*this, 0, Tool::walkDown))
|
if (!ToolSet(*this, 0, Tool::walkDown))
|
||||||
{
|
{
|
||||||
ShowGridlines();
|
ShowGridlines();
|
||||||
InputSetFlag(INPUT_FLAG_6, true);
|
gInputFlags.set(InputFlag::unk6);
|
||||||
SetPatrolAreaToRender(_staffId);
|
SetPatrolAreaToRender(_staffId);
|
||||||
GfxInvalidateScreen();
|
GfxInvalidateScreen();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2444,7 +2444,7 @@ namespace OpenRCT2::Ui::Windows
|
|||||||
gRideEntranceExitPlaceType = ENTRANCE_TYPE_RIDE_ENTRANCE;
|
gRideEntranceExitPlaceType = ENTRANCE_TYPE_RIDE_ENTRANCE;
|
||||||
gRideEntranceExitPlaceRideIndex = _currentRideIndex;
|
gRideEntranceExitPlaceRideIndex = _currentRideIndex;
|
||||||
gRideEntranceExitPlaceStationIndex = StationIndex::FromUnderlying(0);
|
gRideEntranceExitPlaceStationIndex = StationIndex::FromUnderlying(0);
|
||||||
InputSetFlag(INPUT_FLAG_6, true);
|
gInputFlags.set(InputFlag::unk6);
|
||||||
RideConstructionInvalidateCurrentTrack();
|
RideConstructionInvalidateCurrentTrack();
|
||||||
if (_rideConstructionState != RideConstructionState::EntranceExit)
|
if (_rideConstructionState != RideConstructionState::EntranceExit)
|
||||||
{
|
{
|
||||||
@@ -2470,7 +2470,7 @@ namespace OpenRCT2::Ui::Windows
|
|||||||
gRideEntranceExitPlaceType = ENTRANCE_TYPE_RIDE_EXIT;
|
gRideEntranceExitPlaceType = ENTRANCE_TYPE_RIDE_EXIT;
|
||||||
gRideEntranceExitPlaceRideIndex = _currentRideIndex;
|
gRideEntranceExitPlaceRideIndex = _currentRideIndex;
|
||||||
gRideEntranceExitPlaceStationIndex = StationIndex::FromUnderlying(0);
|
gRideEntranceExitPlaceStationIndex = StationIndex::FromUnderlying(0);
|
||||||
InputSetFlag(INPUT_FLAG_6, true);
|
gInputFlags.set(InputFlag::unk6);
|
||||||
RideConstructionInvalidateCurrentTrack();
|
RideConstructionInvalidateCurrentTrack();
|
||||||
if (_rideConstructionState != RideConstructionState::EntranceExit)
|
if (_rideConstructionState != RideConstructionState::EntranceExit)
|
||||||
{
|
{
|
||||||
@@ -3671,7 +3671,7 @@ namespace OpenRCT2::Ui::Windows
|
|||||||
if (w != nullptr)
|
if (w != nullptr)
|
||||||
{
|
{
|
||||||
ToolSet(*w, WIDX_CONSTRUCT, Tool::crosshair);
|
ToolSet(*w, WIDX_CONSTRUCT, Tool::crosshair);
|
||||||
InputSetFlag(INPUT_FLAG_6, true);
|
gInputFlags.set(InputFlag::unk6);
|
||||||
_trackPlaceCtrlState = false;
|
_trackPlaceCtrlState = false;
|
||||||
_trackPlaceShiftState = false;
|
_trackPlaceShiftState = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3300,7 +3300,7 @@ namespace OpenRCT2::Ui::Windows
|
|||||||
{
|
{
|
||||||
auto* toolWindow = ContextOpenWindow(WindowClass::Scenery);
|
auto* toolWindow = ContextOpenWindow(WindowClass::Scenery);
|
||||||
ToolSet(*toolWindow, WIDX_SCENERY_BACKGROUND, Tool::arrow);
|
ToolSet(*toolWindow, WIDX_SCENERY_BACKGROUND, Tool::arrow);
|
||||||
InputSetFlag(INPUT_FLAG_6, true);
|
gInputFlags.set(InputFlag::unk6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace OpenRCT2::Ui::Windows
|
} // namespace OpenRCT2::Ui::Windows
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ namespace OpenRCT2::Ui::Windows
|
|||||||
gTooltipCloseTimeout = 0;
|
gTooltipCloseTimeout = 0;
|
||||||
gTooltipWidget.window_classification = WindowClass::Null;
|
gTooltipWidget.window_classification = WindowClass::Null;
|
||||||
InputSetState(InputState::Normal);
|
InputSetState(InputState::Normal);
|
||||||
InputSetFlag(INPUT_FLAG_4, false);
|
gInputFlags.unset(InputFlag::unk4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowTooltipShow(const OpenRCT2String& message, ScreenCoordsXY screenCoords)
|
void WindowTooltipShow(const OpenRCT2String& message, ScreenCoordsXY screenCoords)
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ namespace OpenRCT2::Ui::Windows
|
|||||||
SetWidgets(_trackPlaceWidgets);
|
SetWidgets(_trackPlaceWidgets);
|
||||||
WindowInitScrollWidgets(*this);
|
WindowInitScrollWidgets(*this);
|
||||||
ToolSet(*this, WIDX_PRICE, Tool::crosshair);
|
ToolSet(*this, WIDX_PRICE, Tool::crosshair);
|
||||||
InputSetFlag(INPUT_FLAG_6, true);
|
gInputFlags.set(InputFlag::unk6);
|
||||||
WindowPushOthersRight(*this);
|
WindowPushOthersRight(*this);
|
||||||
ShowGridlines();
|
ShowGridlines();
|
||||||
_miniPreview.resize(TRACK_MINI_PREVIEW_SIZE);
|
_miniPreview.resize(TRACK_MINI_PREVIEW_SIZE);
|
||||||
|
|||||||
@@ -447,7 +447,7 @@ namespace OpenRCT2::Ui::Windows
|
|||||||
ShowGridlines();
|
ShowGridlines();
|
||||||
auto* toolWindow = ContextOpenWindow(WindowClass::Water);
|
auto* toolWindow = ContextOpenWindow(WindowClass::Water);
|
||||||
ToolSet(*toolWindow, WIDX_BACKGROUND, Tool::waterDown);
|
ToolSet(*toolWindow, WIDX_BACKGROUND, Tool::waterDown);
|
||||||
InputSetFlag(INPUT_FLAG_6, true);
|
gInputFlags.set(InputFlag::unk6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace OpenRCT2::Ui::Windows
|
} // namespace OpenRCT2::Ui::Windows
|
||||||
|
|||||||
@@ -677,9 +677,9 @@ void GameLoadOrQuitNoSavePrompt()
|
|||||||
auto loadOrQuitAction = LoadOrQuitAction(LoadOrQuitModes::CloseSavePrompt);
|
auto loadOrQuitAction = LoadOrQuitAction(LoadOrQuitModes::CloseSavePrompt);
|
||||||
GameActions::Execute(&loadOrQuitAction);
|
GameActions::Execute(&loadOrQuitAction);
|
||||||
ToolCancel();
|
ToolCancel();
|
||||||
if (InputTestFlag(INPUT_FLAG_5))
|
if (gInputFlags.has(InputFlag::unk5))
|
||||||
{
|
{
|
||||||
InputSetFlag(INPUT_FLAG_5, false);
|
gInputFlags.unset(InputFlag::unk5);
|
||||||
}
|
}
|
||||||
GameResetSpeed();
|
GameResetSpeed();
|
||||||
gFirstTimeSaving = true;
|
gFirstTimeSaving = true;
|
||||||
|
|||||||
@@ -190,9 +190,9 @@ namespace OpenRCT2
|
|||||||
{
|
{
|
||||||
if (InputGetState() == InputState::Reset || InputGetState() == InputState::Normal)
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -211,7 +211,7 @@ namespace OpenRCT2
|
|||||||
|
|
||||||
if (!gOpenRCT2Headless)
|
if (!gOpenRCT2Headless)
|
||||||
{
|
{
|
||||||
InputSetFlag(INPUT_FLAG_VIEWPORT_SCROLLING, false);
|
gInputFlags.unset(InputFlag::viewportScrolling);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always perform autosave check, even when paused
|
// Always perform autosave check, even when paused
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
namespace OpenRCT2
|
namespace OpenRCT2
|
||||||
{
|
{
|
||||||
InputState _inputState;
|
InputState _inputState;
|
||||||
uint8_t _inputFlags;
|
InputFlags gInputFlags;
|
||||||
|
|
||||||
WidgetRef gHoverWidget;
|
WidgetRef gHoverWidget;
|
||||||
WidgetRef gPressedWidget;
|
WidgetRef gPressedWidget;
|
||||||
@@ -40,28 +40,6 @@ namespace OpenRCT2
|
|||||||
ContextInputHandleKeyboard(false);
|
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)
|
void InputSetState(InputState state)
|
||||||
{
|
{
|
||||||
_inputState = state;
|
_inputState = state;
|
||||||
|
|||||||
@@ -9,34 +9,36 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/FlagHolder.hpp"
|
||||||
#include "interface/Window.h"
|
#include "interface/Window.h"
|
||||||
|
|
||||||
namespace OpenRCT2
|
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
|
// The dropdown can stay open if the mouse is released, set on flag Dropdown::Flag::StayOpen.
|
||||||
INPUT_FLAG_DROPDOWN_STAY_OPEN = (1 << 1),
|
dropdownStayOpen,
|
||||||
|
|
||||||
// The mouse has been released and the dropdown is still open
|
// The mouse has been released and the dropdown is still open.
|
||||||
// INPUT_FLAG_DROPDOWN_STAY_OPEN is already set if this happens
|
// InputFlag::dropdownStayOpen is already set if this happens.
|
||||||
INPUT_FLAG_DROPDOWN_MOUSE_UP = (1 << 2),
|
dropdownMouseUp,
|
||||||
|
|
||||||
INPUT_FLAG_TOOL_ACTIVE = (1 << 3),
|
toolActive,
|
||||||
|
|
||||||
// Left click on a viewport
|
// 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)
|
// Some of the map tools (clear, footpath, scenery)
|
||||||
// never read as far as I know.
|
// never read as far as I know.
|
||||||
INPUT_FLAG_6 = (1 << 6),
|
unk6,
|
||||||
|
|
||||||
INPUT_FLAG_VIEWPORT_SCROLLING = (1 << 7)
|
viewportScrolling,
|
||||||
};
|
};
|
||||||
|
using InputFlags = FlagHolder<uint8_t, InputFlag>;
|
||||||
|
|
||||||
enum class InputState
|
enum class InputState
|
||||||
{
|
{
|
||||||
@@ -61,16 +63,12 @@ namespace OpenRCT2
|
|||||||
|
|
||||||
// TODO: Move to openrct2-ui and make static again
|
// TODO: Move to openrct2-ui and make static again
|
||||||
extern InputState _inputState;
|
extern InputState _inputState;
|
||||||
extern uint8_t _inputFlags;
|
extern InputFlags gInputFlags;
|
||||||
extern uint32_t _tooltipNotShownTimeout;
|
extern uint32_t _tooltipNotShownTimeout;
|
||||||
|
|
||||||
void TitleHandleKeyboardInput();
|
void TitleHandleKeyboardInput();
|
||||||
void GameHandleKeyboardInput();
|
void GameHandleKeyboardInput();
|
||||||
|
|
||||||
void InputSetFlag(INPUT_FLAGS flag, bool on);
|
|
||||||
bool InputTestFlag(INPUT_FLAGS flag);
|
|
||||||
void InputResetFlags();
|
|
||||||
|
|
||||||
void InputSetState(InputState state);
|
void InputSetState(InputState state);
|
||||||
InputState InputGetState();
|
InputState InputGetState();
|
||||||
|
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ GameActions::Result PeepPickupAction::Execute() const
|
|||||||
if (_owner == NetworkGetCurrentPlayerId())
|
if (_owner == NetworkGetCurrentPlayerId())
|
||||||
{
|
{
|
||||||
// prevent tool_cancel()
|
// prevent tool_cancel()
|
||||||
InputSetFlag(INPUT_FLAG_TOOL_ACTIVE, false);
|
gInputFlags.unset(InputFlag::toolActive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ namespace OpenRCT2
|
|||||||
WindowInitAll();
|
WindowInitAll();
|
||||||
|
|
||||||
// ?
|
// ?
|
||||||
InputResetFlags();
|
gInputFlags.clearAll();
|
||||||
InputSetState(InputState::Reset);
|
InputSetState(InputState::Reset);
|
||||||
gPressedWidget.window_classification = WindowClass::Null;
|
gPressedWidget.window_classification = WindowClass::Null;
|
||||||
gPickupPeepImage = ImageId();
|
gPickupPeepImage = ImageId();
|
||||||
|
|||||||
@@ -629,7 +629,7 @@ static constexpr float kWindowScrollLocations[][2] = {
|
|||||||
|
|
||||||
bool isToolActive(WindowClass cls)
|
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)
|
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)
|
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
|
if (w.classification == gCurrentToolWidget.window_classification && w.number == gCurrentToolWidget.window_number
|
||||||
&& widgetIndex == gCurrentToolWidget.widget_index)
|
&& widgetIndex == gCurrentToolWidget.widget_index)
|
||||||
@@ -674,9 +674,9 @@ static constexpr float kWindowScrollLocations[][2] = {
|
|||||||
ToolCancel();
|
ToolCancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
InputSetFlag(INPUT_FLAG_TOOL_ACTIVE, true);
|
gInputFlags.set(InputFlag::toolActive);
|
||||||
InputSetFlag(INPUT_FLAG_4, false);
|
gInputFlags.unset(InputFlag::unk4);
|
||||||
InputSetFlag(INPUT_FLAG_6, false);
|
gInputFlags.unset(InputFlag::unk6);
|
||||||
gCurrentToolId = tool;
|
gCurrentToolId = tool;
|
||||||
gCurrentToolWidget.window_classification = w.classification;
|
gCurrentToolWidget.window_classification = w.classification;
|
||||||
gCurrentToolWidget.window_number = w.number;
|
gCurrentToolWidget.window_number = w.number;
|
||||||
@@ -690,9 +690,9 @@ static constexpr float kWindowScrollLocations[][2] = {
|
|||||||
*/
|
*/
|
||||||
void ToolCancel()
|
void ToolCancel()
|
||||||
{
|
{
|
||||||
if (InputTestFlag(INPUT_FLAG_TOOL_ACTIVE))
|
if (gInputFlags.has(InputFlag::toolActive))
|
||||||
{
|
{
|
||||||
InputSetFlag(INPUT_FLAG_TOOL_ACTIVE, false);
|
gInputFlags.unset(InputFlag::toolActive);
|
||||||
|
|
||||||
MapInvalidateSelectionRect();
|
MapInvalidateSelectionRect();
|
||||||
MapInvalidateMapSelectionTiles();
|
MapInvalidateMapSelectionTiles();
|
||||||
|
|||||||
@@ -883,7 +883,7 @@ static bool ride_modify_entrance_or_exit(const CoordsXYE& tileElement)
|
|||||||
gRideEntranceExitPlaceType = entranceType;
|
gRideEntranceExitPlaceType = entranceType;
|
||||||
gRideEntranceExitPlaceRideIndex = rideIndex;
|
gRideEntranceExitPlaceRideIndex = rideIndex;
|
||||||
gRideEntranceExitPlaceStationIndex = stationIndex;
|
gRideEntranceExitPlaceStationIndex = stationIndex;
|
||||||
InputSetFlag(INPUT_FLAG_6, true);
|
gInputFlags.set(InputFlag::unk6);
|
||||||
if (_rideConstructionState != RideConstructionState::EntranceExit)
|
if (_rideConstructionState != RideConstructionState::EntranceExit)
|
||||||
{
|
{
|
||||||
gRideEntranceExitPlacePreviousRideConstructionState = _rideConstructionState;
|
gRideEntranceExitPlacePreviousRideConstructionState = _rideConstructionState;
|
||||||
@@ -1073,7 +1073,7 @@ int32_t RideInitialiseConstructionWindow(Ride& ride)
|
|||||||
w = ride_create_or_find_construction_window(ride.id);
|
w = ride_create_or_find_construction_window(ride.id);
|
||||||
|
|
||||||
ToolSet(*w, WC_RIDE_CONSTRUCTION__WIDX_CONSTRUCT, Tool::crosshair);
|
ToolSet(*w, WC_RIDE_CONSTRUCTION__WIDX_CONSTRUCT, Tool::crosshair);
|
||||||
InputSetFlag(INPUT_FLAG_6, true);
|
gInputFlags.set(InputFlag::unk6);
|
||||||
|
|
||||||
_currentlySelectedTrack = ride.getRideTypeDescriptor().StartTrackPiece;
|
_currentlySelectedTrack = ride.getRideTypeDescriptor().StartTrackPiece;
|
||||||
_currentTrackPitchEnd = TrackPitch::None;
|
_currentTrackPitchEnd = TrackPitch::None;
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ void TitleScene::Tick()
|
|||||||
// update_weather_animation();
|
// update_weather_animation();
|
||||||
}
|
}
|
||||||
|
|
||||||
InputSetFlag(INPUT_FLAG_VIEWPORT_SCROLLING, false);
|
gInputFlags.unset(InputFlag::viewportScrolling);
|
||||||
|
|
||||||
ContextHandleInput();
|
ContextHandleInput();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user