From 87ee18b6b96307a73802999afd5c7307922e9b3c Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Fri, 30 Jun 2023 23:18:01 +0100 Subject: [PATCH] Add close/delete window function aliases for upstream --- src/window.cpp | 5 +++++ src/window_func.h | 7 +++++++ src/window_gui.h | 3 +++ 3 files changed, 15 insertions(+) diff --git a/src/window.cpp b/src/window.cpp index c5ef4353d7..0ae991a608 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -1172,6 +1172,11 @@ Window::~Window() const_cast(this->window_class) = WC_INVALID; } +void Window::Close() +{ + if (this->window_class != WC_INVALID) delete this; +} + /** * Find a window by its class and window number * @param cls Window class diff --git a/src/window_func.h b/src/window_func.h index 586f96aa8d..27ca5bef2d 100644 --- a/src/window_func.h +++ b/src/window_func.h @@ -45,6 +45,10 @@ void DeleteNetworkClientWindows(); void HideVitalWindows(); void ShowVitalWindows(); +inline void CloseNonVitalWindows() { DeleteNonVitalWindows(); } +inline void CloseAllNonVitalWindows() { DeleteAllNonVitalWindows(); } +inline void CloseConstructionWindows() { DeleteConstructionWindows(); } + /** * Re-initialize all windows. * @param zoom_changed Set if windows are being re-initialized due to a zoom level changed. @@ -59,6 +63,9 @@ void DeleteWindowById(WindowClass cls, WindowNumber number, bool force = true); void DeleteAllWindowsById(WindowClass cls, WindowNumber number, bool force = true); void DeleteWindowByClass(WindowClass cls); +inline void CloseWindowById(WindowClass cls, WindowNumber number, bool force = true) { DeleteWindowById(cls, number, force); } +inline void CloseWindowByClass(WindowClass cls) { DeleteWindowByClass(cls); } + bool FocusWindowById(WindowClass cls, WindowNumber number); bool EditBoxInGlobalFocus(); diff --git a/src/window_gui.h b/src/window_gui.h index 539f3c7f0d..e1bdc41854 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -289,6 +289,8 @@ public: virtual ~Window(); + virtual void Close(); + /** * Helper allocation function to disallow something. * Don't allow arrays; arrays of Windows are pointless as you need @@ -520,6 +522,7 @@ public: static int SortButtonWidth(); void DeleteChildWindows(WindowClass wc = WC_INVALID) const; + inline void CloseChildWindows(WindowClass wc = WC_INVALID) const { this->DeleteChildWindows(wc); } void SetDirty(); void SetDirtyAsBlocks();