mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-23 15:52:55 +01:00
Remove use of window list in Viewport.cpp
This commit is contained in:
@@ -502,6 +502,18 @@ public:
|
|||||||
{
|
{
|
||||||
window_all_wheel_input();
|
window_all_wheel_input();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rct_window* GetOwner(const rct_viewport* viewport) override
|
||||||
|
{
|
||||||
|
for (auto w = g_window_list; w < gWindowNextSlot; w++)
|
||||||
|
{
|
||||||
|
if (w->viewport == viewport)
|
||||||
|
{
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
IWindowManager * OpenRCT2::Ui::CreateWindowManager()
|
IWindowManager * OpenRCT2::Ui::CreateWindowManager()
|
||||||
|
|||||||
@@ -24,11 +24,15 @@
|
|||||||
#include "../world/Climate.h"
|
#include "../world/Climate.h"
|
||||||
#include "../world/Map.h"
|
#include "../world/Map.h"
|
||||||
#include "../world/Sprite.h"
|
#include "../world/Sprite.h"
|
||||||
|
#include "../ui/UiContext.h"
|
||||||
|
#include "../ui/WindowManager.h"
|
||||||
#include "Colour.h"
|
#include "Colour.h"
|
||||||
#include "Viewport.h"
|
#include "Viewport.h"
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
#include "Window_internal.h"
|
#include "Window_internal.h"
|
||||||
|
|
||||||
|
using namespace OpenRCT2;
|
||||||
|
|
||||||
//#define DEBUG_SHOW_DIRTY_BOX
|
//#define DEBUG_SHOW_DIRTY_BOX
|
||||||
uint8 gShowGridLinesRefCount;
|
uint8 gShowGridLinesRefCount;
|
||||||
uint8 gShowLandRightsRefCount;
|
uint8 gShowLandRightsRefCount;
|
||||||
@@ -1538,17 +1542,17 @@ void viewport_invalidate(rct_viewport *viewport, sint32 left, sint32 top, sint32
|
|||||||
// if unknown viewport visibility, use the containing window to discover the status
|
// if unknown viewport visibility, use the containing window to discover the status
|
||||||
if (viewport->visibility == VC_UNKNOWN)
|
if (viewport->visibility == VC_UNKNOWN)
|
||||||
{
|
{
|
||||||
for (rct_window *w = g_window_list; w < gWindowNextSlot; w++)
|
auto windowManager = GetContext()->GetUiContext()->GetWindowManager();
|
||||||
{
|
auto owner = windowManager->GetOwner(viewport);
|
||||||
if (w->classification != WC_MAIN_WINDOW && w->viewport != nullptr && w->viewport == viewport)
|
if (owner != nullptr && owner->classification != WC_MAIN_WINDOW)
|
||||||
{
|
{
|
||||||
// note, window_is_visible will update viewport->visibility, so this should have a low hit count
|
// note, window_is_visible will update viewport->visibility, so this should have a low hit count
|
||||||
if (!window_is_visible(w)) {
|
if (!window_is_visible(owner))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (viewport->visibility == VC_COVERED) return;
|
if (viewport->visibility == VC_COVERED) return;
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ namespace OpenRCT2::Ui
|
|||||||
std::string GetKeyboardShortcutString(sint32 /*shortcut*/) override { return std::string(); }
|
std::string GetKeyboardShortcutString(sint32 /*shortcut*/) override { return std::string(); }
|
||||||
void SetMainView(sint32 x, sint32 y, sint32 zoom, sint32 rotation) override { }
|
void SetMainView(sint32 x, sint32 y, sint32 zoom, sint32 rotation) override { }
|
||||||
void UpdateMouseWheel() override { }
|
void UpdateMouseWheel() override { }
|
||||||
|
rct_window* GetOwner(const rct_viewport* viewport) override { return nullptr; }
|
||||||
};
|
};
|
||||||
|
|
||||||
IWindowManager * CreateDummyWindowManager()
|
IWindowManager * CreateDummyWindowManager()
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ namespace OpenRCT2::Ui
|
|||||||
virtual std::string GetKeyboardShortcutString(sint32 shortcut) abstract;
|
virtual std::string GetKeyboardShortcutString(sint32 shortcut) abstract;
|
||||||
virtual void SetMainView(sint32 x, sint32 y, sint32 zoom, sint32 rotation) abstract;
|
virtual void SetMainView(sint32 x, sint32 y, sint32 zoom, sint32 rotation) abstract;
|
||||||
virtual void UpdateMouseWheel() abstract;
|
virtual void UpdateMouseWheel() abstract;
|
||||||
|
virtual rct_window* GetOwner(const rct_viewport* viewport) abstract;
|
||||||
};
|
};
|
||||||
|
|
||||||
IWindowManager * CreateDummyWindowManager();
|
IWindowManager * CreateDummyWindowManager();
|
||||||
|
|||||||
Reference in New Issue
Block a user