Add Window method to change window class

Use in BuildRoadStationWindow
pull/532/head
Jonathan G Rennison 1 year ago
parent 6215e326fd
commit 665a4ca55b

@ -1320,7 +1320,8 @@ public:
this->FinishInitNested(TRANSPORT_ROAD); 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()) { if (!newstops || _roadstop_gui_settings.roadstop_class >= (int)RoadStopClass::GetClassCount()) {
/* There's no new stops available or the list has reduced in size. /* There's no new stops available or the list has reduced in size.
* Now, set the default road stops as selected. */ * Now, set the default road stops as selected. */

@ -1527,6 +1527,12 @@ static void BringWindowToFront(Window *w)
w->SetDirty(); 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. * Initializes the data (except the position and initial size) of a new Window.
* @param window_number Number being assigned to the 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) void Window::InitializeData(WindowNumber window_number)
{ {
/* Set up window properties; some of them are needed to set up smallest size below */ /* 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(); this->SetWhiteBorder();
if (this->window_desc->default_pos == WDP_CENTER) this->flags |= WF_CENTERED; if (this->window_desc->default_pos == WDP_CENTER) this->flags |= WF_CENTERED;
this->owner = INVALID_OWNER; this->owner = INVALID_OWNER;
@ -1570,7 +1576,6 @@ void Window::InitializeData(WindowNumber window_number)
AddWindowToZOrdering(this); AddWindowToZOrdering(this);
this->next_window = _first_window; this->next_window = _first_window;
_first_window = this; _first_window = this;
if (this->window_class < WC_END) _present_window_types.set(this->window_class);
} }
/** /**

@ -362,6 +362,8 @@ public:
void CreateNestedTree(bool fill_nested = true); void CreateNestedTree(bool fill_nested = true);
void FinishInitNested(WindowNumber window_number = 0); void FinishInitNested(WindowNumber window_number = 0);
void ChangeWindowClass(WindowClass cls);
/** /**
* Set the timeout flag of the window and initiate the timer. * Set the timeout flag of the window and initiate the timer.
*/ */

Loading…
Cancel
Save