mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-23 14:54:30 +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:
@@ -1730,7 +1730,7 @@ namespace OpenRCT2
|
||||
*/
|
||||
InteractionInfo GetMapCoordinatesFromPos(const ScreenCoordsXY& screenCoords, int32_t flags)
|
||||
{
|
||||
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
|
||||
auto* windowMgr = Ui::GetWindowManager();
|
||||
WindowBase* window = windowMgr->FindFromPoint(screenCoords);
|
||||
return GetMapCoordinatesFromPosWindow(window, screenCoords, flags);
|
||||
}
|
||||
@@ -1783,7 +1783,7 @@ namespace OpenRCT2
|
||||
// if unknown viewport visibility, use the containing window to discover the status
|
||||
if (viewport->visibility == VisibilityCache::Unknown)
|
||||
{
|
||||
auto windowManager = GetContext()->GetUiContext()->GetWindowManager();
|
||||
auto windowManager = Ui::GetWindowManager();
|
||||
auto owner = windowManager->GetOwner(viewport);
|
||||
if (owner != nullptr && owner->classification != WindowClass::MainWindow)
|
||||
{
|
||||
@@ -1819,7 +1819,7 @@ namespace OpenRCT2
|
||||
|
||||
static Viewport* ViewportFindFromPoint(const ScreenCoordsXY& screenCoords)
|
||||
{
|
||||
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
|
||||
auto* windowMgr = Ui::GetWindowManager();
|
||||
WindowBase* w = windowMgr->FindFromPoint(screenCoords);
|
||||
if (w == nullptr)
|
||||
return nullptr;
|
||||
@@ -1848,7 +1848,7 @@ namespace OpenRCT2
|
||||
*/
|
||||
std::optional<CoordsXY> ScreenGetMapXY(const ScreenCoordsXY& screenCoords, Viewport** viewport)
|
||||
{
|
||||
auto* windowMgr = GetContext()->GetUiContext()->GetWindowManager();
|
||||
auto* windowMgr = Ui::GetWindowManager();
|
||||
|
||||
// This will get the tile location but we will need the more accuracy
|
||||
WindowBase* window = windowMgr->FindFromPoint(screenCoords);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -380,11 +380,6 @@ namespace OpenRCT2
|
||||
|
||||
void WindowSetWindowLimit(int32_t value);
|
||||
|
||||
WindowBase* WindowBringToFront(WindowBase& w);
|
||||
WindowBase* WindowBringToFrontByClass(WindowClass cls);
|
||||
WindowBase* WindowBringToFrontByClassWithFlags(WindowClass cls, uint16_t flags);
|
||||
WindowBase* WindowBringToFrontByNumber(WindowClass cls, rct_windownumber number);
|
||||
|
||||
void WindowClose(WindowBase& window);
|
||||
void WindowCloseByClass(WindowClass cls);
|
||||
void WindowCloseByNumber(WindowClass cls, rct_windownumber number);
|
||||
|
||||
Reference in New Issue
Block a user