1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-31 02:35:46 +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

@@ -199,8 +199,7 @@ namespace OpenRCT2::Ui
w.windowPos + ScreenCoordsXY{ widget.right, widget.bottom } };
// Check if the button is pressed down
uint8_t press = WidgetIsPressed(w, widgetIndex) || WidgetIsActiveTool(w, widgetIndex) ? INSET_RECT_FLAG_BORDER_INSET
: 0;
uint8_t press = WidgetIsPressed(w, widgetIndex) || isToolActive(w, widgetIndex) ? INSET_RECT_FLAG_BORDER_INSET : 0;
auto colour = w.colours[widget.colour];
@@ -288,7 +287,7 @@ namespace OpenRCT2::Ui
auto colour = w.colours[widget.colour];
// Check if the button is pressed down
if (WidgetIsPressed(w, widgetIndex) || WidgetIsActiveTool(w, widgetIndex))
if (WidgetIsPressed(w, widgetIndex) || isToolActive(w, widgetIndex))
{
if (static_cast<int32_t>(widget.image.ToUInt32()) == -2)
{
@@ -321,8 +320,7 @@ namespace OpenRCT2::Ui
auto colour = w.colours[widget.colour];
// Border
uint8_t press = WidgetIsPressed(w, widgetIndex) || WidgetIsActiveTool(w, widgetIndex) ? INSET_RECT_FLAG_BORDER_INSET
: 0;
uint8_t press = WidgetIsPressed(w, widgetIndex) || isToolActive(w, widgetIndex) ? INSET_RECT_FLAG_BORDER_INSET : 0;
GfxFillRectInset(dpi, rect, colour, press);
// Button caption
@@ -597,7 +595,7 @@ namespace OpenRCT2::Ui
uint8_t press = 0;
if (w.flags & WF_10)
press |= INSET_RECT_FLAG_FILL_MID_LIGHT;
if (WidgetIsPressed(w, widgetIndex) || WidgetIsActiveTool(w, widgetIndex))
if (WidgetIsPressed(w, widgetIndex) || isToolActive(w, widgetIndex))
press |= INSET_RECT_FLAG_BORDER_INSET;
auto colour = w.colours[widget.colour];
@@ -826,7 +824,7 @@ namespace OpenRCT2::Ui
if (widget.type == WindowWidgetType::ColourBtn || widget.type == WindowWidgetType::TrnBtn
|| widget.type == WindowWidgetType::Tab)
if (WidgetIsPressed(w, widgetIndex) || WidgetIsActiveTool(w, widgetIndex))
if (WidgetIsPressed(w, widgetIndex) || isToolActive(w, widgetIndex))
image = image.WithIndexOffset(1);
const auto colour = w.colours[widget.colour].colour;
@@ -918,20 +916,6 @@ namespace OpenRCT2::Ui
return true;
}
bool WidgetIsActiveTool(const WindowBase& w, WidgetIndex widgetIndex)
{
if (!(InputTestFlag(INPUT_FLAG_TOOL_ACTIVE)))
return false;
if (gCurrentToolWidget.window_classification != w.classification)
return false;
if (gCurrentToolWidget.window_number != w.number)
return false;
if (gCurrentToolWidget.widget_index != widgetIndex)
return false;
return true;
}
/**
*
* rct2: 0x006E9F92