@@ -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 GetToolbarRoadType ()
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,7 +390,18 @@ struct BuildRoadToolbarWindow : Window {
381390 {
382391 if (!gui_scope) return ;
383392
384- if (!ValParamRoadType (this ->roadtype )) {
393+ if (ValParamRoadType (static_cast <RoadType>(data))) {
394+ if (RoadTypeIsRoad (static_cast <RoadType>(data))) {
395+ _last_built_roadtype = _cur_roadtype = static_cast <RoadType>(data);
396+ } else {
397+ _last_built_tramtype = _cur_roadtype = static_cast <RoadType>(data);
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+ } else {
385405 /* Close toolbar if road type is not available. */
386406 this ->Close ();
387407 return ;
@@ -1061,6 +1081,12 @@ Window *ShowBuildRoadToolbar(RoadType roadtype)
10611081{
10621082 if (!Company::IsValidID (_local_company)) return nullptr ;
10631083 if (!ValParamRoadType (roadtype)) return nullptr ;
1084+ Window *w = FindWindowById (WindowClass::BuildToolbar, TRANSPORT_ROAD );
1085+
1086+ if (w != nullptr && GetRoadTramType (roadtype) == GetRoadTramType (_cur_roadtype)) {
1087+ w->OnInvalidateData (roadtype);
1088+ return w;
1089+ }
10641090
10651091 CloseWindowByClass (WindowClass::BuildToolbar);
10661092 _cur_roadtype = roadtype;
0 commit comments