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

Remove forwarding functions in Window.cpp (#21516)

This commit is contained in:
mrmbernardi
2024-03-03 18:04:09 +01:00
committed by GitHub
parent bc149ca95c
commit 4ccecd6e68
28 changed files with 211 additions and 376 deletions

View File

@@ -114,7 +114,7 @@ void WindowVisitEach(std::function<void(WindowBase*)> func)
void WindowDispatchUpdateAll()
{
// gTooltipNotShownTicks++;
WindowVisitEach([&](WindowBase* w) { WindowEventUpdateCall(w); });
WindowVisitEach([&](WindowBase* w) { w->OnUpdate(); });
}
void WindowUpdateAllViewports()
@@ -140,7 +140,7 @@ void WindowUpdateAll()
{
gWindowUpdateTicks = gCurrentRealTimeTicks + kGameUpdateFPS;
WindowVisitEach([](WindowBase* w) { WindowEventPeriodicUpdateCall(w); });
WindowVisitEach([](WindowBase* w) { w->OnPeriodicUpdate(); });
}
// Border flash invalidation
@@ -218,7 +218,7 @@ void WindowSetWindowLimit(int32_t value)
*/
void WindowClose(WindowBase& w)
{
WindowEventCloseCall(&w);
w.OnClose();
// Remove viewport
w.RemoveViewport();
@@ -427,7 +427,7 @@ WindowBase* WindowFindFromPoint(const ScreenCoordsXY& screenCoords)
WidgetIndex WindowFindWidgetFromPoint(WindowBase& w, const ScreenCoordsXY& screenCoords)
{
// Invalidate the window
WindowEventOnPrepareDrawCall(&w);
w.OnPrepareDraw();
// Find the widget at point x, y
WidgetIndex widget_index = -1;
@@ -589,9 +589,10 @@ void WindowUpdateScrollWidgets(WindowBase& w)
continue;
auto& scroll = w.scrolls[scrollIndex];
width = 0;
height = 0;
WindowGetScrollSize(&w, scrollIndex, &width, &height);
ScreenSize scrollSize = w.OnScrollGetSize(scrollIndex);
width = scrollSize.width;
height = scrollSize.height;
if (height == 0)
{
scroll.v_top = 0;
@@ -894,7 +895,7 @@ void WindowScrollToLocation(WindowBase& w, const CoordsXYZ& coords)
*/
static void call_event_viewport_rotate_on_all_windows()
{
WindowVisitEach([](WindowBase* w) { WindowEventViewportRotateCall(w); });
WindowVisitEach([](WindowBase* w) { w->OnViewportRotate(); });
}
/**
@@ -1241,7 +1242,7 @@ static void WindowDrawSingle(DrawPixelInfo& dpi, WindowBase& w, int32_t left, in
// Invalidate modifies the window colours so first get the correct
// colour before setting the global variables for the string painting
WindowEventOnPrepareDrawCall(&w);
w.OnPrepareDraw();
// Text colouring
gCurrentWindowColours[0] = NOT_TRANSLUCENT(w.colours[0]);
@@ -1249,7 +1250,7 @@ static void WindowDrawSingle(DrawPixelInfo& dpi, WindowBase& w, int32_t left, in
gCurrentWindowColours[2] = NOT_TRANSLUCENT(w.colours[2]);
gCurrentWindowColours[3] = NOT_TRANSLUCENT(w.colours[3]);
WindowEventOnDrawCall(&w, copy);
w.OnDraw(copy);
}
/**
@@ -1300,8 +1301,8 @@ void WindowResize(WindowBase& w, int32_t dw, int32_t dh)
w.width = std::clamp<int32_t>(w.width + dw, w.min_width, w.max_width);
w.height = std::clamp<int32_t>(w.height + dh, w.min_height, w.max_height);
WindowEventResizeCall(&w);
WindowEventOnPrepareDrawCall(&w);
w.OnResize();
w.OnPrepareDraw();
// Update scroll widgets
for (auto& scroll : w.scrolls)
@@ -1393,143 +1394,11 @@ void ToolCancel()
// Abort tool event
WindowBase* w = WindowFindByNumber(gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number);
if (w != nullptr)
WindowEventToolAbortCall(w, gCurrentToolWidget.widget_index);
w->OnToolAbort(gCurrentToolWidget.widget_index);
}
}
}
void WindowEventCloseCall(WindowBase* w)
{
w->OnClose();
}
void WindowEventMouseUpCall(WindowBase* w, WidgetIndex widgetIndex)
{
w->OnMouseUp(widgetIndex);
}
void WindowEventResizeCall(WindowBase* w)
{
w->OnResize();
}
void WindowEventMouseDownCall(WindowBase* w, WidgetIndex widgetIndex)
{
w->OnMouseDown(widgetIndex);
}
void WindowEventDropdownCall(WindowBase* w, WidgetIndex widgetIndex, int32_t dropdownIndex)
{
w->OnDropdown(widgetIndex, dropdownIndex);
}
void WindowEventUpdateCall(WindowBase* w)
{
w->OnUpdate();
}
void WindowEventPeriodicUpdateCall(WindowBase* w)
{
w->OnPeriodicUpdate();
}
void WindowEventToolUpdateCall(WindowBase* w, WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords)
{
w->OnToolUpdate(widgetIndex, screenCoords);
}
void WindowEventToolDownCall(WindowBase* w, WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords)
{
w->OnToolDown(widgetIndex, screenCoords);
}
void WindowEventToolDragCall(WindowBase* w, WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords)
{
w->OnToolDrag(widgetIndex, screenCoords);
}
void WindowEventToolUpCall(WindowBase* w, WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords)
{
w->OnToolUp(widgetIndex, screenCoords);
}
void WindowEventToolAbortCall(WindowBase* w, WidgetIndex widgetIndex)
{
w->OnToolAbort(widgetIndex);
}
void WindowGetScrollSize(WindowBase* w, int32_t scrollIndex, int32_t* width, int32_t* height)
{
auto size = w->OnScrollGetSize(scrollIndex);
if (width != nullptr)
*width = size.width;
if (height != nullptr)
*height = size.height;
}
void WindowEventScrollMousedownCall(WindowBase* w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords)
{
w->OnScrollMouseDown(scrollIndex, screenCoords);
}
void WindowEventScrollMousedragCall(WindowBase* w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords)
{
w->OnScrollMouseDrag(scrollIndex, screenCoords);
}
void WindowEventScrollMouseoverCall(WindowBase* w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords)
{
w->OnScrollMouseOver(scrollIndex, screenCoords);
}
void WindowEventTextinputCall(WindowBase* w, WidgetIndex widgetIndex, const char* text)
{
if (text != nullptr)
{
w->OnTextInput(widgetIndex, text);
}
}
void WindowEventViewportRotateCall(WindowBase* w)
{
w->OnViewportRotate();
}
void WindowEventScrollSelectCall(WindowBase* w, int32_t scrollIndex, int32_t scrollAreaType)
{
w->OnScrollSelect(scrollIndex, scrollAreaType);
}
OpenRCT2String WindowEventTooltipCall(WindowBase* w, const WidgetIndex widgetIndex, const StringId fallback)
{
return w->OnTooltip(widgetIndex, fallback);
}
CursorID WindowEventCursorCall(WindowBase* w, WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords)
{
return w->OnCursor(widgetIndex, screenCoords, CursorID::Arrow);
}
void WindowEventMovedCall(WindowBase* w, const ScreenCoordsXY& screenCoords)
{
w->OnMoved(screenCoords);
}
void WindowEventOnPrepareDrawCall(WindowBase* w)
{
w->OnPrepareDraw();
}
void WindowEventOnDrawCall(WindowBase* w, DrawPixelInfo& dpi)
{
w->OnDraw(dpi);
}
void WindowEventScrollDrawCall(WindowBase* w, DrawPixelInfo& dpi, int32_t scrollIndex)
{
w->OnScrollDraw(scrollIndex, dpi);
}
/**
*
* rct2: 0x006ED710
@@ -1874,10 +1743,6 @@ void WindowCancelTextbox()
if (gUsingWidgetTextBox)
{
WindowBase* w = WindowFindByNumber(gCurrentTextBox.window.classification, gCurrentTextBox.window.number);
if (w != nullptr)
{
WindowEventTextinputCall(w, gCurrentTextBox.widget_index, nullptr);
}
gCurrentTextBox.window.classification = WindowClass::Null;
gCurrentTextBox.window.number = 0;
ContextStopTextInput();
@@ -1904,7 +1769,7 @@ void WindowUpdateTextbox()
gTextBoxFrameNo = 0;
WindowBase* w = WindowFindByNumber(gCurrentTextBox.window.classification, gCurrentTextBox.window.number);
WidgetInvalidate(*w, gCurrentTextBox.widget_index);
WindowEventTextinputCall(w, gCurrentTextBox.widget_index, gTextBoxInput.c_str());
w->OnTextInput(gCurrentTextBox.widget_index, gTextBoxInput);
}
}