summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2008-08-02 12:43:45 +0000
committerfrosch <frosch@openttd.org>2008-08-02 12:43:45 +0000
commitf0b1decb3d580f051a56a57f459f011d64fa3574 (patch)
tree20cd82afeafa7ac513ef2faf30ec43ce8d41c2ab
parent196268b7ff622f9cf24e6b7b138b4150b3ca7124 (diff)
downloadopenttd-f0b1decb3d580f051a56a57f459f011d64fa3574.tar.xz
(svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
-rw-r--r--src/depot_gui.cpp71
-rw-r--r--src/lang/english.txt3
2 files changed, 70 insertions, 4 deletions
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp
index e52031db0..47676bff8 100644
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -609,7 +609,6 @@ struct DepotWindow : Window {
this->widget[DEPOT_WIDGET_START_ALL].tooltips= STR_MASS_START_DEPOT_TRAIN_TIP;
this->widget[DEPOT_WIDGET_SELL].tooltips = STR_8841_DRAG_TRAIN_VEHICLE_TO_HERE;
this->widget[DEPOT_WIDGET_SELL_ALL].tooltips = STR_DEPOT_SELL_ALL_BUTTON_TRAIN_TIP;
- this->widget[DEPOT_WIDGET_MATRIX].tooltips = STR_883F_TRAINS_CLICK_ON_TRAIN_FOR;
this->widget[DEPOT_WIDGET_BUILD].data = STR_8815_NEW_VEHICLES;
this->widget[DEPOT_WIDGET_BUILD].tooltips = STR_8840_BUILD_NEW_TRAIN_VEHICLE;
@@ -633,7 +632,6 @@ struct DepotWindow : Window {
this->widget[DEPOT_WIDGET_START_ALL].tooltips= STR_MASS_START_DEPOT_ROADVEH_TIP;
this->widget[DEPOT_WIDGET_SELL].tooltips = STR_9024_DRAG_ROAD_VEHICLE_TO_HERE;
this->widget[DEPOT_WIDGET_SELL_ALL].tooltips = STR_DEPOT_SELL_ALL_BUTTON_ROADVEH_TIP;
- this->widget[DEPOT_WIDGET_MATRIX].tooltips = STR_9022_VEHICLES_CLICK_ON_VEHICLE;
this->widget[DEPOT_WIDGET_BUILD].data = STR_9004_NEW_VEHICLES;
this->widget[DEPOT_WIDGET_BUILD].tooltips = STR_9023_BUILD_NEW_ROAD_VEHICLE;
@@ -657,7 +655,6 @@ struct DepotWindow : Window {
this->widget[DEPOT_WIDGET_START_ALL].tooltips= STR_MASS_START_DEPOT_SHIP_TIP;
this->widget[DEPOT_WIDGET_SELL].tooltips = STR_9821_DRAG_SHIP_TO_HERE_TO_SELL;
this->widget[DEPOT_WIDGET_SELL_ALL].tooltips = STR_DEPOT_SELL_ALL_BUTTON_SHIP_TIP;
- this->widget[DEPOT_WIDGET_MATRIX].tooltips = STR_981F_SHIPS_CLICK_ON_SHIP_FOR;
this->widget[DEPOT_WIDGET_BUILD].data = STR_9804_NEW_SHIPS;
this->widget[DEPOT_WIDGET_BUILD].tooltips = STR_9820_BUILD_NEW_SHIP;
@@ -681,7 +678,6 @@ struct DepotWindow : Window {
this->widget[DEPOT_WIDGET_START_ALL].tooltips= STR_MASS_START_HANGAR_TIP;
this->widget[DEPOT_WIDGET_SELL].tooltips = STR_A023_DRAG_AIRCRAFT_TO_HERE_TO;
this->widget[DEPOT_WIDGET_SELL_ALL].tooltips = STR_DEPOT_SELL_ALL_BUTTON_AIRCRAFT_TIP;
- this->widget[DEPOT_WIDGET_MATRIX].tooltips = STR_A021_AIRCRAFT_CLICK_ON_AIRCRAFT;
this->widget[DEPOT_WIDGET_BUILD].data = STR_A003_NEW_AIRCRAFT;
this->widget[DEPOT_WIDGET_BUILD].tooltips = STR_A022_BUILD_NEW_AIRCRAFT;
@@ -842,6 +838,73 @@ struct DepotWindow : Window {
}
}
+ virtual void OnRightClick(Point pt, int widget)
+ {
+ if (widget != DEPOT_WIDGET_MATRIX) return;
+
+ GetDepotVehiclePtData gdvp = { NULL, NULL };
+ const Vehicle *v = NULL;
+ DepotGUIAction mode = this->GetVehicleFromDepotWndPt(pt.x, pt.y, &v, &gdvp);
+
+ if (this->type == VEH_TRAIN) v = gdvp.wagon;
+
+ if (v != NULL && mode == MODE_DRAG_VEHICLE) {
+ AcceptedCargo capacity, loaded;
+ memset(capacity, 0, sizeof(capacity));
+ memset(loaded, 0, sizeof(loaded));
+
+ /* Display info for single (articulated) vehicle, or for whole chain starting with selected vehicle */
+ bool whole_chain = (this->type == VEH_TRAIN && _ctrl_pressed);
+
+ /* loop through vehicle chain and collect cargos */
+ uint num = 0;
+ for (const Vehicle *w = v; w != NULL; w = w->Next()) {
+ if (w->cargo_cap > 0 && w->cargo_type < NUM_CARGO) {
+ capacity[w->cargo_type] += w->cargo_cap;
+ loaded [w->cargo_type] += w->cargo.Count();
+ }
+
+ if (w->type == VEH_TRAIN && !EngineHasArticPart(w)) {
+ num++;
+ if (!whole_chain) break;
+ }
+ }
+
+ /* Build tooltipstring */
+ static char details[1024];
+ details[0] = '\0';
+ char *pos = details;
+
+ for (CargoID cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) {
+ if (capacity[cargo_type] == 0) continue;
+
+ SetDParam(0, cargo_type); // {CARGO} #1
+ SetDParam(1, loaded[cargo_type]); // {CARGO} #2
+ SetDParam(2, cargo_type); // {SHORTCARGO} #1
+ SetDParam(3, capacity[cargo_type]); // {SHORTCARGO} #2
+ pos = GetString(pos, STR_DEPOT_VEHICLE_TOOLTIP_CARGO, lastof(details));
+ }
+
+ /* Show tooltip window */
+ uint64 args[2];
+ args[0] = (whole_chain ? num : v->engine_type);
+ args[1] = (uint64)details;
+ GuiShowTooltips(whole_chain ? STR_DEPOT_VEHICLE_TOOLTIP_CHAIN : STR_DEPOT_VEHICLE_TOOLTIP, 2, args);
+ } else {
+ /* Show tooltip help */
+ StringID tooltip = INVALID_STRING_ID;
+ switch (this->type) {
+ case VEH_TRAIN: tooltip = STR_883F_TRAINS_CLICK_ON_TRAIN_FOR; break;
+ case VEH_ROAD: tooltip = STR_9022_VEHICLES_CLICK_ON_VEHICLE; break;
+ case VEH_SHIP: tooltip = STR_981F_SHIPS_CLICK_ON_SHIP_FOR; break;
+ case VEH_AIRCRAFT: tooltip = STR_A021_AIRCRAFT_CLICK_ON_AIRCRAFT;break;
+ default: NOT_REACHED();
+ }
+ GuiShowTooltips(tooltip);
+ }
+ }
+
+
virtual void OnPlaceObject(Point pt, TileIndex tile)
{
const Vehicle *v = CheckMouseOverVehicle();
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 0f7a97327..cbfc79e37 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -2948,6 +2948,9 @@ STR_9027_BUILD_THE_HIGHLIGHTED_ROAD :{BLACK}Build th
STR_902A_COST_SPEED_RUNNING_COST :{BLACK}Cost: {CURRENCY}{}Speed: {VELOCITY}{}Running Cost: {CURRENCY}/yr{}Capacity: {CARGO}
STR_ARTICULATED_RV_CAPACITY :{BLACK}Capacity: {LTBLUE}
STR_BARE_CARGO :{CARGO}
+STR_DEPOT_VEHICLE_TOOLTIP :{BLACK}{ENGINE}{RAW_STRING}
+STR_DEPOT_VEHICLE_TOOLTIP_CHAIN :{BLACK}{NUM} vehicle{P "" s}{RAW_STRING}
+STR_DEPOT_VEHICLE_TOOLTIP_CARGO :{}{CARGO} ({SHORTCARGO})
STR_902C_NAME_ROAD_VEHICLE :{WHITE}Name road vehicle
STR_902D_CAN_T_NAME_ROAD_VEHICLE :{WHITE}Can't name road vehicle...