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