@@ -115,6 +115,15 @@ static bool IsRoadStopAvailable(const RoadStopSpec *spec, StationType type)
115115 return Convert8bitBooleanCallback (spec->grf_prop .grffile , CBID_STATION_AVAILABILITY , cb_res);
116116}
117117
118+ /* *
119+ * Get the current roadtype.
120+ * @return the current roadtype.
121+ */
122+ RoadType GetCurrentRoadType ()
123+ {
124+ return _cur_roadtype;
125+ }
126+
118127void CcPlaySound_CONSTRUCTION_OTHER (Commands, const CommandCost &result, TileIndex tile)
119128{
120129 if (result.Succeeded () && _settings_client.sound .confirm ) SndPlayTileFx (SND_1F_CONSTRUCTION_OTHER , tile);
@@ -360,7 +369,7 @@ struct BuildRoadToolbarWindow : Window {
360369 this ->SetWidgetDisabledState (WID_ROT_ONE_WAY , true );
361370 }
362371
363- this ->OnInvalidateData ();
372+ this ->OnInvalidateData (roadtype );
364373
365374 if (_settings_client.gui .link_terraform_toolbar ) ShowTerraformToolbar (this );
366375 }
@@ -381,6 +390,18 @@ struct BuildRoadToolbarWindow : Window {
381390 {
382391 if (!gui_scope) return ;
383392
393+ if (ValParamRoadType (_cur_roadtype = static_cast <RoadType>(data))) {
394+ if (RoadTypeIsRoad (_cur_roadtype)) {
395+ _last_built_roadtype = _cur_roadtype;
396+ } else {
397+ _last_built_tramtype = _cur_roadtype;
398+ }
399+ this ->ModifyRoadType (_cur_roadtype);
400+
401+ if (_thd.GetCallbackWnd () == this ) SetCursor (this ->GetCursorForWidget (this ->last_started_action ), PAL_NONE );
402+ for (WindowClass cls : {WindowClass::BuildBusStation, WindowClass::BuildTruckStation, WindowClass::BuildWaypoint, WindowClass::BuildDepot}) SetWindowDirty (cls, TRANSPORT_ROAD );
403+ }
404+
384405 if (!ValParamRoadType (this ->roadtype )) {
385406 /* Close toolbar if road type is not available. */
386407 this ->Close ();
@@ -1061,6 +1082,12 @@ Window *ShowBuildRoadToolbar(RoadType roadtype)
10611082{
10621083 if (!Company::IsValidID (_local_company)) return nullptr ;
10631084 if (!ValParamRoadType (roadtype)) return nullptr ;
1085+ Window *w = FindWindowById (WindowClass::BuildToolbar, TRANSPORT_ROAD );
1086+
1087+ if (w != nullptr && GetRoadTramType (roadtype) == GetRoadTramType (_cur_roadtype)) {
1088+ w->OnInvalidateData (roadtype);
1089+ return w;
1090+ }
10641091
10651092 CloseWindowByClass (WindowClass::BuildToolbar);
10661093 _cur_roadtype = roadtype;
0 commit comments