1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-22 15:23:01 +01:00

Introduce isToolActive function as alternative for globals (#22430)

* Introduce isToolActive function
* Ride window: use isToolActive instead of gCurrentToolWidget
* Footpath window: use isToolActive instead of gCurrentToolWidget
* Staff window: use isToolActive instead of gCurrentToolWidget
* MazeConstruction window: use isToolActive instead of gCurrentToolWidget
* Guest window: use isToolActive instead of gCurrentToolWidget
* Map window: use isToolActive instead of gCurrentToolWidget
* LandRights window: use isToolActive instead of gCurrentToolWidget
* Replace SceneryToolIsActive legacy function with calls to isToolActive
* ClearScenery window: use isToolActive instead of gCurrentToolWidget
* Scenery window: use isToolActive instead of gCurrentToolWidget
* Water window: use isToolActive instead of gCurrentToolWidget
* Land window: use isToolActive instead of gCurrentToolWidget
* Widget: replace WidgetIsActiveTool with isToolActive
* RideConstruction window: use isToolActive instead of gCurrentToolWidget
* Ride: use isToolActive instead of gCurrentToolWidget
* TrackDesignPlace window: use isToolActive instead of gCurrentToolWidget
* StaffList window: use isToolActive instead of gCurrentToolWidget
* ViewClipping window: use isToolActive instead of gCurrentToolWidget
* PatrolArea window: use isToolActive instead of gCurrentToolWidget
* TileInspector window: use isToolActive instead of gCurrentToolWidget
* Park window: use isToolActive instead of gCurrentToolWidget
This commit is contained in:
Aaron van Geffen
2024-08-05 10:47:36 +02:00
parent 7f46cc8bd0
commit 03bc1e5707
30 changed files with 152 additions and 272 deletions

View File

@@ -50,6 +50,9 @@ WindowCloseModifier gLastCloseModifier = { { WindowClass::Null, 0 }, CloseWindow
uint32_t gWindowUpdateTicks;
colour_t gCurrentWindowColours[3];
Tool gCurrentToolId;
WidgetRef gCurrentToolWidget;
// converted from uint16_t values at 0x009A41EC - 0x009A4230
// these are percentage coordinates of the viewport to centre to, if a window is obscuring a location, the next is tried
// clang-format off
@@ -1103,6 +1106,31 @@ static void WindowDrawSingle(DrawPixelInfo& dpi, WindowBase& w, int32_t left, in
w.OnDraw(copy);
}
bool isToolActive(WindowClass cls)
{
return InputTestFlag(INPUT_FLAG_TOOL_ACTIVE) && gCurrentToolWidget.window_classification == cls;
}
bool isToolActive(WindowClass cls, rct_windownumber number)
{
return isToolActive(cls) && gCurrentToolWidget.window_number == number;
}
bool isToolActive(WindowClass cls, WidgetIndex widgetIndex)
{
return isToolActive(cls) && gCurrentToolWidget.widget_index == widgetIndex;
}
bool isToolActive(WindowClass cls, WidgetIndex widgetIndex, rct_windownumber number)
{
return isToolActive(cls, widgetIndex) && gCurrentToolWidget.window_number == number;
}
bool isToolActive(const WindowBase& w, WidgetIndex widgetIndex)
{
return isToolActive(w.classification, widgetIndex, w.number);
}
/**
*
* rct2: 0x006EE212