Move WindowFind functions into WindowManager (#23517)

* Move WindowFind* functions into WindowManager

* Update parameter documentation where applicable
This commit is contained in:
Aaron van Geffen authored and GitHub committed 2025-01-08 21:12:11 +01:00
1 parent a8ef595248
commit aa45247f21
58 files changed
+657 -354

No files matched your search

+9 -4
View File
@@ -10,11 +10,14 @@
#include "ProvisionalElements.h"
#include <openrct2-ui/windows/Window.h>
#include <openrct2/Context.h>
#include <openrct2/interface/Window.h>
#include <openrct2/interface/WindowClasses.h>
#include <openrct2/network/network.h>
#include <openrct2/profiling/Profiling.h>
#include <openrct2/ride/RideConstruction.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/world/Footpath.h>
using namespace OpenRCT2::Ui::Windows;
@@ -27,14 +30,15 @@ namespace OpenRCT2::Ui
FootpathRemoveProvisionalTemporarily();
if (WindowFindByClass(WindowClass::RideConstruction) != nullptr)
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
if (windowMgr->FindByClass(WindowClass::RideConstruction) != nullptr)
{
RideRemoveProvisionalTrackPiece();
RideEntranceExitRemoveGhost();
}
// This is in non performant so only make network games suffer for it
// non networked games do not need this as its to prevent desyncs.
if ((NetworkGetMode() != NETWORK_MODE_NONE) && WindowFindByClass(WindowClass::TrackDesignPlace) != nullptr)
if ((NetworkGetMode() != NETWORK_MODE_NONE) && windowMgr->FindByClass(WindowClass::TrackDesignPlace) != nullptr)
{
TrackPlaceClearProvisionalTemporarily();
}
@@ -46,14 +50,15 @@ namespace OpenRCT2::Ui
FootpathRestoreProvisional();
if (WindowFindByClass(WindowClass::RideConstruction) != nullptr)
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
if (windowMgr->FindByClass(WindowClass::RideConstruction) != nullptr)
{
RideRestoreProvisionalTrackPiece();
RideEntranceExitPlaceProvisionalGhost();
}
// This is in non performant so only make network games suffer for it
// non networked games do not need this as its to prevent desyncs.
if ((NetworkGetMode() != NETWORK_MODE_NONE) && WindowFindByClass(WindowClass::TrackDesignPlace) != nullptr)
if ((NetworkGetMode() != NETWORK_MODE_NONE) && windowMgr->FindByClass(WindowClass::TrackDesignPlace) != nullptr)
{
TrackPlaceRestoreProvisional();
}
+123 -3
View File
@@ -403,7 +403,7 @@ public:
case INTENT_ACTION_REFRESH_RIDE_LIST:
{
auto window = WindowFindByClass(WindowClass::RideList);
auto window = FindByClass(WindowClass::RideList);
if (window != nullptr)
{
WindowRideListRefreshList(window);
@@ -419,7 +419,7 @@ public:
case INTENT_ACTION_RIDE_CONSTRUCTION_FOCUS:
{
auto rideIndex = intent.GetUIntExtra(INTENT_EXTRA_RIDE_ID);
auto w = WindowFindByClass(WindowClass::RideConstruction);
auto w = FindByClass(WindowClass::RideConstruction);
if (w == nullptr || w->number != rideIndex)
{
WindowCloseConstructionWindows();
@@ -519,7 +519,7 @@ public:
{
rct_windownumber bannerIndex = static_cast<rct_windownumber>(intent.GetUIntExtra(INTENT_EXTRA_BANNER_INDEX));
WindowBase* w = WindowFindByNumber(WindowClass::Banner, bannerIndex);
WindowBase* w = FindByNumber(WindowClass::Banner, bannerIndex);
if (w != nullptr)
{
w->Invalidate();
@@ -646,6 +646,126 @@ public:
}
return nullptr;
}
/**
* Finds the first window with the specified window class.
* rct2: 0x006EA8A0
* @param WindowClass enum
* @returns the window or nullptr if no window was found.
*/
WindowBase* FindByClass(WindowClass cls) override
{
for (auto& w : g_window_list)
{
if (w->flags & WF_DEAD)
continue;
if (w->classification == cls)
{
return w.get();
}
}
return nullptr;
}
/**
* Finds the first window with the specified window class and number.
* rct2: 0x006EA8A0
* @param WindowClass enum
* @param window number
* @returns the window or nullptr if no window was found.
*/
WindowBase* FindByNumber(WindowClass cls, rct_windownumber number) override
{
for (auto& w : g_window_list)
{
if (w->flags & WF_DEAD)
continue;
if (w->classification == cls && w->number == number)
{
return w.get();
}
}
return nullptr;
}
// TODO: Use variant for this once the window framework is done.
WindowBase* FindByNumber(WindowClass cls, EntityId id) override
{
return FindByNumber(cls, static_cast<rct_windownumber>(id.ToUnderlying()));
}
/**
*
* rct2: 0x006EA845
*/
WindowBase* FindFromPoint(const ScreenCoordsXY& screenCoords) override
{
for (auto it = g_window_list.rbegin(); it != g_window_list.rend(); it++)
{
auto& w = *it;
if (w->flags & WF_DEAD)
continue;
if (screenCoords.x < w->windowPos.x || screenCoords.x >= w->windowPos.x + w->width
|| screenCoords.y < w->windowPos.y || screenCoords.y >= w->windowPos.y + w->height)
continue;
if (w->flags & WF_NO_BACKGROUND)
{
auto widgetIndex = FindWidgetFromPoint(*w.get(), screenCoords);
if (widgetIndex == -1)
continue;
}
return w.get();
}
return nullptr;
}
/**
*
* rct2: 0x006EA594
* x (ax)
* y (bx)
* returns widget_index if found, -1 otherwise
*/
WidgetIndex FindWidgetFromPoint(WindowBase& w, const ScreenCoordsXY& screenCoords) override
{
// Invalidate the window
w.OnPrepareDraw();
// Find the widget at point x, y
WidgetIndex widget_index = -1;
for (int32_t i = 0;; i++)
{
const auto& widget = w.widgets[i];
if (widget.type == WindowWidgetType::Last)
{
break;
}
if (widget.type != WindowWidgetType::Empty && widget.IsVisible())
{
if (screenCoords.x >= w.windowPos.x + widget.left && screenCoords.x <= w.windowPos.x + widget.right
&& screenCoords.y >= w.windowPos.y + widget.top && screenCoords.y <= w.windowPos.y + widget.bottom)
{
widget_index = i;
}
}
}
// Return next widget if a dropdown
if (widget_index != -1)
{
const auto& widget = w.widgets[widget_index];
if (widget.type == WindowWidgetType::DropdownMenu)
widget_index++;
}
// Return the widget index
return widget_index;
}
};
std::unique_ptr<IWindowManager> OpenRCT2::Ui::CreateWindowManager()
+8 -4
View File
@@ -24,6 +24,7 @@
#include <openrct2/interface/Window.h>
#include <openrct2/paint/VirtualFloor.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
using namespace OpenRCT2::Ui;
@@ -209,8 +210,10 @@ void InputManager::Process(const InputEvent& e)
if (e.DeviceKind == InputDeviceKind::Keyboard)
{
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
// TODO: replace with event
auto w = WindowFindByClass(WindowClass::Textinput);
auto w = windowMgr->FindByClass(WindowClass::Textinput);
if (w != nullptr)
{
if (e.State == InputEventState::Release)
@@ -221,7 +224,7 @@ void InputManager::Process(const InputEvent& e)
}
// TODO: replace with event
w = WindowFindByClass(WindowClass::LoadsaveOverwritePrompt);
w = windowMgr->FindByClass(WindowClass::LoadsaveOverwritePrompt);
if (w != nullptr)
{
if (e.State == InputEventState::Release)
@@ -232,7 +235,7 @@ void InputManager::Process(const InputEvent& e)
}
// TODO: replace with event
w = WindowFindByClass(WindowClass::Loadsave);
w = windowMgr->FindByClass(WindowClass::Loadsave);
if (w != nullptr)
{
if (e.State == InputEventState::Release)
@@ -421,7 +424,8 @@ bool InputManager::HasTextInputFocus() const
if (OpenRCT2::Ui::Windows::IsUsingWidgetTextBox() || gChatOpen)
return true;
auto w = WindowFindByClass(WindowClass::Textinput);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto w = windowMgr->FindByClass(WindowClass::Textinput);
if (w != nullptr)
return true;
+47 -27
View File
@@ -35,6 +35,8 @@
#include <openrct2/platform/Platform.h>
#include <openrct2/ride/RideData.h>
#include <openrct2/scenario/Scenario.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/world/Banner.h>
#include <openrct2/world/Map.h>
#include <openrct2/world/Scenery.h>
@@ -244,7 +246,8 @@ static void InputScrollDragContinue(const ScreenCoordsXY& screenCoords, WindowBa
*/
static void InputScrollRight(const ScreenCoordsXY& screenCoords, MouseState state)
{
WindowBase* w = WindowFindByNumber(_dragWidget.window_classification, _dragWidget.window_number);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByNumber(_dragWidget.window_classification, _dragWidget.window_number);
if (w == nullptr)
{
ContextShowCursor();
@@ -283,9 +286,11 @@ static void GameHandleInputMouse(const ScreenCoordsXY& screenCoords, MouseState
Widget* widget;
WidgetIndex widgetIndex;
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
// Get window and widget under cursor position
w = WindowFindFromPoint(screenCoords);
widgetIndex = w == nullptr ? -1 : WindowFindWidgetFromPoint(*w, screenCoords);
w = windowMgr->FindFromPoint(screenCoords);
widgetIndex = w == nullptr ? -1 : windowMgr->FindWidgetFromPoint(*w, screenCoords);
widget = widgetIndex == -1 ? nullptr : &w->widgets[widgetIndex];
switch (_inputState)
@@ -338,7 +343,7 @@ static void GameHandleInputMouse(const ScreenCoordsXY& screenCoords, MouseState
InputStateWidgetPressed(screenCoords, state, widgetIndex, w, widget);
break;
case InputState::PositioningWindow:
w = WindowFindByNumber(_dragWidget.window_classification, _dragWidget.window_number);
w = windowMgr->FindByNumber(_dragWidget.window_classification, _dragWidget.window_number);
if (w == nullptr)
{
_inputState = InputState::Reset;
@@ -371,7 +376,7 @@ static void GameHandleInputMouse(const ScreenCoordsXY& screenCoords, MouseState
InputStateWidgetPressed(screenCoords, state, widgetIndex, w, widget);
break;
case InputState::ViewportLeft:
w = WindowFindByNumber(_dragWidget.window_classification, _dragWidget.window_number);
w = windowMgr->FindByNumber(_dragWidget.window_classification, _dragWidget.window_number);
if (w == nullptr)
{
_inputState = InputState::Reset;
@@ -396,7 +401,7 @@ static void GameHandleInputMouse(const ScreenCoordsXY& screenCoords, MouseState
break;
}
w = WindowFindByNumber(gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number);
w = windowMgr->FindByNumber(gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number);
if (w == nullptr)
{
break;
@@ -410,7 +415,8 @@ static void GameHandleInputMouse(const ScreenCoordsXY& screenCoords, MouseState
{
if ((_inputFlags & INPUT_FLAG_TOOL_ACTIVE))
{
w = WindowFindByNumber(gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number);
w = windowMgr->FindByNumber(
gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number);
if (w != nullptr)
{
w->OnToolUp(gCurrentToolWidget.widget_index, screenCoords);
@@ -446,7 +452,7 @@ static void GameHandleInputMouse(const ScreenCoordsXY& screenCoords, MouseState
}
break;
case InputState::Resizing:
w = WindowFindByNumber(_dragWidget.window_classification, _dragWidget.window_number);
w = windowMgr->FindByNumber(_dragWidget.window_classification, _dragWidget.window_number);
if (w == nullptr)
{
_inputState = InputState::Reset;
@@ -560,7 +566,8 @@ static void InputViewportDragContinue()
if (differentialCoords.x == 0 && differentialCoords.y == 0)
return;
w = WindowFindByNumber(_dragWidget.window_classification, _dragWidget.window_number);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
w = windowMgr->FindByNumber(_dragWidget.window_classification, _dragWidget.window_number);
// #3294: Window can be closed during a drag session, so just finish
// the session if the window no longer exists
@@ -768,7 +775,8 @@ static void InputScrollPartUpdateHThumb(WindowBase& w, WidgetIndex widgetIndex,
const auto& widget = w.widgets[widgetIndex];
auto& scroll = w.scrolls[scroll_id];
if (WindowFindByNumber(w.classification, w.number) != nullptr)
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
if (windowMgr->FindByNumber(w.classification, w.number) != nullptr)
{
int32_t newLeft;
newLeft = scroll.contentWidth;
@@ -807,7 +815,8 @@ static void InputScrollPartUpdateVThumb(WindowBase& w, WidgetIndex widgetIndex,
const auto& widget = w.widgets[widgetIndex];
auto& scroll = w.scrolls[scroll_id];
if (WindowFindByNumber(w.classification, w.number) != nullptr)
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
if (windowMgr->FindByNumber(w.classification, w.number) != nullptr)
{
int32_t newTop;
newTop = scroll.contentHeight;
@@ -843,7 +852,8 @@ static void InputScrollPartUpdateVThumb(WindowBase& w, WidgetIndex widgetIndex,
*/
static void InputScrollPartUpdateHLeft(WindowBase& w, WidgetIndex widgetIndex, int32_t scroll_id)
{
if (WindowFindByNumber(w.classification, w.number) != nullptr)
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
if (windowMgr->FindByNumber(w.classification, w.number) != nullptr)
{
auto& scroll = w.scrolls[scroll_id];
scroll.flags |= HSCROLLBAR_LEFT_PRESSED;
@@ -861,7 +871,9 @@ static void InputScrollPartUpdateHLeft(WindowBase& w, WidgetIndex widgetIndex, i
static void InputScrollPartUpdateHRight(WindowBase& w, WidgetIndex widgetIndex, int32_t scroll_id)
{
const auto& widget = w.widgets[widgetIndex];
if (WindowFindByNumber(w.classification, w.number) != nullptr)
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
if (windowMgr->FindByNumber(w.classification, w.number) != nullptr)
{
auto& scroll = w.scrolls[scroll_id];
scroll.flags |= HSCROLLBAR_RIGHT_PRESSED;
@@ -886,7 +898,8 @@ static void InputScrollPartUpdateHRight(WindowBase& w, WidgetIndex widgetIndex,
*/
static void InputScrollPartUpdateVTop(WindowBase& w, WidgetIndex widgetIndex, int32_t scroll_id)
{
if (WindowFindByNumber(w.classification, w.number) != nullptr)
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
if (windowMgr->FindByNumber(w.classification, w.number) != nullptr)
{
auto& scroll = w.scrolls[scroll_id];
scroll.flags |= VSCROLLBAR_UP_PRESSED;
@@ -904,7 +917,9 @@ static void InputScrollPartUpdateVTop(WindowBase& w, WidgetIndex widgetIndex, in
static void InputScrollPartUpdateVBottom(WindowBase& w, WidgetIndex widgetIndex, int32_t scroll_id)
{
const auto& widget = w.widgets[widgetIndex];
if (WindowFindByNumber(w.classification, w.number) != nullptr)
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
if (windowMgr->FindByNumber(w.classification, w.number) != nullptr)
{
auto& scroll = w.scrolls[scroll_id];
scroll.flags |= VSCROLLBAR_DOWN_PRESSED;
@@ -1000,7 +1015,8 @@ static void InputWidgetOverChangeCheck(WindowClass windowClass, rct_windownumber
*/
static void InputWidgetOverFlatbuttonInvalidate()
{
WindowBase* w = WindowFindByNumber(gHoverWidget.window_classification, gHoverWidget.window_number);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByNumber(gHoverWidget.window_classification, gHoverWidget.window_number);
if (w != nullptr)
{
w->OnPrepareDraw();
@@ -1030,7 +1046,8 @@ static void InputWidgetLeft(const ScreenCoordsXY& screenCoords, WindowBase* w, W
WindowCloseByClass(WindowClass::Tooltip);
// Window might have changed position in the list, therefore find it again
w = WindowFindByNumber(windowClass, windowNumber);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
w = windowMgr->FindByNumber(windowClass, windowNumber);
if (w == nullptr)
return;
@@ -1061,7 +1078,7 @@ static void InputWidgetLeft(const ScreenCoordsXY& screenCoords, WindowBase* w, W
_dragWidget.window_number = windowNumber;
if (_inputFlags & INPUT_FLAG_TOOL_ACTIVE)
{
w = WindowFindByNumber(gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number);
w = windowMgr->FindByNumber(gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number);
if (w != nullptr)
{
InputSetFlag(INPUT_FLAG_4, true);
@@ -1122,17 +1139,17 @@ static void InputWidgetLeft(const ScreenCoordsXY& screenCoords, WindowBase* w, W
*/
void ProcessMouseOver(const ScreenCoordsXY& screenCoords)
{
WindowBase* window;
CursorID cursorId = CursorID::Arrow;
auto ft = Formatter();
ft.Add<StringId>(STR_NONE);
SetMapTooltip(ft);
window = WindowFindFromPoint(screenCoords);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* window = windowMgr->FindFromPoint(screenCoords);
if (window != nullptr)
{
WidgetIndex widgetId = WindowFindWidgetFromPoint(*window, screenCoords);
WidgetIndex widgetId = windowMgr->FindWidgetFromPoint(*window, screenCoords);
if (widgetId != -1)
{
switch (window->widgets[widgetId].type)
@@ -1205,7 +1222,8 @@ void ProcessMouseTool(const ScreenCoordsXY& screenCoords)
{
if (_inputFlags & INPUT_FLAG_TOOL_ACTIVE)
{
WindowBase* w = WindowFindByNumber(gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByNumber(gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number);
if (w == nullptr)
ToolCancel();
@@ -1286,7 +1304,8 @@ void InputStateWidgetPressed(
cursor_w_number = gPressedWidget.window_number;
WidgetIndex cursor_widgetIndex = gPressedWidget.widget_index;
WindowBase* cursor_w = WindowFindByNumber(cursor_w_class, cursor_w_number);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* cursor_w = windowMgr->FindByNumber(cursor_w_class, cursor_w_number);
if (cursor_w == nullptr)
{
_inputState = InputState::Reset;
@@ -1407,11 +1426,11 @@ void InputStateWidgetPressed(
if (dropdownCleanup)
{
// Update w as it will be invalid after closing the dropdown window
w = WindowFindByNumber(wClass, wNumber);
w = windowMgr->FindByNumber(wClass, wNumber);
}
else
{
cursor_w = WindowFindByNumber(cursor_w_class, cursor_w_number);
cursor_w = windowMgr->FindByNumber(cursor_w_class, cursor_w_number);
if (_inputFlags & INPUT_FLAG_WIDGET_PRESSED)
{
_inputFlags &= ~INPUT_FLAG_WIDGET_PRESSED;
@@ -1591,7 +1610,8 @@ void SetCursor(CursorID cursor_id)
*/
void InvalidateScroll()
{
WindowBase* w = WindowFindByNumber(gPressedWidget.window_classification, gPressedWidget.window_number);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByNumber(gPressedWidget.window_classification, gPressedWidget.window_number);
if (w != nullptr)
{
// Reset to basic scroll
+46 -24
View File
@@ -40,6 +40,8 @@
#include <openrct2/ride/TrackPaint.h>
#include <openrct2/scenario/Scenario.h>
#include <openrct2/scenes/title/TitleScene.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/windows/Intent.h>
#include <openrct2/windows/TileInspectorGlobals.h>
#include <openrct2/world/Park.h>
@@ -87,8 +89,10 @@ static void ShortcutRotateConstructionObject()
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
// Rotate scenery
WindowBase* w = WindowFindByClass(WindowClass::Scenery);
WindowBase* w = windowMgr->FindByClass(WindowClass::Scenery);
if (w != nullptr && !WidgetIsDisabled(*w, WC_SCENERY__WIDX_SCENERY_ROTATE_OBJECTS_BUTTON)
&& w->widgets[WC_SCENERY__WIDX_SCENERY_ROTATE_OBJECTS_BUTTON].type != WindowWidgetType::Empty)
{
@@ -97,7 +101,7 @@ static void ShortcutRotateConstructionObject()
}
// Rotate construction track piece
w = WindowFindByClass(WindowClass::RideConstruction);
w = windowMgr->FindByClass(WindowClass::RideConstruction);
if (w != nullptr && !WidgetIsDisabled(*w, WC_RIDE_CONSTRUCTION__WIDX_ROTATE)
&& w->widgets[WC_RIDE_CONSTRUCTION__WIDX_ROTATE].type != WindowWidgetType::Empty)
{
@@ -110,7 +114,7 @@ static void ShortcutRotateConstructionObject()
}
// Rotate track design preview
w = WindowFindByClass(WindowClass::TrackDesignList);
w = windowMgr->FindByClass(WindowClass::TrackDesignList);
if (w != nullptr && !WidgetIsDisabled(*w, WC_TRACK_DESIGN_LIST__WIDX_ROTATE)
&& w->widgets[WC_TRACK_DESIGN_LIST__WIDX_ROTATE].type != WindowWidgetType::Empty)
{
@@ -119,7 +123,7 @@ static void ShortcutRotateConstructionObject()
}
// Rotate track design placement
w = WindowFindByClass(WindowClass::TrackDesignPlace);
w = windowMgr->FindByClass(WindowClass::TrackDesignPlace);
if (w != nullptr && !WidgetIsDisabled(*w, WC_TRACK_DESIGN_PLACE__WIDX_ROTATE)
&& w->widgets[WC_TRACK_DESIGN_PLACE__WIDX_ROTATE].type != WindowWidgetType::Empty)
{
@@ -128,7 +132,7 @@ static void ShortcutRotateConstructionObject()
}
// Rotate park entrance
w = WindowFindByClass(WindowClass::EditorParkEntrance);
w = windowMgr->FindByClass(WindowClass::EditorParkEntrance);
if (w != nullptr && !WidgetIsDisabled(*w, WC_EDITOR_PARK_ENTRANCE__WIDX_ROTATE_ENTRANCE_BUTTON)
&& w->widgets[WC_EDITOR_PARK_ENTRANCE__WIDX_ROTATE_ENTRANCE_BUTTON].type != WindowWidgetType::Empty)
{
@@ -137,7 +141,7 @@ static void ShortcutRotateConstructionObject()
}
// Rotate selected element in tile inspector
w = WindowFindByClass(WindowClass::TileInspector);
w = windowMgr->FindByClass(WindowClass::TileInspector);
if (w != nullptr && !WidgetIsDisabled(*w, WC_TILE_INSPECTOR__WIDX_BUTTON_ROTATE)
&& w->widgets[WC_TILE_INSPECTOR__WIDX_BUTTON_ROTATE].type != WindowWidgetType::Empty)
{
@@ -148,9 +152,11 @@ static void ShortcutRotateConstructionObject()
static void ShortcutRemoveTopBottomToolbarToggle()
{
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
{
if (WindowFindByClass(WindowClass::TitleLogo) != nullptr)
if (windowMgr->FindByClass(WindowClass::TitleLogo) != nullptr)
{
WindowCloseByClass(WindowClass::TitleLogo);
WindowCloseByClass(WindowClass::TitleOptions);
@@ -165,7 +171,7 @@ static void ShortcutRemoveTopBottomToolbarToggle()
}
else
{
if (WindowFindByClass(WindowClass::TopToolbar) != nullptr)
if (windowMgr->FindByClass(WindowClass::TopToolbar) != nullptr)
{
WindowCloseByClass(WindowClass::Dropdown);
WindowCloseByClass(WindowClass::TopToolbar);
@@ -366,7 +372,8 @@ static void ShortcutOpenCheatWindow()
return;
// Check if window is already open
WindowBase* window = WindowFindByClass(WindowClass::Cheats);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* window = windowMgr->FindByClass(WindowClass::Cheats);
if (window != nullptr)
{
WindowClose(*window);
@@ -434,11 +441,12 @@ static void ShortcutOpenSceneryPicker()
|| (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR && GetGameState().EditorStep != EditorStep::LandscapeEditor))
return;
WindowBase* window_scenery = WindowFindByClass(WindowClass::Scenery);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* window_scenery = windowMgr->FindByClass(WindowClass::Scenery);
if (window_scenery == nullptr)
ToggleSceneryWindow();
window_scenery = WindowFindByClass(WindowClass::Scenery);
window_scenery = windowMgr->FindByClass(WindowClass::Scenery);
if (window_scenery != nullptr && !WidgetIsDisabled(*window_scenery, WC_SCENERY__WIDX_SCENERY_EYEDROPPER_BUTTON)
&& !gWindowSceneryEyedropperEnabled)
{
@@ -469,7 +477,8 @@ static void ShortcutScaleDown()
// Tile inspector shortcuts
static void TileInspectorMouseUp(WidgetIndex widgetIndex)
{
auto w = WindowFindByClass(WindowClass::TileInspector);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto w = windowMgr->FindByClass(WindowClass::TileInspector);
if (w != nullptr && !WidgetIsDisabled(*w, widgetIndex) && w->widgets[widgetIndex].type != WindowWidgetType::Empty)
{
w->OnMouseUp(widgetIndex);
@@ -478,7 +487,8 @@ static void TileInspectorMouseUp(WidgetIndex widgetIndex)
static void TileInspectorMouseDown(WidgetIndex widgetIndex)
{
auto w = WindowFindByClass(WindowClass::TileInspector);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto w = windowMgr->FindByClass(WindowClass::TileInspector);
if (w != nullptr && !WidgetIsDisabled(*w, widgetIndex) && w->widgets[widgetIndex].type != WindowWidgetType::Empty)
{
w->OnMouseDown(widgetIndex);
@@ -487,7 +497,8 @@ static void TileInspectorMouseDown(WidgetIndex widgetIndex)
static void ShortcutToggleWallSlope()
{
WindowBase* window = WindowFindByClass(WindowClass::TileInspector);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* window = windowMgr->FindByClass(WindowClass::TileInspector);
if (window == nullptr)
{
return;
@@ -518,7 +529,8 @@ static void ShortcutToggleWallSlope()
static void ShortcutIncreaseElementHeight()
{
WindowBase* w = WindowFindByClass(WindowClass::TileInspector);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(WindowClass::TileInspector);
if (w != nullptr)
{
int action = -1;
@@ -557,7 +569,8 @@ static void ShortcutIncreaseElementHeight()
static void ShortcutDecreaseElementHeight()
{
WindowBase* w = WindowFindByClass(WindowClass::TileInspector);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(WindowClass::TileInspector);
if (w != nullptr)
{
int action = -1;
@@ -620,7 +633,8 @@ static void ShortcutConstructionTurnLeft()
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
WindowBase* window = WindowFindByClass(WindowClass::Footpath);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* window = windowMgr->FindByClass(WindowClass::Footpath);
if (window != nullptr)
{
WindowFootpathKeyboardShortcutTurnLeft();
@@ -635,7 +649,9 @@ static void ShortcutConstructionTurnRight()
{
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
WindowBase* window = WindowFindByClass(WindowClass::Footpath);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* window = windowMgr->FindByClass(WindowClass::Footpath);
if (window != nullptr)
{
WindowFootpathKeyboardShortcutTurnRight();
@@ -651,7 +667,8 @@ static void ShortcutConstructionSlopeUp()
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
WindowBase* window = WindowFindByClass(WindowClass::Footpath);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* window = windowMgr->FindByClass(WindowClass::Footpath);
if (window != nullptr)
{
WindowFootpathKeyboardShortcutSlopeUp();
@@ -667,7 +684,8 @@ static void ShortcutConstructionBuildCurrent()
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
WindowBase* window = WindowFindByClass(WindowClass::Footpath);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* window = windowMgr->FindByClass(WindowClass::Footpath);
if (window != nullptr)
{
WindowFootpathKeyboardShortcutBuildCurrent();
@@ -683,7 +701,8 @@ static void ShortcutConstructionSlopeDown()
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
WindowBase* window = WindowFindByClass(WindowClass::Footpath);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* window = windowMgr->FindByClass(WindowClass::Footpath);
if (window != nullptr)
{
WindowFootpathKeyboardShortcutSlopeDown();
@@ -699,7 +718,8 @@ static void ShortcutConstructionDemolishCurrent()
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
WindowBase* window = WindowFindByClass(WindowClass::Footpath);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* window = windowMgr->FindByClass(WindowClass::Footpath);
if (window != nullptr)
{
WindowFootpathKeyboardShortcutDemolishCurrent();
@@ -743,7 +763,8 @@ void ShortcutManager::RegisterDefaultShortcuts()
RegisterShortcut(ShortcutId::kInterfaceCancelConstruction, STR_SHORTCUT_CANCEL_CONSTRUCTION_MODE, "ESCAPE", []() {
if (!(gScreenFlags & SCREEN_FLAGS_TITLE_DEMO))
{
auto window = WindowFindByClass(WindowClass::Error);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto window = windowMgr->FindByClass(WindowClass::Error);
if (window != nullptr)
{
WindowClose(*window);
@@ -879,7 +900,8 @@ void ShortcutManager::RegisterDefaultShortcuts()
RegisterShortcut(ShortcutId::kDebugTogglePaintDebugWindow, STR_SHORTCUT_DEBUG_PAINT_TOGGLE, []() {
if (!(gScreenFlags & SCREEN_FLAGS_TITLE_DEMO))
{
auto window = WindowFindByClass(WindowClass::DebugPaint);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto window = windowMgr->FindByClass(WindowClass::DebugPaint);
if (window != nullptr)
{
WindowClose(*window);
@@ -45,6 +45,8 @@
#include <openrct2/ride/Track.h>
#include <openrct2/ride/Vehicle.h>
#include <openrct2/scenario/Scenario.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/windows/Intent.h>
#include <openrct2/world/Banner.h>
#include <openrct2/world/Footpath.h>
@@ -467,8 +469,9 @@ namespace OpenRCT2::Ui
if (!(InputTestFlag(INPUT_FLAG_6)) || !(InputTestFlag(INPUT_FLAG_TOOL_ACTIVE)))
{
if (WindowFindByClass(WindowClass::RideConstruction) == nullptr
&& WindowFindByClass(WindowClass::Footpath) == nullptr)
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
if (windowMgr->FindByClass(WindowClass::RideConstruction) == nullptr
&& windowMgr->FindByClass(WindowClass::Footpath) == nullptr)
{
info.interactionType = ViewportInteractionItem::None;
return info;
@@ -634,7 +637,8 @@ namespace OpenRCT2::Ui
*/
static void ViewportInteractionRemoveFootpath(const PathElement& pathElement, const CoordsXY& mapCoords)
{
WindowBase* w = WindowFindByClass(WindowClass::Footpath);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(WindowClass::Footpath);
if (w != nullptr)
FootpathUpdateProvisional();
@@ -761,7 +765,8 @@ namespace OpenRCT2::Ui
static Peep* ViewportInteractionGetClosestPeep(ScreenCoordsXY screenCoords, int32_t maxDistance)
{
auto* w = WindowFindFromPoint(screenCoords);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto* w = windowMgr->FindFromPoint(screenCoords);
if (w == nullptr)
return nullptr;
@@ -785,7 +790,8 @@ namespace OpenRCT2::Ui
*/
CoordsXY ViewportInteractionGetTileStartAtCursor(const ScreenCoordsXY& screenCoords)
{
WindowBase* window = WindowFindFromPoint(screenCoords);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* window = windowMgr->FindFromPoint(screenCoords);
if (window == nullptr || window->viewport == nullptr)
{
CoordsXY ret{};
+7 -2
View File
@@ -12,7 +12,10 @@
#include "Window.h"
#include <algorithm>
#include <openrct2/Context.h>
#include <openrct2/core/Numerics.hpp>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/world/Map.h>
#include <openrct2/world/tile_element/EntranceElement.h>
#include <openrct2/world/tile_element/PathElement.h>
@@ -36,7 +39,8 @@ namespace OpenRCT2::Ui
*/
CoordsXY FootpathGetCoordinatesFromPos(const ScreenCoordsXY& screenCoords, int32_t* direction, TileElement** tileElement)
{
WindowBase* window = WindowFindFromPoint(screenCoords);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* window = windowMgr->FindFromPoint(screenCoords);
if (window == nullptr || window->viewport == nullptr)
{
CoordsXY position{};
@@ -134,7 +138,8 @@ namespace OpenRCT2::Ui
CoordsXY FootpathBridgeGetInfoFromPos(const ScreenCoordsXY& screenCoords, int32_t* direction, TileElement** tileElement)
{
// First check if we point at an entrance or exit. In that case, we would want the path coming from the entrance/exit.
WindowBase* window = WindowFindFromPoint(screenCoords);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* window = windowMgr->FindFromPoint(screenCoords);
if (window == nullptr || window->viewport == nullptr)
{
CoordsXY ret{};
+8 -4
View File
@@ -29,6 +29,7 @@
#include <openrct2/localisation/Formatter.h>
#include <openrct2/sprites.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/world/Location.hpp>
using namespace OpenRCT2;
@@ -436,7 +437,8 @@ void WindowAllWheelInput()
// Check window cursor is over
if (!(InputTestFlag(INPUT_FLAG_5)))
{
WindowBase* w = WindowFindFromPoint(cursorState->position);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindFromPoint(cursorState->position);
if (w != nullptr)
{
// Check if main window
@@ -447,7 +449,7 @@ void WindowAllWheelInput()
}
// Check scroll view, cursor is over
WidgetIndex widgetIndex = WindowFindWidgetFromPoint(*w, cursorState->position);
WidgetIndex widgetIndex = windowMgr->FindWidgetFromPoint(*w, cursorState->position);
if (widgetIndex != -1)
{
const auto& widget = w->widgets[widgetIndex];
@@ -867,7 +869,8 @@ namespace OpenRCT2::Ui::Windows
{
if (_usingWidgetTextBox)
{
WindowBase* w = WindowFindByNumber(_currentTextBox.window.classification, _currentTextBox.window.number);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByNumber(_currentTextBox.window.classification, _currentTextBox.window.number);
_currentTextBox.window.classification = WindowClass::Null;
_currentTextBox.window.number = 0;
ContextStopTextInput();
@@ -892,7 +895,8 @@ namespace OpenRCT2::Ui::Windows
if (_usingWidgetTextBox)
{
_textBoxFrameNo = 0;
WindowBase* w = WindowFindByNumber(_currentTextBox.window.classification, _currentTextBox.window.number);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByNumber(_currentTextBox.window.classification, _currentTextBox.window.number);
WidgetInvalidate(*w, _currentTextBox.widget_index);
w->OnTextInput(_currentTextBox.widget_index, _textBoxInput);
}
+4 -1
View File
@@ -16,6 +16,8 @@
#include <openrct2-ui/UiContext.h>
#include <openrct2-ui/input/ShortcutManager.h>
#include <openrct2/Input.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/world/Map.h>
using namespace OpenRCT2;
@@ -266,7 +268,8 @@ namespace OpenRCT2::Scripting
customTool.onUp = dukValue["onUp"];
customTool.onFinish = dukValue["onFinish"];
auto toolbarWindow = WindowFindByClass(WindowClass::TopToolbar);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto toolbarWindow = windowMgr->FindByClass(WindowClass::TopToolbar);
if (toolbarWindow != nullptr)
{
// Use a widget that does not exist on top toolbar but also make sure it isn't -1 as that
+2 -1
View File
@@ -1097,7 +1097,8 @@ namespace OpenRCT2::Ui::Windows
static rct_windownumber GetNewWindowNumber()
{
auto result = _nextWindowNumber++;
while (WindowFindByNumber(WindowClass::Custom, result) != nullptr)
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
while (windowMgr->FindByNumber(WindowClass::Custom, result) != nullptr)
{
result++;
}
+4 -1
View File
@@ -18,6 +18,8 @@
#include <openrct2/interface/Viewport.h>
#include <openrct2/scripting/Duktape.hpp>
#include <openrct2/scripting/ScriptEngine.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/world/Map.h>
namespace OpenRCT2::Scripting
@@ -251,7 +253,8 @@ namespace OpenRCT2::Scripting
if (_class == WindowClass::MainWindow)
return WindowGetMain();
return WindowFindByNumber(_class, _number);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
return windowMgr->FindByNumber(_class, _number);
}
Viewport* GetViewport() const
+4 -1
View File
@@ -22,6 +22,8 @@
#include <openrct2/scripting/Duktape.hpp>
#include <openrct2/scripting/IconNames.hpp>
#include <openrct2/scripting/ScriptEngine.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
namespace OpenRCT2::Scripting
{
@@ -393,7 +395,8 @@ namespace OpenRCT2::Scripting
if (_class == WindowClass::MainWindow)
return WindowGetMain();
return WindowFindByNumber(_class, _number);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
return windowMgr->FindByNumber(_class, _number);
}
Widget* GetWidget() const
+2 -1
View File
@@ -362,7 +362,8 @@ namespace OpenRCT2::Scripting
private:
WindowBase* GetWindow() const
{
return WindowFindByNumber(_class, _number);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
return windowMgr->FindByNumber(_class, _number);
}
};
} // namespace OpenRCT2::Scripting
+6 -1
View File
@@ -18,6 +18,8 @@
#include <openrct2/actions/ClearAction.h>
#include <openrct2/localisation/Formatter.h>
#include <openrct2/sprites.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/world/Park.h>
#include <openrct2/world/Scenery.h>
@@ -341,13 +343,16 @@ namespace OpenRCT2::Ui::Windows
switch (widgetIndex)
{
case WIDX_BACKGROUND:
if (WindowFindByClass(WindowClass::Error) == nullptr && (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE))
{
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
if (windowMgr->FindByClass(WindowClass::Error) == nullptr && (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE))
{
auto action = GetClearAction();
GameActions::Execute(&action);
gCurrentToolId = Tool::Bulldozer;
}
break;
}
}
}
@@ -15,6 +15,8 @@
#include <openrct2/actions/RideDemolishAction.h>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/localisation/Formatter.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/windows/Intent.h>
#include <openrct2/world/Park.h>
@@ -105,7 +107,8 @@ namespace OpenRCT2::Ui::Windows
WindowBase* w;
DemolishRidePromptWindow* newWindow;
w = WindowFindByClass(WindowClass::DemolishRidePrompt);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
w = windowMgr->FindByClass(WindowClass::DemolishRidePrompt);
if (w != nullptr)
{
auto windowPos = w->windowPos;
@@ -11,6 +11,7 @@
#include <openrct2-ui/input/MouseInput.h>
#include <openrct2-ui/interface/Widget.h>
#include <openrct2-ui/windows/Window.h>
#include <openrct2/Context.h>
#include <openrct2/Editor.h>
#include <openrct2/GameState.h>
#include <openrct2/Input.h>
@@ -25,6 +26,8 @@
#include <openrct2/ride/RideData.h>
#include <openrct2/ride/RideManager.hpp>
#include <openrct2/sprites.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/world/Scenery.h>
namespace OpenRCT2::Ui::Windows
@@ -489,7 +492,9 @@ namespace OpenRCT2::Ui::Windows
if (windowPos.x <= screenCoords.x && windowPos.y < screenCoords.y && windowPos.x + width > screenCoords.x
&& windowPos.y + height > screenCoords.y)
{
WidgetIndex widgetIndex = WindowFindWidgetFromPoint(*this, screenCoords);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WidgetIndex widgetIndex = windowMgr->FindWidgetFromPoint(*this, screenCoords);
auto& widget = widgets[widgetIndex];
if (widgetIndex == WIDX_PRE_RESEARCHED_SCROLL || widgetIndex == WIDX_RESEARCH_ORDER_SCROLL)
{
@@ -612,7 +617,9 @@ namespace OpenRCT2::Ui::Windows
CursorID OnCursor(const WidgetIndex widx, const ScreenCoordsXY& screenCoords, const CursorID defaultCursor) override
{
auto* inventionListWindow = static_cast<InventionListWindow*>(WindowFindByClass(WindowClass::EditorInventionList));
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto* inventionListWindow = static_cast<InventionListWindow*>(
windowMgr->FindByClass(WindowClass::EditorInventionList));
if (inventionListWindow != nullptr)
{
auto res = inventionListWindow->GetResearchItemAt(screenCoords);
@@ -629,7 +636,9 @@ namespace OpenRCT2::Ui::Windows
void OnMoved(const ScreenCoordsXY& screenCoords) override
{
auto* inventionListWindow = static_cast<InventionListWindow*>(WindowFindByClass(WindowClass::EditorInventionList));
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto* inventionListWindow = static_cast<InventionListWindow*>(
windowMgr->FindByClass(WindowClass::EditorInventionList));
if (inventionListWindow == nullptr)
{
Close();
@@ -695,7 +704,8 @@ namespace OpenRCT2::Ui::Windows
static const ResearchItem* WindowEditorInventionsListDragGetItem()
{
auto* wnd = static_cast<InventionDragWindow*>(WindowFindByClass(WindowClass::EditorInventionListDrag));
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto* wnd = static_cast<InventionDragWindow*>(windowMgr->FindByClass(WindowClass::EditorInventionListDrag));
if (wnd == nullptr)
{
return nullptr;
@@ -38,6 +38,8 @@
#include <openrct2/scenario/Scenario.h>
#include <openrct2/scenes/title/TitleScene.h>
#include <openrct2/sprites.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/windows/Intent.h>
#include <span>
#include <string>
@@ -1706,8 +1708,6 @@ namespace OpenRCT2::Ui::Windows
bool EditorObjectSelectionWindowCheck()
{
WindowBase* w;
auto [missingObjectType, errorString] = Editor::CheckObjectSelection();
if (missingObjectType == ObjectType::None)
{
@@ -1716,7 +1716,9 @@ namespace OpenRCT2::Ui::Windows
}
ContextShowError(STR_INVALID_SELECTION_OF_OBJECTS, errorString, {});
w = WindowFindByClass(WindowClass::EditorObjectSelection);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(WindowClass::EditorObjectSelection);
if (w != nullptr)
{
// Click tab with missing object
+18 -8
View File
@@ -36,6 +36,8 @@
#include <openrct2/paint/VirtualFloor.h>
#include <openrct2/platform/Platform.h>
#include <openrct2/sprites.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/world/ConstructionClearance.h>
#include <openrct2/world/Footpath.h>
#include <openrct2/world/Park.h>
@@ -1238,7 +1240,8 @@ namespace OpenRCT2::Ui::Windows
Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, result->Position);
}
auto* self = static_cast<FootpathWindow*>(WindowFindByClass(WindowClass::Footpath));
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto* self = static_cast<FootpathWindow*>(windowMgr->FindByClass(WindowClass::Footpath));
if (self == nullptr)
{
return;
@@ -1638,7 +1641,8 @@ namespace OpenRCT2::Ui::Windows
void WindowFootpathKeyboardShortcutTurnLeft()
{
WindowBase* w = WindowFindByClass(WindowClass::Footpath);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(WindowClass::Footpath);
if (w != nullptr)
{
auto* footpathWindow = static_cast<FootpathWindow*>(w);
@@ -1651,7 +1655,8 @@ namespace OpenRCT2::Ui::Windows
void WindowFootpathKeyboardShortcutTurnRight()
{
WindowBase* w = WindowFindByClass(WindowClass::Footpath);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(WindowClass::Footpath);
if (w != nullptr)
{
auto* footpathWindow = static_cast<FootpathWindow*>(w);
@@ -1664,7 +1669,8 @@ namespace OpenRCT2::Ui::Windows
void WindowFootpathKeyboardShortcutSlopeDown()
{
WindowBase* w = WindowFindByClass(WindowClass::Footpath);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(WindowClass::Footpath);
if (w != nullptr)
{
auto* footpathWindow = static_cast<FootpathWindow*>(w);
@@ -1677,7 +1683,8 @@ namespace OpenRCT2::Ui::Windows
void WindowFootpathKeyboardShortcutSlopeUp()
{
WindowBase* w = WindowFindByClass(WindowClass::Footpath);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(WindowClass::Footpath);
if (w != nullptr)
{
auto* footpathWindow = static_cast<FootpathWindow*>(w);
@@ -1690,7 +1697,8 @@ namespace OpenRCT2::Ui::Windows
void WindowFootpathKeyboardShortcutDemolishCurrent()
{
WindowBase* w = WindowFindByClass(WindowClass::Footpath);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(WindowClass::Footpath);
if (w != nullptr)
{
auto* footpathWindow = static_cast<FootpathWindow*>(w);
@@ -1703,7 +1711,8 @@ namespace OpenRCT2::Ui::Windows
void WindowFootpathKeyboardShortcutBuildCurrent()
{
WindowBase* w = WindowFindByClass(WindowClass::Footpath);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(WindowClass::Footpath);
if (w != nullptr)
{
auto* footpathWindow = static_cast<FootpathWindow*>(w);
@@ -1720,7 +1729,8 @@ namespace OpenRCT2::Ui::Windows
*/
void ToggleFootpathWindow()
{
if (WindowFindByClass(WindowClass::Footpath) == nullptr)
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
if (windowMgr->FindByClass(WindowClass::Footpath) == nullptr)
{
ContextOpenWindow(WindowClass::Footpath);
}
+4 -1
View File
@@ -37,6 +37,8 @@
#include <openrct2/ride/ShopItem.h>
#include <openrct2/scenario/Scenario.h>
#include <openrct2/sprites.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/util/Util.h>
#include <openrct2/windows/Intent.h>
#include <openrct2/world/Footpath.h>
@@ -643,7 +645,8 @@ namespace OpenRCT2::Ui::Windows
pickupAction.SetCallback([peepnum = number](const GameAction* ga, const GameActions::Result* result) {
if (result->Error != GameActions::Status::Ok)
return;
WindowBase* wind = WindowFindByNumber(WindowClass::Peep, peepnum);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* wind = windowMgr->FindByNumber(WindowClass::Peep, peepnum);
if (wind != nullptr)
{
ToolSet(*wind, WC_PEEP__WIDX_PICKUP, Tool::Picker);
+4 -1
View File
@@ -26,6 +26,8 @@
#include <openrct2/ride/RideData.h>
#include <openrct2/scenario/Scenario.h>
#include <openrct2/sprites.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/world/Park.h>
#include <vector>
@@ -992,7 +994,8 @@ namespace OpenRCT2::Ui::Windows
void WindowGuestListRefreshList()
{
auto* w = WindowFindByClass(WindowClass::GuestList);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto* w = windowMgr->FindByClass(WindowClass::GuestList);
if (w != nullptr)
{
static_cast<GuestListWindow*>(w)->RefreshList();
+8 -2
View File
@@ -28,6 +28,8 @@
#include <openrct2/object/TerrainEdgeObject.h>
#include <openrct2/object/TerrainSurfaceObject.h>
#include <openrct2/sprites.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/world/Park.h>
namespace OpenRCT2::Ui::Windows
@@ -399,15 +401,19 @@ namespace OpenRCT2::Ui::Windows
*/
void LandToolDrag(const ScreenCoordsXY& screenPos)
{
auto* window = WindowFindFromPoint(screenPos);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto* window = windowMgr->FindFromPoint(screenPos);
if (window == nullptr)
return;
WidgetIndex widget_index = WindowFindWidgetFromPoint(*window, screenPos);
WidgetIndex widget_index = windowMgr->FindWidgetFromPoint(*window, screenPos);
if (widget_index == -1)
return;
const auto& widget = window->widgets[widget_index];
if (widget.type != WindowWidgetType::Viewport)
return;
const auto* selectedViewport = window->viewport;
if (selectedViewport == nullptr)
return;
+14 -7
View File
@@ -31,6 +31,8 @@
#include <openrct2/ride/TrainManager.h>
#include <openrct2/ride/Vehicle.h>
#include <openrct2/sprites.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/world/Footpath.h>
#include <openrct2/world/Scenery.h>
#include <openrct2/world/tile_element/EntranceElement.h>
@@ -275,6 +277,7 @@ namespace OpenRCT2::Ui::Windows
void OnMouseUp(WidgetIndex widgetIndex) override
{
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
switch (widgetIndex)
{
case WIDX_CLOSE:
@@ -282,7 +285,7 @@ namespace OpenRCT2::Ui::Windows
break;
case WIDX_SET_LAND_RIGHTS:
{
if (!WindowFindByClass(WindowClass::LandRights))
if (!windowMgr->FindByClass(WindowClass::LandRights))
ContextOpenWindow(WindowClass::LandRights);
else
WindowCloseByClass(WindowClass::LandRights);
@@ -290,7 +293,7 @@ namespace OpenRCT2::Ui::Windows
}
case WIDX_BUILD_PARK_ENTRANCE:
{
if (!WindowFindByClass(WindowClass::EditorParkEntrance))
if (!windowMgr->FindByClass(WindowClass::EditorParkEntrance))
ContextOpenWindow(WindowClass::EditorParkEntrance);
else
WindowCloseByClass(WindowClass::EditorParkEntrance);
@@ -354,6 +357,8 @@ namespace OpenRCT2::Ui::Windows
void OnUpdate() override
{
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
// the flickering frequency is reduced by 4, compared to the original
// it was done due to inability to reproduce original frequency
// and decision that the original one looks too fast
@@ -362,12 +367,12 @@ namespace OpenRCT2::Ui::Windows
// Handle guest map flashing
_flashingFlags &= ~MapFlashingFlags::FlashGuests;
if (WindowFindByClass(WindowClass::GuestList) != nullptr)
if (windowMgr->FindByClass(WindowClass::GuestList) != nullptr)
_flashingFlags |= MapFlashingFlags::FlashGuests;
// Handle staff map flashing
_flashingFlags &= ~MapFlashingFlags::FlashStaff;
if (WindowFindByClass(WindowClass::StaffList) != nullptr)
if (windowMgr->FindByClass(WindowClass::StaffList) != nullptr)
_flashingFlags |= MapFlashingFlags::FlashStaff;
if (GetCurrentRotation() != _rotation)
@@ -596,18 +601,20 @@ namespace OpenRCT2::Ui::Windows
void OnPrepareDraw() override
{
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
// Set the pressed widgets
pressed_widgets = 0;
SetWidgetPressed(WIDX_MAP_SIZE_LINK, _mapWidthAndHeightLinked);
pressed_widgets |= (1uLL << (WIDX_PEOPLE_TAB + selected_tab));
if (WindowFindByClass(WindowClass::EditorParkEntrance))
if (windowMgr->FindByClass(WindowClass::EditorParkEntrance))
pressed_widgets |= (1uLL << WIDX_BUILD_PARK_ENTRANCE);
if (WindowFindByClass(WindowClass::LandRights))
if (windowMgr->FindByClass(WindowClass::LandRights))
pressed_widgets |= (1uLL << WIDX_SET_LAND_RIGHTS);
if (WindowFindByClass(WindowClass::Mapgen))
if (windowMgr->FindByClass(WindowClass::Mapgen))
pressed_widgets |= (1uLL << WIDX_MAP_GENERATOR);
// Set disabled widgets
+6 -2
View File
@@ -16,6 +16,8 @@
#include <openrct2/Input.h>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/localisation/Formatter.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
namespace OpenRCT2::Ui::Windows
{
@@ -96,8 +98,9 @@ namespace OpenRCT2::Ui::Windows
std::memcpy(&stringId, _mapTooltipArgs.Data(), sizeof(StringId));
auto& im = GetInputManager();
auto* wm = GetContext()->GetUiContext()->GetWindowManager();
if (_cursorHoldDuration < 25 || stringId == STR_NONE || im.IsModifierKeyPressed(ModifierKey::ctrl)
|| im.IsModifierKeyPressed(ModifierKey::shift) || WindowFindByClass(WindowClass::Error) != nullptr)
|| im.IsModifierKeyPressed(ModifierKey::shift) || wm->FindByClass(WindowClass::Error) != nullptr)
{
WindowCloseByClass(WindowClass::MapTooltip);
}
@@ -114,7 +117,8 @@ namespace OpenRCT2::Ui::Windows
const CursorState* state = ContextGetCursorState();
auto pos = state->position + ScreenCoordsXY{ -width / 2, 15 };
if (auto w = WindowFindByClass(WindowClass::MapTooltip))
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
if (auto w = windowMgr->FindByClass(WindowClass::MapTooltip))
{
w->Invalidate();
w->windowPos = pos;
+4 -3
View File
@@ -25,6 +25,8 @@
#include <openrct2/ride/RideData.h>
#include <openrct2/ride/Track.h>
#include <openrct2/sprites.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/windows/Intent.h>
#include <openrct2/world/tile_element/EntranceElement.h>
@@ -442,9 +444,8 @@ namespace OpenRCT2::Ui::Windows
void WindowMazeConstructionUpdatePressedWidgets()
{
WindowBase* w;
w = WindowFindByClass(WindowClass::RideConstruction);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(WindowClass::RideConstruction);
if (w == nullptr)
return;
+7 -2
View File
@@ -12,6 +12,8 @@
#include <openrct2/Context.h>
#include <openrct2/drawing/Text.h>
#include <openrct2/network/network.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
namespace OpenRCT2::Ui::Windows
{
@@ -135,8 +137,10 @@ namespace OpenRCT2::Ui::Windows
{
ContextForceCloseWindowByClass(WindowClass::ProgressWindow);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
NetworkStatusWindow* window;
if ((window = static_cast<NetworkStatusWindow*>(WindowFindByClass(WindowClass::NetworkStatus))) != nullptr)
if ((window = static_cast<NetworkStatusWindow*>(windowMgr->FindByClass(WindowClass::NetworkStatus))) != nullptr)
{
WindowBringToFront(*window);
}
@@ -154,7 +158,8 @@ namespace OpenRCT2::Ui::Windows
// force close
void WindowNetworkStatusClose()
{
auto window = WindowFindByClass(WindowClass::NetworkStatus);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto window = windowMgr->FindByClass(WindowClass::NetworkStatus);
if (window == nullptr)
{
return;
+5 -1
View File
@@ -11,6 +11,7 @@
#include <openrct2-ui/interface/Dropdown.h>
#include <openrct2-ui/interface/Widget.h>
#include <openrct2-ui/windows/Window.h>
#include <openrct2/Context.h>
#include <openrct2/Game.h>
#include <openrct2/actions/ParkMarketingAction.h>
#include <openrct2/core/BitSet.hpp>
@@ -22,6 +23,8 @@
#include <openrct2/ride/RideData.h>
#include <openrct2/ride/RideManager.hpp>
#include <openrct2/ride/ShopItem.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
namespace OpenRCT2::Ui::Windows
{
@@ -421,7 +424,8 @@ namespace OpenRCT2::Ui::Windows
void WindowCampaignRefreshRides()
{
auto w = static_cast<NewCampaignWindow*>(WindowFindByClass(WindowClass::NewCampaign));
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto w = static_cast<NewCampaignWindow*>(windowMgr->FindByClass(WindowClass::NewCampaign));
if (w != nullptr)
{
w->RefreshRides();
+4 -1
View File
@@ -34,6 +34,8 @@
#include <openrct2/ride/TrackData.h>
#include <openrct2/ride/TrackDesignRepository.h>
#include <openrct2/sprites.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/windows/Intent.h>
#include <openrct2/world/Park.h>
@@ -1098,7 +1100,8 @@ namespace OpenRCT2::Ui::Windows
*/
void WindowNewRideFocus(RideSelection rideItem)
{
auto w = static_cast<NewRideWindow*>(WindowFindByClass(WindowClass::ConstructRide));
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto w = static_cast<NewRideWindow*>(windowMgr->FindByClass(WindowClass::ConstructRide));
if (!w)
{
return;
+6 -2
View File
@@ -24,6 +24,8 @@
#include <openrct2/entity/Staff.h>
#include <openrct2/localisation/Formatter.h>
#include <openrct2/sprites.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/world/Park.h>
namespace OpenRCT2::Ui::Windows
@@ -274,7 +276,8 @@ namespace OpenRCT2::Ui::Windows
bool IsStaffWindowOpen()
{
// If staff window for this patrol area was closed, tool is no longer active
auto staffWindow = WindowFindByNumber(WindowClass::Peep, _staffId);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto staffWindow = windowMgr->FindByNumber(WindowClass::Peep, _staffId);
return staffWindow != nullptr;
}
@@ -303,7 +306,8 @@ namespace OpenRCT2::Ui::Windows
EntityId WindowPatrolAreaGetCurrentStaffId()
{
auto current = reinterpret_cast<PatrolAreaWindow*>(WindowFindByClass(WindowClass::PatrolArea));
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto current = reinterpret_cast<PatrolAreaWindow*>(windowMgr->FindByClass(WindowClass::PatrolArea));
return current != nullptr ? current->GetStaffId() : EntityId::GetNull();
}
} // namespace OpenRCT2::Ui::Windows
+9 -3
View File
@@ -16,6 +16,8 @@
#include <openrct2/localisation/Formatting.h>
#include <openrct2/localisation/StringIds.h>
#include <openrct2/sprites.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <random>
#include <sstream>
@@ -235,8 +237,10 @@ namespace OpenRCT2::Ui::Windows
{
ContextForceCloseWindowByClass(WindowClass::NetworkStatus);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
ProgressWindow* window;
if ((window = static_cast<ProgressWindow*>(WindowFindByClass(WindowClass::ProgressWindow))) != nullptr)
if ((window = static_cast<ProgressWindow*>(windowMgr->FindByClass(WindowClass::ProgressWindow))) != nullptr)
{
WindowBringToFront(*window);
}
@@ -254,7 +258,8 @@ namespace OpenRCT2::Ui::Windows
void ProgressWindowSet(uint32_t currentProgress, uint32_t totalCount, StringId format)
{
auto window = WindowFindByClass(WindowClass::ProgressWindow);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto window = windowMgr->FindByClass(WindowClass::ProgressWindow);
if (window == nullptr)
{
return;
@@ -266,7 +271,8 @@ namespace OpenRCT2::Ui::Windows
// Closes the window, deliberately *without* executing the callback.
void ProgressWindowClose()
{
auto window = WindowFindByClass(WindowClass::ProgressWindow);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto window = windowMgr->FindByClass(WindowClass::ProgressWindow);
if (window == nullptr)
{
return;
@@ -14,6 +14,8 @@
#include <openrct2/GameState.h>
#include <openrct2/actions/RideDemolishAction.h>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/windows/Intent.h>
#include <openrct2/world/Park.h>
@@ -101,10 +103,10 @@ namespace OpenRCT2::Ui::Windows
WindowBase* RideRefurbishPromptOpen(const Ride& ride)
{
WindowBase* w;
RefurbishRidePromptWindow* newWindow;
w = WindowFindByClass(WindowClass::DemolishRidePrompt);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(WindowClass::DemolishRidePrompt);
if (w != nullptr)
{
auto windowPos = w->windowPos;
+15 -7
View File
@@ -64,6 +64,8 @@
#include <openrct2/ride/TrackDesignRepository.h>
#include <openrct2/ride/Vehicle.h>
#include <openrct2/sprites.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/util/Util.h>
#include <openrct2/windows/Intent.h>
#include <openrct2/world/Park.h>
@@ -1146,7 +1148,8 @@ namespace OpenRCT2::Ui::Windows
if (newPage == WINDOW_RIDE_PAGE_VEHICLE)
{
auto constructionWindow = WindowFindByClass(WindowClass::RideConstruction);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto constructionWindow = windowMgr->FindByClass(WindowClass::RideConstruction);
if (constructionWindow != nullptr && constructionWindow->number == number)
{
WindowCloseByClass(WindowClass::RideConstruction);
@@ -1640,7 +1643,8 @@ namespace OpenRCT2::Ui::Windows
if (ride != nullptr)
{
RideConstructionStart(*ride);
if (WindowFindByNumber(WindowClass::RideConstruction, ride->id.ToUnderlying()) != nullptr)
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
if (windowMgr->FindByNumber(WindowClass::RideConstruction, ride->id.ToUnderlying()) != nullptr)
{
Close();
return;
@@ -7156,7 +7160,8 @@ namespace OpenRCT2::Ui::Windows
view++;
}
auto* w = static_cast<RideWindow*>(WindowFindByNumber(WindowClass::Ride, ride->id.ToUnderlying()));
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto* w = static_cast<RideWindow*>(windowMgr->FindByNumber(WindowClass::Ride, ride->id.ToUnderlying()));
if (w != nullptr)
{
w->Invalidate();
@@ -7177,7 +7182,8 @@ namespace OpenRCT2::Ui::Windows
continue;
numPeepsLeft--;
WindowBase* w2 = WindowFindByNumber(WindowClass::Peep, vehicle->peep[i]);
WindowBase* w2 = windowMgr->FindByNumber(WindowClass::Peep, vehicle->peep[i]);
if (w2 == nullptr)
{
auto intent = Intent(WindowClass::Peep);
@@ -7191,7 +7197,7 @@ namespace OpenRCT2::Ui::Windows
}
w = static_cast<RideWindow*>(
openedPeepWindow ? WindowFindByNumber(WindowClass::Ride, ride->id.ToUnderlying())
openedPeepWindow ? windowMgr->FindByNumber(WindowClass::Ride, ride->id.ToUnderlying())
: WindowBringToFrontByNumber(WindowClass::Ride, ride->id.ToUnderlying()));
}
@@ -7208,7 +7214,8 @@ namespace OpenRCT2::Ui::Windows
void WindowRideInvalidateVehicle(const Vehicle& vehicle)
{
auto* w = static_cast<RideWindow*>(WindowFindByNumber(WindowClass::Ride, vehicle.ride.ToUnderlying()));
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto* w = static_cast<RideWindow*>(windowMgr->FindByNumber(WindowClass::Ride, vehicle.ride.ToUnderlying()));
if (w == nullptr)
return;
@@ -7225,7 +7232,8 @@ namespace OpenRCT2::Ui::Windows
void WindowRidePaintResetVehicle(RideId rideIndex)
{
auto w = static_cast<RideWindow*>(WindowFindByNumber(WindowClass::Ride, rideIndex.ToUnderlying()));
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto w = static_cast<RideWindow*>(windowMgr->FindByNumber(WindowClass::Ride, rideIndex.ToUnderlying()));
if (w != nullptr)
{
if (w->page == 4) // WINDOW_RIDE_PAGE_COLOUR
+45 -23
View File
@@ -46,6 +46,8 @@
#include <openrct2/ride/Track.h>
#include <openrct2/ride/TrackData.h>
#include <openrct2/sprites.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/windows/Intent.h>
#include <openrct2/world/ConstructionClearance.h>
#include <openrct2/world/Entrance.h>
@@ -210,7 +212,8 @@ namespace OpenRCT2::Ui::Windows
/* move to ride.c */
static void CloseRideWindowForConstruction(RideId rideId)
{
WindowBase* w = WindowFindByNumber(WindowClass::Ride, rideId.ToUnderlying());
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByNumber(WindowClass::Ride, rideId.ToUnderlying());
if (w != nullptr && w->page == 1)
WindowClose(*w);
}
@@ -2812,7 +2815,8 @@ namespace OpenRCT2::Ui::Windows
{
if (_rideConstructionState == RideConstructionState::State0)
{
auto w = WindowFindByClass(WindowClass::RideConstruction);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto w = windowMgr->FindByClass(WindowClass::RideConstruction);
if (w != nullptr)
{
if (RideAreAllPossibleEntrancesAndExitsBuilt(ride).Successful)
@@ -2829,7 +2833,8 @@ namespace OpenRCT2::Ui::Windows
static void WindowRideConstructionDoEntranceExitCheck()
{
auto w = WindowFindByClass(WindowClass::RideConstruction);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto w = windowMgr->FindByClass(WindowClass::RideConstruction);
auto ride = GetRide(_currentRideIndex);
if (w == nullptr || ride == nullptr)
{
@@ -2838,7 +2843,7 @@ namespace OpenRCT2::Ui::Windows
if (_rideConstructionState == RideConstructionState::State0)
{
w = WindowFindByClass(WindowClass::RideConstruction);
w = windowMgr->FindByClass(WindowClass::RideConstruction);
if (w != nullptr)
{
if (!RideAreAllPossibleEntrancesAndExitsBuilt(*ride).Successful)
@@ -3064,8 +3069,8 @@ namespace OpenRCT2::Ui::Windows
{
return;
}
auto window = static_cast<RideConstructionWindow*>(WindowFindByClass(WindowClass::RideConstruction));
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto window = static_cast<RideConstructionWindow*>(windowMgr->FindByClass(WindowClass::RideConstruction));
if (!window)
{
return;
@@ -3296,7 +3301,8 @@ namespace OpenRCT2::Ui::Windows
const auto& rtd = ride->GetRideTypeDescriptor();
if (rtd.specialType != RtdSpecialType::maze)
{
auto window = static_cast<RideConstructionWindow*>(WindowFindByClass(WindowClass::RideConstruction));
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto window = static_cast<RideConstructionWindow*>(windowMgr->FindByClass(WindowClass::RideConstruction));
if (!window)
{
return;
@@ -3598,7 +3604,9 @@ namespace OpenRCT2::Ui::Windows
_currentTrackSelectionFlags = 0;
auto intent = Intent(INTENT_ACTION_UPDATE_MAZE_CONSTRUCTION);
ContextBroadcastIntent(&intent);
w = WindowFindByClass(WindowClass::RideConstruction);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
w = windowMgr->FindByClass(WindowClass::RideConstruction);
if (w == nullptr)
break;
@@ -3630,8 +3638,8 @@ namespace OpenRCT2::Ui::Windows
|| errorText == STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND || errorText == STR_TOO_HIGH_FOR_SUPPORTS
|| zAttempts == (numAttempts - 1) || z < 0)
{
OpenRCT2::Audio::Play(OpenRCT2::Audio::SoundId::Error, 0, state->position.x);
w = WindowFindByClass(WindowClass::RideConstruction);
Audio::Play(OpenRCT2::Audio::SoundId::Error, 0, state->position.x);
w = windowMgr->FindByClass(WindowClass::RideConstruction);
if (w != nullptr)
{
ToolSet(*w, WIDX_CONSTRUCT, Tool::Crosshair);
@@ -3663,7 +3671,9 @@ namespace OpenRCT2::Ui::Windows
_currentTrackBegin.z = z;
_currentTrackSelectionFlags = 0;
WindowRideConstructionUpdateActiveElements();
w = WindowFindByClass(WindowClass::RideConstruction);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
w = windowMgr->FindByClass(WindowClass::RideConstruction);
if (w == nullptr)
break;
@@ -3716,7 +3726,8 @@ namespace OpenRCT2::Ui::Windows
void WindowRideConstructionKeyboardShortcutTurnLeft()
{
WindowBase* w = WindowFindByClass(WindowClass::RideConstruction);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(WindowClass::RideConstruction);
if (w == nullptr || WidgetIsDisabled(*w, WIDX_STRAIGHT) || w->widgets[WIDX_STRAIGHT].type == WindowWidgetType::Empty)
{
return;
@@ -3966,7 +3977,8 @@ namespace OpenRCT2::Ui::Windows
void WindowRideConstructionKeyboardShortcutTurnRight()
{
WindowBase* w = WindowFindByClass(WindowClass::RideConstruction);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(WindowClass::RideConstruction);
if (w == nullptr || WidgetIsDisabled(*w, WIDX_STRAIGHT) || w->widgets[WIDX_STRAIGHT].type == WindowWidgetType::Empty)
{
return;
@@ -4219,7 +4231,8 @@ namespace OpenRCT2::Ui::Windows
void WindowRideConstructionKeyboardShortcutUseTrackDefault()
{
WindowBase* w = WindowFindByClass(WindowClass::RideConstruction);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(WindowClass::RideConstruction);
if (w == nullptr || WidgetIsDisabled(*w, WIDX_STRAIGHT) || w->widgets[WIDX_STRAIGHT].type == WindowWidgetType::Empty)
{
return;
@@ -4249,7 +4262,8 @@ namespace OpenRCT2::Ui::Windows
void WindowRideConstructionKeyboardShortcutSlopeDown()
{
WindowBase* w = WindowFindByClass(WindowClass::RideConstruction);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(WindowClass::RideConstruction);
if (w == nullptr || WidgetIsDisabled(*w, WIDX_STRAIGHT) || w->widgets[WIDX_STRAIGHT].type == WindowWidgetType::Empty)
{
return;
@@ -4359,7 +4373,8 @@ namespace OpenRCT2::Ui::Windows
void WindowRideConstructionKeyboardShortcutSlopeUp()
{
WindowBase* w = WindowFindByClass(WindowClass::RideConstruction);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(WindowClass::RideConstruction);
if (w == nullptr || WidgetIsDisabled(*w, WIDX_STRAIGHT) || w->widgets[WIDX_STRAIGHT].type == WindowWidgetType::Empty)
{
return;
@@ -4469,7 +4484,8 @@ namespace OpenRCT2::Ui::Windows
void WindowRideConstructionKeyboardShortcutChainLiftToggle()
{
WindowBase* w = WindowFindByClass(WindowClass::RideConstruction);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(WindowClass::RideConstruction);
if (w == nullptr || WidgetIsDisabled(*w, WIDX_CHAIN_LIFT)
|| w->widgets[WIDX_CHAIN_LIFT].type == WindowWidgetType::Empty)
{
@@ -4481,7 +4497,8 @@ namespace OpenRCT2::Ui::Windows
void WindowRideConstructionKeyboardShortcutBankLeft()
{
WindowBase* w = WindowFindByClass(WindowClass::RideConstruction);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(WindowClass::RideConstruction);
if (w == nullptr || WidgetIsDisabled(*w, WIDX_BANK_STRAIGHT)
|| w->widgets[WIDX_BANK_STRAIGHT].type == WindowWidgetType::Empty)
{
@@ -4517,7 +4534,8 @@ namespace OpenRCT2::Ui::Windows
void WindowRideConstructionKeyboardShortcutBankRight()
{
WindowBase* w = WindowFindByClass(WindowClass::RideConstruction);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(WindowClass::RideConstruction);
if (w == nullptr || WidgetIsDisabled(*w, WIDX_BANK_STRAIGHT)
|| w->widgets[WIDX_BANK_STRAIGHT].type == WindowWidgetType::Empty)
{
@@ -4553,7 +4571,8 @@ namespace OpenRCT2::Ui::Windows
void WindowRideConstructionKeyboardShortcutPreviousTrack()
{
WindowBase* w = WindowFindByClass(WindowClass::RideConstruction);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(WindowClass::RideConstruction);
if (w == nullptr || WidgetIsDisabled(*w, WIDX_PREVIOUS_SECTION)
|| w->widgets[WIDX_PREVIOUS_SECTION].type == WindowWidgetType::Empty)
{
@@ -4565,7 +4584,8 @@ namespace OpenRCT2::Ui::Windows
void WindowRideConstructionKeyboardShortcutNextTrack()
{
WindowBase* w = WindowFindByClass(WindowClass::RideConstruction);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(WindowClass::RideConstruction);
if (w == nullptr || WidgetIsDisabled(*w, WIDX_NEXT_SECTION)
|| w->widgets[WIDX_NEXT_SECTION].type == WindowWidgetType::Empty)
{
@@ -4577,7 +4597,8 @@ namespace OpenRCT2::Ui::Windows
void WindowRideConstructionKeyboardShortcutBuildCurrent()
{
WindowBase* w = WindowFindByClass(WindowClass::RideConstruction);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(WindowClass::RideConstruction);
if (w == nullptr || WidgetIsDisabled(*w, WIDX_CONSTRUCT) || w->widgets[WIDX_CONSTRUCT].type == WindowWidgetType::Empty)
{
return;
@@ -4588,7 +4609,8 @@ namespace OpenRCT2::Ui::Windows
void WindowRideConstructionKeyboardShortcutDemolishCurrent()
{
WindowBase* w = WindowFindByClass(WindowClass::RideConstruction);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(WindowClass::RideConstruction);
if (w == nullptr || WidgetIsDisabled(*w, WIDX_DEMOLISH) || w->widgets[WIDX_DEMOLISH].type == WindowWidgetType::Empty)
{
return;
+25 -11
View File
@@ -49,6 +49,8 @@
#include <openrct2/object/WallSceneryEntry.h>
#include <openrct2/paint/VirtualFloor.h>
#include <openrct2/sprites.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/util/Util.h>
#include <openrct2/world/ConstructionClearance.h>
#include <openrct2/world/Footpath.h>
@@ -421,7 +423,9 @@ namespace OpenRCT2::Ui::Windows
{
// Find out what scenery the cursor is over
const CursorState* state = ContextGetCursorState();
WidgetIndex widgetIndex = WindowFindWidgetFromPoint(*this, state->position);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WidgetIndex widgetIndex = windowMgr->FindWidgetFromPoint(*this, state->position);
if (widgetIndex == WIDX_SCENERY_LIST)
{
ScreenCoordsXY scrollPos = {};
@@ -448,14 +452,16 @@ namespace OpenRCT2::Ui::Windows
void OnUpdate() override
{
const CursorState* state = ContextGetCursorState();
WindowBase* other = WindowFindFromPoint(state->position);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* other = windowMgr->FindFromPoint(state->position);
if (other == this)
{
ScreenCoordsXY window = state->position - ScreenCoordsXY{ windowPos.x - 26, windowPos.y };
if (window.y < 44 || window.x <= width)
{
WidgetIndex widgetIndex = WindowFindWidgetFromPoint(*this, state->position);
WidgetIndex widgetIndex = windowMgr->FindWidgetFromPoint(*this, state->position);
if (widgetIndex >= WIDX_SCENERY_TAB_CONTENT_PANEL)
{
_hoverCounter++;
@@ -2443,7 +2449,8 @@ namespace OpenRCT2::Ui::Windows
const ScreenCoordsXY& sourceScreenPos, ObjectEntryIndex sceneryIndex, CoordsXY& gridPos, uint8_t* outQuadrant,
Direction* outRotation)
{
auto* w = WindowFindByClass(WindowClass::Scenery);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto* w = windowMgr->FindByClass(WindowClass::Scenery);
if (w == nullptr)
{
@@ -2640,7 +2647,8 @@ namespace OpenRCT2::Ui::Windows
void Sub6E1F34PathItem(
const ScreenCoordsXY& sourceScreenPos, ObjectEntryIndex sceneryIndex, CoordsXY& gridPos, int32_t* outZ)
{
auto* w = WindowFindByClass(WindowClass::Scenery);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto* w = windowMgr->FindByClass(WindowClass::Scenery);
if (w == nullptr)
{
@@ -2673,7 +2681,8 @@ namespace OpenRCT2::Ui::Windows
void Sub6E1F34Wall(
const ScreenCoordsXY& sourceScreenPos, ObjectEntryIndex sceneryIndex, CoordsXY& gridPos, uint8_t* outEdges)
{
auto* w = WindowFindByClass(WindowClass::Scenery);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto* w = windowMgr->FindByClass(WindowClass::Scenery);
if (w == nullptr)
{
@@ -2763,7 +2772,8 @@ namespace OpenRCT2::Ui::Windows
void Sub6E1F34LargeScenery(
const ScreenCoordsXY& sourceScreenPos, ObjectEntryIndex sceneryIndex, CoordsXY& gridPos, Direction* outDirection)
{
auto* w = WindowFindByClass(WindowClass::Scenery);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto* w = windowMgr->FindByClass(WindowClass::Scenery);
if (w == nullptr)
{
@@ -2864,7 +2874,8 @@ namespace OpenRCT2::Ui::Windows
const ScreenCoordsXY& sourceScreenPos, ObjectEntryIndex sceneryIndex, CoordsXY& gridPos, int32_t* outZ,
Direction* outDirection)
{
auto* w = WindowFindByClass(WindowClass::Scenery);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto* w = windowMgr->FindByClass(WindowClass::Scenery);
if (w == nullptr)
{
@@ -3235,7 +3246,8 @@ namespace OpenRCT2::Ui::Windows
void WindowScenerySetSelectedTab(const ObjectEntryIndex sceneryGroupIndex)
{
// Should this bring to front?
auto* w = static_cast<SceneryWindow*>(WindowFindByClass(WindowClass::Scenery));
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto* w = static_cast<SceneryWindow*>(windowMgr->FindByClass(WindowClass::Scenery));
if (w != nullptr)
{
return w->SetSelectedTab(sceneryGroupIndex);
@@ -3261,7 +3273,8 @@ namespace OpenRCT2::Ui::Windows
const ScenerySelection WindowSceneryGetTabSelection()
{
auto* w = static_cast<SceneryWindow*>(WindowFindByClass(WindowClass::Scenery));
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto* w = static_cast<SceneryWindow*>(windowMgr->FindByClass(WindowClass::Scenery));
if (w != nullptr)
{
return w->GetTabSelection();
@@ -3274,7 +3287,8 @@ namespace OpenRCT2::Ui::Windows
void WindowSceneryInit()
{
auto* w = static_cast<SceneryWindow*>(WindowFindByClass(WindowClass::Scenery));
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto* w = static_cast<SceneryWindow*>(windowMgr->FindByClass(WindowClass::Scenery));
if (w != nullptr)
{
w->Init();
+4 -1
View File
@@ -15,6 +15,8 @@
#include <openrct2/core/String.hpp>
#include <openrct2/localisation/Formatter.h>
#include <openrct2/sprites.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/world/Scenery.h>
namespace OpenRCT2::Ui::Windows
@@ -206,7 +208,8 @@ namespace OpenRCT2::Ui::Windows
WindowBase* SceneryScatterOpen()
{
// Check if window is already open
auto* window = WindowFindByClass(WindowClass::SceneryScatter);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto* window = windowMgr->FindByClass(WindowClass::SceneryScatter);
if (window == nullptr)
{
window = WindowCreate<SceneryScatterWindow>(WindowClass::SceneryScatter, 86, 100, 0);
+6 -2
View File
@@ -17,6 +17,8 @@
#include <openrct2/localisation/Formatter.h>
#include <openrct2/localisation/StringIds.h>
#include <openrct2/sprites.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
namespace OpenRCT2::Ui::Windows
{
@@ -547,7 +549,8 @@ namespace OpenRCT2::Ui::Windows
void ChangeShortcutWindow::NotifyShortcutKeysWindow()
{
auto w = WindowFindByClass(WindowClass::KeyboardShortcutList);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto w = windowMgr->FindByClass(WindowClass::KeyboardShortcutList);
if (w != nullptr)
{
static_cast<ShortcutKeysWindow*>(w)->RefreshBindings();
@@ -603,7 +606,8 @@ namespace OpenRCT2::Ui::Windows
{
case WIDX_RESET_PROMPT_RESET:
{
auto w = WindowFindByClass(WindowClass::KeyboardShortcutList);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto w = windowMgr->FindByClass(WindowClass::KeyboardShortcutList);
if (w != nullptr)
{
static_cast<ShortcutKeysWindow*>(w)->ResetAllOnActiveTab();
+5 -1
View File
@@ -31,6 +31,8 @@
#include <openrct2/network/network.h>
#include <openrct2/peep/PeepAnimationData.h>
#include <openrct2/sprites.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/windows/Intent.h>
#include <openrct2/world/Footpath.h>
#include <openrct2/world/Park.h>
@@ -375,7 +377,9 @@ namespace OpenRCT2::Ui::Windows
pickupAction.SetCallback([peepnum = number](const GameAction* ga, const GameActions::Result* result) {
if (result->Error != GameActions::Status::Ok)
return;
WindowBase* wind = WindowFindByNumber(WindowClass::Peep, peepnum);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* wind = windowMgr->FindByNumber(WindowClass::Peep, peepnum);
if (wind != nullptr)
{
ToolSet(*wind, WC_STAFF__WIDX_PICKUP, Tool::Picker);
+6 -2
View File
@@ -35,6 +35,8 @@
#include <openrct2/management/Finance.h>
#include <openrct2/peep/PeepAnimationData.h>
#include <openrct2/sprites.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/util/Util.h>
#include <openrct2/windows/Intent.h>
#include <openrct2/world/Footpath.h>
@@ -200,7 +202,8 @@ namespace OpenRCT2::Ui::Windows
InvalidateWidget(WIDX_STAFF_LIST_HANDYMEN_TAB + _selectedTab);
// Enable highlighting of these staff members in map window
if (WindowFindByClass(WindowClass::Map) != nullptr)
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
if (windowMgr->FindByClass(WindowClass::Map) != nullptr)
{
for (auto peep : EntityList<Staff>())
{
@@ -765,7 +768,8 @@ namespace OpenRCT2::Ui::Windows
void WindowStaffListRefresh()
{
auto* window = WindowFindByClass(WindowClass::StaffList);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto* window = windowMgr->FindByClass(WindowClass::StaffList);
if (window != nullptr)
{
static_cast<StaffListWindow*>(window)->RefreshList();
+6 -2
View File
@@ -18,6 +18,8 @@
#include <openrct2/drawing/Drawing.h>
#include <openrct2/localisation/Formatting.h>
#include <openrct2/localisation/StringIds.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
namespace OpenRCT2::Ui::Windows
{
@@ -363,7 +365,8 @@ namespace OpenRCT2::Ui::Windows
WindowBase* GetParentWindow() const
{
return HasParentWindow() ? WindowFindByNumber(_parentWidget.window.classification, _parentWidget.window.number)
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
return HasParentWindow() ? windowMgr->FindByNumber(_parentWidget.window.classification, _parentWidget.window.number)
: nullptr;
}
};
@@ -422,7 +425,8 @@ namespace OpenRCT2::Ui::Windows
}
// The window can be potentially closed within a callback, we need to check if its still alive.
w = WindowFindByNumber(wndClass, wndNumber);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
w = windowMgr->FindByNumber(wndClass, wndNumber);
if (w != nullptr)
w->Invalidate();
}
+4 -1
View File
@@ -21,6 +21,8 @@
#include <openrct2/localisation/StringIds.h>
#include <openrct2/platform/Platform.h>
#include <openrct2/sprites.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
namespace OpenRCT2::Ui::Windows
{
@@ -386,7 +388,8 @@ namespace OpenRCT2::Ui::Windows
pressed_widgets = pressedWidgets | (1 << widgetIndex);
if (WindowFindByClass(WindowClass::Dropdown) == nullptr)
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
if (windowMgr->FindByClass(WindowClass::Dropdown) == nullptr)
{
_classIndex = -1;
_buttonIndex = -1;
+6 -2
View File
@@ -33,6 +33,8 @@
#include <openrct2/ride/RideData.h>
#include <openrct2/ride/Track.h>
#include <openrct2/sprites.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/windows/TileInspectorGlobals.h>
#include <openrct2/world/Banner.h>
#include <openrct2/world/Entrance.h>
@@ -2436,14 +2438,16 @@ static uint64_t PageDisabledWidgets[] = {
void WindowTileInspectorClearClipboard()
{
auto* window = WindowFindByClass(WindowClass::TileInspector);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto* window = windowMgr->FindByClass(WindowClass::TileInspector);
if (window != nullptr)
static_cast<TileInspector*>(window)->ClearClipboard();
}
void WindowTileInspectorKeyboardShortcutToggleInvisibility()
{
auto* window = WindowFindByClass(WindowClass::TileInspector);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto* window = windowMgr->FindByClass(WindowClass::TileInspector);
if (window != nullptr)
static_cast<TileInspector*>(window)->ToggleInvisibility();
}
+6 -3
View File
@@ -20,6 +20,7 @@
#include <openrct2/actions/LoadOrQuitAction.h>
#include <openrct2/sprites.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
namespace OpenRCT2::Ui::Windows
{
@@ -121,10 +122,12 @@ namespace OpenRCT2::Ui::Windows
{
WindowBase* windowToOpen = nullptr;
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
switch (widgetIndex)
{
case WIDX_START_NEW_GAME:
windowToOpen = WindowFindByClass(WindowClass::ScenarioSelect);
windowToOpen = windowMgr->FindByClass(WindowClass::ScenarioSelect);
if (windowToOpen != nullptr)
{
WindowBringToFront(*windowToOpen);
@@ -137,7 +140,7 @@ namespace OpenRCT2::Ui::Windows
}
break;
case WIDX_CONTINUE_SAVED_GAME:
windowToOpen = WindowFindByClass(WindowClass::Loadsave);
windowToOpen = windowMgr->FindByClass(WindowClass::Loadsave);
if (windowToOpen != nullptr)
{
WindowBringToFront(*windowToOpen);
@@ -151,7 +154,7 @@ namespace OpenRCT2::Ui::Windows
}
break;
case WIDX_MULTIPLAYER:
windowToOpen = WindowFindByClass(WindowClass::ServerList);
windowToOpen = windowMgr->FindByClass(WindowClass::ServerList);
if (windowToOpen != nullptr)
{
WindowBringToFront(*windowToOpen);
+13 -4
View File
@@ -44,6 +44,7 @@
#include <openrct2/scenario/Scenario.h>
#include <openrct2/sprites.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/windows/Intent.h>
#include <openrct2/world/Footpath.h>
#include <openrct2/world/Park.h>
@@ -778,7 +779,8 @@ namespace OpenRCT2::Ui::Windows
void ApplyFootpathPressed()
{
// Footpath button pressed down
if (WindowFindByClass(WindowClass::Footpath) == nullptr)
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
if (windowMgr->FindByClass(WindowClass::Footpath) == nullptr)
pressed_widgets &= ~(1uLL << WIDX_PATH);
else
pressed_widgets |= (1uLL << WIDX_PATH);
@@ -1139,7 +1141,9 @@ namespace OpenRCT2::Ui::Windows
w->viewport->flags ^= VIEWPORT_FLAG_PATH_HEIGHTS;
break;
case DDIDX_VIEW_CLIPPING:
if (WindowFindByClass(WindowClass::ViewClipping) == nullptr)
{
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
if (windowMgr->FindByClass(WindowClass::ViewClipping) == nullptr)
{
ContextOpenWindow(WindowClass::ViewClipping);
}
@@ -1149,6 +1153,7 @@ namespace OpenRCT2::Ui::Windows
w->viewport->flags ^= VIEWPORT_FLAG_CLIP_VIEW;
}
break;
}
case DDIDX_HIGHLIGHT_PATH_ISSUES:
w->viewport->flags ^= VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES;
break;
@@ -1506,7 +1511,8 @@ namespace OpenRCT2::Ui::Windows
{ windowPos.x + widget.left, windowPos.y + widget.top }, widget.height() + 1,
colours[0].withFlag(ColourFlag::translucent, true), Dropdown::Flag::StayOpen, TOP_TOOLBAR_DEBUG_COUNT);
Dropdown::SetChecked(DDIDX_DEBUG_PAINT, WindowFindByClass(WindowClass::DebugPaint) != nullptr);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
Dropdown::SetChecked(DDIDX_DEBUG_PAINT, windowMgr->FindByClass(WindowClass::DebugPaint) != nullptr);
}
void TopToolbar::DebugMenuDropdown(int16_t dropdownIndex)
@@ -1523,7 +1529,9 @@ namespace OpenRCT2::Ui::Windows
break;
}
case DDIDX_DEBUG_PAINT:
if (WindowFindByClass(WindowClass::DebugPaint) == nullptr)
{
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
if (windowMgr->FindByClass(WindowClass::DebugPaint) == nullptr)
{
ContextOpenWindow(WindowClass::DebugPaint);
}
@@ -1532,6 +1540,7 @@ namespace OpenRCT2::Ui::Windows
WindowCloseByClass(WindowClass::DebugPaint);
}
break;
}
}
}
}
+8 -4
View File
@@ -301,18 +301,20 @@ namespace OpenRCT2::Ui::Windows
Audio::Play3D(Audio::SoundId::PlaceItem, trackLoc);
_currentRideIndex = rideId;
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
if (TrackDesignAreEntranceAndExitPlaced())
{
auto intent = Intent(WindowClass::Ride);
intent.PutExtra(INTENT_EXTRA_RIDE_ID, rideId.ToUnderlying());
ContextOpenIntent(&intent);
auto wnd = WindowFindByClass(WindowClass::TrackDesignPlace);
auto* wnd = windowMgr->FindByClass(WindowClass::TrackDesignPlace);
WindowClose(*wnd);
}
else
{
RideInitialiseConstructionWindow(*getRide);
auto wnd = WindowFindByClass(WindowClass::RideConstruction);
auto* wnd = windowMgr->FindByClass(WindowClass::RideConstruction);
wnd->OnMouseUp(WC_RIDE_CONSTRUCTION__WIDX_ENTRANCE);
}
}
@@ -746,7 +748,8 @@ namespace OpenRCT2::Ui::Windows
void TrackPlaceClearProvisionalTemporarily()
{
auto* trackPlaceWnd = static_cast<TrackDesignPlaceWindow*>(WindowFindByClass(WindowClass::TrackDesignPlace));
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto* trackPlaceWnd = static_cast<TrackDesignPlaceWindow*>(windowMgr->FindByClass(WindowClass::TrackDesignPlace));
if (trackPlaceWnd != nullptr)
{
trackPlaceWnd->ClearProvisionalTemporarily();
@@ -755,7 +758,8 @@ namespace OpenRCT2::Ui::Windows
void TrackPlaceRestoreProvisional()
{
auto* trackPlaceWnd = static_cast<TrackDesignPlaceWindow*>(WindowFindByClass(WindowClass::TrackDesignPlace));
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto* trackPlaceWnd = static_cast<TrackDesignPlaceWindow*>(windowMgr->FindByClass(WindowClass::TrackDesignPlace));
if (trackPlaceWnd != nullptr)
{
trackPlaceWnd->RestoreProvisional();
+6 -2
View File
@@ -24,6 +24,8 @@
#include <openrct2/ride/TrackDesign.h>
#include <openrct2/ride/TrackDesignRepository.h>
#include <openrct2/sprites.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/windows/Intent.h>
#include <vector>
@@ -774,7 +776,8 @@ namespace OpenRCT2::Ui::Windows
void WindowTrackDesignListReloadTracks()
{
auto* trackListWindow = static_cast<TrackListWindow*>(WindowFindByClass(WindowClass::TrackDesignList));
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto* trackListWindow = static_cast<TrackListWindow*>(windowMgr->FindByClass(WindowClass::TrackDesignList));
if (trackListWindow != nullptr)
{
trackListWindow->ReloadTrackDesigns();
@@ -783,7 +786,8 @@ namespace OpenRCT2::Ui::Windows
void WindowTrackDesignListSetBeingUpdated(const bool beingUpdated)
{
auto* trackListWindow = static_cast<TrackListWindow*>(WindowFindByClass(WindowClass::TrackDesignList));
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto* trackListWindow = static_cast<TrackListWindow*>(windowMgr->FindByClass(WindowClass::TrackDesignList));
if (trackListWindow != nullptr)
{
trackListWindow->SetIsBeingUpdated(beingUpdated);
+4 -1
View File
@@ -20,6 +20,8 @@
#include <openrct2/drawing/Drawing.h>
#include <openrct2/localisation/Formatter.h>
#include <openrct2/sprites.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/world/Park.h>
namespace OpenRCT2::Ui::Windows
@@ -252,7 +254,8 @@ namespace OpenRCT2::Ui::Windows
*/
void WaterToolDrag(const ScreenCoordsXY& screenPos)
{
auto* window = WindowFindFromPoint(screenPos);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto* window = windowMgr->FindFromPoint(screenPos);
if (window == nullptr || window->viewport == nullptr)
return;
+7 -5
View File
@@ -324,15 +324,17 @@ namespace OpenRCT2::Editor
return;
}
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
switch (GetGameState().EditorStep)
{
case EditorStep::ObjectSelection:
if (WindowFindByClass(WindowClass::EditorObjectSelection) != nullptr)
if (windowMgr->FindByClass(WindowClass::EditorObjectSelection) != nullptr)
{
return;
}
if (WindowFindByClass(WindowClass::InstallTrack) != nullptr)
if (windowMgr->FindByClass(WindowClass::InstallTrack) != nullptr)
{
return;
}
@@ -345,7 +347,7 @@ namespace OpenRCT2::Editor
ContextOpenWindow(WindowClass::EditorObjectSelection);
break;
case EditorStep::InventionsListSetUp:
if (WindowFindByClass(WindowClass::EditorInventionList) != nullptr)
if (windowMgr->FindByClass(WindowClass::EditorInventionList) != nullptr)
{
return;
}
@@ -353,7 +355,7 @@ namespace OpenRCT2::Editor
ContextOpenWindow(WindowClass::EditorInventionList);
break;
case EditorStep::OptionsSelection:
if (WindowFindByClass(WindowClass::EditorScenarioOptions) != nullptr)
if (windowMgr->FindByClass(WindowClass::EditorScenarioOptions) != nullptr)
{
return;
}
@@ -361,7 +363,7 @@ namespace OpenRCT2::Editor
ContextOpenWindow(WindowClass::EditorScenarioOptions);
break;
case EditorStep::ObjectiveSelection:
if (WindowFindByClass(WindowClass::EditorObjectiveOptions) != nullptr)
if (windowMgr->FindByClass(WindowClass::EditorObjectiveOptions) != nullptr)
{
return;
}
+2 -1
View File
@@ -202,7 +202,8 @@ GameActions::Result RideSetStatusAction::Execute() const
// Fix #3183: Make sure we close the construction window so the ride finishes any editing code before opening
// otherwise vehicles get added to the ride incorrectly (such as to a ghost station)
WindowBase* constructionWindow = WindowFindByNumber(WindowClass::RideConstruction, _rideIndex.ToUnderlying());
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* constructionWindow = windowMgr->FindByNumber(WindowClass::RideConstruction, _rideIndex.ToUnderlying());
if (constructionWindow != nullptr)
{
WindowClose(*constructionWindow);
+7 -2
View File
@@ -51,6 +51,8 @@
#include "../scripting/HookEngine.h"
#include "../scripting/ScriptEngine.h"
#include "../sprites.h"
#include "../ui/UiContext.h"
#include "../ui/WindowManager.h"
#include "../util/Util.h"
#include "../windows/Intent.h"
#include "../world/Climate.h"
@@ -1450,7 +1452,9 @@ void Guest::CheckCantFindRide()
return;
GuestHeadingToRideId = RideId::GetNull();
WindowBase* w = WindowFindByNumber(WindowClass::Peep, Id);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByNumber(WindowClass::Peep, Id);
if (w != nullptr)
{
@@ -3142,7 +3146,8 @@ static void PeepLeavePark(Guest* peep)
peep->InsertNewThought(PeepThoughtType::GoHome);
WindowBase* w = WindowFindByNumber(WindowClass::Peep, peep->Id);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByNumber(WindowClass::Peep, peep->Id);
if (w != nullptr)
w->OnPrepareDraw();
WindowInvalidateByNumber(WindowClass::Peep, peep->Id);
+4 -1
View File
@@ -48,6 +48,8 @@
#include "../ride/Track.h"
#include "../scenario/Scenario.h"
#include "../sprites.h"
#include "../ui/UiContext.h"
#include "../ui/WindowManager.h"
#include "../windows/Intent.h"
#include "../world/Climate.h"
#include "../world/ConstructionClearance.h"
@@ -589,7 +591,8 @@ void PeepDecrementNumRiders(Peep* peep)
*/
void PeepWindowStateUpdate(Peep* peep)
{
WindowBase* w = WindowFindByNumber(WindowClass::Peep, peep->Id.ToUnderlying());
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByNumber(WindowClass::Peep, peep->Id.ToUnderlying());
if (w != nullptr)
w->OnPrepareDraw();
+7 -3
View File
@@ -1725,7 +1725,8 @@ InteractionInfo SetInteractionInfoFromPaintSession(PaintSession* session, uint32
*/
InteractionInfo GetMapCoordinatesFromPos(const ScreenCoordsXY& screenCoords, int32_t flags)
{
WindowBase* window = WindowFindFromPoint(screenCoords);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* window = windowMgr->FindFromPoint(screenCoords);
return GetMapCoordinatesFromPosWindow(window, screenCoords, flags);
}
@@ -1813,7 +1814,8 @@ void ViewportInvalidate(const Viewport* viewport, const ScreenRect& screenRect)
static Viewport* ViewportFindFromPoint(const ScreenCoordsXY& screenCoords)
{
WindowBase* w = WindowFindFromPoint(screenCoords);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindFromPoint(screenCoords);
if (w == nullptr)
return nullptr;
@@ -1841,8 +1843,10 @@ static Viewport* ViewportFindFromPoint(const ScreenCoordsXY& screenCoords)
*/
std::optional<CoordsXY> ScreenGetMapXY(const ScreenCoordsXY& screenCoords, Viewport** viewport)
{
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
// This will get the tile location but we will need the more accuracy
WindowBase* window = WindowFindFromPoint(screenCoords);
WindowBase* window = windowMgr->FindFromPoint(screenCoords);
if (window == nullptr || window->viewport == nullptr)
{
return std::nullopt;
+17 -134
View File
@@ -285,53 +285,6 @@ void WindowCloseByNumber(WindowClass cls, EntityId number)
WindowCloseByNumber(cls, static_cast<rct_windownumber>(number.ToUnderlying()));
}
/**
* Finds the first window with the specified window class.
* rct2: 0x006EA8A0
* @param cls (cl) with bit 15 set
* @returns the window or NULL if no window was found.
*/
WindowBase* WindowFindByClass(WindowClass cls)
{
for (auto& w : g_window_list)
{
if (w->flags & WF_DEAD)
continue;
if (w->classification == cls)
{
return w.get();
}
}
return nullptr;
}
/**
* Finds the first window with the specified window class and number.
* rct2: 0x006EA8A0
* @param cls (cl) without bit 15 set
* @param number (dx)
* @returns the window or NULL if no window was found.
*/
WindowBase* WindowFindByNumber(WindowClass cls, rct_windownumber number)
{
for (auto& w : g_window_list)
{
if (w->flags & WF_DEAD)
continue;
if (w->classification == cls && w->number == number)
{
return w.get();
}
}
return nullptr;
}
// TODO: Use variant for this once the window framework is done.
WindowBase* WindowFindByNumber(WindowClass cls, EntityId id)
{
return WindowFindByNumber(cls, static_cast<rct_windownumber>(id.ToUnderlying()));
}
/**
* Closes the top-most window
*
@@ -391,80 +344,6 @@ void WindowCloseAllExceptNumberAndClass(rct_windownumber number, WindowClass cls
});
}
/**
*
* rct2: 0x006EA845
*/
WindowBase* WindowFindFromPoint(const ScreenCoordsXY& screenCoords)
{
for (auto it = g_window_list.rbegin(); it != g_window_list.rend(); it++)
{
auto& w = *it;
if (w->flags & WF_DEAD)
continue;
if (screenCoords.x < w->windowPos.x || screenCoords.x >= w->windowPos.x + w->width || screenCoords.y < w->windowPos.y
|| screenCoords.y >= w->windowPos.y + w->height)
continue;
if (w->flags & WF_NO_BACKGROUND)
{
auto widgetIndex = WindowFindWidgetFromPoint(*w.get(), screenCoords);
if (widgetIndex == -1)
continue;
}
return w.get();
}
return nullptr;
}
/**
*
* rct2: 0x006EA594
* x (ax)
* y (bx)
* returns widget_index (edx)
* EDI NEEDS TO BE SET TO w->widgets[widget_index] AFTER
*/
WidgetIndex WindowFindWidgetFromPoint(WindowBase& w, const ScreenCoordsXY& screenCoords)
{
// Invalidate the window
w.OnPrepareDraw();
// Find the widget at point x, y
WidgetIndex widget_index = -1;
for (int32_t i = 0;; i++)
{
const auto& widget = w.widgets[i];
if (widget.type == WindowWidgetType::Last)
{
break;
}
if (widget.type != WindowWidgetType::Empty && widget.IsVisible())
{
if (screenCoords.x >= w.windowPos.x + widget.left && screenCoords.x <= w.windowPos.x + widget.right
&& screenCoords.y >= w.windowPos.y + widget.top && screenCoords.y <= w.windowPos.y + widget.bottom)
{
widget_index = i;
}
}
}
// Return next widget if a dropdown
if (widget_index != -1)
{
const auto& widget = w.widgets[widget_index];
if (widget.type == WindowWidgetType::DropdownMenu)
widget_index++;
}
// Return the widget index
return widget_index;
}
/**
* Invalidates the specified window.
* rct2: 0x006EB13A
@@ -630,7 +509,8 @@ WindowBase* WindowBringToFront(WindowBase& w)
WindowBase* WindowBringToFrontByClassWithFlags(WindowClass cls, uint16_t flags)
{
WindowBase* w = WindowFindByClass(cls);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(cls);
if (w != nullptr)
{
w->flags |= flags;
@@ -654,9 +534,8 @@ WindowBase* WindowBringToFrontByClass(WindowClass cls)
*/
WindowBase* WindowBringToFrontByNumber(WindowClass cls, rct_windownumber number)
{
WindowBase* w;
w = WindowFindByNumber(cls, number);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByNumber(cls, number);
if (w != nullptr)
{
w->flags |= WF_WHITE_BORDER_MASK;
@@ -1179,7 +1058,8 @@ void ToolCancel()
gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number, gCurrentToolWidget.widget_index);
// Abort tool event
WindowBase* w = WindowFindByNumber(gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByNumber(gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number);
if (w != nullptr)
w->OnToolAbort(gCurrentToolWidget.widget_index);
}
@@ -1195,32 +1075,33 @@ void WindowResizeGui(int32_t width, int32_t height)
if (gScreenFlags & SCREEN_FLAGS_EDITOR)
return;
WindowBase* titleWind = WindowFindByClass(WindowClass::TitleMenu);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* titleWind = windowMgr->FindByClass(WindowClass::TitleMenu);
if (titleWind != nullptr)
{
titleWind->windowPos.x = (width - titleWind->width) / 2;
titleWind->windowPos.y = height - 182;
}
WindowBase* versionWind = WindowFindByClass(WindowClass::TitleVersion);
WindowBase* versionWind = windowMgr->FindByClass(WindowClass::TitleVersion);
if (versionWind != nullptr)
versionWind->windowPos.y = height - 30;
WindowBase* exitWind = WindowFindByClass(WindowClass::TitleExit);
WindowBase* exitWind = windowMgr->FindByClass(WindowClass::TitleExit);
if (exitWind != nullptr)
{
exitWind->windowPos.x = width - 40;
exitWind->windowPos.y = height - 64;
}
WindowBase* optionsWind = WindowFindByClass(WindowClass::TitleOptions);
WindowBase* optionsWind = windowMgr->FindByClass(WindowClass::TitleOptions);
if (optionsWind != nullptr)
{
optionsWind->windowPos.x = width - 80;
}
// Keep options window centred after a resize
WindowBase* optionsWindow = WindowFindByClass(WindowClass::Options);
WindowBase* optionsWindow = windowMgr->FindByClass(WindowClass::Options);
if (optionsWindow != nullptr)
{
optionsWindow->windowPos.x = (ContextGetWidth() - optionsWindow->width) / 2;
@@ -1228,7 +1109,7 @@ void WindowResizeGui(int32_t width, int32_t height)
}
// Keep progress bar window centred after a resize
WindowBase* ProgressWindow = WindowFindByClass(WindowClass::ProgressWindow);
WindowBase* ProgressWindow = windowMgr->FindByClass(WindowClass::ProgressWindow);
if (ProgressWindow != nullptr)
{
ProgressWindow->windowPos.x = (ContextGetWidth() - ProgressWindow->width) / 2;
@@ -1258,13 +1139,15 @@ void WindowResizeGuiScenarioEditor(int32_t width, int32_t height)
}
}
WindowBase* topWind = WindowFindByClass(WindowClass::TopToolbar);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* topWind = windowMgr->FindByClass(WindowClass::TopToolbar);
if (topWind != nullptr)
{
topWind->width = std::max(640, width);
}
WindowBase* bottomWind = WindowFindByClass(WindowClass::BottomToolbar);
WindowBase* bottomWind = windowMgr->FindByClass(WindowClass::BottomToolbar);
if (bottomWind != nullptr)
{
bottomWind->windowPos.y = height - 32;
-5
View File
@@ -483,11 +483,6 @@ void WindowCloseAll();
void WindowCloseAllExceptClass(WindowClass cls);
void WindowCloseAllExceptFlags(uint16_t flags);
void WindowCloseAllExceptNumberAndClass(rct_windownumber number, WindowClass cls);
WindowBase* WindowFindByClass(WindowClass cls);
WindowBase* WindowFindByNumber(WindowClass cls, rct_windownumber number);
WindowBase* WindowFindByNumber(WindowClass cls, EntityId id);
WindowBase* WindowFindFromPoint(const ScreenCoordsXY& screenCoords);
WidgetIndex WindowFindWidgetFromPoint(WindowBase& w, const ScreenCoordsXY& screenCoords);
void WindowInvalidateByClass(WindowClass cls);
void WindowInvalidateByNumber(WindowClass cls, rct_windownumber number);
void WindowInvalidateByNumber(WindowClass cls, EntityId id);
+3 -1
View File
@@ -28,6 +28,7 @@
#include "../scenes/intro/IntroScene.h"
#include "../scenes/title/TitleScene.h"
#include "../ui/UiContext.h"
#include "../ui/WindowManager.h"
#include "../world/TileInspector.h"
using namespace OpenRCT2;
@@ -105,7 +106,8 @@ static bool ShouldShowFPS()
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return true;
return WindowFindByClass(WindowClass::TopToolbar);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
return windowMgr->FindByClass(WindowClass::TopToolbar);
}
void Painter::PaintFPS(DrawPixelInfo& dpi)
+17 -8
View File
@@ -765,7 +765,8 @@ bool Ride::FindTrackGap(const CoordsXYE& input, CoordsXYE* output) const
if (rtd.specialType == RtdSpecialType::maze)
return false;
WindowBase* w = WindowFindByClass(WindowClass::RideConstruction);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(WindowClass::RideConstruction);
if (w != nullptr && _rideConstructionState != RideConstructionState::State0 && _currentRideIndex == id)
{
RideConstructionInvalidateCurrentTrack();
@@ -2700,7 +2701,9 @@ static ResultWithMessage RideCheckBlockBrakes(const CoordsXYE& input, CoordsXYE*
return { false };
RideId rideIndex = input.element->AsTrack()->GetRideIndex();
WindowBase* w = WindowFindByClass(WindowClass::RideConstruction);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(WindowClass::RideConstruction);
if (w != nullptr && _rideConstructionState != RideConstructionState::State0 && _currentRideIndex == rideIndex)
RideConstructionInvalidateCurrentTrack();
@@ -2764,7 +2767,8 @@ static bool RideCheckTrackContainsInversions(const CoordsXYE& input, CoordsXYE*
return true;
}
WindowBase* w = WindowFindByClass(WindowClass::RideConstruction);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(WindowClass::RideConstruction);
if (w != nullptr && _rideConstructionState != RideConstructionState::State0 && rideIndex == _currentRideIndex)
{
RideConstructionInvalidateCurrentTrack();
@@ -2824,7 +2828,8 @@ static bool RideCheckTrackContainsBanked(const CoordsXYE& input, CoordsXYE* outp
if (rtd.specialType == RtdSpecialType::maze)
return true;
WindowBase* w = WindowFindByClass(WindowClass::RideConstruction);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(WindowClass::RideConstruction);
if (w != nullptr && _rideConstructionState != RideConstructionState::State0 && rideIndex == _currentRideIndex)
{
RideConstructionInvalidateCurrentTrack();
@@ -2865,7 +2870,8 @@ static bool RideCheckTrackContainsBanked(const CoordsXYE& input, CoordsXYE* outp
*/
static int32_t RideCheckStationLength(const CoordsXYE& input, CoordsXYE* output)
{
WindowBase* w = WindowFindByClass(WindowClass::RideConstruction);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(WindowClass::RideConstruction);
if (w != nullptr && _rideConstructionState != RideConstructionState::State0
&& _currentRideIndex == input.element->AsTrack()->GetRideIndex())
{
@@ -2927,7 +2933,8 @@ static bool RideCheckStartAndEndIsStation(const CoordsXYE& input)
if (ride == nullptr)
return false;
auto w = WindowFindByClass(WindowClass::RideConstruction);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto w = windowMgr->FindByClass(WindowClass::RideConstruction);
if (w != nullptr && _rideConstructionState != RideConstructionState::State0 && rideIndex == _currentRideIndex)
{
RideConstructionInvalidateCurrentTrack();
@@ -3986,7 +3993,8 @@ void Ride::ConstructMissingEntranceOrExit() const
return;
}
w = WindowFindByClass(WindowClass::RideConstruction);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
w = windowMgr->FindByClass(WindowClass::RideConstruction);
if (w != nullptr)
w->OnMouseUp(entranceOrExit);
}
@@ -5022,7 +5030,8 @@ static int32_t RideGetTrackLength(const Ride& ride)
RideId rideIndex = tileElement->AsTrack()->GetRideIndex();
WindowBase* w = WindowFindByClass(WindowClass::RideConstruction);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(WindowClass::RideConstruction);
if (w != nullptr && _rideConstructionState != RideConstructionState::State0 && _currentRideIndex == rideIndex)
{
RideConstructionInvalidateCurrentTrack();
+7 -5
View File
@@ -119,11 +119,11 @@ static int32_t ride_check_if_construction_allowed(Ride& ride)
static WindowBase* ride_create_or_find_construction_window(RideId rideIndex)
{
auto windowManager = GetContext()->GetUiContext()->GetWindowManager();
auto* windowManager = GetContext()->GetUiContext()->GetWindowManager();
auto intent = Intent(INTENT_ACTION_RIDE_CONSTRUCTION_FOCUS);
intent.PutExtra(INTENT_EXTRA_RIDE_ID, rideIndex.ToUnderlying());
windowManager->BroadcastIntent(intent);
return WindowFindByClass(WindowClass::RideConstruction);
return windowManager->FindByClass(WindowClass::RideConstruction);
}
/**
@@ -238,7 +238,8 @@ void RideClearForConstruction(Ride& ride)
ride.RemoveVehicles();
RideClearBlockedTiles(ride);
auto w = WindowFindByNumber(WindowClass::Ride, ride.id.ToUnderlying());
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto w = windowMgr->FindByNumber(WindowClass::Ride, ride.id.ToUnderlying());
if (w != nullptr)
w->OnResize();
}
@@ -832,13 +833,14 @@ static bool ride_modify_entrance_or_exit(const CoordsXYE& tileElement)
auto stationIndex = entranceElement->GetStationIndex();
// Get or create construction window for ride
auto constructionWindow = WindowFindByClass(WindowClass::RideConstruction);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto constructionWindow = windowMgr->FindByClass(WindowClass::RideConstruction);
if (constructionWindow == nullptr)
{
if (!RideInitialiseConstructionWindow(*ride))
return false;
constructionWindow = WindowFindByClass(WindowClass::RideConstruction);
constructionWindow = windowMgr->FindByClass(WindowClass::RideConstruction);
if (constructionWindow == nullptr)
return false;
}
+20
View File
@@ -69,6 +69,26 @@ namespace OpenRCT2::Ui
{
return nullptr;
}
WindowBase* FindByClass(WindowClass cls) override
{
return nullptr;
}
WindowBase* FindByNumber(WindowClass cls, rct_windownumber number) override
{
return nullptr;
}
WindowBase* FindByNumber(WindowClass cls, EntityId id) override
{
return nullptr;
}
WindowBase* FindFromPoint(const ScreenCoordsXY& screenCoords) override
{
return nullptr;
}
WidgetIndex FindWidgetFromPoint(WindowBase& w, const ScreenCoordsXY& screenCoords) override
{
return -1;
}
};
std::unique_ptr<IWindowManager> CreateDummyWindowManager()
+6
View File
@@ -42,6 +42,12 @@ namespace OpenRCT2::Ui
virtual void SetMainView(const ScreenCoordsXY& viewPos, ZoomLevel zoom, int32_t rotation) = 0;
virtual void UpdateMouseWheel() = 0;
virtual WindowBase* GetOwner(const Viewport* viewport) = 0;
virtual WindowBase* FindByClass(WindowClass cls) = 0;
virtual WindowBase* FindByNumber(WindowClass cls, rct_windownumber number) = 0;
virtual WindowBase* FindByNumber(WindowClass cls, EntityId id) = 0;
virtual WindowBase* FindFromPoint(const ScreenCoordsXY& screenCoords) = 0;
virtual WidgetIndex FindWidgetFromPoint(WindowBase& w, const ScreenCoordsXY& screenCoords) = 0;
};
std::unique_ptr<IWindowManager> CreateDummyWindowManager();
+4 -1
View File
@@ -16,6 +16,8 @@
#include "../ride/Station.h"
#include "../ride/Track.h"
#include "../ride/TrackData.h"
#include "../ui/UiContext.h"
#include "../ui/WindowManager.h"
#include "../windows/TileInspectorGlobals.h"
#include "Banner.h"
#include "Footpath.h"
@@ -84,7 +86,8 @@ namespace OpenRCT2::TileInspector
static bool IsTileSelected(const CoordsXY& loc)
{
// Return true for everyone who has the window open and tile selected
auto* window = WindowFindByClass(WindowClass::TileInspector);
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto* window = windowMgr->FindByClass(WindowClass::TileInspector);
return window != nullptr && loc == windowTileInspectorTile.ToCoordsXY();
}