author | hackykid |
Mon, 06 Jun 2005 22:44:11 +0000 | |
changeset 1922 | 797081e56d13 |
parent 1908 | bc48a30aba72 |
child 1926 | 68d60188a22f |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1820
diff
changeset
|
2 |
#include "openttd.h" |
1299
0a6510cc889b
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1294
diff
changeset
|
3 |
#include "debug.h" |
1922
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
4 |
#include "table/sprites.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
460
diff
changeset
|
5 |
#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
|
6 |
#include "map.h" |
0 | 7 |
#include "window.h" |
8 |
#include "gui.h" |
|
9 |
#include "gfx.h" |
|
10 |
#include "vehicle.h" |
|
11 |
#include "viewport.h" |
|
12 |
#include "station.h" |
|
13 |
#include "command.h" |
|
14 |
#include "player.h" |
|
15 |
#include "engine.h" |
|
588 | 16 |
#include "vehicle_gui.h" |
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1299
diff
changeset
|
17 |
#include "depot.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
|
18 |
|
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
|
19 |
int _traininfo_vehicle_pitch = 0; |
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
|
20 |
|
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
|
21 |
/** |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
22 |
* 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
|
23 |
* @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
|
24 |
* @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
|
25 |
*/ |
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 |
void DrawTrainEnginePurchaseInfo(int x, int y, EngineID engine_number) |
842 | 27 |
{ |
28 |
const RailVehicleInfo *rvi = RailVehInfo(engine_number); |
|
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
|
29 |
Engine *e = &_engines[engine_number]; |
842 | 30 |
int multihead = (rvi->flags&RVI_MULTIHEAD?1:0); |
31 |
YearMonthDay ymd; |
|
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
|
32 |
ConvertDayToYMD(&ymd, e->intro_date); |
842 | 33 |
|
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
|
34 |
/* Purchase Cost - Engine weight */ |
842 | 35 |
SetDParam(0, rvi->base_cost * (_price.build_railvehicle >> 3) >> 5); |
36 |
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
|
37 |
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
|
38 |
y += 10; |
842 | 39 |
|
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
|
40 |
/* Max speed - Engine power */ |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
41 |
SetDParam(0, rvi->max_speed * 10 >> 4); |
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 |
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
|
43 |
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
|
44 |
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
|
45 |
|
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
46 |
/* Running 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
|
47 |
SetDParam(0, (rvi->running_cost_base * _price.running_rail[rvi->engclass] >> 8) << 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_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
|
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 |
|
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1907
diff
changeset
|
51 |
/* 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
|
52 |
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
|
53 |
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
|
54 |
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
|
55 |
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
|
56 |
y += 10; |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1907
diff
changeset
|
57 |
}; |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1907
diff
changeset
|
58 |
|
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
|
59 |
/* 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
|
60 |
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
|
61 |
SetDParam(2, STR_EMPTY); |
842 | 62 |
if (rvi->capacity != 0) { |
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
|
63 |
SetDParam(0, _cargoc.names_long_p[rvi->cargo_type]); |
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 |
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
|
65 |
SetDParam(2, STR_9842_REFITTABLE); |
842 | 66 |
} |
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
|
67 |
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
|
68 |
y += 10; |
842 | 69 |
|
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
|
70 |
/* Design date - Life length */ |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
71 |
SetDParam(0, ymd.year + 1920); |
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 |
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
|
73 |
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
|
74 |
y += 10; |
842 | 75 |
|
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
|
76 |
/* 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
|
77 |
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
|
78 |
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
|
79 |
y += 10; |
842 | 80 |
} |
81 |
||
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
|
82 |
/** |
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 |
* 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
|
84 |
* @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
|
85 |
* @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
|
86 |
*/ |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
87 |
void DrawTrainWagonPurchaseInfo(int x, int y, EngineID engine_number) |
842 | 88 |
{ |
89 |
const RailVehicleInfo *rvi = RailVehInfo(engine_number); |
|
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
|
90 |
bool refittable = (_engine_refit_masks[engine_number] != 0); |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
91 |
|
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
|
92 |
/* 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
|
93 |
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
|
94 |
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
|
95 |
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
|
96 |
|
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
97 |
/* 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
|
98 |
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
|
99 |
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
|
100 |
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
|
101 |
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
|
102 |
|
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 |
/* Cargo type + capacity */ |
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 |
SetDParam(0, _cargoc.names_long_p[rvi->cargo_type]); |
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 |
SetDParam(1, rvi->capacity); |
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 |
SetDParam(2, refittable ? STR_9842_REFITTABLE : STR_EMPTY); |
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 |
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
|
108 |
y += 10; |
842 | 109 |
} |
0 | 110 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
540
diff
changeset
|
111 |
void CcBuildWagon(bool success, uint tile, uint32 p1, uint32 p2) |
0 | 112 |
{ |
113 |
Vehicle *v,*found; |
|
114 |
||
115 |
if (!success) |
|
116 |
return; |
|
117 |
||
118 |
// find a locomotive in the depot. |
|
119 |
found = NULL; |
|
120 |
FOR_ALL_VEHICLES(v) { |
|
1067
a083a6dd1419
(svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents:
1019
diff
changeset
|
121 |
if (v->type == VEH_Train && v->subtype == TS_Front_Engine && |
0 | 122 |
v->tile == tile && |
123 |
v->u.rail.track == 0x80) { |
|
124 |
if (found != NULL) // must be exactly one. |
|
125 |
return; |
|
126 |
found = v; |
|
127 |
} |
|
128 |
} |
|
129 |
||
130 |
// if we found a loco, |
|
131 |
if (found != NULL) { |
|
132 |
found = GetLastVehicleInChain(found); |
|
133 |
// put the new wagon at the end of the loco. |
|
134 |
DoCommandP(0, _new_wagon_id | (found->index<<16), 0, NULL, CMD_MOVE_RAIL_VEHICLE); |
|
588 | 135 |
RebuildVehicleLists(); |
0 | 136 |
} |
137 |
} |
|
138 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
540
diff
changeset
|
139 |
void CcBuildLoco(bool success, uint tile, uint32 p1, uint32 p2) |
0 | 140 |
{ |
141 |
Vehicle *v; |
|
142 |
||
143 |
if (!success) |
|
144 |
return; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
145 |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
146 |
v = GetVehicle(_new_train_id); |
0 | 147 |
if (tile == _backup_orders_tile) { |
148 |
_backup_orders_tile = 0; |
|
149 |
RestoreVehicleOrders(v, _backup_orders_data); |
|
150 |
} |
|
151 |
ShowTrainViewWindow(v); |
|
152 |
} |
|
153 |
||
524
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
154 |
static void engine_drawing_loop(int *x, int *y, int *pos, int *sel, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
155 |
int *selected_id, byte 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
|
156 |
{ |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
157 |
int i; |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
158 |
|
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
159 |
for (i = 0; i < NUM_TRAIN_ENGINES; i++) { |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
160 |
const Engine *e = DEREF_ENGINE(i); |
539 | 161 |
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
|
162 |
|
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
163 |
if (e->railtype != railtype || !(rvi->flags & RVI_WAGON) != is_engine || |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
164 |
!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
|
165 |
continue; |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
166 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
167 |
if (*sel == 0) |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
168 |
*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
|
169 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
170 |
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
|
171 |
DrawString(*x + 59, *y + 2, GetCustomEngineName(i), *sel == 0 ? 0xC : 0x10); |
524
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
172 |
DrawTrainEngine(*x + 29, *y + 6 + _traininfo_vehicle_pitch, i, |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
173 |
SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player))); |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
174 |
*y += 14; |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
175 |
} |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
176 |
--*sel; |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
177 |
} |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
178 |
} |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
179 |
|
0 | 180 |
static void NewRailVehicleWndProc(Window *w, WindowEvent *e) |
181 |
{ |
|
182 |
switch(e->event) { |
|
183 |
case WE_PAINT: |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
184 |
|
0 | 185 |
if (w->window_number == 0) |
186 |
SETBIT(w->disabled_state, 5); |
|
187 |
||
188 |
{ |
|
189 |
int count = 0; |
|
460
f11659d28617
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
420
diff
changeset
|
190 |
byte railtype = WP(w,buildtrain_d).railtype; |
f11659d28617
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
420
diff
changeset
|
191 |
int i; |
f11659d28617
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
420
diff
changeset
|
192 |
|
f11659d28617
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
420
diff
changeset
|
193 |
for (i = 0; i < NUM_TRAIN_ENGINES; 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 |
const Engine *e = DEREF_ENGINE(i); |
460
f11659d28617
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
420
diff
changeset
|
195 |
if (e->railtype == railtype |
f11659d28617
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
420
diff
changeset
|
196 |
&& HASBIT(e->player_avail, _local_player)) |
0 | 197 |
count++; |
460
f11659d28617
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
420
diff
changeset
|
198 |
} |
0 | 199 |
SetVScrollCount(w, count); |
200 |
} |
|
201 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
202 |
SetDParam(0, WP(w,buildtrain_d).railtype + STR_881C_NEW_RAIL_VEHICLES); |
0 | 203 |
DrawWindowWidgets(w); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
204 |
|
0 | 205 |
{ |
460
f11659d28617
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
420
diff
changeset
|
206 |
byte railtype = WP(w,buildtrain_d).railtype; |
0 | 207 |
int sel = WP(w,buildtrain_d).sel_index; |
208 |
int pos = w->vscroll.pos; |
|
209 |
int x = 1; |
|
210 |
int y = 15; |
|
211 |
int selected_id = -1; |
|
212 |
||
460
f11659d28617
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
420
diff
changeset
|
213 |
/* 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
|
214 |
* 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
|
215 |
* 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
|
216 |
* 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
|
217 |
* 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
|
218 |
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
|
219 |
engine_drawing_loop(&x, &y, &pos, &sel, &selected_id, railtype, w->vscroll.cap, false); // Feeble wagons |
0 | 220 |
|
221 |
WP(w,buildtrain_d).sel_engine = selected_id; |
|
222 |
||
223 |
if (selected_id != -1) { |
|
539 | 224 |
const RailVehicleInfo *rvi = RailVehInfo(selected_id); |
0 | 225 |
|
226 |
if (!(rvi->flags & RVI_WAGON)) { |
|
227 |
/* 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
|
228 |
DrawTrainEnginePurchaseInfo(2, w->widget[4].top + 1,selected_id); |
0 | 229 |
} else { |
230 |
/* 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
|
231 |
DrawTrainWagonPurchaseInfo(2, w->widget[4].top + 1, selected_id); |
0 | 232 |
} |
233 |
} |
|
234 |
} |
|
235 |
break; |
|
236 |
||
237 |
case WE_CLICK: { |
|
238 |
switch(e->click.widget) { |
|
239 |
case 2: { |
|
240 |
uint i = (e->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
|
241 |
if (i < w->vscroll.cap) { |
0 | 242 |
WP(w,buildtrain_d).sel_index = i + w->vscroll.pos; |
243 |
SetWindowDirty(w); |
|
244 |
} |
|
245 |
} break; |
|
246 |
case 5: { |
|
247 |
int sel_eng; |
|
248 |
sel_eng = WP(w,buildtrain_d).sel_engine; |
|
249 |
if (sel_eng != -1) |
|
540
fbed599dadbb
(svn r924) Use RailVehInfo() instead of &_rail_vehicle_info[]
tron
parents:
539
diff
changeset
|
250 |
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 | 251 |
} 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
|
252 |
case 6: { /* rename */ |
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
|
253 |
int sel_eng = WP(w,buildtrain_d).sel_engine; |
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
|
254 |
if (sel_eng != -1) { |
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
|
255 |
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
|
256 |
ShowQueryString(GetCustomEngineName(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
|
257 |
STR_886A_RENAME_TRAIN_VEHICLE_TYPE, 31, 160, w->window_class, w->window_number); |
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
|
258 |
} |
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
|
259 |
} break; |
0 | 260 |
} |
261 |
} break; |
|
262 |
||
263 |
case WE_4: |
|
264 |
if (w->window_number != 0 && !FindWindowById(WC_VEHICLE_DEPOT, w->window_number)) { |
|
265 |
DeleteWindow(w); |
|
266 |
} |
|
267 |
break; |
|
268 |
||
269 |
case WE_ON_EDIT_TEXT: { |
|
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
|
270 |
if (e->edittext.str[0] != '\0') { |
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
|
271 |
_cmd_text = e->edittext.str; |
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
|
272 |
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
|
273 |
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
|
274 |
} |
0 | 275 |
} break; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
276 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
277 |
case WE_RESIZE: { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
278 |
if (e->sizing.diff.y == 0) |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
279 |
break; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
280 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
281 |
w->vscroll.cap += e->sizing.diff.y / 14; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
282 |
w->widget[2].unkA = (w->vscroll.cap << 8) + 1; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
283 |
} break; |
0 | 284 |
} |
285 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
286 |
|
0 | 287 |
static const Widget _new_rail_vehicle_widgets[] = { |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
288 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1017
608592d4d7a6
(svn r1518) -Fix: server issue where some company names were wrong
darkvater
parents:
1006
diff
changeset
|
289 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 227, 0, 13, STR_JUST_STRING, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
290 |
{ WWT_MATRIX, RESIZE_BOTTOM, 14, 0, 215, 14, 125, 0x801, STR_8843_TRAIN_VEHICLE_SELECTION}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
291 |
{ WWT_SCROLLBAR, RESIZE_BOTTOM, 14, 216, 227, 14, 125, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1907
diff
changeset
|
292 |
{ WWT_PANEL, RESIZE_TB, 14, 0, 227, 126, 197, 0x0, STR_NULL}, |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1907
diff
changeset
|
293 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 107, 198, 209, STR_881F_BUILD_VEHICLE, STR_8844_BUILD_THE_HIGHLIGHTED_TRAIN}, |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1907
diff
changeset
|
294 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 108, 215, 198, 209, STR_8820_RENAME, STR_8845_RENAME_TRAIN_VEHICLE_TYPE}, |
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1907
diff
changeset
|
295 |
{ 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
|
296 |
{ WIDGETS_END}, |
0 | 297 |
}; |
298 |
||
299 |
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
|
300 |
-1, -1, 228, 210, |
0 | 301 |
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
|
302 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
0 | 303 |
_new_rail_vehicle_widgets, |
304 |
NewRailVehicleWndProc |
|
305 |
}; |
|
306 |
||
307 |
static void ShowBuildTrainWindow(uint tile) |
|
308 |
{ |
|
309 |
Window *w; |
|
310 |
||
311 |
DeleteWindowById(WC_BUILD_VEHICLE, tile); |
|
312 |
||
313 |
w = AllocateWindowDesc(&_new_rail_vehicle_desc); |
|
314 |
w->window_number = tile; |
|
315 |
w->vscroll.cap = 8; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
316 |
w->widget[2].unkA = (w->vscroll.cap << 8) + 1; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
317 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
318 |
w->resize.step_height = 14; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
319 |
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
|
320 |
|
0 | 321 |
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
|
322 |
w->caption_color = GetTileOwner(tile); |
0 | 323 |
WP(w,buildtrain_d).railtype = _map3_lo[tile] & 0xF; |
324 |
} else { |
|
325 |
w->caption_color = _local_player; |
|
326 |
WP(w,buildtrain_d).railtype = DEREF_PLAYER(_local_player)->max_railtype - 1; |
|
327 |
} |
|
328 |
} |
|
329 |
||
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
|
330 |
static void DrawTrainImage(const Vehicle *v, int x, int y, int count, int skip, VehicleID selection) |
0 | 331 |
{ |
1922
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
332 |
int max_x = x + count * 29; |
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
333 |
|
0 | 334 |
do { |
335 |
if (--skip < 0) { |
|
336 |
int image = GetTrainImage(v, 6); |
|
337 |
uint32 ormod = SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)); |
|
1922
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
338 |
int width = v->u.rail.cached_veh_length * 3; |
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
339 |
|
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
340 |
if (x + width + 4 <= max_x) { |
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
341 |
if (v->vehstatus & VS_CRASHED) |
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
342 |
ormod = PALETTE_CRASH; |
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
343 |
DrawSprite(image | ormod, x + 14, y + 6 + _traininfo_vehicle_pitch); |
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
344 |
if (v->index == selection) |
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
345 |
DrawFrameRect(x - 1, y - 1, x + width + 4, y + 12, 15, 0x10); |
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
346 |
} |
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
347 |
x += width + 5; |
0 | 348 |
} |
349 |
||
350 |
if (!(v = v->next)) |
|
351 |
break; |
|
1922
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
352 |
} while (x < max_x); |
0 | 353 |
} |
354 |
||
355 |
static void DrawTrainDepotWindow(Window *w) |
|
356 |
{ |
|
357 |
uint tile; |
|
358 |
Vehicle *v, *u; |
|
359 |
int num,x,y,i, hnum; |
|
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1299
diff
changeset
|
360 |
Depot *depot; |
0 | 361 |
|
362 |
tile = w->window_number; |
|
363 |
||
364 |
/* setup disabled buttons */ |
|
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
|
365 |
w->disabled_state = |
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
|
366 |
IsTileOwner(tile, _local_player) ? 0 : ((1 << 4) | (1 << 5) | (1 << 8)); |
0 | 367 |
|
368 |
/* determine amount of items for scroller */ |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
369 |
num = 0; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
370 |
hnum = 1; |
0 | 371 |
FOR_ALL_VEHICLES(v) { |
372 |
if (v->type == VEH_Train && |
|
1067
a083a6dd1419
(svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents:
1019
diff
changeset
|
373 |
(v->subtype == TS_Front_Engine || v->subtype == TS_Free_Car) && |
0 | 374 |
v->tile == (TileIndex)tile && |
375 |
v->u.rail.track == 0x80) { |
|
376 |
num++; |
|
377 |
// determine number of items in the X direction. |
|
1067
a083a6dd1419
(svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents:
1019
diff
changeset
|
378 |
if (v->subtype == TS_Front_Engine) { |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
379 |
i = 0; |
0 | 380 |
u = v; |
381 |
do i++; while ( (u=u->next) != NULL); |
|
382 |
if (i > hnum) hnum = i; |
|
383 |
} |
|
384 |
} |
|
385 |
} |
|
914
c3ad2a35b937
(svn r1401) -Fix: glitches in train-depot GUI (tnx to Hackykid)
truelight
parents:
894
diff
changeset
|
386 |
|
c3ad2a35b937
(svn r1401) -Fix: glitches in train-depot GUI (tnx to Hackykid)
truelight
parents:
894
diff
changeset
|
387 |
/* Always have 1 empty row, so people can change the setting of the train */ |
c3ad2a35b937
(svn r1401) -Fix: glitches in train-depot GUI (tnx to Hackykid)
truelight
parents:
894
diff
changeset
|
388 |
num++; |
c3ad2a35b937
(svn r1401) -Fix: glitches in train-depot GUI (tnx to Hackykid)
truelight
parents:
894
diff
changeset
|
389 |
|
0 | 390 |
SetVScrollCount(w, num); |
391 |
SetHScrollCount(w, hnum); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
392 |
|
0 | 393 |
/* locate the depot struct */ |
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1299
diff
changeset
|
394 |
depot = GetDepotByTile(tile); |
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1299
diff
changeset
|
395 |
assert(depot != NULL); |
0 | 396 |
|
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1299
diff
changeset
|
397 |
SetDParam(0, depot->town_index); |
0 | 398 |
DrawWindowWidgets(w); |
399 |
||
400 |
x = 2; |
|
401 |
y = 15; |
|
402 |
num = w->vscroll.pos; |
|
403 |
||
404 |
// draw all trains |
|
405 |
FOR_ALL_VEHICLES(v) { |
|
406 |
if (v->type == VEH_Train && |
|
1067
a083a6dd1419
(svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents:
1019
diff
changeset
|
407 |
v->subtype == TS_Front_Engine && |
0 | 408 |
v->tile == (TileIndex)tile && |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
409 |
v->u.rail.track == 0x80 && |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
410 |
--num < 0 && num >= -w->vscroll.cap) { |
0 | 411 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
412 |
DrawTrainImage(v, x+21, y, w->hscroll.cap, w->hscroll.pos, WP(w,traindepot_d).sel); |
22 | 413 |
/* Draw the train number */ |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
414 |
SetDParam(0, v->unitnumber); |
0 | 415 |
DrawString(x, y, (v->max_age - 366 < v->age) ? STR_00E3 : STR_00E2, 0); |
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1017
diff
changeset
|
416 |
|
1002
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
417 |
/*Draw the train counter */ |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
418 |
i = 0; |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
419 |
u = v; |
1922
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
420 |
do { |
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
421 |
i += u->u.rail.cached_veh_length + 1; |
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
422 |
} while ( (u=u->next) != NULL); //Determine length of train |
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
423 |
SetDParam(0, (i+8) / 9); //Set the counter |
1002
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
424 |
i = (w->hscroll.cap * 29) + (x + 26); //Calculate position of text according to window size |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
425 |
DrawStringCentered(i, y+5, STR_TINY_BLACK, 0); //Draw the counter |
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1017
diff
changeset
|
426 |
|
22 | 427 |
/* Draw the pretty flag */ |
0 | 428 |
DrawSprite(v->vehstatus&VS_STOPPED ? 0xC12 : 0xC13, x+15, y); |
429 |
||
430 |
y += 14; |
|
431 |
} |
|
432 |
} |
|
433 |
||
434 |
// draw all remaining vehicles |
|
435 |
FOR_ALL_VEHICLES(v) { |
|
436 |
if (v->type == VEH_Train && |
|
1067
a083a6dd1419
(svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents:
1019
diff
changeset
|
437 |
v->subtype == TS_Free_Car && |
0 | 438 |
v->tile == (TileIndex)tile && |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
439 |
v->u.rail.track == 0x80 && |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
440 |
--num < 0 && num >= -w->vscroll.cap) { |
0 | 441 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
442 |
DrawTrainImage(v, x+50, y, w->hscroll.cap - 1, 0, WP(w,traindepot_d).sel); |
0 | 443 |
DrawString(x, y+2, STR_8816, 0); |
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1017
diff
changeset
|
444 |
|
1002
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
445 |
/*Draw the train counter */ |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
446 |
i = 0; |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
447 |
u = v; |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
448 |
do i++; while ( (u=u->next) != NULL); //Determine length of train |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
449 |
SetDParam(0, i); //Set the counter |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
450 |
i = (w->hscroll.cap * 29) + (x + 26); //Calculate position of text according to window size |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
451 |
DrawStringCentered(i, y+5, STR_TINY_BLACK, 0); //Draw the counter |
0 | 452 |
y += 14; |
453 |
} |
|
454 |
} |
|
455 |
} |
|
456 |
||
457 |
typedef struct GetDepotVehiclePtData { |
|
458 |
Vehicle *head; |
|
459 |
Vehicle *wagon; |
|
460 |
} GetDepotVehiclePtData; |
|
461 |
||
462 |
static int GetVehicleFromTrainDepotWndPt(Window *w, int x, int y, GetDepotVehiclePtData *d) |
|
463 |
{ |
|
464 |
int row; |
|
1922
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
465 |
int skip = 0; |
0 | 466 |
Vehicle *v; |
467 |
||
468 |
x = x - 23; |
|
469 |
||
470 |
row = (y - 14) / 14; |
|
914
c3ad2a35b937
(svn r1401) -Fix: glitches in train-depot GUI (tnx to Hackykid)
truelight
parents:
894
diff
changeset
|
471 |
if ( (uint) row >= w->vscroll.cap) |
0 | 472 |
return 1; /* means err */ |
473 |
||
474 |
row += w->vscroll.pos; |
|
475 |
||
476 |
/* go through all the locomotives */ |
|
477 |
FOR_ALL_VEHICLES(v) { |
|
478 |
if (v->type == VEH_Train && |
|
1067
a083a6dd1419
(svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents:
1019
diff
changeset
|
479 |
v->subtype == TS_Front_Engine && |
0 | 480 |
v->tile == w->window_number && |
481 |
v->u.rail.track == 0x80 && |
|
482 |
--row < 0) { |
|
1922
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
483 |
skip = w->hscroll.pos; |
0 | 484 |
goto found_it; |
485 |
} |
|
486 |
} |
|
487 |
||
1922
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
488 |
x -= 29; /* free wagons don't have an initial loco. */ |
0 | 489 |
|
490 |
/* and then the list of free wagons */ |
|
491 |
FOR_ALL_VEHICLES(v) { |
|
492 |
if (v->type == VEH_Train && |
|
1067
a083a6dd1419
(svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents:
1019
diff
changeset
|
493 |
v->subtype == TS_Free_Car && |
0 | 494 |
v->tile == w->window_number && |
495 |
v->u.rail.track == 0x80 && |
|
496 |
--row < 0) |
|
497 |
goto found_it; |
|
498 |
} |
|
499 |
||
500 |
d->head = NULL; |
|
501 |
d->wagon = NULL; |
|
502 |
||
503 |
/* didn't find anything, get out */ |
|
504 |
return 0; |
|
505 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
506 |
found_it: |
0 | 507 |
d->head = d->wagon = v; |
508 |
||
509 |
/* either pressed the flag or the number, but only when it's a loco */ |
|
1922
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
510 |
if (x < 0 && v->subtype == TS_Front_Engine) |
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
511 |
return (x >= -10) ? -2 : -1; |
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
512 |
|
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
513 |
// skip vehicles that are scrolled off the left side |
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
514 |
while (skip--) v = v->next; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
515 |
|
0 | 516 |
/* find the vehicle in this row that was clicked */ |
1922
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
517 |
while ((x -= v->u.rail.cached_veh_length * 3 + 5) >= 0) { |
0 | 518 |
v = v->next; |
519 |
if (v == NULL) break; |
|
520 |
} |
|
521 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
522 |
d->wagon = v; |
0 | 523 |
|
524 |
return 0; |
|
525 |
} |
|
526 |
||
527 |
static void TrainDepotMoveVehicle(Vehicle *wagon, int sel, Vehicle *head) |
|
528 |
{ |
|
529 |
Vehicle *v; |
|
530 |
||
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
531 |
v = GetVehicle(sel); |
0 | 532 |
|
1067
a083a6dd1419
(svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents:
1019
diff
changeset
|
533 |
if (/*v->subtype == TS_Front_Engine ||*/ v == wagon) |
0 | 534 |
return; |
535 |
||
536 |
if (wagon == NULL) { |
|
537 |
if (head != NULL) |
|
538 |
wagon = GetLastVehicleInChain(head); |
|
539 |
} else { |
|
540 |
wagon = GetPrevVehicleInChain(wagon); |
|
541 |
if (wagon == NULL) |
|
542 |
return; |
|
543 |
} |
|
544 |
||
545 |
if (wagon == v) |
|
546 |
return; |
|
547 |
||
548 |
DoCommandP(v->tile, v->index + ((wagon==NULL ? (uint32)-1 : wagon->index) << 16), _ctrl_pressed ? 1 : 0, NULL, CMD_MOVE_RAIL_VEHICLE | CMD_MSG(STR_8837_CAN_T_MOVE_VEHICLE)); |
|
549 |
} |
|
550 |
||
551 |
static void TrainDepotClickTrain(Window *w, int x, int y) |
|
552 |
{ |
|
553 |
GetDepotVehiclePtData gdvp; |
|
554 |
int mode, sel; |
|
555 |
Vehicle *v; |
|
556 |
||
557 |
mode = GetVehicleFromTrainDepotWndPt(w, x, y, &gdvp); |
|
10
c35ab8426202
(svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents:
0
diff
changeset
|
558 |
|
c35ab8426202
(svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents:
0
diff
changeset
|
559 |
// share / copy orders |
0 | 560 |
if (_thd.place_mode && mode <= 0) { _place_clicked_vehicle = gdvp.head; return; } |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
561 |
|
0 | 562 |
v = gdvp.wagon; |
563 |
||
564 |
switch(mode) { |
|
10
c35ab8426202
(svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents:
0
diff
changeset
|
565 |
case 0: // start dragging of vehicle |
0 | 566 |
sel = (int16)WP(w,traindepot_d).sel; |
567 |
if (sel != -1) { |
|
568 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
569 |
TrainDepotMoveVehicle(v, sel, gdvp.head); |
|
570 |
} else if (v != NULL) { |
|
571 |
WP(w,traindepot_d).sel = v->index; |
|
572 |
SetObjectToPlaceWnd( SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)) + GetTrainImage(v, 6), 4, w); |
|
573 |
SetWindowDirty(w); |
|
574 |
} |
|
575 |
break; |
|
576 |
||
10
c35ab8426202
(svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents:
0
diff
changeset
|
577 |
case -1: // show info window |
0 | 578 |
ShowTrainViewWindow(v); |
579 |
break; |
|
580 |
||
10
c35ab8426202
(svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents:
0
diff
changeset
|
581 |
case -2: // click start/stop flag |
0 | 582 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_TRAIN | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN)); |
583 |
break; |
|
584 |
} |
|
585 |
} |
|
586 |
||
587 |
static void TrainDepotWndProc(Window *w, WindowEvent *e) |
|
588 |
{ |
|
589 |
switch(e->event) { |
|
590 |
case WE_PAINT: |
|
591 |
DrawTrainDepotWindow(w); |
|
592 |
break; |
|
593 |
||
594 |
case WE_CLICK: { |
|
595 |
switch(e->click.widget) { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
596 |
case 8: |
0 | 597 |
ShowBuildTrainWindow(w->window_number); |
598 |
break; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
599 |
case 9: |
0 | 600 |
ScrollMainWindowToTile(w->window_number); |
601 |
break; |
|
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
968
diff
changeset
|
602 |
case 6: |
0 | 603 |
TrainDepotClickTrain(w, e->click.pt.x, e->click.pt.y); |
604 |
break; |
|
605 |
} |
|
606 |
} break; |
|
607 |
||
608 |
case WE_DESTROY: |
|
609 |
DeleteWindowById(WC_BUILD_VEHICLE, w->window_number); |
|
610 |
break; |
|
611 |
||
612 |
case WE_DRAGDROP: { |
|
613 |
switch(e->click.widget) { |
|
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
968
diff
changeset
|
614 |
case 4: case 5: { |
0 | 615 |
Vehicle *v; |
616 |
int sell_cmd; |
|
617 |
||
618 |
/* sell vehicle */ |
|
619 |
if (w->disabled_state & (1 << e->click.widget)) |
|
620 |
return; |
|
621 |
||
622 |
if (WP(w,traindepot_d).sel == INVALID_VEHICLE) |
|
623 |
return; |
|
624 |
||
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
625 |
v = GetVehicle(WP(w,traindepot_d).sel); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
626 |
|
0 | 627 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
628 |
SetWindowDirty(w); |
|
629 |
||
630 |
HandleButtonClick(w, e->click.widget); |
|
631 |
||
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
968
diff
changeset
|
632 |
sell_cmd = (e->click.widget == 5 || _ctrl_pressed) ? 1 : 0; |
0 | 633 |
|
1067
a083a6dd1419
(svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents:
1019
diff
changeset
|
634 |
if (v->subtype != TS_Front_Engine) { |
0 | 635 |
DoCommandP(v->tile, v->index, sell_cmd, NULL, CMD_SELL_RAIL_WAGON | CMD_MSG(STR_8839_CAN_T_SELL_RAILROAD_VEHICLE)); |
636 |
} else { |
|
637 |
_backup_orders_tile = v->tile; |
|
638 |
BackupVehicleOrders(v, _backup_orders_data); |
|
639 |
if (!DoCommandP(v->tile, v->index, sell_cmd, NULL, CMD_SELL_RAIL_WAGON | CMD_MSG(STR_8839_CAN_T_SELL_RAILROAD_VEHICLE))) |
|
640 |
_backup_orders_tile = 0; |
|
641 |
} |
|
642 |
} break; |
|
643 |
||
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
968
diff
changeset
|
644 |
case 6: { |
0 | 645 |
GetDepotVehiclePtData gdvp; |
646 |
VehicleID sel = WP(w,traindepot_d).sel; |
|
647 |
||
648 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
649 |
SetWindowDirty(w); |
|
650 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
651 |
if (GetVehicleFromTrainDepotWndPt(w, e->dragdrop.pt.x, e->dragdrop.pt.y, &gdvp) == 0 && |
0 | 652 |
sel != INVALID_VEHICLE) { |
653 |
if (gdvp.wagon == NULL || gdvp.wagon->index != sel) { |
|
654 |
TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head); |
|
1067
a083a6dd1419
(svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents:
1019
diff
changeset
|
655 |
} else if (gdvp.head != NULL && gdvp.head->subtype == TS_Front_Engine) { |
0 | 656 |
ShowTrainViewWindow(gdvp.head); |
657 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
658 |
} |
0 | 659 |
} break; |
660 |
||
661 |
default: |
|
662 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
663 |
SetWindowDirty(w); |
|
664 |
break; |
|
665 |
} |
|
666 |
} break; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
667 |
case WE_RESIZE: { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
668 |
/* Update the scroll + matrix */ |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
669 |
w->vscroll.cap += e->sizing.diff.y / 14; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
670 |
w->hscroll.cap += e->sizing.diff.x / 29; |
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
968
diff
changeset
|
671 |
w->widget[6].unkA = (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
|
672 |
} break; |
0 | 673 |
} |
674 |
} |
|
675 |
||
676 |
static const Widget _train_depot_widgets[] = { |
|
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
968
diff
changeset
|
677 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1002
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
678 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 348, 0, 13, STR_8800_TRAIN_DEPOT, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
679 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 349, 360, 0, 13, 0x0, STR_STICKY_BUTTON}, |
0 | 680 |
|
1002
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
681 |
{ WWT_PANEL, RESIZE_LRB, 14, 326, 348, 14, 13, 0x0, STR_NULL}, |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
682 |
{ WWT_PANEL, RESIZE_LRTB, 14, 326, 348, 14, 54, 0x2A9, STR_8841_DRAG_TRAIN_VEHICLE_TO_HERE}, |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
683 |
{ WWT_PANEL, RESIZE_LRTB, 14, 326, 348, 55, 109, 0x2BF, STR_DRAG_WHOLE_TRAIN_TO_SELL_TIP}, |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
684 |
|
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
685 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 325, 14, 97, 0x601, STR_883F_TRAINS_CLICK_ON_TRAIN_FOR}, |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
686 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 349, 360, 14, 109, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
914
c3ad2a35b937
(svn r1401) -Fix: glitches in train-depot GUI (tnx to Hackykid)
truelight
parents:
894
diff
changeset
|
687 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 167, 110, 121, STR_8815_NEW_VEHICLES, STR_8840_BUILD_NEW_TRAIN_VEHICLE}, |
1002
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
688 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 168, 348, 110, 121, STR_00E4_LOCATION, STR_8842_CENTER_MAIN_VIEW_ON_TRAIN}, |
1658
bf518eb5d3b4
(svn r2162) - Fix: Tooltips of horizontal scrollbars were wrong; they now say left/right instead of up/down
Darkvater
parents:
1485
diff
changeset
|
689 |
{ WWT_HSCROLLBAR, RESIZE_RTB, 14, 0, 325, 98, 109, 0x0, STR_HSCROLL_BAR_SCROLLS_LIST}, |
1002
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
690 |
{ WWT_PANEL, RESIZE_RTB, 14, 349, 348, 110, 121, 0x0, STR_NULL}, |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
691 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 349, 360, 110, 121, 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
|
692 |
{ WIDGETS_END}, |
0 | 693 |
}; |
694 |
||
695 |
static const WindowDesc _train_depot_desc = { |
|
1002
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
696 |
-1, -1, 361, 122, |
0 | 697 |
WC_VEHICLE_DEPOT,0, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
698 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 699 |
_train_depot_widgets, |
700 |
TrainDepotWndProc |
|
701 |
}; |
|
702 |
||
703 |
||
704 |
void ShowTrainDepotWindow(uint tile) |
|
705 |
{ |
|
706 |
Window *w; |
|
707 |
||
708 |
w = AllocateWindowDescFront(&_train_depot_desc, tile); |
|
709 |
if (w) { |
|
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
|
710 |
w->caption_color = GetTileOwner(w->window_number); |
0 | 711 |
w->vscroll.cap = 6; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
712 |
w->hscroll.cap = 10; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
713 |
w->resize.step_width = 29; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
714 |
w->resize.step_height = 14; |
0 | 715 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
716 |
_backup_orders_tile = 0; |
|
717 |
} |
|
718 |
} |
|
719 |
||
720 |
static void RailVehicleRefitWndProc(Window *w, WindowEvent *e) |
|
721 |
{ |
|
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
|
722 |
switch (e->event) { |
0 | 723 |
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
|
724 |
const Vehicle *v = GetVehicle(w->window_number); |
0 | 725 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
726 |
SetDParam(0, v->string_id); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
727 |
SetDParam(1, v->unitnumber); |
0 | 728 |
DrawWindowWidgets(w); |
729 |
||
730 |
DrawString(1, 15, STR_983F_SELECT_CARGO_TYPE_TO_CARRY, 0); |
|
731 |
||
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
|
732 |
/* TODO: Support for custom GRFSpecial-specified refitting! --pasky */ |
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
|
733 |
WP(w,refit_d).cargo = DrawVehicleRefitWindow(v, WP(w, refit_d).sel); |
382
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
734 |
|
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
|
735 |
if (WP(w,refit_d).cargo != CT_INVALID) { |
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
|
736 |
int32 cost = DoCommandByTile(v->tile, v->index, WP(w,refit_d).cargo, DC_QUERY_COST, CMD_REFIT_RAIL_VEHICLE); |
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
|
737 |
if (!CmdFailed(cost)) { |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
738 |
SetDParam(2, cost); |
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
|
739 |
SetDParam(0, _cargoc.names_long_p[WP(w,refit_d).cargo]); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
740 |
SetDParam(1, _returned_refit_amount); |
0 | 741 |
DrawString(1, 137, STR_9840_NEW_CAPACITY_COST_OF_REFIT, 0); |
742 |
} |
|
743 |
} |
|
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
|
744 |
} break; |
0 | 745 |
|
746 |
case WE_CLICK: |
|
747 |
switch(e->click.widget) { |
|
748 |
case 2: { /* listbox */ |
|
749 |
int y = e->click.pt.y - 25; |
|
750 |
if (y >= 0) { |
|
751 |
WP(w,refit_d).sel = y / 10; |
|
752 |
SetWindowDirty(w); |
|
753 |
} |
|
754 |
} break; |
|
755 |
case 4: /* refit button */ |
|
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
|
756 |
if (WP(w,refit_d).cargo != CT_INVALID) { |
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
|
757 |
const Vehicle *v = GetVehicle(w->window_number); |
0 | 758 |
if (DoCommandP(v->tile, v->index, WP(w,refit_d).cargo, NULL, CMD_REFIT_RAIL_VEHICLE | CMD_MSG(STR_RAIL_CAN_T_REFIT_VEHICLE))) |
759 |
DeleteWindow(w); |
|
760 |
} |
|
761 |
break; |
|
762 |
} |
|
763 |
break; |
|
764 |
} |
|
765 |
} |
|
766 |
||
767 |
||
768 |
static const Widget _rail_vehicle_refit_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
769 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
770 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 239, 0, 13, STR_983B_REFIT, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
771 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 239, 14, 135, 0x0, STR_RAIL_SELECT_TYPE_OF_CARGO_FOR}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
772 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 239, 136, 157, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
773 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 239, 158, 169, STR_RAIL_REFIT_VEHICLE,STR_RAIL_REFIT_TO_CARRY_HIGHLIGHTED}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
774 |
{ WIDGETS_END}, |
0 | 775 |
}; |
776 |
||
777 |
static const WindowDesc _rail_vehicle_refit_desc = { |
|
778 |
-1,-1, 240, 170, |
|
779 |
WC_VEHICLE_REFIT,WC_VEHICLE_VIEW, |
|
780 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
781 |
_rail_vehicle_refit_widgets, |
|
782 |
RailVehicleRefitWndProc, |
|
783 |
}; |
|
784 |
||
785 |
static void ShowRailVehicleRefitWindow(Vehicle *v) |
|
786 |
{ |
|
787 |
Window *w; |
|
788 |
DeleteWindowById(WC_VEHICLE_REFIT, v->index); |
|
789 |
_alloc_wnd_parent_num = v->index; |
|
790 |
w = AllocateWindowDesc(&_rail_vehicle_refit_desc); |
|
791 |
w->window_number = v->index; |
|
792 |
w->caption_color = v->owner; |
|
793 |
WP(w,refit_d).sel = -1; |
|
794 |
} |
|
795 |
||
796 |
static Widget _train_view_widgets[] = { |
|
1485
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
797 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
798 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 237, 0, 13, STR_882E, STR_018C_WINDOW_TITLE_DRAG_THIS }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
799 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 238, 249, 0, 13, 0x0, STR_STICKY_BUTTON }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
800 |
{ WWT_PANEL, RESIZE_RB, 14, 0, 231, 14, 121, 0x0, STR_NULL }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
801 |
{ WWT_6, RESIZE_RB, 14, 2, 229, 16, 119, 0x0, STR_NULL }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
802 |
{ WWT_PUSHIMGBTN, RESIZE_RTB, 14, 0, 237, 122, 133, 0x0, STR_8846_CURRENT_TRAIN_ACTION_CLICK }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
803 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 14, 31, 0x2AB, STR_8848_CENTER_MAIN_VIEW_ON_TRAIN }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
804 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 32, 49, 0x2AD, STR_8849_SEND_TRAIN_TO_DEPOT }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
805 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 50, 67, 0x2B1, STR_884A_FORCE_TRAIN_TO_PROCEED }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
806 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 68, 85, 0x2CB, STR_884B_REVERSE_DIRECTION_OF_TRAIN }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
807 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 86, 103, 0x2B2, STR_8847_SHOW_TRAIN_S_ORDERS }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
808 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 104, 121, 0x2B3, STR_884C_SHOW_TRAIN_DETAILS }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
809 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 68, 85, 0x2B4, STR_RAIL_REFIT_VEHICLE_TO_CARRY }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
810 |
{ WWT_PANEL, RESIZE_LRB, 14, 232, 249, 122, 121, 0x0, STR_NULL }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
811 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 238, 249, 122, 133, 0x0, STR_NULL }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
812 |
{ WIDGETS_END } |
0 | 813 |
}; |
814 |
||
815 |
static void TrainViewWndProc(Window *w, WindowEvent *e) |
|
816 |
{ |
|
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
|
817 |
switch (e->event) { |
0 | 818 |
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
|
819 |
const Vehicle *v, *u; |
0 | 820 |
StringID str; |
821 |
||
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
822 |
v = GetVehicle(w->window_number); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
823 |
|
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
|
824 |
w->disabled_state = (v->owner == _local_player) ? 0 : 0x380; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
825 |
|
1387
eff794048d92
(svn r1891) -Fix: [ 1143587 ] carriages of newgrfs can be refitted again
celestar
parents:
1330
diff
changeset
|
826 |
SETBIT(w->disabled_state, 12); |
eff794048d92
(svn r1891) -Fix: [ 1143587 ] carriages of newgrfs can be refitted again
celestar
parents:
1330
diff
changeset
|
827 |
|
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
|
828 |
/* See if any vehicle can be refitted */ |
1387
eff794048d92
(svn r1891) -Fix: [ 1143587 ] carriages of newgrfs can be refitted again
celestar
parents:
1330
diff
changeset
|
829 |
for ( u = v; u != NULL; u = u->next) { |
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
|
830 |
if (_engine_refit_masks[u->engine_type] != 0 || |
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
|
831 |
(!(RailVehInfo(v->engine_type)->flags & RVI_WAGON) && v->cargo_cap != 0)) { |
1387
eff794048d92
(svn r1891) -Fix: [ 1143587 ] carriages of newgrfs can be refitted again
celestar
parents:
1330
diff
changeset
|
832 |
CLRBIT(w->disabled_state, 12); |
eff794048d92
(svn r1891) -Fix: [ 1143587 ] carriages of newgrfs can be refitted again
celestar
parents:
1330
diff
changeset
|
833 |
/* We have a refittable carriage, bail out */ |
eff794048d92
(svn r1891) -Fix: [ 1143587 ] carriages of newgrfs can be refitted again
celestar
parents:
1330
diff
changeset
|
834 |
break; |
eff794048d92
(svn r1891) -Fix: [ 1143587 ] carriages of newgrfs can be refitted again
celestar
parents:
1330
diff
changeset
|
835 |
} |
eff794048d92
(svn r1891) -Fix: [ 1143587 ] carriages of newgrfs can be refitted again
celestar
parents:
1330
diff
changeset
|
836 |
} |
eff794048d92
(svn r1891) -Fix: [ 1143587 ] carriages of newgrfs can be refitted again
celestar
parents:
1330
diff
changeset
|
837 |
|
0 | 838 |
/* draw widgets & caption */ |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
839 |
SetDParam(0, v->string_id); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
840 |
SetDParam(1, v->unitnumber); |
0 | 841 |
DrawWindowWidgets(w); |
842 |
||
843 |
/* draw the flag */ |
|
1485
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
844 |
DrawSprite(v->vehstatus & VS_STOPPED ? 0xC12 : 0xC13, 2, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
845 |
w->widget[5].top + 1); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
846 |
|
0 | 847 |
if (v->u.rail.crash_anim_pos != 0) { |
848 |
str = STR_8863_CRASHED; |
|
849 |
} else if (v->breakdown_ctr == 1) { |
|
850 |
str = STR_885C_BROKEN_DOWN; |
|
851 |
} else if (v->vehstatus & VS_STOPPED) { |
|
852 |
if (v->u.rail.last_speed == 0) { |
|
853 |
str = STR_8861_STOPPED; |
|
854 |
} else { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
855 |
SetDParam(0, v->u.rail.last_speed * 10 >> 4); |
0 | 856 |
str = STR_TRAIN_STOPPING + _patches.vehicle_speed; |
857 |
} |
|
858 |
} else { |
|
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
859 |
switch (v->current_order.type) { |
0 | 860 |
case OT_GOTO_STATION: { |
861 |
str = STR_HEADING_FOR_STATION + _patches.vehicle_speed; |
|
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
862 |
SetDParam(0, v->current_order.station); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
863 |
SetDParam(1, v->u.rail.last_speed * 10 >> 4); |
0 | 864 |
} break; |
865 |
||
866 |
case OT_GOTO_DEPOT: { |
|
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1299
diff
changeset
|
867 |
Depot *dep = GetDepot(v->current_order.station); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
868 |
SetDParam(0, dep->town_index); |
0 | 869 |
str = STR_HEADING_FOR_TRAIN_DEPOT + _patches.vehicle_speed; |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
870 |
SetDParam(1, v->u.rail.last_speed * 10 >> 4); |
0 | 871 |
} break; |
872 |
||
873 |
case OT_LOADING: |
|
874 |
case OT_LEAVESTATION: |
|
875 |
str = STR_882F_LOADING_UNLOADING; |
|
876 |
break; |
|
877 |
||
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
|
878 |
case OT_GOTO_WAYPOINT: { |
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
879 |
SetDParam(0, v->current_order.station); |
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
|
880 |
str = STR_HEADING_FOR_WAYPOINT + _patches.vehicle_speed; |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
881 |
SetDParam(1, v->u.rail.last_speed * 10 >> 4); |
0 | 882 |
break; |
883 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
884 |
|
0 | 885 |
default: |
886 |
if (v->num_orders == 0) { |
|
887 |
str = STR_NO_ORDERS + _patches.vehicle_speed; |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
888 |
SetDParam(0, v->u.rail.last_speed * 10 >> 4); |
0 | 889 |
} else |
890 |
str = STR_EMPTY; |
|
891 |
break; |
|
892 |
} |
|
893 |
} |
|
894 |
||
1485
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
895 |
DrawStringCentered((w->widget[5].right - w->widget[5].left) / 2, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
896 |
w->widget[5].top + 1, str, 0); |
0 | 897 |
DrawWindowViewport(w); |
898 |
} break; |
|
899 |
||
900 |
case WE_CLICK: { |
|
901 |
int wid = e->click.widget; |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
902 |
Vehicle *v = GetVehicle(w->window_number); |
0 | 903 |
|
904 |
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
|
905 |
case 5: /* start/stop train */ |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
906 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_TRAIN | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN)); |
0 | 907 |
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
|
908 |
case 6: /* center main view */ |
0 | 909 |
ScrollMainWindowTo(v->x_pos, v->y_pos); |
910 |
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
|
911 |
case 7: /* goto depot */ |
601
952c0295f79a
(svn r1025) -Fix: [Network] [ 1083687 ] Sending to depot caused desync because the
truelight
parents:
588
diff
changeset
|
912 |
/* TrainGotoDepot has a nice randomizer in the pathfinder, which causes desyncs... */ |
952c0295f79a
(svn r1025) -Fix: [Network] [ 1083687 ] Sending to depot caused desync because the
truelight
parents:
588
diff
changeset
|
913 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_TRAIN_GOTO_DEPOT | CMD_NO_TEST_IF_IN_NETWORK | CMD_MSG(STR_8830_CAN_T_SEND_TRAIN_TO_DEPOT)); |
0 | 914 |
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
|
915 |
case 8: /* force proceed */ |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
916 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_FORCE_TRAIN_PROCEED | CMD_MSG(STR_8862_CAN_T_MAKE_TRAIN_PASS_SIGNAL)); |
0 | 917 |
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
|
918 |
case 9: /* reverse direction */ |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
919 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_8869_CAN_T_REVERSE_DIRECTION)); |
0 | 920 |
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
|
921 |
case 10: /* show train orders */ |
0 | 922 |
ShowOrdersWindow(v); |
923 |
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
|
924 |
case 11: /* show train details */ |
0 | 925 |
ShowTrainDetailsWindow(v); |
926 |
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
|
927 |
case 12: |
0 | 928 |
ShowRailVehicleRefitWindow(v); |
929 |
break; |
|
930 |
} |
|
931 |
} break; |
|
932 |
||
1485
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
933 |
case WE_RESIZE: |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
934 |
w->viewport->width += e->sizing.diff.x; |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
935 |
w->viewport->height += e->sizing.diff.y; |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
936 |
w->viewport->virtual_width += e->sizing.diff.x; |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
937 |
w->viewport->virtual_height += e->sizing.diff.y; |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
938 |
break; |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
939 |
|
0 | 940 |
case WE_DESTROY: |
338
04ad3e897bf8
(svn r514) -Fix: [1053397] Refit Train Window Stays Open
tron
parents:
243
diff
changeset
|
941 |
DeleteWindowById(WC_VEHICLE_REFIT, w->window_number); |
0 | 942 |
DeleteWindowById(WC_VEHICLE_ORDERS, w->window_number); |
943 |
DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number); |
|
944 |
break; |
|
945 |
||
946 |
case WE_MOUSELOOP: { |
|
947 |
Vehicle *v; |
|
948 |
uint32 h; |
|
949 |
||
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
950 |
v = GetVehicle(w->window_number); |
0 | 951 |
assert(v->type == VEH_Train); |
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1299
diff
changeset
|
952 |
h = CheckTrainStoppedInDepot(v) >= 0 ? (1 << 9) : (1 << 12); |
0 | 953 |
if (h != w->hidden_state) { |
954 |
w->hidden_state = h; |
|
955 |
SetWindowDirty(w); |
|
956 |
} |
|
957 |
break; |
|
958 |
} |
|
959 |
||
960 |
} |
|
961 |
} |
|
962 |
||
963 |
static const WindowDesc _train_view_desc = { |
|
964 |
-1,-1, 250, 134, |
|
965 |
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
|
966 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 967 |
_train_view_widgets, |
968 |
TrainViewWndProc |
|
969 |
}; |
|
970 |
||
971 |
void ShowTrainViewWindow(Vehicle *v) |
|
972 |
{ |
|
973 |
Window *w; |
|
974 |
||
975 |
w = AllocateWindowDescFront(&_train_view_desc,v->index); |
|
976 |
if (w) { |
|
977 |
w->caption_color = v->owner; |
|
978 |
AssignWindowViewport(w, 3, 17, 0xE2, 0x66, w->window_number | (1 << 31), 0); |
|
979 |
} |
|
980 |
} |
|
981 |
||
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
|
982 |
static void TrainDetailsCargoTab(const Vehicle *v, int x, int y) |
0 | 983 |
{ |
984 |
int num; |
|
985 |
StringID str; |
|
986 |
||
987 |
if (v->cargo_cap != 0) { |
|
988 |
num = v->cargo_count; |
|
989 |
str = STR_8812_EMPTY; |
|
990 |
if (num != 0) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
991 |
SetDParam(0, v->cargo_type); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
992 |
SetDParam(1, num); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
993 |
SetDParam(2, v->cargo_source); |
0 | 994 |
str = STR_8813_FROM; |
995 |
} |
|
996 |
DrawString(x, y, str, 0); |
|
997 |
} |
|
998 |
} |
|
999 |
||
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
|
1000 |
static void TrainDetailsInfoTab(const Vehicle *v, int x, int y) |
0 | 1001 |
{ |
540
fbed599dadbb
(svn r924) Use RailVehInfo() instead of &_rail_vehicle_info[]
tron
parents:
539
diff
changeset
|
1002 |
const RailVehicleInfo *rvi = RailVehInfo(v->engine_type); |
0 | 1003 |
|
1004 |
if (!(rvi->flags & RVI_WAGON)) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1005 |
SetDParam(0, GetCustomEngineName(v->engine_type)); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1006 |
SetDParam(1, v->build_year + 1920); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1007 |
SetDParam(2, v->value); |
0 | 1008 |
DrawString(x, y, STR_882C_BUILT_VALUE, 0x10); |
1009 |
} else { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1010 |
SetDParam(0, GetCustomEngineName(v->engine_type)); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1011 |
SetDParam(1, v->value); |
0 | 1012 |
DrawString(x, y, STR_882D_VALUE, 0x10); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1013 |
} |
0 | 1014 |
} |
1015 |
||
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
|
1016 |
static void TrainDetailsCapacityTab(const Vehicle *v, int x, int y) |
0 | 1017 |
{ |
1018 |
if (v->cargo_cap != 0) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1019 |
SetDParam(1, v->cargo_cap); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1020 |
SetDParam(0, _cargoc.names_long_p[v->cargo_type]); |
0 | 1021 |
DrawString(x, y, STR_013F_CAPACITY, 0); |
1022 |
} |
|
1023 |
} |
|
1024 |
||
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
|
1025 |
typedef void TrainDetailsDrawerProc(const Vehicle *v, int x, int y); |
0 | 1026 |
|
1027 |
static TrainDetailsDrawerProc * const _train_details_drawer_proc[3] = { |
|
1028 |
TrainDetailsCargoTab, |
|
1029 |
TrainDetailsInfoTab, |
|
1030 |
TrainDetailsCapacityTab, |
|
1031 |
}; |
|
1032 |
||
1033 |
static void DrawTrainDetailsWindow(Window *w) |
|
1034 |
{ |
|
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
|
1035 |
const Vehicle *v, *u; |
0 | 1036 |
uint16 tot_cargo[NUM_CARGO][2]; // count total cargo ([0]-actual cargo, [1]-total cargo) |
1037 |
int i,num,x,y,sel; |
|
1038 |
StringID str; |
|
1039 |
byte det_tab = WP(w, traindetails_d).tab; |
|
1040 |
||
1041 |
/* Count number of vehicles */ |
|
1042 |
num = 0; |
|
1043 |
||
1044 |
// det_tab == 3 <-- Total Cargo tab |
|
1045 |
if (det_tab == 3) // reset tot_cargo array to 0 values |
|
1046 |
memset(tot_cargo, 0, sizeof(tot_cargo)); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1047 |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
1048 |
u = v = GetVehicle(w->window_number); |
0 | 1049 |
do { |
1050 |
if (det_tab != 3) |
|
1051 |
num++; |
|
1052 |
else { |
|
1053 |
tot_cargo[u->cargo_type][0] += u->cargo_count; |
|
1054 |
tot_cargo[u->cargo_type][1] += u->cargo_cap; |
|
1055 |
} |
|
1056 |
} while ( (u = u->next) != NULL); |
|
1057 |
||
1058 |
/* set scroll-amount seperately from counting, as to not |
|
1059 |
compute num double for more carriages of the same type |
|
1060 |
*/ |
|
1061 |
if (det_tab == 3) { |
|
1062 |
for (i = 0; i != NUM_CARGO; i++) { |
|
1063 |
if (tot_cargo[i][1] > 0) // only count carriages that the train has |
|
1064 |
num++; |
|
1065 |
} |
|
1066 |
num++; // needs one more because first line is description string |
|
1067 |
} |
|
1068 |
||
1069 |
SetVScrollCount(w, num); |
|
1070 |
||
1071 |
w->disabled_state = 1 << (det_tab + 9); |
|
1072 |
if (v->owner != _local_player) |
|
1073 |
w->disabled_state |= (1 << 2); |
|
1074 |
||
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
|
1075 |
if (!_patches.servint_trains) // disable service-scroller when interval is set to disabled |
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
|
1076 |
w->disabled_state |= (1 << 6) | (1 << 7); |
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
|
1077 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1078 |
SetDParam(0, v->string_id); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1079 |
SetDParam(1, v->unitnumber); |
0 | 1080 |
DrawWindowWidgets(w); |
1081 |
||
1082 |
num = v->age / 366; |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1083 |
SetDParam(1, num); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1084 |
|
0 | 1085 |
x = 2; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1086 |
|
0 | 1087 |
str = STR_0199_YEAR; |
1088 |
if (num != 1) { |
|
1089 |
str += STR_019A_YEARS - STR_0199_YEAR; |
|
1090 |
if ((uint16)(v->max_age - 366) < v->age) |
|
1091 |
str += STR_019B_YEARS - STR_019A_YEARS; |
|
1092 |
} |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1093 |
SetDParam(0, str); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1094 |
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
|
1095 |
SetDParam(3, GetTrainRunningCost(v) >> 8); |
0 | 1096 |
DrawString(x, 15, STR_885D_AGE_RUNNING_COST_YR, 0); |
1097 |
||
1905
f43d9e821deb
(svn r2411) - Codechange: Have trains cache stuff like consist power/weight/max speed instead of recalculating it each time.
hackykid
parents:
1901
diff
changeset
|
1098 |
SetDParam(2, v->u.rail.cached_max_speed * 10 >> 4); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1099 |
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
|
1100 |
SetDParam(0, v->u.rail.cached_weight); |
0 | 1101 |
DrawString(x, 25, STR_885E_WEIGHT_T_POWER_HP_MAX_SPEED, 0); |
1102 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1103 |
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
|
1104 |
SetDParam(1, v->profit_last_year); |
0 | 1105 |
DrawString(x, 35, STR_885F_PROFIT_THIS_YEAR_LAST_YEAR, 0); |
1106 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1107 |
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
|
1108 |
SetDParam(1, v->breakdowns_since_last_service); |
0 | 1109 |
DrawString(x, 45, STR_8860_RELIABILITY_BREAKDOWNS, 0); |
1110 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1111 |
SetDParam(0, v->service_interval); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1112 |
SetDParam(1, v->date_of_last_service); |
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
|
1113 |
DrawString(x + 11, 141, _patches.servint_ispercent?STR_SERVICING_INTERVAL_PERCENT:STR_883C_SERVICING_INTERVAL_DAYS, 0); |
0 | 1114 |
|
1115 |
x = 1; |
|
1116 |
y = 57; |
|
1117 |
sel = w->vscroll.pos; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1118 |
|
0 | 1119 |
// draw the first 3 details tabs |
1120 |
if (det_tab != 3) { |
|
1121 |
for(;;) { |
|
1122 |
if (--sel < 0 && sel >= -6) { |
|
1123 |
DrawTrainImage(v, x, y, 1, 0, INVALID_VEHICLE); |
|
1124 |
_train_details_drawer_proc[WP(w,traindetails_d).tab](v, x + 30, y + 2); |
|
1125 |
y += 14; |
|
1126 |
} |
|
1127 |
if ( (v=v->next) == NULL) |
|
1128 |
return; |
|
1129 |
} |
|
1130 |
} |
|
1131 |
else { // draw total cargo tab |
|
1132 |
i = 0; |
|
1133 |
DrawString(x, y + 2, STR_013F_TOTAL_CAPACITY_TEXT, 0); |
|
1134 |
do { |
|
1135 |
if (tot_cargo[i][1] > 0 && --sel < 0 && sel >= -5) { |
|
1136 |
y += 14; |
|
1137 |
// STR_013F_TOTAL_CAPACITY :{LTBLUE}- {CARGO} ({SHORTCARGO}) |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1138 |
SetDParam(0, i); // {CARGO} #1 |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1139 |
SetDParam(1, tot_cargo[i][0]); // {CARGO} #2 |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1140 |
SetDParam(2, i); // {SHORTCARGO} #1 |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1141 |
SetDParam(3, tot_cargo[i][1]); // {SHORTCARGO} #2 |
0 | 1142 |
DrawString(x, y, STR_013F_TOTAL_CAPACITY, 0); |
1143 |
} |
|
1144 |
} while (++i != NUM_CARGO); |
|
1145 |
} |
|
1146 |
} |
|
1147 |
||
1148 |
static void TrainDetailsWndProc(Window *w, WindowEvent *e) |
|
1149 |
{ |
|
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
|
1150 |
switch (e->event) { |
0 | 1151 |
case WE_PAINT: |
1152 |
DrawTrainDetailsWindow(w); |
|
1153 |
break; |
|
1154 |
case WE_CLICK: { |
|
1155 |
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
|
1156 |
const Vehicle *v; |
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
|
1157 |
switch (e->click.widget) { |
0 | 1158 |
case 2: /* name train */ |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
1159 |
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
|
1160 |
SetDParam(0, v->unitnumber); |
0 | 1161 |
ShowQueryString(v->string_id, STR_8865_NAME_TRAIN, 31, 150, w->window_class, w->window_number); |
1162 |
break; |
|
1163 |
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
|
1164 |
mod = _ctrl_pressed? 5 : 10; |
0 | 1165 |
goto do_change_service_int; |
1166 |
||
1167 |
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
|
1168 |
mod = _ctrl_pressed? -5 : -10; |
0 | 1169 |
do_change_service_int: |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
1170 |
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
|
1171 |
|
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
|
1172 |
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
|
1173 |
if (mod == v->service_interval) return; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1174 |
|
0 | 1175 |
DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_TRAIN_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING)); |
1176 |
break; |
|
1177 |
/* details buttons*/ |
|
1178 |
case 9: // Cargo |
|
1179 |
case 10: // Information |
|
1180 |
case 11: // Capacities |
|
1181 |
case 12: // Total cargo |
|
1182 |
CLRBIT(w->disabled_state, 9); |
|
1183 |
CLRBIT(w->disabled_state, 10); |
|
1184 |
CLRBIT(w->disabled_state, 11); |
|
1185 |
CLRBIT(w->disabled_state, 12); |
|
1186 |
SETBIT(w->disabled_state, e->click.widget); |
|
1187 |
WP(w,traindetails_d).tab = e->click.widget - 9; |
|
1188 |
SetWindowDirty(w); |
|
1189 |
break; |
|
1190 |
} |
|
1191 |
} break; |
|
1192 |
||
1193 |
case WE_4: |
|
1194 |
if (FindWindowById(WC_VEHICLE_VIEW, w->window_number) == NULL) |
|
1195 |
DeleteWindow(w); |
|
1196 |
break; |
|
1197 |
||
1198 |
case WE_ON_EDIT_TEXT: { |
|
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
|
1199 |
if (e->edittext.str[0] != '\0') { |
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
|
1200 |
_cmd_text = e->edittext.str; |
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
|
1201 |
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
|
1202 |
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
|
1203 |
} |
0 | 1204 |
} break; |
1205 |
} |
|
1206 |
} |
|
1207 |
||
1208 |
static const Widget _train_details_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1209 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1210 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 329, 0, 13, STR_8802_DETAILS,STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1211 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 330, 369, 0, 13, STR_01AA_NAME, STR_8867_NAME_TRAIN}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1212 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 369, 14, 55, 0x0, STR_NULL}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
1213 |
{ WWT_MATRIX, RESIZE_NONE, 14, 0, 357, 56, 139, 0x601, STR_NULL}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
1214 |
{ WWT_SCROLLBAR, RESIZE_NONE, 14, 358, 369, 56, 139, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1215 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 10, 140, 145, STR_0188, STR_884D_INCREASE_SERVICING_INTERVAL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1216 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 10, 146, 151, STR_0189, STR_884E_DECREASE_SERVICING_INTERVAL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1217 |
{ WWT_PANEL, RESIZE_NONE, 14, 11, 369, 140, 151, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1218 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 92, 152, 163, STR_013C_CARGO, STR_884F_SHOW_DETAILS_OF_CARGO_CARRIED}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1219 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 93, 184, 152, 163, STR_013D_INFORMATION, STR_8850_SHOW_DETAILS_OF_TRAIN_VEHICLES}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1220 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 185, 277, 152, 163, STR_013E_CAPACITIES, STR_8851_SHOW_CAPACITIES_OF_EACH}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1221 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 278, 369, 152, 163, STR_013E_TOTAL_CARGO, STR_8852_SHOW_TOTAL_CARGO}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
1222 |
{ WIDGETS_END}, |
0 | 1223 |
}; |
1224 |
||
1225 |
||
1226 |
static const WindowDesc _train_details_desc = { |
|
1227 |
-1,-1, 370, 164, |
|
1228 |
WC_VEHICLE_DETAILS,WC_VEHICLE_VIEW, |
|
1229 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
1230 |
_train_details_widgets, |
|
1231 |
TrainDetailsWndProc |
|
1232 |
}; |
|
1233 |
||
1234 |
||
1235 |
void ShowTrainDetailsWindow(Vehicle *v) |
|
1236 |
{ |
|
1237 |
Window *w; |
|
1238 |
VehicleID veh = v->index; |
|
1239 |
||
1240 |
DeleteWindowById(WC_VEHICLE_ORDERS, veh); |
|
1241 |
DeleteWindowById(WC_VEHICLE_DETAILS, veh); |
|
1242 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1243 |
_alloc_wnd_parent_num = veh; |
0 | 1244 |
w = AllocateWindowDesc(&_train_details_desc); |
1245 |
||
1246 |
w->window_number = veh; |
|
1247 |
w->caption_color = v->owner; |
|
1248 |
w->vscroll.cap = 6; |
|
1249 |
WP(w,traindetails_d).tab = 0; |
|
1250 |
} |
|
1251 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1252 |
static const Widget _player_trains_widgets[] = { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1253 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1254 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 312, 0, 13, STR_881B_TRAINS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1255 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 313, 324, 0, 13, 0x0, STR_STICKY_BUTTON}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1256 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_ORDER_TIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1257 |
{ WWT_PANEL, RESIZE_NONE, 14, 81, 232, 14, 25, 0x0, STR_SORT_CRITERIA_TIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1258 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 233, 243, 14, 25, STR_0225, STR_SORT_CRITERIA_TIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1259 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 244, 324, 14, 25, 0x0, STR_NULL}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
1260 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 312, 26, 207, 0x701, STR_883D_TRAINS_CLICK_ON_TRAIN_FOR}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
1261 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 313, 324, 26, 207, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1262 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 156, 208, 219, STR_8815_NEW_VEHICLES, STR_883E_BUILD_NEW_TRAINS_REQUIRES}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
1263 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 157, 312, 208, 219, STR_REPLACE_VEHICLES, STR_REPLACE_HELP}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
1264 |
{ WWT_PANEL, RESIZE_RTB, 14, 313, 312, 208, 219, 0x0, STR_NULL}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
1265 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 313, 324, 208, 219, 0x0, STR_RESIZE_BUTTON}, |
588 | 1266 |
{ WIDGETS_END}, |
1267 |
}; |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1268 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1269 |
static const Widget _other_player_trains_widgets[] = { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1270 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1271 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 312, 0, 13, STR_881B_TRAINS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1272 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 313, 324, 0, 13, 0x0, STR_STICKY_BUTTON}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1273 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_ORDER_TIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1274 |
{ WWT_PANEL, RESIZE_NONE, 14, 81, 232, 14, 25, 0x0, STR_SORT_CRITERIA_TIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1275 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 233, 243, 14, 25, STR_0225, STR_SORT_CRITERIA_TIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1276 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 244, 324, 14, 25, 0x0, STR_NULL}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
1277 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 312, 26, 207, 0x701, STR_883D_TRAINS_CLICK_ON_TRAIN_FOR}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
1278 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 313, 324, 26, 207, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
1279 |
{ WWT_PANEL, RESIZE_RTB, 14, 0, 312, 208, 219, 0x0, STR_NULL}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
1280 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 313, 324, 208, 219, 0x0, STR_RESIZE_BUTTON}, |
588 | 1281 |
{ WIDGETS_END}, |
1282 |
}; |
|
0 | 1283 |
|
1284 |
static void PlayerTrainsWndProc(Window *w, WindowEvent *e) |
|
1285 |
{ |
|
588 | 1286 |
int station = (int)w->window_number >> 16; |
1287 |
int owner = w->window_number & 0xff; |
|
1288 |
vehiclelist_d *vl = &WP(w, vehiclelist_d); |
|
1289 |
||
0 | 1290 |
switch(e->event) { |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1291 |
case WE_PAINT: { |
588 | 1292 |
int x = 2; |
1293 |
int y = PLY_WND_PRC__OFFSET_TOP_WIDGET; |
|
1294 |
int max; |
|
1295 |
int i; |
|
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1296 |
|
588 | 1297 |
BuildVehicleList(vl, VEH_Train, owner, station); |
1298 |
SortVehicleList(vl); |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1299 |
|
588 | 1300 |
SetVScrollCount(w, vl->list_length); |
1301 |
||
1302 |
// disable 'Sort By' tooltip on Unsorted sorting criteria |
|
1303 |
if (vl->sort_type == SORT_BY_UNSORTED) |
|
757 | 1304 |
w->disabled_state |= (1 << 3); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1305 |
|
0 | 1306 |
/* draw the widgets */ |
1307 |
{ |
|
588 | 1308 |
const Player *p = DEREF_PLAYER(owner); |
1309 |
if (station == -1) { |
|
1310 |
/* Company Name -- (###) Trains */ |
|
1311 |
SetDParam(0, p->name_1); |
|
1312 |
SetDParam(1, p->name_2); |
|
1313 |
SetDParam(2, w->vscroll.count); |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1314 |
w->widget[1].unkA = STR_881B_TRAINS; |
588 | 1315 |
} else { |
1316 |
/* Station Name -- (###) Trains */ |
|
1294
bc831562148e
(svn r1798) GetFoo(i)->index is per definition i, so replace the former with the latter
tron
parents:
1246
diff
changeset
|
1317 |
SetDParam(0, station); |
588 | 1318 |
SetDParam(1, w->vscroll.count); |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1319 |
w->widget[1].unkA = STR_SCHEDULED_TRAINS; |
588 | 1320 |
} |
0 | 1321 |
DrawWindowWidgets(w); |
1322 |
} |
|
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
1323 |
/* draw sorting criteria string */ |
588 | 1324 |
DrawString(85, 15, _vehicle_sort_listing[vl->sort_type], 0x10); |
1325 |
/* draw arrow pointing up/down for ascending/descending sorting */ |
|
1246
45f15251412b
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents:
1179
diff
changeset
|
1326 |
DoDrawString(vl->flags & VL_DESC ? "\xAA" : "\xA0", 69, 15, 0x10); |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1327 |
|
588 | 1328 |
max = min(w->vscroll.pos + w->vscroll.cap, vl->list_length); |
1329 |
for (i = w->vscroll.pos; i < max; ++i) { |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
1330 |
Vehicle *v = GetVehicle(vl->sort_list[i].index); |
588 | 1331 |
StringID str; |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1332 |
|
588 | 1333 |
assert(v->type == VEH_Train && v->owner == owner); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1334 |
|
588 | 1335 |
DrawTrainImage( |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1336 |
v, x + 21, y + 6 + _traininfo_vehicle_pitch, w->hscroll.cap, 0, INVALID_VEHICLE); |
588 | 1337 |
DrawVehicleProfitButton(v, x, y + 13); |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1338 |
|
588 | 1339 |
SetDParam(0, v->unitnumber); |
1330
8a67d04016ce
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1323
diff
changeset
|
1340 |
if (IsTileDepotType(v->tile, TRANSPORT_RAIL) && (v->vehstatus & VS_HIDDEN)) |
588 | 1341 |
str = STR_021F; |
1342 |
else |
|
1343 |
str = v->age > v->max_age - 366 ? STR_00E3 : STR_00E2; |
|
1344 |
DrawString(x, y + 2, str, 0); |
|
1345 |
||
1346 |
SetDParam(0, v->profit_this_year); |
|
1347 |
SetDParam(1, v->profit_last_year); |
|
1348 |
DrawString(x + 21, y + 18, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 0); |
|
1349 |
||
1350 |
if (v->string_id != STR_SV_TRAIN_NAME) { |
|
1351 |
SetDParam(0, v->string_id); |
|
1352 |
DrawString(x + 21, y, STR_01AB, 0); |
|
0 | 1353 |
} |
588 | 1354 |
|
1355 |
y += PLY_WND_PRC__SIZE_OF_ROW_SMALL; |
|
0 | 1356 |
} |
588 | 1357 |
break; |
1358 |
} |
|
0 | 1359 |
|
1360 |
case WE_CLICK: { |
|
1361 |
switch(e->click.widget) { |
|
757 | 1362 |
case 3: /* Flip sorting method ascending/descending */ |
588 | 1363 |
vl->flags ^= VL_DESC; |
1364 |
vl->flags |= VL_RESORT; |
|
1246
45f15251412b
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents:
1179
diff
changeset
|
1365 |
_sorting.train.order = !!(vl->flags & VL_DESC); |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1366 |
SetWindowDirty(w); |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1367 |
break; |
588 | 1368 |
|
757 | 1369 |
case 4: case 5:/* Select sorting criteria dropdown menu */ |
842 | 1370 |
ShowDropDownMenu(w, _vehicle_sort_listing, vl->sort_type, 5, 0, 0); |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1371 |
return; |
588 | 1372 |
|
757 | 1373 |
case 7: { /* Matrix to show vehicles */ |
174
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
168
diff
changeset
|
1374 |
uint32 id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_SMALL; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1375 |
|
174
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
168
diff
changeset
|
1376 |
if (id_v >= w->vscroll.cap) { return;} // click out of bounds |
0 | 1377 |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1378 |
id_v += w->vscroll.pos; |
0 | 1379 |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1380 |
{ |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1381 |
Vehicle *v; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1382 |
|
588 | 1383 |
if (id_v >= vl->list_length) return; // click out of list bound |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1384 |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
1385 |
v = GetVehicle(vl->sort_list[id_v].index); |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1386 |
|
1067
a083a6dd1419
(svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents:
1019
diff
changeset
|
1387 |
assert(v->type == VEH_Train && v->subtype == TS_Front_Engine && v->owner == owner); |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1388 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1389 |
ShowTrainViewWindow(v); |
0 | 1390 |
} |
1391 |
} break; |
|
1392 |
||
757 | 1393 |
case 9: { /* Build new Vehicle */ |
0 | 1394 |
uint tile; |
1395 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1396 |
if (!IsWindowOfPrototype(w, _player_trains_widgets)) |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1397 |
break; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1398 |
|
0 | 1399 |
tile = _last_built_train_depot_tile; |
1400 |
do { |
|
1906
f5ae1d8ad052
(svn r2412) - Fix: [ 1214948 ] building vehicles without depot crashes game. (Chris Huebsch)
hackykid
parents:
1905
diff
changeset
|
1401 |
if (IsTileDepotType(tile, TRANSPORT_RAIL) && IsTileOwner(tile, _local_player)) { |
0 | 1402 |
ShowTrainDepotWindow(tile); |
1403 |
ShowBuildTrainWindow(tile); |
|
1404 |
return; |
|
1405 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1406 |
|
0 | 1407 |
tile = TILE_MASK(tile + 1); |
1408 |
} while(tile != _last_built_train_depot_tile); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1409 |
|
0 | 1410 |
ShowBuildTrainWindow(0); |
1411 |
} break; |
|
842 | 1412 |
case 10: { |
886
4442d7859ea7
(svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight
parents:
878
diff
changeset
|
1413 |
if (!IsWindowOfPrototype(w, _player_trains_widgets)) |
4442d7859ea7
(svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight
parents:
878
diff
changeset
|
1414 |
break; |
4442d7859ea7
(svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight
parents:
878
diff
changeset
|
1415 |
|
842 | 1416 |
ShowReplaceVehicleWindow(VEH_Train); |
1417 |
break; |
|
1418 |
} |
|
1419 |
||
0 | 1420 |
} |
1421 |
} break; |
|
1422 |
||
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1423 |
case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */ |
588 | 1424 |
if (vl->sort_type != e->dropdown.index) { |
1425 |
// value has changed -> resort |
|
1426 |
vl->flags |= VL_RESORT; |
|
1427 |
vl->sort_type = e->dropdown.index; |
|
1246
45f15251412b
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents:
1179
diff
changeset
|
1428 |
_sorting.train.criteria = vl->sort_type; |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1429 |
|
588 | 1430 |
// enable 'Sort By' if a sorter criteria is chosen |
1431 |
if (vl->sort_type != SORT_BY_UNSORTED) |
|
1246
45f15251412b
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents:
1179
diff
changeset
|
1432 |
CLRBIT(w->disabled_state, 3); |
588 | 1433 |
} |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1434 |
SetWindowDirty(w); |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1435 |
break; |
588 | 1436 |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1437 |
case WE_CREATE: /* set up resort timer */ |
588 | 1438 |
vl->sort_list = NULL; |
1246
45f15251412b
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents:
1179
diff
changeset
|
1439 |
vl->flags = VL_REBUILD | (_sorting.train.order << (VL_DESC - 1)); |
45f15251412b
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents:
1179
diff
changeset
|
1440 |
vl->sort_type = _sorting.train.criteria; |
588 | 1441 |
vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1442 |
break; |
588 | 1443 |
|
767 | 1444 |
case WE_DESTROY: |
1445 |
free(vl->sort_list); |
|
1446 |
break; |
|
1447 |
||
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1448 |
case WE_TICK: /* resort the list every 20 seconds orso (10 days) */ |
588 | 1449 |
if (--vl->resort_timer == 0) { |
1450 |
DEBUG(misc, 1) ("Periodic resort trains list player %d station %d", |
|
1451 |
owner, station); |
|
1452 |
vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; |
|
1453 |
vl->flags |= VL_RESORT; |
|
1454 |
SetWindowDirty(w); |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1455 |
} |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1456 |
break; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1457 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1458 |
case WE_RESIZE: |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1459 |
/* Update the scroll + matrix */ |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1460 |
w->hscroll.cap += e->sizing.diff.x / 29; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1461 |
w->vscroll.cap += e->sizing.diff.y / PLY_WND_PRC__SIZE_OF_ROW_SMALL; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1462 |
w->widget[7].unkA = (w->vscroll.cap << 8) + 1; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1463 |
break; |
0 | 1464 |
} |
1465 |
} |
|
1466 |
||
1467 |
static const WindowDesc _player_trains_desc = { |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1468 |
-1, -1, 325, 220, |
0 | 1469 |
WC_TRAINS_LIST,0, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1470 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 1471 |
_player_trains_widgets, |
1472 |
PlayerTrainsWndProc |
|
1473 |
}; |
|
1474 |
||
1475 |
static const WindowDesc _other_player_trains_desc = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1476 |
-1, -1, 325, 220, |
0 | 1477 |
WC_TRAINS_LIST,0, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1478 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 1479 |
_other_player_trains_widgets, |
1480 |
PlayerTrainsWndProc |
|
1481 |
}; |
|
1482 |
||
588 | 1483 |
void ShowPlayerTrains(int player, int station) |
0 | 1484 |
{ |
1485 |
Window *w; |
|
1486 |
||
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1487 |
if (player == _local_player) { |
588 | 1488 |
w = AllocateWindowDescFront(&_player_trains_desc, (station << 16) | player); |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1489 |
} else { |
588 | 1490 |
w = AllocateWindowDescFront(&_other_player_trains_desc, (station << 16) | player); |
0 | 1491 |
} |
1492 |
if (w) { |
|
1402
05f6d79373ee
(svn r1906) - Fix: [ 1117327 ] Assertion error on kick. When a company is cleaned all its windows need to be closed. For global vehicle lists, the no-staiton index of -1 was not taken into account
Darkvater
parents:
1387
diff
changeset
|
1493 |
w->caption_color = player; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1494 |
w->hscroll.cap = 10; |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1495 |
w->vscroll.cap = 7; // maximum number of vehicles shown |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1496 |
w->widget[7].unkA = (w->vscroll.cap << 8) + 1; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1497 |
w->resize.step_height = PLY_WND_PRC__SIZE_OF_ROW_SMALL; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1498 |
w->resize.step_width = 29; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1499 |
w->resize.height = 220 - (PLY_WND_PRC__SIZE_OF_ROW_SMALL * 3); /* Minimum of 4 vehicles */ |
0 | 1500 |
} |
1501 |
} |