diff --git a/src/window.cpp b/src/window.cpp index 1b357a5f69..715c8ca2cd 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -3344,6 +3344,28 @@ restart_search: FOR_ALL_WINDOWS_FROM_BACK(w) w->SetDirty(); } +/** + * Delete all windows that are linked to the main toolbar. + * Once done with that, refresh other windows too. + */ +void DeleteToolbarLinkedWindows() +{ + Window *w; + +restart_search: + /* When we find the window to delete, we need to restart the search + * as deleting this window could cascade in deleting (many) others + * anywhere in the z-array */ + FOR_ALL_WINDOWS_FROM_BACK(w) { + if (w->window_desc->default_pos == WDP_ALIGN_TOOLBAR) { + delete w; + goto restart_search; + } + } + + FOR_ALL_WINDOWS_FROM_BACK(w) w->SetDirty(); +} + /** Delete all always on-top windows to get an empty screen */ void HideVitalWindows() { diff --git a/src/window_func.h b/src/window_func.h index a0fff7c098..335ab9eae3 100644 --- a/src/window_func.h +++ b/src/window_func.h @@ -42,6 +42,7 @@ void InvalidateWindowClassesData(WindowClass cls, int data = 0, bool gui_scope = void DeleteNonVitalWindows(); void DeleteAllNonVitalWindows(); void DeleteConstructionWindows(); +void DeleteToolbarLinkedWindows(); void HideVitalWindows(); void ShowVitalWindows();