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

Move WindowCreate and WindowFocusOrCreate into WindowManager (#23643)

* Move WindowBringToFront into WindowManager

* Move WindowCreate and WindowFocusOrCreate into WindowManager

* Cut back on Context/UiContext includes
This commit is contained in:
Aaron van Geffen
2025-01-19 10:58:28 +01:00
committed by GitHub
parent 66ede938f8
commit bed4d5bdca
113 changed files with 895 additions and 767 deletions

View File

@@ -165,7 +165,7 @@ static constexpr float window_scroll_locations[][2] = {
}
});
auto windowManager = GetContext()->GetUiContext()->GetWindowManager();
auto windowManager = Ui::GetWindowManager();
windowManager->UpdateMouseWheel();
}
@@ -472,84 +472,6 @@ static constexpr float window_scroll_locations[][2] = {
return result;
}
/**
*
* rct2: 0x006ECDA4
*/
WindowBase* WindowBringToFront(WindowBase& w)
{
if (!(w.flags & (WF_STICK_TO_BACK | WF_STICK_TO_FRONT)))
{
auto itSourcePos = WindowGetIterator(&w);
if (itSourcePos != g_window_list.end())
{
// Insert in front of the first non-stick-to-front window
auto itDestPos = g_window_list.begin();
for (auto it = g_window_list.rbegin(); it != g_window_list.rend(); it++)
{
auto& w2 = *it;
if (!(w2->flags & WF_STICK_TO_FRONT))
{
itDestPos = it.base();
break;
}
}
g_window_list.splice(itDestPos, g_window_list, itSourcePos);
w.Invalidate();
if (w.windowPos.x + w.width < 20)
{
int32_t i = 20 - w.windowPos.x;
w.windowPos.x += i;
if (w.viewport != nullptr)
w.viewport->pos.x += i;
w.Invalidate();
}
}
}
return &w;
}
WindowBase* WindowBringToFrontByClassWithFlags(WindowClass cls, uint16_t flags)
{
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByClass(cls);
if (w != nullptr)
{
w->flags |= flags;
w->Invalidate();
w = WindowBringToFront(*w);
}
return w;
}
WindowBase* WindowBringToFrontByClass(WindowClass cls)
{
return WindowBringToFrontByClassWithFlags(cls, WF_WHITE_BORDER_MASK);
}
/**
*
* rct2: 0x006ED78A
* cls (cl)
* number (dx)
*/
WindowBase* WindowBringToFrontByNumber(WindowClass cls, rct_windownumber number)
{
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
WindowBase* w = windowMgr->FindByNumber(cls, number);
if (w != nullptr)
{
w->flags |= WF_WHITE_BORDER_MASK;
w->Invalidate();
w = WindowBringToFront(*w);
}
return w;
}
/**
*
* rct2: 0x006EE65A
@@ -834,7 +756,8 @@ static constexpr float window_scroll_locations[][2] = {
// HACK: Prevents the redraw from failing when there is
// a window on top of the viewport.
WindowBringToFront(w);
auto* windowMgr = Ui::GetWindowManager();
windowMgr->BringToFront(w);
w.Invalidate();
}
@@ -1063,7 +986,7 @@ static constexpr float window_scroll_locations[][2] = {
gCurrentToolWidget.widget_index);
// Abort tool event
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto* windowMgr = Ui::GetWindowManager();
WindowBase* w = windowMgr->FindByNumber(
gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number);
if (w != nullptr)
@@ -1081,7 +1004,7 @@ static constexpr float window_scroll_locations[][2] = {
if (gScreenFlags & SCREEN_FLAGS_EDITOR)
return;
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto* windowMgr = Ui::GetWindowManager();
WindowBase* titleWind = windowMgr->FindByClass(WindowClass::TitleMenu);
if (titleWind != nullptr)
{
@@ -1145,7 +1068,7 @@ static constexpr float window_scroll_locations[][2] = {
}
}
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
auto* windowMgr = Ui::GetWindowManager();
WindowBase* topWind = windowMgr->FindByClass(WindowClass::TopToolbar);
if (topWind != nullptr)
@@ -1338,4 +1261,10 @@ static constexpr float window_scroll_locations[][2] = {
return w->viewport;
}
// TODO: declared in WindowManager.h; move when refactors continue
Ui::IWindowManager* Ui::GetWindowManager()
{
return GetContext()->GetUiContext()->GetWindowManager();
}
} // namespace OpenRCT2