Codechange: Set up rail/road toolbar buttons during window's OnInit event.
This ensures the buttons are configured without extra initialisation methods.
This commit is contained in:
committed by
Peter Nelson
parent
0e3fdfb1b5
commit
6d2b93d3b3
@@ -347,9 +347,8 @@ struct BuildRoadToolbarWindow : Window {
|
||||
|
||||
BuildRoadToolbarWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc)
|
||||
{
|
||||
this->Initialize(_cur_roadtype);
|
||||
this->roadtype = _cur_roadtype;
|
||||
this->CreateNestedTree();
|
||||
this->SetupRoadToolbar();
|
||||
this->FinishInitNested(window_number);
|
||||
this->SetWidgetDisabledState(WID_ROT_REMOVE, true);
|
||||
|
||||
@@ -409,18 +408,9 @@ struct BuildRoadToolbarWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
void Initialize(RoadType roadtype)
|
||||
{
|
||||
assert(roadtype < ROADTYPE_END);
|
||||
this->roadtype = roadtype;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the road toolbar for roadtype given
|
||||
* @param roadtype the roadtype to display
|
||||
*/
|
||||
void SetupRoadToolbar()
|
||||
void OnInit() override
|
||||
{
|
||||
/* Configure the road toolbar for the roadtype. */
|
||||
const RoadTypeInfo *rti = GetRoadTypeInfo(this->roadtype);
|
||||
this->GetWidget<NWidgetCore>(WID_ROT_ROAD_X)->widget_data = rti->gui_sprites.build_x_road;
|
||||
this->GetWidget<NWidgetCore>(WID_ROT_ROAD_Y)->widget_data = rti->gui_sprites.build_y_road;
|
||||
@@ -438,8 +428,7 @@ struct BuildRoadToolbarWindow : Window {
|
||||
*/
|
||||
void ModifyRoadType(RoadType roadtype)
|
||||
{
|
||||
this->Initialize(roadtype);
|
||||
this->SetupRoadToolbar();
|
||||
this->roadtype = roadtype;
|
||||
this->ReInit();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user