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

Move more Ui functions to Ui library (#22444)

* Move various methods into the ui library

* Move various zoom functions to ui
This commit is contained in:
Duncan
2024-08-01 20:09:06 +01:00
committed by GitHub
parent b1e14c676d
commit 144fa13a84
7 changed files with 189 additions and 185 deletions

View File

@@ -960,45 +960,6 @@ void WindowZoomSet(WindowBase& w, ZoomLevel zoomLevel, bool atCursor)
w.Invalidate();
}
/**
*
* rct2: 0x006887A6
*/
void WindowZoomIn(WindowBase& w, bool atCursor)
{
WindowZoomSet(w, w.viewport->zoom - 1, atCursor);
}
/**
*
* rct2: 0x006887E0
*/
void WindowZoomOut(WindowBase& w, bool atCursor)
{
WindowZoomSet(w, w.viewport->zoom + 1, atCursor);
}
void MainWindowZoom(bool zoomIn, bool atCursor)
{
auto* mainWindow = WindowGetMain();
if (mainWindow == nullptr)
return;
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR && GetGameState().EditorStep != EditorStep::LandscapeEditor)
return;
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)
return;
if (zoomIn)
WindowZoomIn(*mainWindow, atCursor);
else
WindowZoomOut(*mainWindow, atCursor);
}
/**
* Splits a drawing of a window into regions that can be seen and are not hidden
* by other opaque overlapping windows.
@@ -1142,18 +1103,6 @@ static void WindowDrawSingle(DrawPixelInfo& dpi, WindowBase& w, int32_t left, in
w.OnDraw(copy);
}
/**
*
* rct2: 0x00685BE1
*
* @param dpi (edi)
* @param w (esi)
*/
void WindowDrawViewport(DrawPixelInfo& dpi, WindowBase& w)
{
ViewportRender(dpi, w.viewport, { { dpi.x, dpi.y }, { dpi.x + dpi.width, dpi.y + dpi.height } });
}
/**
*
* rct2: 0x006EE212
@@ -1481,66 +1430,3 @@ Viewport* WindowGetViewport(WindowBase* w)
return w->viewport;
}
void WindowBase::ResizeFrame()
{
// Frame
widgets[0].right = width - 1;
widgets[0].bottom = height - 1;
// Title
widgets[1].right = width - 2;
// Close button
if (Config::Get().interface.WindowButtonsOnTheLeft)
{
widgets[2].left = 2;
widgets[2].right = 2 + kCloseButtonWidth;
}
else
{
widgets[2].left = width - 3 - kCloseButtonWidth;
widgets[2].right = width - 3;
}
}
void WindowBase::ResizeFrameWithPage()
{
ResizeFrame();
// Page background
widgets[3].right = width - 1;
widgets[3].bottom = height - 1;
}
void WindowBase::ResizeSpinner(WidgetIndex widgetIndex, const ScreenCoordsXY& origin, const ScreenSize& size)
{
auto right = origin.x + size.width - 1;
auto bottom = origin.y + size.height - 1;
widgets[widgetIndex].left = origin.x;
widgets[widgetIndex].top = origin.y;
widgets[widgetIndex].right = right;
widgets[widgetIndex].bottom = bottom;
widgets[widgetIndex + 1].left = right - size.height; // subtract height to maintain aspect ratio
widgets[widgetIndex + 1].top = origin.y + 1;
widgets[widgetIndex + 1].right = right - 1;
widgets[widgetIndex + 1].bottom = bottom - 1;
widgets[widgetIndex + 2].left = right - size.height * 2;
widgets[widgetIndex + 2].top = origin.y + 1;
widgets[widgetIndex + 2].right = right - size.height - 1;
widgets[widgetIndex + 2].bottom = bottom - 1;
}
void WindowBase::ResizeDropdown(WidgetIndex widgetIndex, const ScreenCoordsXY& origin, const ScreenSize& size)
{
auto right = origin.x + size.width - 1;
auto bottom = origin.y + size.height - 1;
widgets[widgetIndex].left = origin.x;
widgets[widgetIndex].top = origin.y;
widgets[widgetIndex].right = right;
widgets[widgetIndex].bottom = bottom;
widgets[widgetIndex + 1].left = right - size.height + 1; // subtract height to maintain aspect ratio
widgets[widgetIndex + 1].top = origin.y + 1;
widgets[widgetIndex + 1].right = right - 1;
widgets[widgetIndex + 1].bottom = bottom - 1;
}