# HG changeset patch # User peter1138 # Date 2010-03-16 06:18:52 # Node ID db1930e2798e7ee1804325076de5f666a25b9812 # Parent 12f0b09ddc04dd253dd5a6053b5318c6f60284ce (svn r19431) -Codechange: Append rail type speed limit (if set) to rail type selection list, and toolbar title. diff --git a/src/lang/english.txt b/src/lang/english.txt --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -4118,3 +4118,5 @@ STR_BUS STR_LORRY :{BLACK}{LORRY} STR_PLANE :{BLACK}{PLANE} STR_SHIP :{BLACK}{SHIP} + +STR_TOOLBAR_RAILTYPE_VELOCITY :{STRING} ({VELOCITY}) diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -617,6 +617,8 @@ static const RailBuildingGUIButtonData _ * @param clicked_widget Widget clicked in the toolbar */ struct BuildRailToolbarWindow : Window { + RailType railtype; + BuildRailToolbarWindow(const WindowDesc *desc, WindowNumber window_number, RailType railtype) : Window() { this->InitNested(desc); @@ -636,10 +638,11 @@ struct BuildRailToolbarWindow : Window { */ void SetupRailToolbar(RailType railtype) { + this->railtype = railtype; const RailtypeInfo *rti = GetRailTypeInfo(railtype); assert(railtype < RAILTYPE_END); - this->GetWidget(RTW_CAPTION)->widget_data = rti->strings.toolbar_caption; + this->GetWidget(RTW_CAPTION)->widget_data = rti->max_speed > 0 ? STR_TOOLBAR_RAILTYPE_VELOCITY : STR_JUST_STRING; this->GetWidget(RTW_BUILD_NS)->widget_data = rti->gui_sprites.build_ns_rail; this->GetWidget(RTW_BUILD_X)->widget_data = rti->gui_sprites.build_x_rail; this->GetWidget(RTW_BUILD_EW)->widget_data = rti->gui_sprites.build_ew_rail; @@ -689,6 +692,15 @@ struct BuildRailToolbarWindow : Window { } } + virtual void SetStringParameters(int widget) const + { + if (widget == RTW_CAPTION) { + const RailtypeInfo *rti = GetRailTypeInfo(this->railtype); + SetDParam(0, rti->strings.toolbar_caption); + SetDParam(1, rti->max_speed); + } + } + virtual void OnPaint() { this->DrawWidgets(); diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -650,7 +650,12 @@ static void ToolbarBuildRailClick(Window const RailtypeInfo *rti = GetRailTypeInfo(rt); /* Skip rail type if it has no label */ if (rti->label == 0) continue; - list->push_back(new DropDownListStringItem(rti->strings.menu_text, rt, !HasBit(c->avail_railtypes, rt))); + + StringID str = rti->max_speed > 0 ? STR_TOOLBAR_RAILTYPE_VELOCITY : STR_JUST_STRING; + DropDownListParamStringItem *item = new DropDownListParamStringItem(str, rt, !HasBit(c->avail_railtypes, rt)); + item->SetParam(0, rti->strings.menu_text); + item->SetParam(1, rti->max_speed); + list->push_back(item); } ShowDropDownList(w, list, _last_built_railtype, TBN_RAILS, 140, true, true); SndPlayFx(SND_15_BEEP);