author | peter1138 |
Sun, 01 Oct 2006 12:00:32 +0000 | |
changeset 4694 | a4d2a3abe75c |
parent 4668 | 8b6035c51188 |
child 4702 | 5179f9adc5b3 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1820
diff
changeset
|
4 |
#include "openttd.h" |
1299
0a6510cc889b
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1294
diff
changeset
|
5 |
#include "debug.h" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2147
diff
changeset
|
6 |
#include "functions.h" |
4041
caf4fcb4e05b
(svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents:
4012
diff
changeset
|
7 |
#include "rail_map.h" |
1922
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
8 |
#include "table/sprites.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
460
diff
changeset
|
9 |
#include "table/strings.h" |
679
e959706a3e4d
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
601
diff
changeset
|
10 |
#include "map.h" |
0 | 11 |
#include "window.h" |
12 |
#include "gui.h" |
|
13 |
#include "gfx.h" |
|
14 |
#include "vehicle.h" |
|
15 |
#include "viewport.h" |
|
16 |
#include "station.h" |
|
17 |
#include "command.h" |
|
18 |
#include "player.h" |
|
19 |
#include "engine.h" |
|
588 | 20 |
#include "vehicle_gui.h" |
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1299
diff
changeset
|
21 |
#include "depot.h" |
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
2639
diff
changeset
|
22 |
#include "train.h" |
2962
dbd168a4703a
(svn r3524) - Split newgrf features from engine.[ch] into newgrf_engine.[ch], and add the new files to project files.
peter1138
parents:
2959
diff
changeset
|
23 |
#include "newgrf_engine.h" |
4261
2ec8f5a9747b
(svn r5887) -Cleanup: move date related functions, defines and variables to date.[ch]
rubidium
parents:
4251
diff
changeset
|
24 |
#include "date.h" |
420
d3a089648ec3
(svn r617) -newgrf: Support for parameter 0x8E (train Y-pitch in info windows) both setting and testing. This should fix displaced wagons in DBSetXL as reported by DarkVater. (pasky)
darkvater
parents:
395
diff
changeset
|
25 |
|
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
26 |
/** |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
27 |
* Draw the purchase info details of train engine at a given location. |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
28 |
* @param x,y location where to draw the info |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
29 |
* @param engine_number the engine of which to draw the info of |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
30 |
*/ |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
31 |
void DrawTrainEnginePurchaseInfo(int x, int y, EngineID engine_number) |
842 | 32 |
{ |
33 |
const RailVehicleInfo *rvi = RailVehInfo(engine_number); |
|
4171 | 34 |
const Engine *e = GetEngine(engine_number); |
842 | 35 |
int multihead = (rvi->flags&RVI_MULTIHEAD?1:0); |
36 |
YearMonthDay ymd; |
|
4288
60398d0e64ee
(svn r5918) -Cleanup: rename ConvertDayToYMD/ConvertYMDToDay as they really convert a Date to/from a YearMonthDay.
rubidium
parents:
4286
diff
changeset
|
37 |
ConvertDateToYMD(e->intro_date, &ymd); |
842 | 38 |
|
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
39 |
/* Purchase Cost - Engine weight */ |
842 | 40 |
SetDParam(0, rvi->base_cost * (_price.build_railvehicle >> 3) >> 5); |
41 |
SetDParam(1, rvi->weight << multihead); |
|
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
42 |
DrawString(x,y, STR_PURCHASE_INFO_COST_WEIGHT, 0); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
43 |
y += 10; |
842 | 44 |
|
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
45 |
/* Max speed - Engine power */ |
3477
80c3465b38ee
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3401
diff
changeset
|
46 |
SetDParam(0, rvi->max_speed); |
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
47 |
SetDParam(1, rvi->power << multihead); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
48 |
DrawString(x,y, STR_PURCHASE_INFO_SPEED_POWER, 0); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
49 |
y += 10; |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
50 |
|
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
51 |
/* Running cost */ |
2840
d68a605b2087
(svn r3388) - NewGRF: Allow train running cost class to differ from engine class. Also fix typo in r3384.
peter1138
parents:
2822
diff
changeset
|
52 |
SetDParam(0, (rvi->running_cost_base * _price.running_rail[rvi->running_cost_class] >> 8) << multihead); |
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
53 |
DrawString(x,y, STR_PURCHASE_INFO_RUNNINGCOST, 0); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
54 |
y += 10; |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
55 |
|
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1907
diff
changeset
|
56 |
/* Powered wagons power - Powered wagons extra weight */ |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1907
diff
changeset
|
57 |
if (rvi->pow_wag_power != 0) { |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1907
diff
changeset
|
58 |
SetDParam(0, rvi->pow_wag_power); |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1907
diff
changeset
|
59 |
SetDParam(1, rvi->pow_wag_weight); |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1907
diff
changeset
|
60 |
DrawString(x,y, STR_PURCHASE_INFO_PWAGPOWER_PWAGWEIGHT, 0); |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1907
diff
changeset
|
61 |
y += 10; |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1907
diff
changeset
|
62 |
}; |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1907
diff
changeset
|
63 |
|
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
64 |
/* Cargo type + capacity, or N/A */ |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
65 |
SetDParam(0, STR_8838_N_A); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
66 |
SetDParam(2, STR_EMPTY); |
842 | 67 |
if (rvi->capacity != 0) { |
2084
d67790a49f78
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
2049
diff
changeset
|
68 |
SetDParam(0, _cargoc.names_long[rvi->cargo_type]); |
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
69 |
SetDParam(1, rvi->capacity << multihead); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
70 |
SetDParam(2, STR_9842_REFITTABLE); |
842 | 71 |
} |
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
72 |
DrawString(x,y, STR_PURCHASE_INFO_CAPACITY, 0); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
73 |
y += 10; |
842 | 74 |
|
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
75 |
/* Design date - Life length */ |
4293
2c24234a7aec
(svn r5926) -Codechange: make _cur_year contain the full year, instead of the offset since 1920
rubidium
parents:
4288
diff
changeset
|
76 |
SetDParam(0, ymd.year); |
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
77 |
SetDParam(1, e->lifelength); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
78 |
DrawString(x,y, STR_PURCHASE_INFO_DESIGNED_LIFE, 0); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
79 |
y += 10; |
842 | 80 |
|
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
81 |
/* Reliability */ |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
82 |
SetDParam(0, e->reliability * 100 >> 16); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
83 |
DrawString(x,y, STR_PURCHASE_INFO_RELIABILITY, 0); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
84 |
y += 10; |
3651
688936ccf1d2
(svn r4562) - NewGRF: Add additional vehicle text to train engine and wagon purchase information. Other vehicle types to come.
peter1138
parents:
3491
diff
changeset
|
85 |
|
688936ccf1d2
(svn r4562) - NewGRF: Add additional vehicle text to train engine and wagon purchase information. Other vehicle types to come.
peter1138
parents:
3491
diff
changeset
|
86 |
/* Additional text from NewGRF */ |
688936ccf1d2
(svn r4562) - NewGRF: Add additional vehicle text to train engine and wagon purchase information. Other vehicle types to come.
peter1138
parents:
3491
diff
changeset
|
87 |
// XXX 227 will become a calculated width... |
688936ccf1d2
(svn r4562) - NewGRF: Add additional vehicle text to train engine and wagon purchase information. Other vehicle types to come.
peter1138
parents:
3491
diff
changeset
|
88 |
y += ShowAdditionalText(x, y, 227, engine_number); |
842 | 89 |
} |
90 |
||
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
91 |
/** |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
92 |
* Draw the purchase info details of a train wagon at a given location. |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
93 |
* @param x,y location where to draw the info |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
94 |
* @param engine_number the engine of which to draw the info of |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
95 |
*/ |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
96 |
void DrawTrainWagonPurchaseInfo(int x, int y, EngineID engine_number) |
842 | 97 |
{ |
98 |
const RailVehicleInfo *rvi = RailVehInfo(engine_number); |
|
3393
48ce4c723a76
(svn r4201) - Codechange: Do for _engine_info[] what we do for _*_vehicle_info[]; create and use a function to retrieve data, and ensure constness.
peter1138
parents:
3384
diff
changeset
|
99 |
bool refittable = (EngInfo(engine_number)->refit_mask != 0); |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
100 |
|
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
101 |
/* Purchase cost */ |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
102 |
SetDParam(0, (rvi->base_cost * _price.build_railwagon) >> 8); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
103 |
DrawString(x, y, STR_PURCHASE_INFO_COST, 0); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
104 |
y += 10; |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
105 |
|
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
106 |
/* Wagon weight - (including cargo) */ |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
107 |
SetDParam(0, rvi->weight); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
108 |
SetDParam(1, (_cargoc.weights[rvi->cargo_type] * rvi->capacity >> 4) + rvi->weight); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
109 |
DrawString(x, y, STR_PURCHASE_INFO_WEIGHT_CWEIGHT, 0); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
110 |
y += 10; |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
111 |
|
3685
7d2d1fee14d7
(svn r4610) - If a wagon has a capacity of 0 (zero), display it in the purchase list as N/A.
peter1138
parents:
3651
diff
changeset
|
112 |
/* Cargo type + capacity, or N/A */ |
7d2d1fee14d7
(svn r4610) - If a wagon has a capacity of 0 (zero), display it in the purchase list as N/A.
peter1138
parents:
3651
diff
changeset
|
113 |
SetDParam(0, STR_8838_N_A); |
7d2d1fee14d7
(svn r4610) - If a wagon has a capacity of 0 (zero), display it in the purchase list as N/A.
peter1138
parents:
3651
diff
changeset
|
114 |
SetDParam(2, STR_EMPTY); |
7d2d1fee14d7
(svn r4610) - If a wagon has a capacity of 0 (zero), display it in the purchase list as N/A.
peter1138
parents:
3651
diff
changeset
|
115 |
if (rvi->capacity != 0) { |
7d2d1fee14d7
(svn r4610) - If a wagon has a capacity of 0 (zero), display it in the purchase list as N/A.
peter1138
parents:
3651
diff
changeset
|
116 |
SetDParam(0, _cargoc.names_long[rvi->cargo_type]); |
7d2d1fee14d7
(svn r4610) - If a wagon has a capacity of 0 (zero), display it in the purchase list as N/A.
peter1138
parents:
3651
diff
changeset
|
117 |
SetDParam(1, rvi->capacity); |
7d2d1fee14d7
(svn r4610) - If a wagon has a capacity of 0 (zero), display it in the purchase list as N/A.
peter1138
parents:
3651
diff
changeset
|
118 |
SetDParam(2, refittable ? STR_9842_REFITTABLE : STR_EMPTY); |
7d2d1fee14d7
(svn r4610) - If a wagon has a capacity of 0 (zero), display it in the purchase list as N/A.
peter1138
parents:
3651
diff
changeset
|
119 |
} |
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
120 |
DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, 0); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
121 |
y += 10; |
2443
62ff46a3f530
(svn r2969) -Newgrf: Show a wagon's speed limit in purchase list.
peter1138
parents:
2436
diff
changeset
|
122 |
|
62ff46a3f530
(svn r2969) -Newgrf: Show a wagon's speed limit in purchase list.
peter1138
parents:
2436
diff
changeset
|
123 |
/* Wagon speed limit, displayed if above zero */ |
2456
93041d70867b
(svn r2982) Newgrf: Added patch option for wagon speed limits. This is enabled by default.
peter1138
parents:
2443
diff
changeset
|
124 |
if (rvi->max_speed > 0 && _patches.wagon_speed_limits) { |
3477
80c3465b38ee
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3401
diff
changeset
|
125 |
SetDParam(0, rvi->max_speed); |
2443
62ff46a3f530
(svn r2969) -Newgrf: Show a wagon's speed limit in purchase list.
peter1138
parents:
2436
diff
changeset
|
126 |
DrawString(x,y, STR_PURCHASE_INFO_SPEED, 0); |
62ff46a3f530
(svn r2969) -Newgrf: Show a wagon's speed limit in purchase list.
peter1138
parents:
2436
diff
changeset
|
127 |
y += 10; |
62ff46a3f530
(svn r2969) -Newgrf: Show a wagon's speed limit in purchase list.
peter1138
parents:
2436
diff
changeset
|
128 |
} |
3651
688936ccf1d2
(svn r4562) - NewGRF: Add additional vehicle text to train engine and wagon purchase information. Other vehicle types to come.
peter1138
parents:
3491
diff
changeset
|
129 |
|
688936ccf1d2
(svn r4562) - NewGRF: Add additional vehicle text to train engine and wagon purchase information. Other vehicle types to come.
peter1138
parents:
3491
diff
changeset
|
130 |
/* Additional text from NewGRF */ |
688936ccf1d2
(svn r4562) - NewGRF: Add additional vehicle text to train engine and wagon purchase information. Other vehicle types to come.
peter1138
parents:
3491
diff
changeset
|
131 |
y += ShowAdditionalText(x, y, 227, engine_number); |
842 | 132 |
} |
0 | 133 |
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
134 |
void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 135 |
{ |
4171 | 136 |
Vehicle *v, *found; |
0 | 137 |
|
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4049
diff
changeset
|
138 |
if (!success) return; |
0 | 139 |
|
140 |
// find a locomotive in the depot. |
|
141 |
found = NULL; |
|
142 |
FOR_ALL_VEHICLES(v) { |
|
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
2639
diff
changeset
|
143 |
if (v->type == VEH_Train && IsFrontEngine(v) && |
0 | 144 |
v->tile == tile && |
145 |
v->u.rail.track == 0x80) { |
|
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4049
diff
changeset
|
146 |
if (found != NULL) return; // must be exactly one. |
0 | 147 |
found = v; |
148 |
} |
|
149 |
} |
|
150 |
||
151 |
// if we found a loco, |
|
152 |
if (found != NULL) { |
|
153 |
found = GetLastVehicleInChain(found); |
|
154 |
// put the new wagon at the end of the loco. |
|
3948
95f9fa0ac551
(svn r5094) Remove _new_{aircraft,roadveh,ship,train,wagon}_id. _new_vehicle_id is enough.
tron
parents:
3919
diff
changeset
|
155 |
DoCommandP(0, _new_vehicle_id | (found->index << 16), 0, NULL, CMD_MOVE_RAIL_VEHICLE); |
588 | 156 |
RebuildVehicleLists(); |
0 | 157 |
} |
158 |
} |
|
159 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
160 |
void CcBuildLoco(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 161 |
{ |
4171 | 162 |
const Vehicle *v; |
0 | 163 |
|
2639 | 164 |
if (!success) return; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
165 |
|
3948
95f9fa0ac551
(svn r5094) Remove _new_{aircraft,roadveh,ship,train,wagon}_id. _new_vehicle_id is enough.
tron
parents:
3919
diff
changeset
|
166 |
v = GetVehicle(_new_vehicle_id); |
0 | 167 |
if (tile == _backup_orders_tile) { |
168 |
_backup_orders_tile = 0; |
|
169 |
RestoreVehicleOrders(v, _backup_orders_data); |
|
170 |
} |
|
171 |
ShowTrainViewWindow(v); |
|
172 |
} |
|
173 |
||
3887
3e44ae3b1e7c
(svn r4943) uint tile -> TileIndex tile, byte player -> PlayerID player
tron
parents:
3884
diff
changeset
|
174 |
void CcCloneTrain(bool success, TileIndex tile, uint32 p1, uint32 p2) |
2244 | 175 |
{ |
3948
95f9fa0ac551
(svn r5094) Remove _new_{aircraft,roadveh,ship,train,wagon}_id. _new_vehicle_id is enough.
tron
parents:
3919
diff
changeset
|
176 |
if (success) ShowTrainViewWindow(GetVehicle(_new_vehicle_id)); |
2244 | 177 |
} |
178 |
||
524
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
179 |
static void engine_drawing_loop(int *x, int *y, int *pos, int *sel, |
4171 | 180 |
EngineID *selected_id, RailType railtype, byte show_max, bool is_engine) |
524
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
181 |
{ |
2971
9b62397dbd56
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
182 |
EngineID j; |
524
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
183 |
|
2971
9b62397dbd56
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
184 |
for (j = 0; j < NUM_TRAIN_ENGINES; j++) { |
9b62397dbd56
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents:
2962
diff
changeset
|
185 |
EngineID i = GetRailVehAtPosition(j); |
1926
68d60188a22f
(svn r2432) Use GetEngine() instead of DEREF_ENGINE() or even _engines[]
tron
parents:
1922
diff
changeset
|
186 |
const Engine *e = GetEngine(i); |
539 | 187 |
const RailVehicleInfo *rvi = RailVehInfo(i); |
524
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
188 |
|
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3256
diff
changeset
|
189 |
if (!HasPowerOnRail(e->railtype, railtype) || !(rvi->flags & RVI_WAGON) != is_engine || |
524
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
190 |
!HASBIT(e->player_avail, _local_player)) |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
191 |
continue; |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
192 |
|
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4049
diff
changeset
|
193 |
if (*sel == 0) *selected_id = i; |
524
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
194 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
195 |
if (IS_INT_INSIDE(--*pos, -show_max, 0)) { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
196 |
DrawString(*x + 59, *y + 2, GetCustomEngineName(i), *sel == 0 ? 0xC : 0x10); |
3040
c3473d1fb81f
(svn r3620) - 2cc: Replace use of macro to determine colour map with a function call for drawing of vehicles.
peter1138
parents:
3008
diff
changeset
|
197 |
DrawTrainEngine(*x + 29, *y + 6, i, GetEnginePalette(i, _local_player)); |
524
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
198 |
*y += 14; |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
199 |
} |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
200 |
--*sel; |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
201 |
} |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
202 |
} |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
203 |
|
0 | 204 |
static void NewRailVehicleWndProc(Window *w, WindowEvent *e) |
205 |
{ |
|
2952 | 206 |
switch (e->event) { |
0 | 207 |
case WE_PAINT: |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
208 |
|
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4049
diff
changeset
|
209 |
if (w->window_number == 0) SETBIT(w->disabled_state, 5); |
0 | 210 |
|
211 |
{ |
|
212 |
int count = 0; |
|
2520
75eb66d6e371
(svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents:
2518
diff
changeset
|
213 |
RailType railtype = WP(w,buildtrain_d).railtype; |
2477
d454d5152386
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2466
diff
changeset
|
214 |
EngineID i; |
460
f11659d28617
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
420
diff
changeset
|
215 |
|
f11659d28617
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
420
diff
changeset
|
216 |
for (i = 0; i < NUM_TRAIN_ENGINES; i++) { |
1926
68d60188a22f
(svn r2432) Use GetEngine() instead of DEREF_ENGINE() or even _engines[]
tron
parents:
1922
diff
changeset
|
217 |
const Engine *e = GetEngine(i); |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4049
diff
changeset
|
218 |
if (HasPowerOnRail(e->railtype, railtype) && |
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4049
diff
changeset
|
219 |
HASBIT(e->player_avail, _local_player)) { |
0 | 220 |
count++; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4049
diff
changeset
|
221 |
} |
460
f11659d28617
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
420
diff
changeset
|
222 |
} |
0 | 223 |
SetVScrollCount(w, count); |
224 |
} |
|
225 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
226 |
SetDParam(0, WP(w,buildtrain_d).railtype + STR_881C_NEW_RAIL_VEHICLES); |
0 | 227 |
DrawWindowWidgets(w); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
228 |
|
0 | 229 |
{ |
2520
75eb66d6e371
(svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents:
2518
diff
changeset
|
230 |
RailType railtype = WP(w,buildtrain_d).railtype; |
0 | 231 |
int sel = WP(w,buildtrain_d).sel_index; |
232 |
int pos = w->vscroll.pos; |
|
233 |
int x = 1; |
|
234 |
int y = 15; |
|
2498
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2493
diff
changeset
|
235 |
EngineID selected_id = INVALID_ENGINE; |
0 | 236 |
|
460
f11659d28617
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
420
diff
changeset
|
237 |
/* Ensure that custom engines which substituted wagons |
524
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
238 |
* are sorted correctly. |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
239 |
* XXX - DO NOT EVER DO THIS EVER AGAIN! GRRR hacking in wagons as |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
240 |
* engines to get more types.. Stays here until we have our own format |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
241 |
* then it is exit!!! */ |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
242 |
engine_drawing_loop(&x, &y, &pos, &sel, &selected_id, railtype, w->vscroll.cap, true); // True engines |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
243 |
engine_drawing_loop(&x, &y, &pos, &sel, &selected_id, railtype, w->vscroll.cap, false); // Feeble wagons |
0 | 244 |
|
245 |
WP(w,buildtrain_d).sel_engine = selected_id; |
|
246 |
||
2498
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2493
diff
changeset
|
247 |
if (selected_id != INVALID_ENGINE) { |
539 | 248 |
const RailVehicleInfo *rvi = RailVehInfo(selected_id); |
0 | 249 |
|
250 |
if (!(rvi->flags & RVI_WAGON)) { |
|
251 |
/* it's an engine */ |
|
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
252 |
DrawTrainEnginePurchaseInfo(2, w->widget[4].top + 1,selected_id); |
0 | 253 |
} else { |
254 |
/* it's a wagon */ |
|
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
255 |
DrawTrainWagonPurchaseInfo(2, w->widget[4].top + 1, selected_id); |
0 | 256 |
} |
257 |
} |
|
258 |
} |
|
259 |
break; |
|
260 |
||
261 |
case WE_CLICK: { |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
262 |
switch (e->we.click.widget) { |
0 | 263 |
case 2: { |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
264 |
uint i = (e->we.click.pt.y - 14) / 14; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
265 |
if (i < w->vscroll.cap) { |
0 | 266 |
WP(w,buildtrain_d).sel_index = i + w->vscroll.pos; |
267 |
SetWindowDirty(w); |
|
268 |
} |
|
269 |
} break; |
|
270 |
case 5: { |
|
2498
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2493
diff
changeset
|
271 |
EngineID sel_eng = WP(w,buildtrain_d).sel_engine; |
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2493
diff
changeset
|
272 |
if (sel_eng != INVALID_ENGINE) |
540
fbed599dadbb
(svn r924) Use RailVehInfo() instead of &_rail_vehicle_info[]
tron
parents:
539
diff
changeset
|
273 |
DoCommandP(w->window_number, sel_eng, 0, (RailVehInfo(sel_eng)->flags & RVI_WAGON) ? CcBuildWagon : CcBuildLoco, CMD_BUILD_RAIL_VEHICLE | CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE)); |
0 | 274 |
} break; |
968
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
275 |
case 6: { /* rename */ |
2498
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2493
diff
changeset
|
276 |
EngineID sel_eng = WP(w,buildtrain_d).sel_engine; |
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2493
diff
changeset
|
277 |
if (sel_eng != INVALID_ENGINE) { |
968
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
278 |
WP(w,buildtrain_d).rename_engine = sel_eng; |
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
279 |
ShowQueryString(GetCustomEngineName(sel_eng), |
4299
b86602eaaff1
(svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents:
4293
diff
changeset
|
280 |
STR_886A_RENAME_TRAIN_VEHICLE_TYPE, 31, 160, w->window_class, w->window_number, CS_ALPHANUMERAL); |
968
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
281 |
} |
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
282 |
} break; |
0 | 283 |
} |
284 |
} break; |
|
285 |
||
286 |
case WE_ON_EDIT_TEXT: { |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
287 |
if (e->we.edittext.str[0] != '\0') { |
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
288 |
_cmd_text = e->we.edittext.str; |
1820
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1802
diff
changeset
|
289 |
DoCommandP(0, WP(w,buildtrain_d).rename_engine, 0, NULL, |
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1802
diff
changeset
|
290 |
CMD_RENAME_ENGINE | CMD_MSG(STR_886B_CAN_T_RENAME_TRAIN_VEHICLE)); |
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1802
diff
changeset
|
291 |
} |
0 | 292 |
} break; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
293 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
294 |
case WE_RESIZE: { |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
295 |
if (e->we.sizing.diff.y == 0) |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
296 |
break; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
297 |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
298 |
w->vscroll.cap += e->we.sizing.diff.y / 14; |
4547
9786a24c4102
(svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents:
4541
diff
changeset
|
299 |
w->widget[2].data = (w->vscroll.cap << 8) + 1; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
300 |
} break; |
0 | 301 |
} |
302 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
303 |
|
0 | 304 |
static const Widget _new_rail_vehicle_widgets[] = { |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
305 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
306 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 227, 0, 13, STR_JUST_STRING, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
307 |
{ WWT_MATRIX, RESIZE_BOTTOM, 14, 0, 215, 14, 125, 0x801, STR_8843_TRAIN_VEHICLE_SELECTION}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
308 |
{ WWT_SCROLLBAR, RESIZE_BOTTOM, 14, 216, 227, 14, 125, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
309 |
{ WWT_PANEL, RESIZE_TB, 14, 0, 227, 126, 197, 0x0, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
310 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 107, 198, 209, STR_881F_BUILD_VEHICLE, STR_8844_BUILD_THE_HIGHLIGHTED_TRAIN}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
311 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 108, 215, 198, 209, STR_8820_RENAME, STR_8845_RENAME_TRAIN_VEHICLE_TYPE}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
312 |
{ WWT_RESIZEBOX, RESIZE_TB, 14, 216, 227, 198, 209, 0x0, STR_RESIZE_BUTTON}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
313 |
{ WIDGETS_END}, |
0 | 314 |
}; |
315 |
||
316 |
static const WindowDesc _new_rail_vehicle_desc = { |
|
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1907
diff
changeset
|
317 |
-1, -1, 228, 210, |
0 | 318 |
WC_BUILD_VEHICLE,0, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
319 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
0 | 320 |
_new_rail_vehicle_widgets, |
321 |
NewRailVehicleWndProc |
|
322 |
}; |
|
323 |
||
4442
8d8d0c2df7cb
(svn r6215) -Codechange: [vehicle list windows] unified Player(vehicle)WndProc into PlayerVehWndProc
bjarni
parents:
4434
diff
changeset
|
324 |
void ShowBuildTrainWindow(TileIndex tile) |
0 | 325 |
{ |
326 |
Window *w; |
|
327 |
||
328 |
DeleteWindowById(WC_BUILD_VEHICLE, tile); |
|
329 |
||
330 |
w = AllocateWindowDesc(&_new_rail_vehicle_desc); |
|
331 |
w->window_number = tile; |
|
332 |
w->vscroll.cap = 8; |
|
4547
9786a24c4102
(svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents:
4541
diff
changeset
|
333 |
w->widget[2].data = (w->vscroll.cap << 8) + 1; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
334 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
335 |
w->resize.step_height = 14; |
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3948
diff
changeset
|
336 |
w->resize.height = w->height - 14 * 4; // Minimum of 4 vehicles in the display |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
337 |
|
0 | 338 |
if (tile != 0) { |
1901
fb05044cf5c3
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
339 |
w->caption_color = GetTileOwner(tile); |
3242
1cefa03f0d5e
(svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents:
3157
diff
changeset
|
340 |
WP(w,buildtrain_d).railtype = GetRailType(tile); |
0 | 341 |
} else { |
342 |
w->caption_color = _local_player; |
|
2147
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
2113
diff
changeset
|
343 |
WP(w,buildtrain_d).railtype = GetBestRailtype(GetPlayer(_local_player)); |
0 | 344 |
} |
345 |
} |
|
346 |
||
2593
a9f7d3d70639
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
peter1138
parents:
2570
diff
changeset
|
347 |
/** |
a9f7d3d70639
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
peter1138
parents:
2570
diff
changeset
|
348 |
* Get the number of pixels for the given wagon length. |
a9f7d3d70639
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
peter1138
parents:
2570
diff
changeset
|
349 |
* @param len Length measured in 1/8ths of a standard wagon. |
a9f7d3d70639
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
peter1138
parents:
2570
diff
changeset
|
350 |
* @return Number of pixels across. |
a9f7d3d70639
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
peter1138
parents:
2570
diff
changeset
|
351 |
*/ |
4638
8abe4f10b94b
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
4635
diff
changeset
|
352 |
int WagonLengthToPixels(int len) { |
3845
c3cd4b825c2f
(svn r4869) - NewGRF: support setting train list vehicle width to 32 instead of 29 pixels, for sets which use 32 pixel long engines/wagons.
peter1138
parents:
3844
diff
changeset
|
353 |
return (len * _traininfo_vehicle_width) / 8; |
2593
a9f7d3d70639
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
peter1138
parents:
2570
diff
changeset
|
354 |
} |
a9f7d3d70639
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
peter1138
parents:
2570
diff
changeset
|
355 |
|
4442
8d8d0c2df7cb
(svn r6215) -Codechange: [vehicle list windows] unified Player(vehicle)WndProc into PlayerVehWndProc
bjarni
parents:
4434
diff
changeset
|
356 |
void DrawTrainImage(const Vehicle *v, int x, int y, int count, int skip, VehicleID selection) |
0 | 357 |
{ |
3919
1ba6c2e9b46d
(svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents:
3887
diff
changeset
|
358 |
DrawPixelInfo tmp_dpi, *old_dpi; |
1ba6c2e9b46d
(svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents:
3887
diff
changeset
|
359 |
int dx = -(skip * 8) / _traininfo_vehicle_width; |
4049
dd384acac472
(svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents:
4041
diff
changeset
|
360 |
/* Position of highlight box */ |
dd384acac472
(svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents:
4041
diff
changeset
|
361 |
int highlight_l = 0; |
dd384acac472
(svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents:
4041
diff
changeset
|
362 |
int highlight_r = 0; |
3919
1ba6c2e9b46d
(svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents:
3887
diff
changeset
|
363 |
|
4429
1bb01569940c
(svn r6184) Remove the unused (because it was NULL in all callers) second parameter of FillDrawPixelInfo() and simplify some expressions
tron
parents:
4426
diff
changeset
|
364 |
if (!FillDrawPixelInfo(&tmp_dpi, x - 2, y - 1, count + 1, 14)) return; |
3919
1ba6c2e9b46d
(svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents:
3887
diff
changeset
|
365 |
|
1ba6c2e9b46d
(svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents:
3887
diff
changeset
|
366 |
count = (count * 8) / _traininfo_vehicle_width; |
1ba6c2e9b46d
(svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents:
3887
diff
changeset
|
367 |
|
1ba6c2e9b46d
(svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents:
3887
diff
changeset
|
368 |
old_dpi = _cur_dpi; |
1ba6c2e9b46d
(svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents:
3887
diff
changeset
|
369 |
_cur_dpi = &tmp_dpi; |
1922
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
370 |
|
0 | 371 |
do { |
3919
1ba6c2e9b46d
(svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents:
3887
diff
changeset
|
372 |
int width = v->u.rail.cached_veh_length; |
1922
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
373 |
|
3919
1ba6c2e9b46d
(svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents:
3887
diff
changeset
|
374 |
if (dx + width > 0) { |
1ba6c2e9b46d
(svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents:
3887
diff
changeset
|
375 |
if (dx <= count) { |
3049
b797ca543c13
(svn r3631) - 2cc: Remove use of some temporary variables and perform minor optimization in the form of the ternary operator.
peter1138
parents:
3040
diff
changeset
|
376 |
PalSpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v); |
4049
dd384acac472
(svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents:
4041
diff
changeset
|
377 |
DrawSprite(GetTrainImage(v, DIR_W) | pal, 16 + WagonLengthToPixels(dx), 7 + (is_custom_sprite(RailVehInfo(v->engine_type)->image_index) ? _traininfo_vehicle_pitch : 0)); |
dd384acac472
(svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents:
4041
diff
changeset
|
378 |
if (v->index == selection) { |
dd384acac472
(svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents:
4041
diff
changeset
|
379 |
/* Set the highlight position */ |
dd384acac472
(svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents:
4041
diff
changeset
|
380 |
highlight_l = WagonLengthToPixels(dx) + 1; |
dd384acac472
(svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents:
4041
diff
changeset
|
381 |
highlight_r = WagonLengthToPixels(dx + width) + 1; |
dd384acac472
(svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents:
4041
diff
changeset
|
382 |
} |
1922
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
383 |
} |
0 | 384 |
} |
3919
1ba6c2e9b46d
(svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents:
3887
diff
changeset
|
385 |
dx += width; |
0 | 386 |
|
2593
a9f7d3d70639
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
peter1138
parents:
2570
diff
changeset
|
387 |
v = v->next; |
3919
1ba6c2e9b46d
(svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents:
3887
diff
changeset
|
388 |
} while (dx < count && v != NULL); |
1ba6c2e9b46d
(svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents:
3887
diff
changeset
|
389 |
|
4049
dd384acac472
(svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents:
4041
diff
changeset
|
390 |
if (highlight_l != highlight_r) { |
dd384acac472
(svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents:
4041
diff
changeset
|
391 |
/* Draw the highlight. Now done after drawing all the engines, as |
dd384acac472
(svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents:
4041
diff
changeset
|
392 |
* the next engine after the highlight could overlap it. */ |
dd384acac472
(svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents:
4041
diff
changeset
|
393 |
DrawFrameRect(highlight_l, 0, highlight_r, 13, 15, FR_BORDERONLY); |
dd384acac472
(svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents:
4041
diff
changeset
|
394 |
} |
dd384acac472
(svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents:
4041
diff
changeset
|
395 |
|
3919
1ba6c2e9b46d
(svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents:
3887
diff
changeset
|
396 |
_cur_dpi = old_dpi; |
0 | 397 |
} |
398 |
||
2275
cbaeb07740b1
(svn r2799) Make the only two non-const widget lists const
tron
parents:
2261
diff
changeset
|
399 |
static const Widget _train_view_widgets[] = { |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
400 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
401 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 237, 0, 13, STR_882E, STR_018C_WINDOW_TITLE_DRAG_THIS }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
402 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 238, 249, 0, 13, 0x0, STR_STICKY_BUTTON }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
403 |
{ WWT_PANEL, RESIZE_RB, 14, 0, 231, 14, 121, 0x0, STR_NULL }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
404 |
{ WWT_6, RESIZE_RB, 14, 2, 229, 16, 119, 0x0, STR_NULL }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
405 |
{ WWT_PUSHIMGBTN, RESIZE_RTB, 14, 0, 237, 122, 133, 0x0, STR_8846_CURRENT_TRAIN_ACTION_CLICK }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
406 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 14, 31, 0x2AB, STR_8848_CENTER_MAIN_VIEW_ON_TRAIN }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
407 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 32, 49, 0x2AD, STR_8849_SEND_TRAIN_TO_DEPOT }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
408 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 50, 67, 0x2B1, STR_884A_FORCE_TRAIN_TO_PROCEED }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
409 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 68, 85, 0x2CB, STR_884B_REVERSE_DIRECTION_OF_TRAIN }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
410 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 86, 103, 0x2B2, STR_8847_SHOW_TRAIN_S_ORDERS }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
411 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 104, 121, 0x2B3, STR_884C_SHOW_TRAIN_DETAILS }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
412 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 68, 85, 0x2B4, STR_RAIL_REFIT_VEHICLE_TO_CARRY }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
413 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 32, 49, SPR_CLONE_TRAIN, STR_CLONE_TRAIN_INFO }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
414 |
{ WWT_PANEL, RESIZE_LRB, 14, 232, 249, 122, 121, 0x0, STR_NULL }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
415 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 238, 249, 122, 133, 0x0, STR_NULL }, |
1485
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
416 |
{ WIDGETS_END } |
0 | 417 |
}; |
418 |
||
4171 | 419 |
static void ShowTrainDetailsWindow(const Vehicle *v); |
2561
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
420 |
|
0 | 421 |
static void TrainViewWndProc(Window *w, WindowEvent *e) |
422 |
{ |
|
1802
448f187042d3
(svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents:
1790
diff
changeset
|
423 |
switch (e->event) { |
0 | 424 |
case WE_PAINT: { |
1802
448f187042d3
(svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents:
1790
diff
changeset
|
425 |
const Vehicle *v, *u; |
0 | 426 |
StringID str; |
427 |
||
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
428 |
v = GetVehicle(w->window_number); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
429 |
|
2867
66a9c4e27e34
(svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
peter1138
parents:
2840
diff
changeset
|
430 |
if (v->owner != _local_player) { |
66a9c4e27e34
(svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
peter1138
parents:
2840
diff
changeset
|
431 |
w->disabled_state = 0x3380; |
66a9c4e27e34
(svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
peter1138
parents:
2840
diff
changeset
|
432 |
} else { |
66a9c4e27e34
(svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
peter1138
parents:
2840
diff
changeset
|
433 |
w->disabled_state = 0; |
1387
eff794048d92
(svn r1891) -Fix: [ 1143587 ] carriages of newgrfs can be refitted again
celestar
parents:
1330
diff
changeset
|
434 |
|
2867
66a9c4e27e34
(svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
peter1138
parents:
2840
diff
changeset
|
435 |
SETBIT(w->disabled_state, 12); |
66a9c4e27e34
(svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
peter1138
parents:
2840
diff
changeset
|
436 |
|
66a9c4e27e34
(svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
peter1138
parents:
2840
diff
changeset
|
437 |
/* See if any vehicle can be refitted */ |
66a9c4e27e34
(svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
peter1138
parents:
2840
diff
changeset
|
438 |
for (u = v; u != NULL; u = u->next) { |
3393
48ce4c723a76
(svn r4201) - Codechange: Do for _engine_info[] what we do for _*_vehicle_info[]; create and use a function to retrieve data, and ensure constness.
peter1138
parents:
3384
diff
changeset
|
439 |
if (EngInfo(u->engine_type)->refit_mask != 0 || |
2867
66a9c4e27e34
(svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
peter1138
parents:
2840
diff
changeset
|
440 |
(!(RailVehInfo(v->engine_type)->flags & RVI_WAGON) && v->cargo_cap != 0)) { |
66a9c4e27e34
(svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
peter1138
parents:
2840
diff
changeset
|
441 |
CLRBIT(w->disabled_state, 12); |
66a9c4e27e34
(svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
peter1138
parents:
2840
diff
changeset
|
442 |
/* We have a refittable carriage, bail out */ |
66a9c4e27e34
(svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
peter1138
parents:
2840
diff
changeset
|
443 |
break; |
66a9c4e27e34
(svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
peter1138
parents:
2840
diff
changeset
|
444 |
} |
1387
eff794048d92
(svn r1891) -Fix: [ 1143587 ] carriages of newgrfs can be refitted again
celestar
parents:
1330
diff
changeset
|
445 |
} |
eff794048d92
(svn r1891) -Fix: [ 1143587 ] carriages of newgrfs can be refitted again
celestar
parents:
1330
diff
changeset
|
446 |
} |
eff794048d92
(svn r1891) -Fix: [ 1143587 ] carriages of newgrfs can be refitted again
celestar
parents:
1330
diff
changeset
|
447 |
|
0 | 448 |
/* draw widgets & caption */ |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
449 |
SetDParam(0, v->string_id); |
2261
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2252
diff
changeset
|
450 |
SetDParam(1, v->unitnumber); |
0 | 451 |
DrawWindowWidgets(w); |
452 |
||
453 |
if (v->u.rail.crash_anim_pos != 0) { |
|
454 |
str = STR_8863_CRASHED; |
|
455 |
} else if (v->breakdown_ctr == 1) { |
|
456 |
str = STR_885C_BROKEN_DOWN; |
|
457 |
} else if (v->vehstatus & VS_STOPPED) { |
|
458 |
if (v->u.rail.last_speed == 0) { |
|
4251
85befcd5f435
(svn r5853) -Fix: [elrails] FS#178 Electric Trains can leave Conventional Depot
bjarni
parents:
4171
diff
changeset
|
459 |
if (v->u.rail.cached_power == 0) { |
85befcd5f435
(svn r5853) -Fix: [elrails] FS#178 Electric Trains can leave Conventional Depot
bjarni
parents:
4171
diff
changeset
|
460 |
str = STR_TRAIN_NO_POWER; |
85befcd5f435
(svn r5853) -Fix: [elrails] FS#178 Electric Trains can leave Conventional Depot
bjarni
parents:
4171
diff
changeset
|
461 |
} else { |
85befcd5f435
(svn r5853) -Fix: [elrails] FS#178 Electric Trains can leave Conventional Depot
bjarni
parents:
4171
diff
changeset
|
462 |
str = STR_8861_STOPPED; |
85befcd5f435
(svn r5853) -Fix: [elrails] FS#178 Electric Trains can leave Conventional Depot
bjarni
parents:
4171
diff
changeset
|
463 |
} |
0 | 464 |
} else { |
3477
80c3465b38ee
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3401
diff
changeset
|
465 |
SetDParam(0, v->u.rail.last_speed); |
0 | 466 |
str = STR_TRAIN_STOPPING + _patches.vehicle_speed; |
467 |
} |
|
468 |
} else { |
|
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
469 |
switch (v->current_order.type) { |
0 | 470 |
case OT_GOTO_STATION: { |
471 |
str = STR_HEADING_FOR_STATION + _patches.vehicle_speed; |
|
4527
b18634a31a4a
(svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents:
4524
diff
changeset
|
472 |
SetDParam(0, v->current_order.dest); |
3477
80c3465b38ee
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3401
diff
changeset
|
473 |
SetDParam(1, v->u.rail.last_speed); |
0 | 474 |
} break; |
475 |
||
476 |
case OT_GOTO_DEPOT: { |
|
4527
b18634a31a4a
(svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents:
4524
diff
changeset
|
477 |
Depot *dep = GetDepot(v->current_order.dest); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
478 |
SetDParam(0, dep->town_index); |
4633
fae5d85ef53d
(svn r6497) -Fix r6165: Vehicles heading for depots when their orders contained "service in depot" displayed the stopping in depot string
bjarni
parents:
4547
diff
changeset
|
479 |
if (HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT) && !HASBIT(v->current_order.flags, OFB_PART_OF_ORDERS)) { |
4412
945e8a9bb89a
(svn r6165) -Feature: control click Goto Depot will now make the vehicle service
bjarni
parents:
4408
diff
changeset
|
480 |
str = STR_HEADING_FOR_TRAIN_DEPOT + _patches.vehicle_speed; |
945e8a9bb89a
(svn r6165) -Feature: control click Goto Depot will now make the vehicle service
bjarni
parents:
4408
diff
changeset
|
481 |
} else { |
945e8a9bb89a
(svn r6165) -Feature: control click Goto Depot will now make the vehicle service
bjarni
parents:
4408
diff
changeset
|
482 |
str = STR_HEADING_FOR_TRAIN_DEPOT_SERVICE + _patches.vehicle_speed; |
945e8a9bb89a
(svn r6165) -Feature: control click Goto Depot will now make the vehicle service
bjarni
parents:
4408
diff
changeset
|
483 |
} |
3477
80c3465b38ee
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3401
diff
changeset
|
484 |
SetDParam(1, v->u.rail.last_speed); |
0 | 485 |
} break; |
486 |
||
487 |
case OT_LOADING: |
|
488 |
case OT_LEAVESTATION: |
|
489 |
str = STR_882F_LOADING_UNLOADING; |
|
490 |
break; |
|
491 |
||
395
4c990f33dab7
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
382
diff
changeset
|
492 |
case OT_GOTO_WAYPOINT: { |
4527
b18634a31a4a
(svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents:
4524
diff
changeset
|
493 |
SetDParam(0, v->current_order.dest); |
395
4c990f33dab7
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
382
diff
changeset
|
494 |
str = STR_HEADING_FOR_WAYPOINT + _patches.vehicle_speed; |
3477
80c3465b38ee
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3401
diff
changeset
|
495 |
SetDParam(1, v->u.rail.last_speed); |
0 | 496 |
break; |
497 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
498 |
|
0 | 499 |
default: |
500 |
if (v->num_orders == 0) { |
|
501 |
str = STR_NO_ORDERS + _patches.vehicle_speed; |
|
3477
80c3465b38ee
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3401
diff
changeset
|
502 |
SetDParam(0, v->u.rail.last_speed); |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4049
diff
changeset
|
503 |
} else { |
0 | 504 |
str = STR_EMPTY; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4049
diff
changeset
|
505 |
} |
0 | 506 |
break; |
507 |
} |
|
508 |
} |
|
509 |
||
2103
9266bb2ac29d
(svn r2613) - Truncate savegames, and vehicle-texts in their window.
Darkvater
parents:
2084
diff
changeset
|
510 |
/* draw the flag plus orders */ |
2517
b90693227193
(svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents:
2498
diff
changeset
|
511 |
DrawSprite(v->vehstatus & VS_STOPPED ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, 2, w->widget[5].top + 1); |
2113
f228b399da01
(svn r2623) - CodeChange: rework DrawStringCenteredTruncated() a bit. Instead of giving center + width you give the coordinates of the bounding box (left, right) it has to fit in (ludde)
Darkvater
parents:
2103
diff
changeset
|
512 |
DrawStringCenteredTruncated(w->widget[5].left + 8, w->widget[5].right, w->widget[5].top + 1, str, 0); |
0 | 513 |
DrawWindowViewport(w); |
514 |
} break; |
|
515 |
||
516 |
case WE_CLICK: { |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
517 |
int wid = e->we.click.widget; |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
518 |
Vehicle *v = GetVehicle(w->window_number); |
0 | 519 |
|
2952 | 520 |
switch (wid) { |
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
521 |
case 5: /* start/stop train */ |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
522 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_TRAIN | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN)); |
0 | 523 |
break; |
4434
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4429
diff
changeset
|
524 |
case 6: /* center main view */ |
0 | 525 |
ScrollMainWindowTo(v->x_pos, v->y_pos); |
526 |
break; |
|
4434
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4429
diff
changeset
|
527 |
case 7: /* goto depot */ |
601
952c0295f79a
(svn r1025) -Fix: [Network] [ 1083687 ] Sending to depot caused desync because the
truelight
parents:
588
diff
changeset
|
528 |
/* TrainGotoDepot has a nice randomizer in the pathfinder, which causes desyncs... */ |
4506
0d8fcc0a4e49
(svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents:
4495
diff
changeset
|
529 |
DoCommandP(v->tile, v->index, _ctrl_pressed ? DEPOT_SERVICE : 0, NULL, CMD_SEND_TRAIN_TO_DEPOT | CMD_NO_TEST_IF_IN_NETWORK | CMD_MSG(STR_8830_CAN_T_SEND_TRAIN_TO_DEPOT)); |
0 | 530 |
break; |
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
531 |
case 8: /* force proceed */ |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
532 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_FORCE_TRAIN_PROCEED | CMD_MSG(STR_8862_CAN_T_MAKE_TRAIN_PASS_SIGNAL)); |
0 | 533 |
break; |
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
534 |
case 9: /* reverse direction */ |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
535 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_8869_CAN_T_REVERSE_DIRECTION)); |
0 | 536 |
break; |
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
537 |
case 10: /* show train orders */ |
0 | 538 |
ShowOrdersWindow(v); |
539 |
break; |
|
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
540 |
case 11: /* show train details */ |
0 | 541 |
ShowTrainDetailsWindow(v); |
542 |
break; |
|
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
543 |
case 12: |
4642
486900e9288d
(svn r6518) -Codechange: unified the vehicle refit windows
bjarni
parents:
4638
diff
changeset
|
544 |
ShowVehicleRefitWindow(v); |
0 | 545 |
break; |
2244 | 546 |
case 13: |
547 |
DoCommandP(v->tile, v->index, _ctrl_pressed ? 1 : 0, NULL, CMD_CLONE_VEHICLE | CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE)); |
|
548 |
break; |
|
0 | 549 |
} |
550 |
} break; |
|
551 |
||
1485
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
552 |
case WE_RESIZE: |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
553 |
w->viewport->width += e->we.sizing.diff.x; |
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
554 |
w->viewport->height += e->we.sizing.diff.y; |
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
555 |
w->viewport->virtual_width += e->we.sizing.diff.x; |
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
556 |
w->viewport->virtual_height += e->we.sizing.diff.y; |
1485
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
557 |
break; |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
558 |
|
0 | 559 |
case WE_DESTROY: |
338
04ad3e897bf8
(svn r514) -Fix: [1053397] Refit Train Window Stays Open
tron
parents:
243
diff
changeset
|
560 |
DeleteWindowById(WC_VEHICLE_REFIT, w->window_number); |
0 | 561 |
DeleteWindowById(WC_VEHICLE_ORDERS, w->window_number); |
562 |
DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number); |
|
563 |
break; |
|
564 |
||
565 |
case WE_MOUSELOOP: { |
|
4171 | 566 |
const Vehicle *v = GetVehicle(w->window_number); |
0 | 567 |
uint32 h; |
568 |
||
569 |
assert(v->type == VEH_Train); |
|
2244 | 570 |
h = CheckTrainStoppedInDepot(v) >= 0 ? (1 << 9)| (1 << 7) : (1 << 12) | (1 << 13); |
0 | 571 |
if (h != w->hidden_state) { |
572 |
w->hidden_state = h; |
|
573 |
SetWindowDirty(w); |
|
574 |
} |
|
575 |
break; |
|
576 |
} |
|
577 |
||
578 |
} |
|
579 |
} |
|
580 |
||
581 |
static const WindowDesc _train_view_desc = { |
|
582 |
-1,-1, 250, 134, |
|
583 |
WC_VEHICLE_VIEW,0, |
|
1485
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
584 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 585 |
_train_view_widgets, |
586 |
TrainViewWndProc |
|
587 |
}; |
|
588 |
||
4171 | 589 |
void ShowTrainViewWindow(const Vehicle *v) |
0 | 590 |
{ |
4171 | 591 |
Window *w = AllocateWindowDescFront(&_train_view_desc,v->index); |
0 | 592 |
|
2561
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
593 |
if (w != NULL) { |
0 | 594 |
w->caption_color = v->owner; |
595 |
AssignWindowViewport(w, 3, 17, 0xE2, 0x66, w->window_number | (1 << 31), 0); |
|
596 |
} |
|
597 |
} |
|
598 |
||
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1658
diff
changeset
|
599 |
static void TrainDetailsCargoTab(const Vehicle *v, int x, int y) |
0 | 600 |
{ |
4492
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
601 |
if (v->cargo_cap != 0) { |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
602 |
uint num = v->cargo_count; |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
603 |
StringID str = STR_8812_EMPTY; |
0 | 604 |
|
605 |
if (num != 0) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
606 |
SetDParam(0, v->cargo_type); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
607 |
SetDParam(1, num); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
608 |
SetDParam(2, v->cargo_source); |
0 | 609 |
str = STR_8813_FROM; |
610 |
} |
|
611 |
DrawString(x, y, str, 0); |
|
612 |
} |
|
613 |
} |
|
614 |
||
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1658
diff
changeset
|
615 |
static void TrainDetailsInfoTab(const Vehicle *v, int x, int y) |
0 | 616 |
{ |
4492
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
617 |
if (RailVehInfo(v->engine_type)->flags & RVI_WAGON) { |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
618 |
SetDParam(0, GetCustomEngineName(v->engine_type)); |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
619 |
SetDParam(1, v->value); |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
620 |
DrawString(x, y, STR_882D_VALUE, 0x10); |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
621 |
} else { |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
622 |
SetDParam(0, GetCustomEngineName(v->engine_type)); |
4329
9759d5c52010
(svn r6002) -Cleanup: remove the now redundant BASE_YEAR constant.
rubidium
parents:
4299
diff
changeset
|
623 |
SetDParam(1, v->build_year); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
624 |
SetDParam(2, v->value); |
0 | 625 |
DrawString(x, y, STR_882C_BUILT_VALUE, 0x10); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
626 |
} |
0 | 627 |
} |
628 |
||
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1658
diff
changeset
|
629 |
static void TrainDetailsCapacityTab(const Vehicle *v, int x, int y) |
0 | 630 |
{ |
631 |
if (v->cargo_cap != 0) { |
|
2084
d67790a49f78
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
2049
diff
changeset
|
632 |
SetDParam(0, _cargoc.names_long[v->cargo_type]); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
633 |
SetDParam(1, v->cargo_cap); |
0 | 634 |
DrawString(x, y, STR_013F_CAPACITY, 0); |
635 |
} |
|
636 |
} |
|
637 |
||
638 |
||
639 |
static void DrawTrainDetailsWindow(Window *w) |
|
640 |
{ |
|
641 |
byte det_tab = WP(w, traindetails_d).tab; |
|
4492
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
642 |
const Vehicle* v; |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
643 |
const Vehicle* u; |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
644 |
AcceptedCargo act_cargo; |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
645 |
AcceptedCargo max_cargo; |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
646 |
uint i; |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
647 |
int num; |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
648 |
int x; |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
649 |
int y; |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
650 |
int sel; |
0 | 651 |
|
652 |
num = 0; |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
653 |
u = v = GetVehicle(w->window_number); |
4492
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
654 |
if (det_tab == 3) { // Total cargo tab |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
655 |
for (i = 0; i < lengthof(act_cargo); i++) { |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
656 |
act_cargo[i] = 0; |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
657 |
max_cargo[i] = 0; |
0 | 658 |
} |
659 |
||
4492
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
660 |
do { |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
661 |
act_cargo[u->cargo_type] += u->cargo_count; |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
662 |
max_cargo[u->cargo_type] += u->cargo_cap; |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
663 |
} while ((u = GetNextVehicle(u)) != NULL); |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
664 |
|
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
665 |
/* Set scroll-amount seperately from counting, as to not compute num double |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
666 |
* for more carriages of the same type |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
667 |
*/ |
0 | 668 |
for (i = 0; i != NUM_CARGO; i++) { |
4492
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
669 |
if (max_cargo[i] > 0) num++; // only count carriages that the train has |
0 | 670 |
} |
4434
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4429
diff
changeset
|
671 |
num++; // needs one more because first line is description string |
4492
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
672 |
} else { |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
673 |
do { |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
674 |
num++; |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
675 |
} while ((u = GetNextVehicle(u)) != NULL); |
0 | 676 |
} |
677 |
||
678 |
SetVScrollCount(w, num); |
|
679 |
||
680 |
w->disabled_state = 1 << (det_tab + 9); |
|
4492
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
681 |
if (v->owner != _local_player) w->disabled_state |= (1 << 2); |
0 | 682 |
|
4492
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
683 |
// disable service-scroller when interval is set to disabled |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
684 |
if (!_patches.servint_trains) w->disabled_state |= (1 << 6) | (1 << 7); |
156
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
22
diff
changeset
|
685 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
686 |
SetDParam(0, v->string_id); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
687 |
SetDParam(1, v->unitnumber); |
0 | 688 |
DrawWindowWidgets(w); |
689 |
||
4492
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
690 |
SetDParam(1, v->age / 366); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
691 |
|
0 | 692 |
x = 2; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
693 |
|
2252
37e3ca7014e0
(svn r2772) Simplify the age notice in the vehicle details window
tron
parents:
2244
diff
changeset
|
694 |
SetDParam(0, (v->age + 365 < v->max_age) ? STR_AGE : STR_AGE_RED); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
695 |
SetDParam(2, v->max_age / 366); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
696 |
SetDParam(3, GetTrainRunningCost(v) >> 8); |
0 | 697 |
DrawString(x, 15, STR_885D_AGE_RUNNING_COST_YR, 0); |
698 |
||
3477
80c3465b38ee
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3401
diff
changeset
|
699 |
SetDParam(2, v->u.rail.cached_max_speed); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
700 |
SetDParam(1, v->u.rail.cached_power); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
701 |
SetDParam(0, v->u.rail.cached_weight); |
3401
ad8175f44c3b
(svn r4211) - Removed measuring units from the names of two strings.
peter1138
parents:
3393
diff
changeset
|
702 |
DrawString(x, 25, STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED, 0); |
0 | 703 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
704 |
SetDParam(0, v->profit_this_year); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
705 |
SetDParam(1, v->profit_last_year); |
0 | 706 |
DrawString(x, 35, STR_885F_PROFIT_THIS_YEAR_LAST_YEAR, 0); |
707 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
708 |
SetDParam(0, 100 * (v->reliability>>8) >> 8); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
709 |
SetDParam(1, v->breakdowns_since_last_service); |
0 | 710 |
DrawString(x, 45, STR_8860_RELIABILITY_BREAKDOWNS, 0); |
711 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
712 |
SetDParam(0, v->service_interval); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
713 |
SetDParam(1, v->date_of_last_service); |
2959
940962dab788
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
714 |
DrawString(x + 11, 57 + (w->vscroll.cap * 14), _patches.servint_ispercent ? STR_SERVICING_INTERVAL_PERCENT : STR_883C_SERVICING_INTERVAL_DAYS, 0); |
0 | 715 |
|
716 |
y = 57; |
|
717 |
sel = w->vscroll.pos; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
718 |
|
0 | 719 |
// draw the first 3 details tabs |
720 |
if (det_tab != 3) { |
|
2822
ff15d6f947ed
(svn r3370) Improve alignment of text within total cargo tab of train view window
peter1138
parents:
2819
diff
changeset
|
721 |
x = 1; |
2952 | 722 |
for (;;) { |
2959
940962dab788
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
723 |
if (--sel < 0 && sel >= -w->vscroll.cap) { |
2602
f0e2dcce3695
(svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
peter1138
parents:
2593
diff
changeset
|
724 |
int dx = 0; |
4492
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
725 |
int px; |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
726 |
int py; |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
727 |
|
2602
f0e2dcce3695
(svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
peter1138
parents:
2593
diff
changeset
|
728 |
u = v; |
f0e2dcce3695
(svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
peter1138
parents:
2593
diff
changeset
|
729 |
do { |
3844
bed426de30ea
(svn r4868) - Codechange: in the train detail window, don't call DrawTrainImage() for each row, as we already loop to find the vehicles to
peter1138
parents:
3785
diff
changeset
|
730 |
PalSpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v); |
bed426de30ea
(svn r4868) - Codechange: in the train detail window, don't call DrawTrainImage() for each row, as we already loop to find the vehicles to
peter1138
parents:
3785
diff
changeset
|
731 |
DrawSprite(GetTrainImage(u, DIR_W) | pal, x + 14 + WagonLengthToPixels(dx), y + 6 + (is_custom_sprite(RailVehInfo(u->engine_type)->image_index) ? _traininfo_vehicle_pitch : 0)); |
2602
f0e2dcce3695
(svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
peter1138
parents:
2593
diff
changeset
|
732 |
dx += u->u.rail.cached_veh_length; |
f0e2dcce3695
(svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
peter1138
parents:
2593
diff
changeset
|
733 |
u = u->next; |
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
2639
diff
changeset
|
734 |
} while (u != NULL && IsArticulatedPart(u)); |
4492
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
735 |
|
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
736 |
px = x + WagonLengthToPixels(dx) + 2; |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
737 |
py = y + 2; |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
738 |
switch (det_tab) { |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
739 |
default: NOT_REACHED(); |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
740 |
case 0: TrainDetailsCargoTab( v, px, py); break; |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
741 |
case 1: TrainDetailsInfoTab( v, px, py); break; |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
742 |
case 2: TrainDetailsCapacityTab(v, px, py); break; |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
743 |
} |
0 | 744 |
y += 14; |
745 |
} |
|
4492
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
746 |
v = GetNextVehicle(v); |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
747 |
if (v == NULL) return; |
0 | 748 |
} |
2959
940962dab788
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
749 |
} else { |
940962dab788
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
750 |
// draw total cargo tab |
0 | 751 |
DrawString(x, y + 2, STR_013F_TOTAL_CAPACITY_TEXT, 0); |
2959
940962dab788
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
752 |
for (i = 0; i != NUM_CARGO; i++) { |
4492
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
753 |
if (max_cargo[i] > 0 && --sel < 0 && sel > -w->vscroll.cap) { |
0 | 754 |
y += 14; |
4492
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
755 |
SetDParam(0, i); // {CARGO} #1 |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
756 |
SetDParam(1, act_cargo[i]); // {CARGO} #2 |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
757 |
SetDParam(2, i); // {SHORTCARGO} #1 |
f73138c71092
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
758 |
SetDParam(3, max_cargo[i]); // {SHORTCARGO} #2 |
2822
ff15d6f947ed
(svn r3370) Improve alignment of text within total cargo tab of train view window
peter1138
parents:
2819
diff
changeset
|
759 |
DrawString(x, y + 2, STR_013F_TOTAL_CAPACITY, 0); |
0 | 760 |
} |
2959
940962dab788
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
761 |
} |
0 | 762 |
} |
763 |
} |
|
764 |
||
765 |
static void TrainDetailsWndProc(Window *w, WindowEvent *e) |
|
766 |
{ |
|
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1658
diff
changeset
|
767 |
switch (e->event) { |
0 | 768 |
case WE_PAINT: |
769 |
DrawTrainDetailsWindow(w); |
|
770 |
break; |
|
771 |
case WE_CLICK: { |
|
772 |
int mod; |
|
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1658
diff
changeset
|
773 |
const Vehicle *v; |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
774 |
switch (e->we.click.widget) { |
0 | 775 |
case 2: /* name train */ |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
776 |
v = GetVehicle(w->window_number); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
777 |
SetDParam(0, v->unitnumber); |
4299
b86602eaaff1
(svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents:
4293
diff
changeset
|
778 |
ShowQueryString(v->string_id, STR_8865_NAME_TRAIN, 31, 150, w->window_class, w->window_number, CS_ALPHANUMERAL); |
0 | 779 |
break; |
4434
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4429
diff
changeset
|
780 |
case 6: /* inc serv interval */ |
156
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
22
diff
changeset
|
781 |
mod = _ctrl_pressed? 5 : 10; |
0 | 782 |
goto do_change_service_int; |
783 |
||
784 |
case 7: /* dec serv interval */ |
|
156
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
22
diff
changeset
|
785 |
mod = _ctrl_pressed? -5 : -10; |
0 | 786 |
do_change_service_int: |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
787 |
v = GetVehicle(w->window_number); |
156
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
22
diff
changeset
|
788 |
|
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1658
diff
changeset
|
789 |
mod = GetServiceIntervalClamped(mod + v->service_interval); |
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1658
diff
changeset
|
790 |
if (mod == v->service_interval) return; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
791 |
|
2819
710436dd4288
(svn r3367) Unify the 4 distinct CMD_CHANGE_{AIRCRAFT,ROADVEH,SHIP,TRAIN}_SERVICE_INT commands into one CMD_CHANGE_SERVICE_INT command.
tron
parents:
2806
diff
changeset
|
792 |
DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING)); |
0 | 793 |
break; |
794 |
/* details buttons*/ |
|
4434
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4429
diff
changeset
|
795 |
case 9: // Cargo |
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4429
diff
changeset
|
796 |
case 10: // Information |
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4429
diff
changeset
|
797 |
case 11: // Capacities |
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4429
diff
changeset
|
798 |
case 12: // Total cargo |
0 | 799 |
CLRBIT(w->disabled_state, 9); |
800 |
CLRBIT(w->disabled_state, 10); |
|
801 |
CLRBIT(w->disabled_state, 11); |
|
802 |
CLRBIT(w->disabled_state, 12); |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
803 |
SETBIT(w->disabled_state, e->we.click.widget); |
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
804 |
WP(w,traindetails_d).tab = e->we.click.widget - 9; |
0 | 805 |
SetWindowDirty(w); |
806 |
break; |
|
807 |
} |
|
808 |
} break; |
|
809 |
||
2548
97ada3bd2702
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2520
diff
changeset
|
810 |
case WE_ON_EDIT_TEXT: |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
811 |
if (e->we.edittext.str[0] != '\0') { |
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
812 |
_cmd_text = e->we.edittext.str; |
1820
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1802
diff
changeset
|
813 |
DoCommandP(0, w->window_number, 0, NULL, |
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1802
diff
changeset
|
814 |
CMD_NAME_VEHICLE | CMD_MSG(STR_8866_CAN_T_NAME_TRAIN)); |
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1802
diff
changeset
|
815 |
} |
2548
97ada3bd2702
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2520
diff
changeset
|
816 |
break; |
2959
940962dab788
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
817 |
|
940962dab788
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
818 |
case WE_RESIZE: |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
819 |
if (e->we.sizing.diff.y == 0) break; |
2959
940962dab788
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
820 |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
821 |
w->vscroll.cap += e->we.sizing.diff.y / 14; |
4547
9786a24c4102
(svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents:
4541
diff
changeset
|
822 |
w->widget[4].data = (w->vscroll.cap << 8) + 1; |
2959
940962dab788
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
823 |
break; |
0 | 824 |
} |
825 |
} |
|
826 |
||
827 |
static const Widget _train_details_widgets[] = { |
|
2959
940962dab788
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
828 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
940962dab788
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
829 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 329, 0, 13, STR_8802_DETAILS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
940962dab788
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
830 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 330, 369, 0, 13, STR_01AA_NAME, STR_8867_NAME_TRAIN}, |
940962dab788
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
831 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 369, 14, 55, 0x0, STR_NULL}, |
940962dab788
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
832 |
{ WWT_MATRIX, RESIZE_BOTTOM, 14, 0, 357, 56, 139, 0x601, STR_NULL}, |
940962dab788
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
833 |
{ WWT_SCROLLBAR, RESIZE_BOTTOM, 14, 358, 369, 56, 139, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
940962dab788
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
834 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 10, 140, 145, STR_0188, STR_884D_INCREASE_SERVICING_INTERVAL}, |
940962dab788
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
835 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 10, 146, 151, STR_0189, STR_884E_DECREASE_SERVICING_INTERVAL}, |
940962dab788
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
836 |
{ WWT_PANEL, RESIZE_TB, 14, 11, 369, 140, 151, 0x0, STR_NULL}, |
940962dab788
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
837 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 89, 152, 163, STR_013C_CARGO, STR_884F_SHOW_DETAILS_OF_CARGO_CARRIED}, |
940962dab788
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
838 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 90, 178, 152, 163, STR_013D_INFORMATION, STR_8850_SHOW_DETAILS_OF_TRAIN_VEHICLES}, |
940962dab788
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
839 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 179, 268, 152, 163, STR_013E_CAPACITIES, STR_8851_SHOW_CAPACITIES_OF_EACH}, |
940962dab788
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
840 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 269, 357, 152, 163, STR_013E_TOTAL_CARGO, STR_8852_SHOW_TOTAL_CARGO}, |
940962dab788
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
841 |
{ WWT_RESIZEBOX, RESIZE_TB, 14, 358, 369, 152, 163, 0x0, STR_RESIZE_BUTTON}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
842 |
{ WIDGETS_END}, |
0 | 843 |
}; |
844 |
||
845 |
||
846 |
static const WindowDesc _train_details_desc = { |
|
847 |
-1,-1, 370, 164, |
|
848 |
WC_VEHICLE_DETAILS,WC_VEHICLE_VIEW, |
|
2959
940962dab788
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
849 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
0 | 850 |
_train_details_widgets, |
851 |
TrainDetailsWndProc |
|
852 |
}; |
|
853 |
||
854 |
||
4171 | 855 |
static void ShowTrainDetailsWindow(const Vehicle *v) |
0 | 856 |
{ |
857 |
Window *w; |
|
858 |
VehicleID veh = v->index; |
|
859 |
||
860 |
DeleteWindowById(WC_VEHICLE_ORDERS, veh); |
|
861 |
DeleteWindowById(WC_VEHICLE_DETAILS, veh); |
|
862 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
863 |
_alloc_wnd_parent_num = veh; |
0 | 864 |
w = AllocateWindowDesc(&_train_details_desc); |
865 |
||
866 |
w->window_number = veh; |
|
867 |
w->caption_color = v->owner; |
|
868 |
w->vscroll.cap = 6; |
|
4547
9786a24c4102
(svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents:
4541
diff
changeset
|
869 |
w->widget[4].data = (w->vscroll.cap << 8) + 1; |
2959
940962dab788
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
870 |
|
940962dab788
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
871 |
w->resize.step_height = 14; |
940962dab788
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
872 |
w->resize.height = w->height - 14 * 2; /* Minimum of 4 wagons in the display */ |
940962dab788
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
873 |
|
0 | 874 |
WP(w,traindetails_d).tab = 0; |
875 |
} |