diff --git a/src/road_gui.cpp b/src/road_gui.cpp index 38af08f70a..ec5436b5f2 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -1320,7 +1320,8 @@ public: this->FinishInitNested(TRANSPORT_ROAD); - this->window_class = (rs == ROADSTOP_BUS) ? WC_BUS_STATION : WC_TRUCK_STATION; + this->ChangeWindowClass((rs == ROADSTOP_BUS) ? WC_BUS_STATION : WC_TRUCK_STATION); + if (!newstops || _roadstop_gui_settings.roadstop_class >= (int)RoadStopClass::GetClassCount()) { /* There's no new stops available or the list has reduced in size. * Now, set the default road stops as selected. */ diff --git a/src/window.cpp b/src/window.cpp index 585f3e4bc9..ddeb7a53a5 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -1527,6 +1527,12 @@ static void BringWindowToFront(Window *w) w->SetDirty(); } +void Window::ChangeWindowClass(WindowClass cls) +{ + this->window_class = cls; + if (this->window_class < WC_END) _present_window_types.set(this->window_class); +} + /** * Initializes the data (except the position and initial size) of a new Window. * @param window_number Number being assigned to the new window @@ -1537,7 +1543,7 @@ static void BringWindowToFront(Window *w) void Window::InitializeData(WindowNumber window_number) { /* Set up window properties; some of them are needed to set up smallest size below */ - this->window_class = this->window_desc->cls; + this->ChangeWindowClass(this->window_desc->cls); this->SetWhiteBorder(); if (this->window_desc->default_pos == WDP_CENTER) this->flags |= WF_CENTERED; this->owner = INVALID_OWNER; @@ -1570,7 +1576,6 @@ void Window::InitializeData(WindowNumber window_number) AddWindowToZOrdering(this); this->next_window = _first_window; _first_window = this; - if (this->window_class < WC_END) _present_window_types.set(this->window_class); } /** diff --git a/src/window_gui.h b/src/window_gui.h index 7631fe7529..539f3c7f0d 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -362,6 +362,8 @@ public: void CreateNestedTree(bool fill_nested = true); void FinishInitNested(WindowNumber window_number = 0); + void ChangeWindowClass(WindowClass cls); + /** * Set the timeout flag of the window and initiate the timer. */