diff options
author | rubidium <rubidium@openttd.org> | 2010-05-12 18:19:36 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-05-12 18:19:36 +0000 |
commit | 5051ef80c663e252ed6867b3cd0298d3b1c8717c (patch) | |
tree | 92906fbbf435190a120e62033f0d4bb413f9a35f /src | |
parent | 007c9641a6706abc3afc84fda542b1915dc21d35 (diff) | |
download | openttd-5051ef80c663e252ed6867b3cd0298d3b1c8717c.tar.xz |
(svn r19796) -Codechange: introduce and use a {DEPOT} string command
Diffstat (limited to 'src')
-rw-r--r-- | src/depot_gui.cpp | 18 | ||||
-rw-r--r-- | src/lang/english.txt | 43 | ||||
-rw-r--r-- | src/order_gui.cpp | 24 | ||||
-rw-r--r-- | src/strings.cpp | 8 | ||||
-rw-r--r-- | src/table/control_codes.h | 1 | ||||
-rw-r--r-- | src/table/strgen_tables.h | 1 | ||||
-rw-r--r-- | src/vehicle_gui.cpp | 33 |
7 files changed, 53 insertions, 75 deletions
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index f663dcd57..b6e65982c 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -62,7 +62,7 @@ enum DepotWindowWidgets { static const NWidgetPart _nested_train_depot_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), - NWidget(WWT_CAPTION, COLOUR_GREY, DEPOT_WIDGET_CAPTION), + NWidget(WWT_CAPTION, COLOUR_GREY, DEPOT_WIDGET_CAPTION), SetDataTip(STR_DEPOT_CAPTION, STR_NULL), NWidget(WWT_SHADEBOX, COLOUR_GREY), NWidget(WWT_STICKYBOX, COLOUR_GREY), EndContainer(), @@ -340,14 +340,8 @@ struct DepotWindow : Window { /* locate the depot struct */ TileIndex tile = this->window_number; - if (this->type == VEH_AIRCRAFT) { - SetDParam(0, GetStationIndex(tile)); // Airport name - } else { - Depot *depot = Depot::GetByTile(tile); - assert(depot != NULL); - - SetDParam(0, depot->town_index); - } + SetDParam(0, this->type); + SetDParam(1, (this->type == VEH_AIRCRAFT) ? GetStationIndex(tile) : GetDepotIndex(tile)); } struct GetDepotVehiclePtData { @@ -543,7 +537,6 @@ struct DepotWindow : Window { { if (type != VEH_TRAIN) this->GetWidget<NWidgetCore>(DEPOT_WIDGET_SELL_CHAIN)->fill_y = 0; // Disable vertical filling of chain-sell widget for non-train windows. - this->GetWidget<NWidgetCore>(DEPOT_WIDGET_CAPTION)->widget_data = STR_DEPOT_TRAIN_CAPTION + type; this->GetWidget<NWidgetCore>(DEPOT_WIDGET_STOP_ALL)->tool_tip = STR_DEPOT_MASS_STOP_DEPOT_TRAIN_TOOLTIP + type; this->GetWidget<NWidgetCore>(DEPOT_WIDGET_START_ALL)->tool_tip = STR_DEPOT_MASS_START_DEPOT_TRAIN_TOOLTIP + type; this->GetWidget<NWidgetCore>(DEPOT_WIDGET_SELL)->tool_tip = STR_DEPOT_TRAIN_SELL_TOOLTIP + type; @@ -752,9 +745,10 @@ struct DepotWindow : Window { TileIndex tile = this->window_number; byte vehtype = this->type; - SetDParam(0, (vehtype == VEH_AIRCRAFT) ? GetStationIndex(tile) : Depot::GetByTile(tile)->town_index); + SetDParam(0, vehtype); + SetDParam(1, (vehtype == VEH_AIRCRAFT) ? GetStationIndex(tile) : GetDepotIndex(tile)); ShowQuery( - STR_DEPOT_TRAIN_CAPTION + vehtype, + STR_DEPOT_CAPTION, STR_DEPOT_SELL_CONFIRMATION_TEXT, this, DepotSellAllConfirmationCallback diff --git a/src/lang/english.txt b/src/lang/english.txt index 743efbdac..f542cf576 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -2666,10 +2666,10 @@ STR_INDUSTRY_VIEW_PRODUCES_CARGO_CARGO :{BLACK}Produces STR_CONFIG_GAME_PRODUCTION :{WHITE}Change production (multiple of 8, up to 2040) # Vehicle lists -STR_VEHICLE_LIST_TRAIN_CAPTION :{WHITE}{STRING1} - {COMMA} Train{P "" s} -STR_VEHICLE_LIST_ROAD_VEHICLE_CAPTION :{WHITE}{STRING1} - {COMMA} Road Vehicle{P "" s} -STR_VEHICLE_LIST_SHIP_CAPTION :{WHITE}{STRING1} - {COMMA} Ship{P "" s} -STR_VEHICLE_LIST_AIRCRAFT_CAPTION :{WHITE}{STRING1} - {COMMA} Aircraft +STR_VEHICLE_LIST_TRAIN_CAPTION :{WHITE}{STRING2} - {COMMA} Train{P "" s} +STR_VEHICLE_LIST_ROAD_VEHICLE_CAPTION :{WHITE}{STRING2} - {COMMA} Road Vehicle{P "" s} +STR_VEHICLE_LIST_SHIP_CAPTION :{WHITE}{STRING2} - {COMMA} Ship{P "" s} +STR_VEHICLE_LIST_AIRCRAFT_CAPTION :{WHITE}{STRING2} - {COMMA} Aircraft STR_VEHICLE_LIST_TRAIN_LIST_TOOLTIP :{BLACK}Trains - click on train for information STR_VEHICLE_LIST_ROAD_VEHICLE_TOOLTIP :{BLACK}Road vehicles - click on vehicle for information @@ -2781,10 +2781,7 @@ STR_QUERY_RENAME_SHIP_TYPE_CAPTION :{WHITE}Rename s STR_QUERY_RENAME_AIRCRAFT_TYPE_CAPTION :{WHITE}Rename aircraft type # Depot window -STR_DEPOT_TRAIN_CAPTION :{WHITE}{TOWN} Train Depot -STR_DEPOT_ROAD_VEHICLE_CAPTION :{WHITE}{TOWN} Road Vehicle Depot -STR_DEPOT_SHIP_CAPTION :{WHITE}{TOWN} Ship Depot -STR_DEPOT_AIRCRAFT_CAPTION :{WHITE}{STATION} Aircraft Hangar +STR_DEPOT_CAPTION :{WHITE}{DEPOT} STR_DEPOT_NO_ENGINE :{BLACK}- STR_DEPOT_VEHICLE_TOOLTIP :{BLACK}{ENGINE}{RAW_STRING} @@ -2964,23 +2961,11 @@ STR_VEHICLE_STATUS_NO_ORDERS_VEL :{LTBLUE}No orde STR_VEHICLE_STATUS_HEADING_FOR_WAYPOINT :{LTBLUE}Heading for {WAYPOINT} STR_VEHICLE_STATUS_HEADING_FOR_WAYPOINT_VEL :{LTBLUE}Heading for {WAYPOINT}, {VELOCITY} -STR_VEHICLE_STATUS_HEADING_FOR_TRAIN_DEPOT :{ORANGE}Heading for {TOWN} Train Depot -STR_VEHICLE_STATUS_HEADING_FOR_TRAIN_DEPOT_VEL :{ORANGE}Heading for {TOWN} Train Depot, {VELOCITY} -STR_VEHICLE_STATUS_HEADING_FOR_ROAD_VEHICLE_DEPOT :{ORANGE}Heading for {TOWN} Road Depot -STR_VEHICLE_STATUS_HEADING_FOR_ROAD_VEHICLE_DEPOT_VEL :{ORANGE}Heading for {TOWN} Road Depot, {VELOCITY} -STR_VEHICLE_STATUS_HEADING_FOR_SHIP_DEPOT :{ORANGE}Heading for {TOWN} Ship Depot -STR_VEHICLE_STATUS_HEADING_FOR_SHIP_DEPOT_VEL :{ORANGE}Heading for {TOWN} Ship Depot, {VELOCITY} -STR_VEHICLE_STATUS_HEADING_FOR_HANGAR :{ORANGE}Heading for {STATION} Hangar -STR_VEHICLE_STATUS_HEADING_FOR_HANGAR_VEL :{ORANGE}Heading for {STATION} Hangar, {VELOCITY} - -STR_VEHICLE_STATUS_HEADING_FOR_TRAIN_DEPOT_SERVICE :{LTBLUE}Service at {TOWN} Train Depot -STR_VEHICLE_STATUS_HEADING_FOR_TRAIN_DEPOT_SERVICE_VEL :{LTBLUE}Service at {TOWN} Train Depot, {VELOCITY} -STR_VEHICLE_STATUS_HEADING_FOR_ROAD_VEHICLE_DEPOT_SERVICE :{LTBLUE}Service at {TOWN} Road Depot -STR_VEHICLE_STATUS_HEADING_FOR_ROAD_VEHICLE_DEPOT_SERVICE_VEL :{LTBLUE}Service at {TOWN} Road Depot, {VELOCITY} -STR_VEHICLE_STATUS_HEADING_FOR_SHIP_DEPOT_SERVICE :{LTBLUE}Service at {TOWN} Ship Depot -STR_VEHICLE_STATUS_HEADING_FOR_SHIP_DEPOT_SERVICE_VEL :{LTBLUE}Service at {TOWN} Ship Depot, {VELOCITY} -STR_VEHICLE_STATUS_HEADING_FOR_HANGAR_SERVICE :{LTBLUE}Service at {STATION} Hangar -STR_VEHICLE_STATUS_HEADING_FOR_HANGAR_SERVICE_VEL :{LTBLUE}Service at {STATION} Hangar, {VELOCITY} +STR_VEHICLE_STATUS_HEADING_FOR_DEPOT :{ORANGE}Heading for {DEPOT} +STR_VEHICLE_STATUS_HEADING_FOR_DEPOT_VEL :{ORANGE}Heading for {DEPOT}, {VELOCITY} + +STR_VEHICLE_STATUS_HEADING_FOR_DEPOT_SERVICE :{LTBLUE}Service at {DEPOT} +STR_VEHICLE_STATUS_HEADING_FOR_DEPOT_SERVICE_VEL :{LTBLUE}Service at {DEPOT}, {VELOCITY} # Vehicle stopped/started animations STR_VEHICLE_COMMAND_STOPPED_SMALL :{TINYFONT}{RED}Stopped @@ -3161,9 +3146,8 @@ STR_ORDER_NEAREST_HANGAR :the nearest Han STR_ORDER_TRAIN_DEPOT :Train Depot STR_ORDER_ROAD_VEHICLE_DEPOT :Road Vehicle Depot STR_ORDER_SHIP_DEPOT :Ship Depot -STR_ORDER_GO_TO_DEPOT_FORMAT :{STRING} {TOWN} {STRING} STR_ORDER_GO_TO_NEAREST_DEPOT_FORMAT :{STRING} {STRING} {STRING} -STR_ORDER_GO_TO_HANGAR_FORMAT :{STRING} {STATION} Hangar +STR_ORDER_GO_TO_DEPOT_FORMAT :{STRING} {DEPOT} STR_ORDER_REFIT_ORDER :(Refit to {STRING}) STR_ORDER_REFIT_STOP_ORDER :(Refit to {STRING} and stop) @@ -4075,6 +4059,11 @@ STR_FORMAT_INDUSTRY_NAME :{TOWN} {STRING} STR_FORMAT_WAYPOINT_NAME :{TOWN} Waypoint STR_FORMAT_WAYPOINT_NAME_SERIAL :{TOWN} Waypoint #{COMMA} +STR_FORMAT_DEPOT_NAME_TRAIN :{TOWN} Train Depot +STR_FORMAT_DEPOT_NAME_ROAD_VEHICLE :{TOWN} Road Vehicle Depot +STR_FORMAT_DEPOT_NAME_SHIP :{TOWN} Ship Depot +STR_FORMAT_DEPOT_NAME_AIRCRAFT :{STATION} Hangar + STR_UNKNOWN_STATION :unknown station STR_DEFAULT_SIGN_NAME :Sign STR_COMPANY_SOMEONE :someone diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 5030d003a..cc3f2571e 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -232,25 +232,19 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int } break; case OT_GOTO_DEPOT: - if (v->type == VEH_AIRCRAFT) { - if (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) { - SetDParam(0, STR_ORDER_GO_TO_NEAREST_DEPOT_FORMAT); + if (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) { + SetDParam(0, STR_ORDER_GO_TO_NEAREST_DEPOT_FORMAT); + if (v->type == VEH_AIRCRAFT) { SetDParam(2, STR_ORDER_NEAREST_HANGAR); + SetDParam(3, STR_EMPTY); } else { - SetDParam(0, STR_ORDER_GO_TO_HANGAR_FORMAT); - SetDParam(2, order->GetDestination()); - } - SetDParam(3, STR_EMPTY); - } else { - if (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) { - SetDParam(0, STR_ORDER_GO_TO_NEAREST_DEPOT_FORMAT); SetDParam(2, STR_ORDER_NEAREST_DEPOT); - } else { - SetDParam(0, STR_ORDER_GO_TO_DEPOT_FORMAT); - SetDParam(2, Depot::Get(order->GetDestination())->town_index); + SetDParam(3, STR_ORDER_TRAIN_DEPOT + v->type); } - - SetDParam(3, STR_ORDER_TRAIN_DEPOT + v->type); + } else { + SetDParam(0, STR_ORDER_GO_TO_DEPOT_FORMAT); + SetDParam(2, v->type); + SetDParam(3, order->GetDestination()); } if (order->GetDepotOrderType() & ODTFB_SERVICE) { diff --git a/src/strings.cpp b/src/strings.cpp index 3f4339153..1f9d96096 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -15,6 +15,7 @@ #include "town.h" #include "screenshot.h" #include "waypoint_base.h" +#include "depot_base.h" #include "industry.h" #include "newgrf_text.h" #include "fileio_func.h" @@ -944,6 +945,13 @@ static char *FormatString(char *buff, const char *str, int64 *argv, uint casei, break; } + case SCC_DEPOT_NAME: { // {DEPOT} + VehicleType vt = (VehicleType)GetInt32(&argv); + int64 temp[1] = { vt == VEH_AIRCRAFT ? GetInt32(&argv) : Depot::Get(GetInt32(&argv))->town_index }; + buff = GetStringWithArgs(buff, STR_FORMAT_DEPOT_NAME_TRAIN + vt, temp, last); + break; + } + case SCC_TOWN_NAME: { // {TOWN} const Town *t = Town::Get(GetInt32(&argv)); diff --git a/src/table/control_codes.h b/src/table/control_codes.h index 4df3badee..6306192d5 100644 --- a/src/table/control_codes.h +++ b/src/table/control_codes.h @@ -36,6 +36,7 @@ enum StringControlCode { SCC_INDUSTRY_NAME, SCC_WAYPOINT_NAME, SCC_STATION_NAME, + SCC_DEPOT_NAME, SCC_TOWN_NAME, SCC_GROUP_NAME, SCC_VEHICLE_NAME, diff --git a/src/table/strgen_tables.h b/src/table/strgen_tables.h index c0271434a..e8f827ee2 100644 --- a/src/table/strgen_tables.h +++ b/src/table/strgen_tables.h @@ -101,6 +101,7 @@ static const CmdStruct _cmd_structs[] = { {"WAYPOINT", EmitSingleChar, SCC_WAYPOINT_NAME, 1, C_NONE | C_GENDER}, // waypoint name {"STATION", EmitSingleChar, SCC_STATION_NAME, 1, C_NONE | C_GENDER}, + {"DEPOT", EmitSingleChar, SCC_DEPOT_NAME, 2, C_NONE | C_GENDER}, {"TOWN", EmitSingleChar, SCC_TOWN_NAME, 1, C_NONE | C_GENDER}, {"GROUP", EmitSingleChar, SCC_GROUP_NAME, 1, C_NONE | C_GENDER}, {"SIGN", EmitSingleChar, SCC_SIGN_NAME, 1, C_NONE | C_GENDER}, diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 89a3f9430..bc286d81b 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -1073,29 +1073,26 @@ public: case VLW_STANDARD: // Company Name SetDParam(0, STR_COMPANY_NAME); SetDParam(1, index); - SetDParam(2, this->vscroll.GetCount()); + SetDParam(3, this->vscroll.GetCount()); break; case VLW_WAYPOINT_LIST: SetDParam(0, STR_WAYPOINT_NAME); SetDParam(1, index); - SetDParam(2, this->vscroll.GetCount()); + SetDParam(3, this->vscroll.GetCount()); break; case VLW_STATION_LIST: // Station Name SetDParam(0, STR_STATION_NAME); SetDParam(1, index); - SetDParam(2, this->vscroll.GetCount()); + SetDParam(3, this->vscroll.GetCount()); break; case VLW_DEPOT_LIST: - SetDParam(0, STR_DEPOT_TRAIN_CAPTION + this->vehicle_type); - if (this->vehicle_type == VEH_AIRCRAFT) { - SetDParam(1, index); // Airport name - } else { - SetDParam(1, Depot::Get(index)->town_index); - } - SetDParam(2, this->vscroll.GetCount()); + SetDParam(0, STR_DEPOT_CAPTION); + SetDParam(1, this->vehicle_type); + SetDParam(2, index); + SetDParam(3, this->vscroll.GetCount()); break; default: NOT_REACHED(); } @@ -2086,19 +2083,13 @@ public: } break; case OT_GOTO_DEPOT: { - if (v->type == VEH_AIRCRAFT) { - /* Aircrafts always go to a station, even if you say depot */ - SetDParam(0, v->current_order.GetDestination()); - SetDParam(1, v->GetDisplaySpeed()); - } else { - Depot *depot = Depot::Get(v->current_order.GetDestination()); - SetDParam(0, depot->town_index); - SetDParam(1, v->GetDisplaySpeed()); - } + SetDParam(0, v->type); + SetDParam(1, v->current_order.GetDestination()); + SetDParam(2, v->GetDisplaySpeed()); if (v->current_order.GetDepotActionType() & ODATFB_HALT) { - str = STR_VEHICLE_STATUS_HEADING_FOR_TRAIN_DEPOT + 2 * v->type + _settings_client.gui.vehicle_speed; + str = STR_VEHICLE_STATUS_HEADING_FOR_DEPOT + _settings_client.gui.vehicle_speed; } else { - str = STR_VEHICLE_STATUS_HEADING_FOR_TRAIN_DEPOT_SERVICE + 2 * v->type + _settings_client.gui.vehicle_speed; + str = STR_VEHICLE_STATUS_HEADING_FOR_DEPOT_SERVICE + _settings_client.gui.vehicle_speed; } } break; |