mirror of https://github.com/OpenTTD/OpenTTD
Add: Add the widget for rail depots.
parent
afcbba8d6b
commit
2654cfeae7
|
@ -2806,7 +2806,8 @@ STR_RAIL_TOOLBAR_MAGLEV_CONSTRUCTION_CAPTION :Maglev Construc
|
|||
|
||||
STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_TRACK :{BLACK}Build railway track. Ctrl+Click to remove railway track. Also press Shift to show cost estimate only
|
||||
STR_RAIL_TOOLBAR_TOOLTIP_BUILD_AUTORAIL :{BLACK}Build railway track using the Autorail mode. Ctrl+Click to remove railway track. Also press Shift to show cost estimate only
|
||||
STR_RAIL_TOOLBAR_TOOLTIP_BUILD_TRAIN_DEPOT_FOR_BUILDING :{BLACK}Build train depot (for buying and servicing trains). Also press Shift to show cost estimate only
|
||||
STR_RAIL_TOOLBAR_TOOLTIP_BUILD_TRAIN_DEPOT :{BLACK}Build standard train depot (for buying and servicing trains). Ctrl+Click to select another depot to join. Also press Shift to show cost estimate only
|
||||
STR_RAIL_TOOLBAR_TOOLTIP_BUILD_EXTENDED_TRAIN_DEPOT :{BLACK}Build extended train depot (for buying and servicing trains). Ctrl+Click to select another depot to join. Also press Shift to show cost estimate only
|
||||
STR_RAIL_TOOLBAR_TOOLTIP_CONVERT_RAIL_TO_WAYPOINT :{BLACK}Build waypoint on railway. Ctrl+Click to select another waypoint to join. Also press Shift to show cost estimate only
|
||||
STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_STATION :{BLACK}Build railway station. Ctrl+Click to select another station to join. Also press Shift to show cost estimate only
|
||||
STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_SIGNALS :{BLACK}Build signal on railway. Ctrl+Click to build the alternate signal style{}Click+Drag to fill the selected section of rail with signals at the chosen spacing. Ctrl+Click+Drag to fill signals up to the next junction, station, or signal. Also press Shift to show cost estimate only
|
||||
|
|
|
@ -337,9 +337,8 @@ static bool RailToolbar_CtrlChanged(Window *w)
|
|||
if (w->IsWidgetDisabled(WID_RAT_REMOVE)) return false;
|
||||
|
||||
/* allow ctrl to switch remove mode only for these widgets */
|
||||
|
||||
for (WidgetID i = WID_RAT_BUILD_NS; i <= WID_RAT_BUILD_STATION; i++) {
|
||||
if ((i <= WID_RAT_AUTORAIL || i >= WID_RAT_BUILD_DEPOT) && w->IsWidgetLowered(i)) {
|
||||
if ((i <= WID_RAT_AUTORAIL || i >= WID_RAT_BUILD_DEPOT) && w->HasWidget(i) && w->IsWidgetLowered(i)) {
|
||||
ToggleRailButton_Remove(w);
|
||||
return true;
|
||||
}
|
||||
|
@ -459,7 +458,11 @@ struct BuildRailToolbarWindow : Window {
|
|||
if (this->IsWidgetLowered(WID_RAT_BUILD_WAYPOINT)) SetViewportCatchmentWaypoint(nullptr, true);
|
||||
if (_settings_client.gui.link_terraform_toolbar) CloseWindowById(WC_SCEN_LAND_GEN, 0, false);
|
||||
CloseWindowById(WC_SELECT_STATION, 0);
|
||||
if (this->IsWidgetLowered(WID_RAT_BUILD_DEPOT)) SetViewportHighlightDepot(INVALID_DEPOT, true);
|
||||
if ((this->HasWidget(WID_RAT_BUILD_DEPOT) && this->IsWidgetLowered(WID_RAT_BUILD_DEPOT)) ||
|
||||
(this->HasWidget(WID_RAT_BUILD_EXTENDED_DEPOT) && this->IsWidgetLowered(WID_RAT_BUILD_EXTENDED_DEPOT))) {
|
||||
SetViewportHighlightDepot(INVALID_DEPOT, true);
|
||||
}
|
||||
|
||||
this->Window::Close();
|
||||
}
|
||||
|
||||
|
@ -511,7 +514,8 @@ struct BuildRailToolbarWindow : Window {
|
|||
this->GetWidget<NWidgetCore>(WID_RAT_BUILD_EW)->widget_data = rti->gui_sprites.build_ew_rail;
|
||||
this->GetWidget<NWidgetCore>(WID_RAT_BUILD_Y)->widget_data = rti->gui_sprites.build_y_rail;
|
||||
this->GetWidget<NWidgetCore>(WID_RAT_AUTORAIL)->widget_data = rti->gui_sprites.auto_rail;
|
||||
this->GetWidget<NWidgetCore>(WID_RAT_BUILD_DEPOT)->widget_data = rti->gui_sprites.build_depot;
|
||||
if (this->HasWidget(WID_RAT_BUILD_DEPOT)) this->GetWidget<NWidgetCore>(WID_RAT_BUILD_DEPOT)->widget_data = rti->gui_sprites.build_depot;
|
||||
if (this->HasWidget(WID_RAT_BUILD_EXTENDED_DEPOT)) this->GetWidget<NWidgetCore>(WID_RAT_BUILD_EXTENDED_DEPOT)->widget_data = rti->gui_sprites.build_depot;
|
||||
this->GetWidget<NWidgetCore>(WID_RAT_CONVERT_RAIL)->widget_data = rti->gui_sprites.convert_rail;
|
||||
this->GetWidget<NWidgetCore>(WID_RAT_BUILD_TUNNEL)->widget_data = rti->gui_sprites.build_tunnel;
|
||||
}
|
||||
|
@ -540,6 +544,7 @@ struct BuildRailToolbarWindow : Window {
|
|||
case WID_RAT_BUILD_Y:
|
||||
case WID_RAT_AUTORAIL:
|
||||
case WID_RAT_BUILD_DEPOT:
|
||||
case WID_RAT_BUILD_EXTENDED_DEPOT:
|
||||
case WID_RAT_BUILD_WAYPOINT:
|
||||
case WID_RAT_BUILD_STATION:
|
||||
case WID_RAT_BUILD_SIGNALS:
|
||||
|
@ -821,7 +826,10 @@ struct BuildRailToolbarWindow : Window {
|
|||
if (this->IsWidgetLowered(WID_RAT_BUILD_STATION)) SetViewportCatchmentStation(nullptr, true);
|
||||
if (this->IsWidgetLowered(WID_RAT_BUILD_WAYPOINT)) SetViewportCatchmentWaypoint(nullptr, true);
|
||||
|
||||
if (this->IsWidgetLowered(WID_RAT_BUILD_DEPOT)) SetViewportHighlightDepot(INVALID_DEPOT, true);
|
||||
if ((this->HasWidget(WID_RAT_BUILD_DEPOT) && this->IsWidgetLowered(WID_RAT_BUILD_DEPOT)) ||
|
||||
(this->HasWidget(WID_RAT_BUILD_EXTENDED_DEPOT) && this->IsWidgetLowered(WID_RAT_BUILD_EXTENDED_DEPOT))) {
|
||||
SetViewportHighlightDepot(INVALID_DEPOT, true);
|
||||
}
|
||||
|
||||
this->RaiseButtons();
|
||||
this->DisableWidget(WID_RAT_REMOVE);
|
||||
|
@ -847,7 +855,8 @@ struct BuildRailToolbarWindow : Window {
|
|||
/* do not toggle Remove button by Ctrl when placing station or depot */
|
||||
if (!this->IsWidgetLowered(WID_RAT_BUILD_STATION) &&
|
||||
!this->IsWidgetLowered(WID_RAT_BUILD_WAYPOINT) &&
|
||||
!this->IsWidgetLowered(WID_RAT_BUILD_DEPOT) &&
|
||||
!(this->HasWidget(WID_RAT_BUILD_DEPOT) && this->IsWidgetLowered(WID_RAT_BUILD_DEPOT)) &&
|
||||
!(this->HasWidget(WID_RAT_BUILD_EXTENDED_DEPOT) && this->IsWidgetLowered(WID_RAT_BUILD_EXTENDED_DEPOT)) &&
|
||||
RailToolbar_CtrlChanged(this)) return ES_HANDLED;
|
||||
return ES_NOT_HANDLED;
|
||||
}
|
||||
|
@ -889,6 +898,27 @@ struct BuildRailToolbarWindow : Window {
|
|||
}, RailToolbarGlobalHotkeys};
|
||||
};
|
||||
|
||||
/**
|
||||
* Add the depot icons depending on availability of construction.
|
||||
* @return Panel with rail depot buttons.
|
||||
*/
|
||||
static std::unique_ptr<NWidgetBase> MakeNWidgetRailDepot()
|
||||
{
|
||||
auto hor = std::make_unique<NWidgetHorizontal>();
|
||||
|
||||
if (HasBit(_settings_game.depot.rail_depot_types, 0)) {
|
||||
/* Add the widget for building standard rail depot. */
|
||||
hor->Add(std::make_unique<NWidgetLeaf>(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_DEPOT, SPR_IMG_DEPOT_RAIL, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_TRAIN_DEPOT));
|
||||
}
|
||||
|
||||
if (HasBit(_settings_game.depot.rail_depot_types, 1)) {
|
||||
/* Add the widget for building extended rail depot. */
|
||||
hor->Add(std::make_unique<NWidgetLeaf>(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_EXTENDED_DEPOT, SPR_IMG_DEPOT_RAIL, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_EXTENDED_TRAIN_DEPOT));
|
||||
}
|
||||
|
||||
return hor;
|
||||
}
|
||||
|
||||
static constexpr NWidgetPart _nested_build_rail_widgets[] = {
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
|
||||
|
@ -911,8 +941,7 @@ static constexpr NWidgetPart _nested_build_rail_widgets[] = {
|
|||
|
||||
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_DEMOLISH),
|
||||
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
|
||||
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_DEPOT),
|
||||
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DEPOT_RAIL, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_TRAIN_DEPOT_FOR_BUILDING),
|
||||
NWidgetFunction(MakeNWidgetRailDepot),
|
||||
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_WAYPOINT),
|
||||
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_WAYPOINT, STR_RAIL_TOOLBAR_TOOLTIP_CONVERT_RAIL_TO_WAYPOINT),
|
||||
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_STATION),
|
||||
|
|
|
@ -21,6 +21,7 @@ enum RailToolbarWidgets : WidgetID {
|
|||
WID_RAT_AUTORAIL, ///< Autorail tool.
|
||||
WID_RAT_DEMOLISH, ///< Destroy something with dynamite!
|
||||
WID_RAT_BUILD_DEPOT, ///< Build a depot.
|
||||
WID_RAT_BUILD_EXTENDED_DEPOT, ///< Build an extended depot.
|
||||
WID_RAT_BUILD_WAYPOINT, ///< Build a waypoint.
|
||||
WID_RAT_BUILD_STATION, ///< Build a station.
|
||||
WID_RAT_BUILD_SIGNALS, ///< Build signals.
|
||||
|
|
Loading…
Reference in New Issue