Add close/delete window function aliases for upstream

This commit is contained in:
Jonathan G Rennison
2023-06-30 23:18:01 +01:00
parent 01c6705339
commit 87ee18b6b9
3 changed files with 15 additions and 0 deletions

View File

@@ -1172,6 +1172,11 @@ Window::~Window()
const_cast<volatile WindowClass &>(this->window_class) = WC_INVALID; const_cast<volatile WindowClass &>(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 * Find a window by its class and window number
* @param cls Window class * @param cls Window class

View File

@@ -45,6 +45,10 @@ void DeleteNetworkClientWindows();
void HideVitalWindows(); void HideVitalWindows();
void ShowVitalWindows(); void ShowVitalWindows();
inline void CloseNonVitalWindows() { DeleteNonVitalWindows(); }
inline void CloseAllNonVitalWindows() { DeleteAllNonVitalWindows(); }
inline void CloseConstructionWindows() { DeleteConstructionWindows(); }
/** /**
* Re-initialize all windows. * Re-initialize all windows.
* @param zoom_changed Set if windows are being re-initialized due to a zoom level changed. * @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 DeleteAllWindowsById(WindowClass cls, WindowNumber number, bool force = true);
void DeleteWindowByClass(WindowClass cls); 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 FocusWindowById(WindowClass cls, WindowNumber number);
bool EditBoxInGlobalFocus(); bool EditBoxInGlobalFocus();

View File

@@ -289,6 +289,8 @@ public:
virtual ~Window(); virtual ~Window();
virtual void Close();
/** /**
* Helper allocation function to disallow something. * Helper allocation function to disallow something.
* Don't allow arrays; arrays of Windows are pointless as you need * Don't allow arrays; arrays of Windows are pointless as you need
@@ -520,6 +522,7 @@ public:
static int SortButtonWidth(); static int SortButtonWidth();
void DeleteChildWindows(WindowClass wc = WC_INVALID) const; void DeleteChildWindows(WindowClass wc = WC_INVALID) const;
inline void CloseChildWindows(WindowClass wc = WC_INVALID) const { this->DeleteChildWindows(wc); }
void SetDirty(); void SetDirty();
void SetDirtyAsBlocks(); void SetDirtyAsBlocks();