| author | Darkvater | 
| Mon, 13 Mar 2006 23:20:24 +0000 | |
| changeset 3194 | 8059a48ec9f6 | 
| parent 3157 | 3f35e2d9c8e3 | 
| child 3242 | 4c32bf21153b | 
| 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"  | 
| 
2676
 
59b65b4fb480
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
 
bjarni 
parents: 
2639 
diff
changeset
 | 
21  | 
#include "train.h"  | 
| 
2962
 
f0a49b646c48
(svn r3524) - Split newgrf features from engine.[ch] into newgrf_engine.[ch], and add the new files to project files.
 
peter1138 
parents: 
2959 
diff
changeset
 | 
22  | 
#include "newgrf_engine.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
 | 
23  | 
|
| 
 
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
 | 
24  | 
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
 | 
25  | 
|
| 
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
 | 
26  | 
/**  | 
| 
 
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  | 
* 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
 | 
28  | 
* @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
 | 
29  | 
* @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
 | 
30  | 
*/  | 
| 
 
61bafb476865
(svn r2413)  - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
 
hackykid 
parents: 
1906 
diff
changeset
 | 
31  | 
void DrawTrainEnginePurchaseInfo(int x, int y, EngineID engine_number)  | 
| 842 | 32  | 
{
 | 
33  | 
const RailVehicleInfo *rvi = RailVehInfo(engine_number);  | 
|
| 
1926
 
530480d14685
(svn r2432) Use GetEngine() instead of DEREF_ENGINE() or even _engines[]
 
tron 
parents: 
1922 
diff
changeset
 | 
34  | 
const Engine* e = GetEngine(engine_number);  | 
| 842 | 35  | 
int multihead = (rvi->flags&RVI_MULTIHEAD?1:0);  | 
36  | 
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
 | 
37  | 
ConvertDayToYMD(&ymd, e->intro_date);  | 
| 842 | 38  | 
|
| 
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
 | 
39  | 
/* Purchase Cost - Engine weight */  | 
| 842 | 40  | 
SetDParam(0, rvi->base_cost * (_price.build_railvehicle >> 3) >> 5);  | 
41  | 
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
 | 
42  | 
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
 | 
43  | 
y += 10;  | 
| 842 | 44  | 
|
| 
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
 | 
45  | 
/* 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
 | 
46  | 
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
 | 
47  | 
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
 | 
48  | 
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
 | 
49  | 
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
 | 
50  | 
|
| 
 
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  | 
/* Running cost */  | 
| 
2840
 
9038b4ab8c9a
(svn r3388) - NewGRF: Allow train running cost class to differ from engine class. Also fix typo in r3384.
 
peter1138 
parents: 
2822 
diff
changeset
 | 
52  | 
SetDParam(0, (rvi->running_cost_base * _price.running_rail[rvi->running_cost_class] >> 8) << multihead);  | 
| 
1907
 
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  | 
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
 | 
54  | 
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
 | 
55  | 
|
| 
1908
 
2fa391fed79a
(svn r2414)  - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
 
hackykid 
parents: 
1907 
diff
changeset
 | 
56  | 
/* Powered wagons power - Powered wagons extra weight */  | 
| 
 
2fa391fed79a
(svn r2414)  - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
 
hackykid 
parents: 
1907 
diff
changeset
 | 
57  | 
	if (rvi->pow_wag_power != 0) {
 | 
| 
 
2fa391fed79a
(svn r2414)  - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
 
hackykid 
parents: 
1907 
diff
changeset
 | 
58  | 
SetDParam(0, rvi->pow_wag_power);  | 
| 
 
2fa391fed79a
(svn r2414)  - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
 
hackykid 
parents: 
1907 
diff
changeset
 | 
59  | 
SetDParam(1, rvi->pow_wag_weight);  | 
| 
 
2fa391fed79a
(svn r2414)  - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
 
hackykid 
parents: 
1907 
diff
changeset
 | 
60  | 
DrawString(x,y, STR_PURCHASE_INFO_PWAGPOWER_PWAGWEIGHT, 0);  | 
| 
 
2fa391fed79a
(svn r2414)  - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
 
hackykid 
parents: 
1907 
diff
changeset
 | 
61  | 
y += 10;  | 
| 
 
2fa391fed79a
(svn r2414)  - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
 
hackykid 
parents: 
1907 
diff
changeset
 | 
62  | 
};  | 
| 
 
2fa391fed79a
(svn r2414)  - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
 
hackykid 
parents: 
1907 
diff
changeset
 | 
63  | 
|
| 
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
 | 
64  | 
/* 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
 | 
65  | 
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
 | 
66  | 
SetDParam(2, STR_EMPTY);  | 
| 842 | 67  | 
	if (rvi->capacity != 0) {
 | 
| 
2084
 
65639f898a50
(svn r2594) Fix: [strgen] Misc updates to the string system.
 
ludde 
parents: 
2049 
diff
changeset
 | 
68  | 
SetDParam(0, _cargoc.names_long[rvi->cargo_type]);  | 
| 
1907
 
61bafb476865
(svn r2413)  - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
 
hackykid 
parents: 
1906 
diff
changeset
 | 
69  | 
SetDParam(1, rvi->capacity << multihead);  | 
| 
 
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  | 
SetDParam(2, STR_9842_REFITTABLE);  | 
| 842 | 71  | 
}  | 
| 
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
 | 
72  | 
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
 | 
73  | 
y += 10;  | 
| 842 | 74  | 
|
| 
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
 | 
75  | 
/* 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
 | 
76  | 
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
 | 
77  | 
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
 | 
78  | 
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
 | 
79  | 
y += 10;  | 
| 842 | 80  | 
|
| 
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
 | 
81  | 
/* 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
 | 
82  | 
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
 | 
83  | 
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
 | 
84  | 
y += 10;  | 
| 842 | 85  | 
}  | 
86  | 
||
| 
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
 | 
87  | 
/**  | 
| 
 
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  | 
* 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
 | 
89  | 
* @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
 | 
90  | 
* @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
 | 
91  | 
*/  | 
| 
 
61bafb476865
(svn r2413)  - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
 
hackykid 
parents: 
1906 
diff
changeset
 | 
92  | 
void DrawTrainWagonPurchaseInfo(int x, int y, EngineID engine_number)  | 
| 842 | 93  | 
{
 | 
94  | 
const RailVehicleInfo *rvi = RailVehInfo(engine_number);  | 
|
| 
2611
 
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
 
peter1138 
parents: 
2602 
diff
changeset
 | 
95  | 
bool refittable = (_engine_info[engine_number].refit_mask != 0);  | 
| 
867
 
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
 
truelight 
parents: 
842 
diff
changeset
 | 
96  | 
|
| 
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
 | 
97  | 
/* 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
 | 
98  | 
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
 | 
99  | 
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
 | 
100  | 
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
 | 
101  | 
|
| 
 
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  | 
/* 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
 | 
103  | 
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
 | 
104  | 
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
 | 
105  | 
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
 | 
106  | 
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
 | 
107  | 
|
| 
 
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  | 
/* Cargo type + capacity */  | 
| 
2084
 
65639f898a50
(svn r2594) Fix: [strgen] Misc updates to the string system.
 
ludde 
parents: 
2049 
diff
changeset
 | 
109  | 
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
 | 
110  | 
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
 | 
111  | 
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
 | 
112  | 
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
 | 
113  | 
y += 10;  | 
| 
2443
 
dd16304c477d
(svn r2969) -Newgrf: Show a wagon's speed limit in purchase list.
 
peter1138 
parents: 
2436 
diff
changeset
 | 
114  | 
|
| 
 
dd16304c477d
(svn r2969) -Newgrf: Show a wagon's speed limit in purchase list.
 
peter1138 
parents: 
2436 
diff
changeset
 | 
115  | 
/* Wagon speed limit, displayed if above zero */  | 
| 
2456
 
2317dd6f4b19
(svn r2982) Newgrf: Added patch option for wagon speed limits. This is enabled by default.
 
peter1138 
parents: 
2443 
diff
changeset
 | 
116  | 
	if (rvi->max_speed > 0 && _patches.wagon_speed_limits) {
 | 
| 
2443
 
dd16304c477d
(svn r2969) -Newgrf: Show a wagon's speed limit in purchase list.
 
peter1138 
parents: 
2436 
diff
changeset
 | 
117  | 
SetDParam(0, rvi->max_speed * 10 >> 4);  | 
| 
 
dd16304c477d
(svn r2969) -Newgrf: Show a wagon's speed limit in purchase list.
 
peter1138 
parents: 
2436 
diff
changeset
 | 
118  | 
DrawString(x,y, STR_PURCHASE_INFO_SPEED, 0);  | 
| 
 
dd16304c477d
(svn r2969) -Newgrf: Show a wagon's speed limit in purchase list.
 
peter1138 
parents: 
2436 
diff
changeset
 | 
119  | 
y += 10;  | 
| 
 
dd16304c477d
(svn r2969) -Newgrf: Show a wagon's speed limit in purchase list.
 
peter1138 
parents: 
2436 
diff
changeset
 | 
120  | 
}  | 
| 842 | 121  | 
}  | 
| 0 | 122  | 
|
| 
1977
 
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
 
tron 
parents: 
1962 
diff
changeset
 | 
123  | 
void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2)  | 
| 0 | 124  | 
{
 | 
125  | 
Vehicle *v,*found;  | 
|
126  | 
||
127  | 
if (!success)  | 
|
128  | 
return;  | 
|
129  | 
||
130  | 
// find a locomotive in the depot.  | 
|
131  | 
found = NULL;  | 
|
132  | 
	FOR_ALL_VEHICLES(v) {
 | 
|
| 
2676
 
59b65b4fb480
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
 
bjarni 
parents: 
2639 
diff
changeset
 | 
133  | 
if (v->type == VEH_Train && IsFrontEngine(v) &&  | 
| 0 | 134  | 
v->tile == tile &&  | 
135  | 
				v->u.rail.track == 0x80) {
 | 
|
136  | 
if (found != NULL) // must be exactly one.  | 
|
137  | 
return;  | 
|
138  | 
found = v;  | 
|
139  | 
}  | 
|
140  | 
}  | 
|
141  | 
||
142  | 
// if we found a loco,  | 
|
143  | 
	if (found != NULL) {
 | 
|
144  | 
found = GetLastVehicleInChain(found);  | 
|
145  | 
// put the new wagon at the end of the loco.  | 
|
146  | 
DoCommandP(0, _new_wagon_id | (found->index<<16), 0, NULL, CMD_MOVE_RAIL_VEHICLE);  | 
|
| 588 | 147  | 
RebuildVehicleLists();  | 
| 0 | 148  | 
}  | 
149  | 
}  | 
|
150  | 
||
| 
1977
 
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
 
tron 
parents: 
1962 
diff
changeset
 | 
151  | 
void CcBuildLoco(bool success, TileIndex tile, uint32 p1, uint32 p2)  | 
| 0 | 152  | 
{
 | 
| 2630 | 153  | 
const Vehicle* v;  | 
| 0 | 154  | 
|
| 2639 | 155  | 
if (!success) return;  | 
| 
193
 
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
 
truelight 
parents: 
176 
diff
changeset
 | 
156  | 
|
| 
919
 
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
 
truelight 
parents: 
914 
diff
changeset
 | 
157  | 
v = GetVehicle(_new_train_id);  | 
| 0 | 158  | 
	if (tile == _backup_orders_tile) {
 | 
159  | 
_backup_orders_tile = 0;  | 
|
160  | 
RestoreVehicleOrders(v, _backup_orders_data);  | 
|
161  | 
}  | 
|
162  | 
ShowTrainViewWindow(v);  | 
|
163  | 
}  | 
|
164  | 
||
| 2244 | 165  | 
void CcCloneTrain(bool success, uint tile, uint32 p1, uint32 p2)  | 
166  | 
{
 | 
|
| 2639 | 167  | 
if (success) ShowTrainViewWindow(GetVehicle(_new_train_id));  | 
| 2244 | 168  | 
}  | 
169  | 
||
| 
524
 
bcbcedbf5ccd
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
 
darkvater 
parents: 
517 
diff
changeset
 | 
170  | 
static void engine_drawing_loop(int *x, int *y, int *pos, int *sel,  | 
| 
2520
 
8a52362c4ada
(svn r3049) Replace byte/int/uint by RailType where appropriate
 
tron 
parents: 
2518 
diff
changeset
 | 
171  | 
EngineID* selected_id, RailType 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
 | 
172  | 
{
 | 
| 
2971
 
cae3a81e8674
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
 
peter1138 
parents: 
2962 
diff
changeset
 | 
173  | 
EngineID j;  | 
| 
524
 
bcbcedbf5ccd
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
 
darkvater 
parents: 
517 
diff
changeset
 | 
174  | 
|
| 
2971
 
cae3a81e8674
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
 
peter1138 
parents: 
2962 
diff
changeset
 | 
175  | 
	for (j = 0; j < NUM_TRAIN_ENGINES; j++) {
 | 
| 
 
cae3a81e8674
(svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
 
peter1138 
parents: 
2962 
diff
changeset
 | 
176  | 
EngineID i = GetRailVehAtPosition(j);  | 
| 
1926
 
530480d14685
(svn r2432) Use GetEngine() instead of DEREF_ENGINE() or even _engines[]
 
tron 
parents: 
1922 
diff
changeset
 | 
177  | 
const Engine *e = GetEngine(i);  | 
| 539 | 178  | 
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
 | 
179  | 
|
| 
2518
 
bec1f669b1ff
(svn r3047) The parameters for the railtype check got flipped in the train build window (this caused no visible problem so far, therefore no Fix tag)
 
tron 
parents: 
2517 
diff
changeset
 | 
180  | 
if (!IsCompatibleRail(e->railtype, 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
 | 
181  | 
!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
 | 
182  | 
continue;  | 
| 
 
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 (*sel == 0)  | 
| 
 
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
 
truelight 
parents: 
842 
diff
changeset
 | 
185  | 
*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
 | 
186  | 
|
| 
867
 
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
 
truelight 
parents: 
842 
diff
changeset
 | 
187  | 
		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
 | 
188  | 
DrawString(*x + 59, *y + 2, GetCustomEngineName(i), *sel == 0 ? 0xC : 0x10);  | 
| 
3040
 
7043c0de7c6d
(svn r3620) - 2cc: Replace use of macro to determine colour map with a function call for drawing of vehicles.
 
peter1138 
parents: 
3008 
diff
changeset
 | 
189  | 
DrawTrainEngine(*x + 29, *y + 6, i, GetEnginePalette(i, _local_player));  | 
| 
524
 
bcbcedbf5ccd
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
 
darkvater 
parents: 
517 
diff
changeset
 | 
190  | 
*y += 14;  | 
| 
 
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  | 
--*sel;  | 
| 
 
bcbcedbf5ccd
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
 
darkvater 
parents: 
517 
diff
changeset
 | 
193  | 
}  | 
| 
 
bcbcedbf5ccd
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
 
darkvater 
parents: 
517 
diff
changeset
 | 
194  | 
}  | 
| 
 
bcbcedbf5ccd
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
 
darkvater 
parents: 
517 
diff
changeset
 | 
195  | 
|
| 0 | 196  | 
static void NewRailVehicleWndProc(Window *w, WindowEvent *e)  | 
197  | 
{
 | 
|
| 2952 | 198  | 
	switch (e->event) {
 | 
| 0 | 199  | 
case WE_PAINT:  | 
| 
193
 
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
 
truelight 
parents: 
176 
diff
changeset
 | 
200  | 
|
| 0 | 201  | 
if (w->window_number == 0)  | 
202  | 
SETBIT(w->disabled_state, 5);  | 
|
203  | 
||
204  | 
		{
 | 
|
205  | 
int count = 0;  | 
|
| 
2520
 
8a52362c4ada
(svn r3049) Replace byte/int/uint by RailType where appropriate
 
tron 
parents: 
2518 
diff
changeset
 | 
206  | 
RailType railtype = WP(w,buildtrain_d).railtype;  | 
| 
2477
 
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
 
tron 
parents: 
2466 
diff
changeset
 | 
207  | 
EngineID i;  | 
| 
460
 
7506c66ce4c3
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
 
darkvater 
parents: 
420 
diff
changeset
 | 
208  | 
|
| 
 
7506c66ce4c3
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
 
darkvater 
parents: 
420 
diff
changeset
 | 
209  | 
			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
 | 
210  | 
const Engine *e = GetEngine(i);  | 
| 
2518
 
bec1f669b1ff
(svn r3047) The parameters for the railtype check got flipped in the train build window (this caused no visible problem so far, therefore no Fix tag)
 
tron 
parents: 
2517 
diff
changeset
 | 
211  | 
if (IsCompatibleRail(e->railtype, railtype)  | 
| 
460
 
7506c66ce4c3
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
 
darkvater 
parents: 
420 
diff
changeset
 | 
212  | 
&& HASBIT(e->player_avail, _local_player))  | 
| 0 | 213  | 
count++;  | 
| 
460
 
7506c66ce4c3
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
 
darkvater 
parents: 
420 
diff
changeset
 | 
214  | 
}  | 
| 0 | 215  | 
SetVScrollCount(w, count);  | 
216  | 
}  | 
|
217  | 
||
| 
534
 
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
 
tron 
parents: 
524 
diff
changeset
 | 
218  | 
SetDParam(0, WP(w,buildtrain_d).railtype + STR_881C_NEW_RAIL_VEHICLES);  | 
| 0 | 219  | 
DrawWindowWidgets(w);  | 
| 
193
 
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
 
truelight 
parents: 
176 
diff
changeset
 | 
220  | 
|
| 0 | 221  | 
		{
 | 
| 
2520
 
8a52362c4ada
(svn r3049) Replace byte/int/uint by RailType where appropriate
 
tron 
parents: 
2518 
diff
changeset
 | 
222  | 
RailType railtype = WP(w,buildtrain_d).railtype;  | 
| 0 | 223  | 
int sel = WP(w,buildtrain_d).sel_index;  | 
224  | 
int pos = w->vscroll.pos;  | 
|
225  | 
int x = 1;  | 
|
226  | 
int y = 15;  | 
|
| 
2498
 
3ed05caa4449
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
 
tron 
parents: 
2493 
diff
changeset
 | 
227  | 
EngineID selected_id = INVALID_ENGINE;  | 
| 0 | 228  | 
|
| 
460
 
7506c66ce4c3
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
 
darkvater 
parents: 
420 
diff
changeset
 | 
229  | 
/* 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
 | 
230  | 
* 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
 | 
231  | 
* 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
 | 
232  | 
* 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
 | 
233  | 
* 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
 | 
234  | 
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
 | 
235  | 
engine_drawing_loop(&x, &y, &pos, &sel, &selected_id, railtype, w->vscroll.cap, false); // Feeble wagons  | 
| 0 | 236  | 
|
237  | 
WP(w,buildtrain_d).sel_engine = selected_id;  | 
|
238  | 
||
| 
2498
 
3ed05caa4449
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
 
tron 
parents: 
2493 
diff
changeset
 | 
239  | 
			if (selected_id != INVALID_ENGINE) {
 | 
| 539 | 240  | 
const RailVehicleInfo *rvi = RailVehInfo(selected_id);  | 
| 0 | 241  | 
|
242  | 
				if (!(rvi->flags & RVI_WAGON)) {
 | 
|
243  | 
/* 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
 | 
244  | 
DrawTrainEnginePurchaseInfo(2, w->widget[4].top + 1,selected_id);  | 
| 0 | 245  | 
				} else {
 | 
246  | 
/* 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
 | 
247  | 
DrawTrainWagonPurchaseInfo(2, w->widget[4].top + 1, selected_id);  | 
| 0 | 248  | 
}  | 
249  | 
}  | 
|
250  | 
}  | 
|
251  | 
break;  | 
|
252  | 
||
253  | 
	case WE_CLICK: {
 | 
|
| 2952 | 254  | 
		switch (e->click.widget) {
 | 
| 0 | 255  | 
		case 2: {
 | 
256  | 
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
 | 
257  | 
			if (i < w->vscroll.cap) {
 | 
| 0 | 258  | 
WP(w,buildtrain_d).sel_index = i + w->vscroll.pos;  | 
259  | 
SetWindowDirty(w);  | 
|
260  | 
}  | 
|
261  | 
} break;  | 
|
262  | 
		case 5: {
 | 
|
| 
2498
 
3ed05caa4449
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
 
tron 
parents: 
2493 
diff
changeset
 | 
263  | 
EngineID sel_eng = WP(w,buildtrain_d).sel_engine;  | 
| 
 
3ed05caa4449
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
 
tron 
parents: 
2493 
diff
changeset
 | 
264  | 
if (sel_eng != INVALID_ENGINE)  | 
| 
540
 
2987d7976ea2
(svn r924) Use RailVehInfo() instead of &_rail_vehicle_info[]
 
tron 
parents: 
539 
diff
changeset
 | 
265  | 
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 | 266  | 
} 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
 | 
267  | 
		case 6: { /* rename */
 | 
| 
2498
 
3ed05caa4449
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
 
tron 
parents: 
2493 
diff
changeset
 | 
268  | 
EngineID sel_eng = WP(w,buildtrain_d).sel_engine;  | 
| 
 
3ed05caa4449
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
 
tron 
parents: 
2493 
diff
changeset
 | 
269  | 
			if (sel_eng != INVALID_ENGINE) {
 | 
| 
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
 | 
270  | 
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
 | 
271  | 
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
 | 
272  | 
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
 | 
273  | 
}  | 
| 
 
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
 | 
274  | 
} break;  | 
| 0 | 275  | 
}  | 
276  | 
} break;  | 
|
277  | 
||
278  | 
case WE_4:  | 
|
279  | 
		if (w->window_number != 0 && !FindWindowById(WC_VEHICLE_DEPOT, w->window_number)) {
 | 
|
280  | 
DeleteWindow(w);  | 
|
281  | 
}  | 
|
282  | 
break;  | 
|
283  | 
||
284  | 
	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
 | 
285  | 
		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
 | 
286  | 
_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
 | 
287  | 
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
 | 
288  | 
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
 | 
289  | 
}  | 
| 0 | 290  | 
} break;  | 
| 
867
 
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
 
truelight 
parents: 
842 
diff
changeset
 | 
291  | 
|
| 
 
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
 
truelight 
parents: 
842 
diff
changeset
 | 
292  | 
	case WE_RESIZE: {
 | 
| 
 
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
 
truelight 
parents: 
842 
diff
changeset
 | 
293  | 
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
 | 
294  | 
break;  | 
| 
 
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
 
truelight 
parents: 
842 
diff
changeset
 | 
295  | 
|
| 
 
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
 
truelight 
parents: 
842 
diff
changeset
 | 
296  | 
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
 | 
297  | 
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
 | 
298  | 
} break;  | 
| 0 | 299  | 
}  | 
300  | 
}  | 
|
| 
193
 
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
 
truelight 
parents: 
176 
diff
changeset
 | 
301  | 
|
| 0 | 302  | 
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
 | 
303  | 
{   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
 | 
304  | 
{    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
 | 
305  | 
{     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
 | 
306  | 
{  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
 | 
307  | 
{      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
 | 
308  | 
{ 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
 | 
309  | 
{ 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
 | 
310  | 
{  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
 | 
311  | 
{   WIDGETS_END},
 | 
| 0 | 312  | 
};  | 
313  | 
||
314  | 
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
 | 
315  | 
-1, -1, 228, 210,  | 
| 0 | 316  | 
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
 | 
317  | 
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,  | 
| 0 | 318  | 
_new_rail_vehicle_widgets,  | 
319  | 
NewRailVehicleWndProc  | 
|
320  | 
};  | 
|
321  | 
||
| 
1977
 
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
 
tron 
parents: 
1962 
diff
changeset
 | 
322  | 
static void ShowBuildTrainWindow(TileIndex tile)  | 
| 0 | 323  | 
{
 | 
324  | 
Window *w;  | 
|
325  | 
||
326  | 
DeleteWindowById(WC_BUILD_VEHICLE, tile);  | 
|
327  | 
||
328  | 
w = AllocateWindowDesc(&_new_rail_vehicle_desc);  | 
|
329  | 
w->window_number = tile;  | 
|
330  | 
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
 | 
331  | 
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
 | 
332  | 
|
| 
 
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
 
truelight 
parents: 
842 
diff
changeset
 | 
333  | 
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
 | 
334  | 
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
 | 
335  | 
|
| 0 | 336  | 
	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
 | 
337  | 
w->caption_color = GetTileOwner(tile);  | 
| 
2493
 
f6b4300cc2b0
(svn r3019) -Codechange: Replace explicit shifting/anding/oring with GB and SB
 
tron 
parents: 
2484 
diff
changeset
 | 
338  | 
WP(w,buildtrain_d).railtype = GB(_m[tile].m3, 0, 4);  | 
| 0 | 339  | 
	} else {
 | 
340  | 
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
 | 
341  | 
WP(w,buildtrain_d).railtype = GetBestRailtype(GetPlayer(_local_player));  | 
| 0 | 342  | 
}  | 
343  | 
}  | 
|
344  | 
||
| 
2593
 
ccb101f0439c
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
 
peter1138 
parents: 
2570 
diff
changeset
 | 
345  | 
/**  | 
| 
 
ccb101f0439c
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
 
peter1138 
parents: 
2570 
diff
changeset
 | 
346  | 
* Get the number of pixels for the given wagon length.  | 
| 
 
ccb101f0439c
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
 
peter1138 
parents: 
2570 
diff
changeset
 | 
347  | 
* @param len Length measured in 1/8ths of a standard wagon.  | 
| 
 
ccb101f0439c
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
 
peter1138 
parents: 
2570 
diff
changeset
 | 
348  | 
* @return Number of pixels across.  | 
| 
 
ccb101f0439c
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
 
peter1138 
parents: 
2570 
diff
changeset
 | 
349  | 
*/  | 
| 
 
ccb101f0439c
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
 
peter1138 
parents: 
2570 
diff
changeset
 | 
350  | 
static int WagonLengthToPixels(int len) {
 | 
| 
 
ccb101f0439c
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
 
peter1138 
parents: 
2570 
diff
changeset
 | 
351  | 
return (len * 29) / 8;  | 
| 
 
ccb101f0439c
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
 
peter1138 
parents: 
2570 
diff
changeset
 | 
352  | 
}  | 
| 
 
ccb101f0439c
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
 
peter1138 
parents: 
2570 
diff
changeset
 | 
353  | 
|
| 
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
 | 
354  | 
static void DrawTrainImage(const Vehicle *v, int x, int y, int count, int skip, VehicleID selection)  | 
| 0 | 355  | 
{
 | 
| 
2593
 
ccb101f0439c
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
 
peter1138 
parents: 
2570 
diff
changeset
 | 
356  | 
int dx = 0;  | 
| 
 
ccb101f0439c
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
 
peter1138 
parents: 
2570 
diff
changeset
 | 
357  | 
count *= 8;  | 
| 
1922
 
bda6f85eefaa
(svn r2428)  - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
 
hackykid 
parents: 
1908 
diff
changeset
 | 
358  | 
|
| 0 | 359  | 
	do {
 | 
360  | 
		if (--skip < 0) {
 | 
|
| 
2593
 
ccb101f0439c
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
 
peter1138 
parents: 
2570 
diff
changeset
 | 
361  | 
int width = v->u.rail.cached_veh_length;  | 
| 
1922
 
bda6f85eefaa
(svn r2428)  - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
 
hackykid 
parents: 
1908 
diff
changeset
 | 
362  | 
|
| 
2593
 
ccb101f0439c
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
 
peter1138 
parents: 
2570 
diff
changeset
 | 
363  | 
			if (dx + width <= count) {
 | 
| 
3049
 
d6109b5fd55d
(svn r3631) - 2cc: Remove use of some temporary variables and perform minor optimization in the form of the ternary operator.
 
peter1138 
parents: 
3040 
diff
changeset
 | 
364  | 
PalSpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);  | 
| 
3157
 
3f35e2d9c8e3
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
 
tron 
parents: 
3049 
diff
changeset
 | 
365  | 
DrawSprite(GetTrainImage(v, DIR_W) | pal, x + 14 + WagonLengthToPixels(dx), y + 6 + (is_custom_sprite(RailVehInfo(v->engine_type)->image_index) ? _traininfo_vehicle_pitch : 0));  | 
| 
1922
 
bda6f85eefaa
(svn r2428)  - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
 
hackykid 
parents: 
1908 
diff
changeset
 | 
366  | 
if (v->index == selection)  | 
| 
2593
 
ccb101f0439c
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
 
peter1138 
parents: 
2570 
diff
changeset
 | 
367  | 
DrawFrameRect(x - 1 + WagonLengthToPixels(dx), y - 1, x + WagonLengthToPixels(dx + width) - 1, 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
 | 
368  | 
}  | 
| 
2593
 
ccb101f0439c
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
 
peter1138 
parents: 
2570 
diff
changeset
 | 
369  | 
dx += width;  | 
| 0 | 370  | 
}  | 
371  | 
||
| 
2593
 
ccb101f0439c
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
 
peter1138 
parents: 
2570 
diff
changeset
 | 
372  | 
v = v->next;  | 
| 
 
ccb101f0439c
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
 
peter1138 
parents: 
2570 
diff
changeset
 | 
373  | 
} while (dx < count && v != NULL);  | 
| 0 | 374  | 
}  | 
375  | 
||
376  | 
static void DrawTrainDepotWindow(Window *w)  | 
|
377  | 
{
 | 
|
| 
1977
 
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
 
tron 
parents: 
1962 
diff
changeset
 | 
378  | 
TileIndex tile;  | 
| 0 | 379  | 
Vehicle *v, *u;  | 
380  | 
int num,x,y,i, hnum;  | 
|
| 
1313
 
f1013ec3d318
(svn r1817) -Codechange: Moved depot-functions to depot.c
 
truelight 
parents: 
1299 
diff
changeset
 | 
381  | 
Depot *depot;  | 
| 0 | 382  | 
|
383  | 
tile = w->window_number;  | 
|
384  | 
||
385  | 
/* 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
 | 
386  | 
w->disabled_state =  | 
| 2244 | 387  | 
IsTileOwner(tile, _local_player) ? 0 : ((1 << 4) | (1 << 5) | (1 << 8) | (1<<9));  | 
| 0 | 388  | 
|
389  | 
/* 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
 | 
390  | 
num = 0;  | 
| 
2593
 
ccb101f0439c
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
 
peter1138 
parents: 
2570 
diff
changeset
 | 
391  | 
hnum = 8;  | 
| 0 | 392  | 
	FOR_ALL_VEHICLES(v) {
 | 
393  | 
if (v->type == VEH_Train &&  | 
|
| 
2676
 
59b65b4fb480
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
 
bjarni 
parents: 
2639 
diff
changeset
 | 
394  | 
(IsFrontEngine(v) || IsFreeWagon(v)) &&  | 
| 
1986
 
fcc849a38ae6
(svn r2492) Remove some pointless casts and fix some nearby indentation
 
tron 
parents: 
1977 
diff
changeset
 | 
395  | 
v->tile == tile &&  | 
| 0 | 396  | 
				v->u.rail.track == 0x80) {
 | 
| 
1986
 
fcc849a38ae6
(svn r2492) Remove some pointless casts and fix some nearby indentation
 
tron 
parents: 
1977 
diff
changeset
 | 
397  | 
num++;  | 
| 
 
fcc849a38ae6
(svn r2492) Remove some pointless casts and fix some nearby indentation
 
tron 
parents: 
1977 
diff
changeset
 | 
398  | 
// determine number of items in the X direction.  | 
| 
2676
 
59b65b4fb480
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
 
bjarni 
parents: 
2639 
diff
changeset
 | 
399  | 
			if (IsFrontEngine(v)) {
 | 
| 
2593
 
ccb101f0439c
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
 
peter1138 
parents: 
2570 
diff
changeset
 | 
400  | 
hnum = max(hnum, v->u.rail.cached_total_length);  | 
| 
1986
 
fcc849a38ae6
(svn r2492) Remove some pointless casts and fix some nearby indentation
 
tron 
parents: 
1977 
diff
changeset
 | 
401  | 
}  | 
| 0 | 402  | 
}  | 
403  | 
}  | 
|
| 
914
 
4359607898f7
(svn r1401) -Fix: glitches in train-depot GUI (tnx to Hackykid)
 
truelight 
parents: 
894 
diff
changeset
 | 
404  | 
|
| 
 
4359607898f7
(svn r1401) -Fix: glitches in train-depot GUI (tnx to Hackykid)
 
truelight 
parents: 
894 
diff
changeset
 | 
405  | 
/* 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
 | 
406  | 
num++;  | 
| 
 
4359607898f7
(svn r1401) -Fix: glitches in train-depot GUI (tnx to Hackykid)
 
truelight 
parents: 
894 
diff
changeset
 | 
407  | 
|
| 0 | 408  | 
SetVScrollCount(w, num);  | 
| 
2593
 
ccb101f0439c
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
 
peter1138 
parents: 
2570 
diff
changeset
 | 
409  | 
SetHScrollCount(w, (hnum + 7) / 8);  | 
| 
193
 
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
 
truelight 
parents: 
176 
diff
changeset
 | 
410  | 
|
| 0 | 411  | 
/* locate the depot struct */  | 
| 
1313
 
f1013ec3d318
(svn r1817) -Codechange: Moved depot-functions to depot.c
 
truelight 
parents: 
1299 
diff
changeset
 | 
412  | 
depot = GetDepotByTile(tile);  | 
| 
 
f1013ec3d318
(svn r1817) -Codechange: Moved depot-functions to depot.c
 
truelight 
parents: 
1299 
diff
changeset
 | 
413  | 
assert(depot != NULL);  | 
| 0 | 414  | 
|
| 
1313
 
f1013ec3d318
(svn r1817) -Codechange: Moved depot-functions to depot.c
 
truelight 
parents: 
1299 
diff
changeset
 | 
415  | 
SetDParam(0, depot->town_index);  | 
| 0 | 416  | 
DrawWindowWidgets(w);  | 
417  | 
||
418  | 
x = 2;  | 
|
419  | 
y = 15;  | 
|
420  | 
num = w->vscroll.pos;  | 
|
421  | 
||
422  | 
// draw all trains  | 
|
423  | 
	FOR_ALL_VEHICLES(v) {
 | 
|
| 
2676
 
59b65b4fb480
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
 
bjarni 
parents: 
2639 
diff
changeset
 | 
424  | 
if (v->type == VEH_Train && IsFrontEngine(v) &&  | 
| 
1986
 
fcc849a38ae6
(svn r2492) Remove some pointless casts and fix some nearby indentation
 
tron 
parents: 
1977 
diff
changeset
 | 
425  | 
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
 | 
426  | 
				--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
 | 
427  | 
DrawTrainImage(v, x+21, y, w->hscroll.cap, w->hscroll.pos, WP(w,traindepot_d).sel);  | 
| 22 | 428  | 
/* Draw the train number */  | 
| 
534
 
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
 
tron 
parents: 
524 
diff
changeset
 | 
429  | 
SetDParam(0, v->unitnumber);  | 
| 0 | 430  | 
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
 | 
431  | 
|
| 
2593
 
ccb101f0439c
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
 
peter1138 
parents: 
2570 
diff
changeset
 | 
432  | 
// Number of wagons relative to a standard length wagon (rounded up)  | 
| 
 
ccb101f0439c
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
 
peter1138 
parents: 
2570 
diff
changeset
 | 
433  | 
SetDParam(0, (v->u.rail.cached_total_length + 7) / 8);  | 
| 
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  | 
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
 | 
435  | 
|
| 22 | 436  | 
/* Draw the pretty flag */  | 
| 
2517
 
6e3832ddd0f6
(svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
 
tron 
parents: 
2498 
diff
changeset
 | 
437  | 
DrawSprite(v->vehstatus & VS_STOPPED ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, x + 15, y);  | 
| 0 | 438  | 
|
439  | 
y += 14;  | 
|
440  | 
}  | 
|
441  | 
}  | 
|
442  | 
||
443  | 
// draw all remaining vehicles  | 
|
444  | 
	FOR_ALL_VEHICLES(v) {
 | 
|
| 
2676
 
59b65b4fb480
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
 
bjarni 
parents: 
2639 
diff
changeset
 | 
445  | 
if (v->type == VEH_Train && IsFreeWagon(v) &&  | 
| 
1986
 
fcc849a38ae6
(svn r2492) Remove some pointless casts and fix some nearby indentation
 
tron 
parents: 
1977 
diff
changeset
 | 
446  | 
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
 | 
447  | 
				--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
 | 
448  | 
DrawTrainImage(v, x+50, y, w->hscroll.cap - 1, 0, WP(w,traindepot_d).sel);  | 
| 0 | 449  | 
DrawString(x, y+2, STR_8816, 0);  | 
| 
1019
 
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
 
tron 
parents: 
1017 
diff
changeset
 | 
450  | 
|
| 
1002
 
9d83f1842257
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
 
celestar 
parents: 
982 
diff
changeset
 | 
451  | 
/*Draw the train counter */  | 
| 
 
9d83f1842257
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
 
celestar 
parents: 
982 
diff
changeset
 | 
452  | 
i = 0;  | 
| 
 
9d83f1842257
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
 
celestar 
parents: 
982 
diff
changeset
 | 
453  | 
u = v;  | 
| 
 
9d83f1842257
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
 
celestar 
parents: 
982 
diff
changeset
 | 
454  | 
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
 | 
455  | 
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
 | 
456  | 
DrawStringRightAligned(w->widget[6].right - 1, y + 4, STR_TINY_BLACK, 0); //Draw the counter  | 
| 0 | 457  | 
y += 14;  | 
458  | 
}  | 
|
459  | 
}  | 
|
460  | 
}  | 
|
461  | 
||
462  | 
typedef struct GetDepotVehiclePtData {
 | 
|
463  | 
Vehicle *head;  | 
|
464  | 
Vehicle *wagon;  | 
|
465  | 
} GetDepotVehiclePtData;  | 
|
466  | 
||
| 
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
 | 
467  | 
static int GetVehicleFromTrainDepotWndPt(const Window *w, int x, int y, GetDepotVehiclePtData *d)  | 
| 0 | 468  | 
{
 | 
469  | 
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
 | 
470  | 
int skip = 0;  | 
| 0 | 471  | 
Vehicle *v;  | 
472  | 
||
473  | 
x = x - 23;  | 
|
474  | 
||
475  | 
row = (y - 14) / 14;  | 
|
| 2951 | 476  | 
if ((uint)row >= w->vscroll.cap) return 1; /* means err */  | 
| 0 | 477  | 
|
478  | 
row += w->vscroll.pos;  | 
|
479  | 
||
480  | 
/* go through all the locomotives */  | 
|
481  | 
	FOR_ALL_VEHICLES(v) {
 | 
|
482  | 
if (v->type == VEH_Train &&  | 
|
| 
2676
 
59b65b4fb480
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
 
bjarni 
parents: 
2639 
diff
changeset
 | 
483  | 
IsFrontEngine(v) &&  | 
| 0 | 484  | 
v->tile == w->window_number &&  | 
485  | 
v->u.rail.track == 0x80 &&  | 
|
486  | 
				--row < 0) {
 | 
|
| 2951 | 487  | 
skip = w->hscroll.pos;  | 
488  | 
goto found_it;  | 
|
| 0 | 489  | 
}  | 
490  | 
}  | 
|
491  | 
||
| 
1922
 
bda6f85eefaa
(svn r2428)  - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
 
hackykid 
parents: 
1908 
diff
changeset
 | 
492  | 
x -= 29; /* free wagons don't have an initial loco. */  | 
| 0 | 493  | 
|
494  | 
/* and then the list of free wagons */  | 
|
495  | 
	FOR_ALL_VEHICLES(v) {
 | 
|
496  | 
if (v->type == VEH_Train &&  | 
|
| 
2676
 
59b65b4fb480
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
 
bjarni 
parents: 
2639 
diff
changeset
 | 
497  | 
IsFreeWagon(v) &&  | 
| 0 | 498  | 
v->tile == w->window_number &&  | 
499  | 
v->u.rail.track == 0x80 &&  | 
|
| 2951 | 500  | 
				--row < 0) {
 | 
501  | 
goto found_it;  | 
|
502  | 
}  | 
|
| 0 | 503  | 
}  | 
504  | 
||
505  | 
d->head = NULL;  | 
|
506  | 
d->wagon = NULL;  | 
|
507  | 
||
508  | 
/* didn't find anything, get out */  | 
|
509  | 
return 0;  | 
|
510  | 
||
| 
193
 
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
 
truelight 
parents: 
176 
diff
changeset
 | 
511  | 
found_it:  | 
| 0 | 512  | 
d->head = d->wagon = v;  | 
513  | 
||
514  | 
/* either pressed the flag or the number, but only when it's a loco */  | 
|
| 2951 | 515  | 
if (x < 0 && IsFrontEngine(v)) return (x >= -10) ? -2 : -1;  | 
| 
1922
 
bda6f85eefaa
(svn r2428)  - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
 
hackykid 
parents: 
1908 
diff
changeset
 | 
516  | 
|
| 
 
bda6f85eefaa
(svn r2428)  - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
 
hackykid 
parents: 
1908 
diff
changeset
 | 
517  | 
// 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
 | 
518  | 
while (skip--) v = v->next;  | 
| 
193
 
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
 
truelight 
parents: 
176 
diff
changeset
 | 
519  | 
|
| 0 | 520  | 
/* find the vehicle in this row that was clicked */  | 
| 
2593
 
ccb101f0439c
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
 
peter1138 
parents: 
2570 
diff
changeset
 | 
521  | 
	while ((x -= WagonLengthToPixels(v->u.rail.cached_veh_length)) >= 0) {
 | 
| 0 | 522  | 
v = v->next;  | 
523  | 
if (v == NULL) break;  | 
|
524  | 
}  | 
|
525  | 
||
| 
2602
 
1a6561c9a408
(svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
 
peter1138 
parents: 
2593 
diff
changeset
 | 
526  | 
// if an articulated part was selected, find its parent  | 
| 
2676
 
59b65b4fb480
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
 
bjarni 
parents: 
2639 
diff
changeset
 | 
527  | 
while (v != NULL && IsArticulatedPart(v)) v = GetPrevVehicleInChain(v);  | 
| 
2602
 
1a6561c9a408
(svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
 
peter1138 
parents: 
2593 
diff
changeset
 | 
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  | 
||
| 
2484
 
0e45d70ae908
(svn r3010) Get rid of quite some dubious casts, either by using GB(), proper types or just removing them
 
tron 
parents: 
2477 
diff
changeset
 | 
534  | 
static void TrainDepotMoveVehicle(Vehicle *wagon, VehicleID sel, Vehicle *head)  | 
| 0 | 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  | 
|
| 
2676
 
59b65b4fb480
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
 
bjarni 
parents: 
2639 
diff
changeset
 | 
540  | 
if (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  | 
||
| 
2484
 
0e45d70ae908
(svn r3010) Get rid of quite some dubious casts, either by using GB(), proper types or just removing them
 
tron 
parents: 
2477 
diff
changeset
 | 
555  | 
DoCommandP(v->tile, v->index + ((wagon == NULL ? INVALID_VEHICLE : wagon->index) << 16), _ctrl_pressed ? 1 : 0, NULL, CMD_MOVE_RAIL_VEHICLE | CMD_MSG(STR_8837_CAN_T_MOVE_VEHICLE));  | 
| 0 | 556  | 
}  | 
557  | 
||
558  | 
static void TrainDepotClickTrain(Window *w, int x, int y)  | 
|
559  | 
{
 | 
|
560  | 
GetDepotVehiclePtData gdvp;  | 
|
| 
2484
 
0e45d70ae908
(svn r3010) Get rid of quite some dubious casts, either by using GB(), proper types or just removing them
 
tron 
parents: 
2477 
diff
changeset
 | 
561  | 
int mode;  | 
| 0 | 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  | 
||
| 2952 | 571  | 
	switch (mode) {
 | 
| 
2484
 
0e45d70ae908
(svn r3010) Get rid of quite some dubious casts, either by using GB(), proper types or just removing them
 
tron 
parents: 
2477 
diff
changeset
 | 
572  | 
	case 0: { // start dragging of vehicle
 | 
| 
 
0e45d70ae908
(svn r3010) Get rid of quite some dubious casts, either by using GB(), proper types or just removing them
 
tron 
parents: 
2477 
diff
changeset
 | 
573  | 
VehicleID sel = WP(w, traindepot_d).sel;  | 
| 
 
0e45d70ae908
(svn r3010) Get rid of quite some dubious casts, either by using GB(), proper types or just removing them
 
tron 
parents: 
2477 
diff
changeset
 | 
574  | 
|
| 
 
0e45d70ae908
(svn r3010) Get rid of quite some dubious casts, either by using GB(), proper types or just removing them
 
tron 
parents: 
2477 
diff
changeset
 | 
575  | 
		if (sel != INVALID_VEHICLE) {
 | 
| 0 | 576  | 
WP(w,traindepot_d).sel = INVALID_VEHICLE;  | 
577  | 
TrainDepotMoveVehicle(v, sel, gdvp.head);  | 
|
578  | 
		} else if (v != NULL) {
 | 
|
579  | 
WP(w,traindepot_d).sel = v->index;  | 
|
| 
3157
 
3f35e2d9c8e3
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
 
tron 
parents: 
3049 
diff
changeset
 | 
580  | 
SetObjectToPlaceWnd(GetVehiclePalette(v) | GetTrainImage(v, DIR_W), 4, w);  | 
| 0 | 581  | 
SetWindowDirty(w);  | 
582  | 
}  | 
|
583  | 
break;  | 
|
| 
2484
 
0e45d70ae908
(svn r3010) Get rid of quite some dubious casts, either by using GB(), proper types or just removing them
 
tron 
parents: 
2477 
diff
changeset
 | 
584  | 
}  | 
| 0 | 585  | 
|
| 
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
 | 
586  | 
case -1: // show info window  | 
| 0 | 587  | 
ShowTrainViewWindow(v);  | 
588  | 
break;  | 
|
589  | 
||
| 
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
 | 
590  | 
case -2: // click start/stop flag  | 
| 0 | 591  | 
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_TRAIN | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN));  | 
592  | 
break;  | 
|
593  | 
}  | 
|
594  | 
}  | 
|
595  | 
||
| 2244 | 596  | 
/**  | 
597  | 
* Clones a train  | 
|
598  | 
* @param *v is the original vehicle to clone  | 
|
599  | 
* @param *w is the window of the depot where the clone is build  | 
|
600  | 
*/  | 
|
| 
2561
 
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
 
tron 
parents: 
2549 
diff
changeset
 | 
601  | 
static void HandleCloneVehClick(const Vehicle* v, const Window* w)  | 
| 2244 | 602  | 
{
 | 
| 
2561
 
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
 
tron 
parents: 
2549 
diff
changeset
 | 
603  | 
if (v == NULL || v->type != VEH_Train) return;  | 
| 2244 | 604  | 
|
605  | 
// for train vehicles: subtype 0 for locs and not zero for others  | 
|
| 
2676
 
59b65b4fb480
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
 
bjarni 
parents: 
2639 
diff
changeset
 | 
606  | 
	if (!IsFrontEngine(v)) {
 | 
| 2244 | 607  | 
v = GetFirstVehicleInChain(v);  | 
| 
2561
 
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
 
tron 
parents: 
2549 
diff
changeset
 | 
608  | 
// Do nothing when clicking on a train in depot with no loc attached  | 
| 
2676
 
59b65b4fb480
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
 
bjarni 
parents: 
2639 
diff
changeset
 | 
609  | 
if (!IsFrontEngine(v)) return;  | 
| 2244 | 610  | 
}  | 
611  | 
||
| 
2561
 
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
 
tron 
parents: 
2549 
diff
changeset
 | 
612  | 
DoCommandP(w->window_number, v->index, _ctrl_pressed ? 1 : 0, CcCloneTrain,  | 
| 
 
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
 
tron 
parents: 
2549 
diff
changeset
 | 
613  | 
CMD_CLONE_VEHICLE | CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE)  | 
| 
 
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
 
tron 
parents: 
2549 
diff
changeset
 | 
614  | 
);  | 
| 2244 | 615  | 
|
616  | 
ResetObjectToPlace();  | 
|
617  | 
}  | 
|
618  | 
||
| 
2958
 
ac0a9673b522
(svn r3520) Remove unused parameters from some functions
 
tron 
parents: 
2952 
diff
changeset
 | 
619  | 
static void ClonePlaceObj(const Window* w)  | 
| 2244 | 620  | 
{
 | 
| 
2561
 
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
 
tron 
parents: 
2549 
diff
changeset
 | 
621  | 
Vehicle* v = CheckMouseOverVehicle();  | 
| 2244 | 622  | 
|
| 
2561
 
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
 
tron 
parents: 
2549 
diff
changeset
 | 
623  | 
if (v != NULL) HandleCloneVehClick(v, w);  | 
| 2244 | 624  | 
}  | 
625  | 
||
| 0 | 626  | 
static void TrainDepotWndProc(Window *w, WindowEvent *e)  | 
627  | 
{
 | 
|
| 2952 | 628  | 
	switch (e->event) {
 | 
| 0 | 629  | 
case WE_PAINT:  | 
630  | 
DrawTrainDepotWindow(w);  | 
|
631  | 
break;  | 
|
632  | 
||
633  | 
	case WE_CLICK: {
 | 
|
| 2952 | 634  | 
		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
 | 
635  | 
case 8:  | 
| 2244 | 636  | 
ResetObjectToPlace();  | 
| 0 | 637  | 
ShowBuildTrainWindow(w->window_number);  | 
638  | 
break;  | 
|
| 2244 | 639  | 
case 10:  | 
640  | 
ResetObjectToPlace();  | 
|
| 0 | 641  | 
ScrollMainWindowToTile(w->window_number);  | 
642  | 
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
 | 
643  | 
case 6:  | 
| 0 | 644  | 
TrainDepotClickTrain(w, e->click.pt.x, e->click.pt.y);  | 
645  | 
break;  | 
|
| 2244 | 646  | 
case 9: /* clone button */  | 
647  | 
InvalidateWidget(w, 9);  | 
|
648  | 
TOGGLEBIT(w->click_state, 9);  | 
|
649  | 
||
650  | 
			if (HASBIT(w->click_state, 9)) {
 | 
|
651  | 
_place_clicked_vehicle = NULL;  | 
|
652  | 
SetObjectToPlaceWnd(SPR_CURSOR_CLONE, VHM_RECT, w);  | 
|
653  | 
			} else {
 | 
|
654  | 
ResetObjectToPlace();  | 
|
655  | 
}  | 
|
656  | 
break;  | 
|
657  | 
||
658  | 
}  | 
|
659  | 
} break;  | 
|
| 
2261
 
d3554e5d3e86
(svn r2781) Fix some of the issues with variables in .h files.
 
ludde 
parents: 
2252 
diff
changeset
 | 
660  | 
|
| 2244 | 661  | 
	case WE_PLACE_OBJ: {
 | 
| 
2958
 
ac0a9673b522
(svn r3520) Remove unused parameters from some functions
 
tron 
parents: 
2952 
diff
changeset
 | 
662  | 
ClonePlaceObj(w);  | 
| 2244 | 663  | 
} break;  | 
664  | 
||
665  | 
	case WE_ABORT_PLACE_OBJ: {
 | 
|
666  | 
CLRBIT(w->click_state, 9);  | 
|
667  | 
InvalidateWidget(w, 9);  | 
|
668  | 
} break;  | 
|
| 
2261
 
d3554e5d3e86
(svn r2781) Fix some of the issues with variables in .h files.
 
ludde 
parents: 
2252 
diff
changeset
 | 
669  | 
|
| 2244 | 670  | 
// check if a vehicle in a depot was clicked..  | 
671  | 
	case WE_MOUSELOOP: {
 | 
|
| 
2561
 
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
 
tron 
parents: 
2549 
diff
changeset
 | 
672  | 
const Vehicle* v = _place_clicked_vehicle;  | 
| 
 
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
 
tron 
parents: 
2549 
diff
changeset
 | 
673  | 
|
| 
 
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
 
tron 
parents: 
2549 
diff
changeset
 | 
674  | 
// since OTTD checks all open depot windows, we will make sure that it triggers the one with a clicked clone button  | 
| 2244 | 675  | 
		if (v != NULL && HASBIT(w->click_state, 9)) {
 | 
676  | 
_place_clicked_vehicle = NULL;  | 
|
| 
2561
 
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
 
tron 
parents: 
2549 
diff
changeset
 | 
677  | 
HandleCloneVehClick(v, w);  | 
| 0 | 678  | 
}  | 
679  | 
} break;  | 
|
680  | 
||
| 2244 | 681  | 
|
| 0 | 682  | 
case WE_DESTROY:  | 
683  | 
DeleteWindowById(WC_BUILD_VEHICLE, w->window_number);  | 
|
684  | 
break;  | 
|
685  | 
||
686  | 
	case WE_DRAGDROP: {
 | 
|
| 2952 | 687  | 
		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
 | 
688  | 
		case 4: case 5: {
 | 
| 0 | 689  | 
Vehicle *v;  | 
690  | 
int sell_cmd;  | 
|
691  | 
||
692  | 
/* sell vehicle */  | 
|
693  | 
if (w->disabled_state & (1 << e->click.widget))  | 
|
694  | 
return;  | 
|
695  | 
||
696  | 
if (WP(w,traindepot_d).sel == INVALID_VEHICLE)  | 
|
697  | 
return;  | 
|
698  | 
||
| 
919
 
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
 
truelight 
parents: 
914 
diff
changeset
 | 
699  | 
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
 | 
700  | 
|
| 0 | 701  | 
WP(w,traindepot_d).sel = INVALID_VEHICLE;  | 
702  | 
SetWindowDirty(w);  | 
|
703  | 
||
704  | 
HandleButtonClick(w, e->click.widget);  | 
|
705  | 
||
| 
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
 | 
706  | 
sell_cmd = (e->click.widget == 5 || _ctrl_pressed) ? 1 : 0;  | 
| 0 | 707  | 
|
| 
2676
 
59b65b4fb480
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
 
bjarni 
parents: 
2639 
diff
changeset
 | 
708  | 
			if (!IsFrontEngine(v)) {
 | 
| 0 | 709  | 
DoCommandP(v->tile, v->index, sell_cmd, NULL, CMD_SELL_RAIL_WAGON | CMD_MSG(STR_8839_CAN_T_SELL_RAILROAD_VEHICLE));  | 
710  | 
			} else {
 | 
|
711  | 
_backup_orders_tile = v->tile;  | 
|
712  | 
BackupVehicleOrders(v, _backup_orders_data);  | 
|
713  | 
if (!DoCommandP(v->tile, v->index, sell_cmd, NULL, CMD_SELL_RAIL_WAGON | CMD_MSG(STR_8839_CAN_T_SELL_RAILROAD_VEHICLE)))  | 
|
714  | 
_backup_orders_tile = 0;  | 
|
715  | 
}  | 
|
716  | 
} break;  | 
|
717  | 
||
| 
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
 | 
718  | 
		case 6: {
 | 
| 0 | 719  | 
GetDepotVehiclePtData gdvp;  | 
720  | 
VehicleID sel = WP(w,traindepot_d).sel;  | 
|
721  | 
||
722  | 
WP(w,traindepot_d).sel = INVALID_VEHICLE;  | 
|
723  | 
SetWindowDirty(w);  | 
|
724  | 
||
| 
193
 
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
 
truelight 
parents: 
176 
diff
changeset
 | 
725  | 
if (GetVehicleFromTrainDepotWndPt(w, e->dragdrop.pt.x, e->dragdrop.pt.y, &gdvp) == 0 &&  | 
| 0 | 726  | 
						sel != INVALID_VEHICLE) {
 | 
727  | 
					if (gdvp.wagon == NULL || gdvp.wagon->index != sel) {
 | 
|
728  | 
TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head);  | 
|
| 
2676
 
59b65b4fb480
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
 
bjarni 
parents: 
2639 
diff
changeset
 | 
729  | 
					} else if (gdvp.head != NULL && IsFrontEngine(gdvp.head)) {
 | 
| 0 | 730  | 
ShowTrainViewWindow(gdvp.head);  | 
731  | 
}  | 
|
| 
193
 
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
 
truelight 
parents: 
176 
diff
changeset
 | 
732  | 
}  | 
| 0 | 733  | 
} break;  | 
734  | 
||
735  | 
default:  | 
|
736  | 
WP(w,traindepot_d).sel = INVALID_VEHICLE;  | 
|
737  | 
SetWindowDirty(w);  | 
|
738  | 
break;  | 
|
739  | 
}  | 
|
740  | 
} break;  | 
|
| 
867
 
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
 
truelight 
parents: 
842 
diff
changeset
 | 
741  | 
	case WE_RESIZE: {
 | 
| 
 
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
 
truelight 
parents: 
842 
diff
changeset
 | 
742  | 
/* Update the scroll + matrix */  | 
| 
 
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
 
truelight 
parents: 
842 
diff
changeset
 | 
743  | 
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
 | 
744  | 
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
 | 
745  | 
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
 | 
746  | 
} break;  | 
| 0 | 747  | 
}  | 
748  | 
}  | 
|
749  | 
||
750  | 
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
 | 
751  | 
{   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
 | 
752  | 
{    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
 | 
753  | 
{  WWT_STICKYBOX,     RESIZE_LR,    14,   349,   360,     0,    13, 0x0,										STR_STICKY_BUTTON},
 | 
| 0 | 754  | 
|
| 
1002
 
9d83f1842257
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
 
celestar 
parents: 
982 
diff
changeset
 | 
755  | 
{      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
 | 
756  | 
{      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
 | 
757  | 
{      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
 | 
758  | 
|
| 
 
9d83f1842257
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
 
celestar 
parents: 
982 
diff
changeset
 | 
759  | 
{     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
 | 
760  | 
{  WWT_SCROLLBAR,    RESIZE_LRB,    14,   349,   360,    14,   109, 0x0,										STR_0190_SCROLL_BAR_SCROLLS_LIST},
 | 
| 2244 | 761  | 
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,   116,   110,   121, STR_8815_NEW_VEHICLES,	STR_8840_BUILD_NEW_TRAIN_VEHICLE},
 | 
762  | 
{WWT_NODISTXTBTN,     RESIZE_TB,    14,   117,   232,   110,   121, STR_CLONE_TRAIN,		STR_CLONE_TRAIN_DEPOT_INFO},
 | 
|
763  | 
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,   233,   348,   110,   121, STR_00E4_LOCATION,			STR_8842_CENTER_MAIN_VIEW_ON_TRAIN},
 | 
|
764  | 
||
765  | 
||
| 
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
 | 
766  | 
{ 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
 | 
767  | 
{      WWT_PANEL,    RESIZE_RTB,    14,   349,   348,   110,   121, 0x0,										STR_NULL},
 | 
| 2244 | 768  | 
|
| 
1002
 
9d83f1842257
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
 
celestar 
parents: 
982 
diff
changeset
 | 
769  | 
{  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
 | 
770  | 
{   WIDGETS_END},
 | 
| 0 | 771  | 
};  | 
772  | 
||
773  | 
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
 | 
774  | 
-1, -1, 361, 122,  | 
| 0 | 775  | 
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
 | 
776  | 
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,  | 
| 0 | 777  | 
_train_depot_widgets,  | 
778  | 
TrainDepotWndProc  | 
|
779  | 
};  | 
|
780  | 
||
781  | 
||
| 
1977
 
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
 
tron 
parents: 
1962 
diff
changeset
 | 
782  | 
void ShowTrainDepotWindow(TileIndex tile)  | 
| 0 | 783  | 
{
 | 
784  | 
Window *w;  | 
|
785  | 
||
786  | 
w = AllocateWindowDescFront(&_train_depot_desc, tile);  | 
|
787  | 
	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
 | 
788  | 
w->caption_color = GetTileOwner(w->window_number);  | 
| 0 | 789  | 
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
 | 
790  | 
w->hscroll.cap = 10;  | 
| 
 
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
 
truelight 
parents: 
842 
diff
changeset
 | 
791  | 
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
 | 
792  | 
w->resize.step_height = 14;  | 
| 0 | 793  | 
WP(w,traindepot_d).sel = INVALID_VEHICLE;  | 
794  | 
_backup_orders_tile = 0;  | 
|
795  | 
}  | 
|
796  | 
}  | 
|
797  | 
||
798  | 
static void RailVehicleRefitWndProc(Window *w, WindowEvent *e)  | 
|
799  | 
{
 | 
|
| 
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
 | 
800  | 
	switch (e->event) {
 | 
| 0 | 801  | 
	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
 | 
802  | 
const Vehicle *v = GetVehicle(w->window_number);  | 
| 0 | 803  | 
|
| 
534
 
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
 
tron 
parents: 
524 
diff
changeset
 | 
804  | 
SetDParam(0, v->string_id);  | 
| 
 
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
 
tron 
parents: 
524 
diff
changeset
 | 
805  | 
SetDParam(1, v->unitnumber);  | 
| 0 | 806  | 
DrawWindowWidgets(w);  | 
807  | 
||
808  | 
DrawString(1, 15, STR_983F_SELECT_CARGO_TYPE_TO_CARRY, 0);  | 
|
809  | 
||
| 
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  | 
/* 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
 | 
811  | 
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
 | 
812  | 
|
| 
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
 | 
813  | 
		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
 | 
814  | 
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
 | 
815  | 
			if (!CmdFailed(cost)) {
 | 
| 
534
 
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
 
tron 
parents: 
524 
diff
changeset
 | 
816  | 
SetDParam(2, cost);  | 
| 
2084
 
65639f898a50
(svn r2594) Fix: [strgen] Misc updates to the string system.
 
ludde 
parents: 
2049 
diff
changeset
 | 
817  | 
SetDParam(0, _cargoc.names_long[WP(w,refit_d).cargo]);  | 
| 
3008
 
cef26520c91e
(svn r3588) - Refit: Use only one global to return the refit capacity rather than one per vehicle type.
 
peter1138 
parents: 
2971 
diff
changeset
 | 
818  | 
SetDParam(1, _returned_refit_capacity);  | 
| 0 | 819  | 
DrawString(1, 137, STR_9840_NEW_CAPACITY_COST_OF_REFIT, 0);  | 
820  | 
}  | 
|
821  | 
}  | 
|
| 
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
 | 
822  | 
} break;  | 
| 0 | 823  | 
|
824  | 
case WE_CLICK:  | 
|
| 2952 | 825  | 
		switch (e->click.widget) {
 | 
| 0 | 826  | 
		case 2: { /* listbox */
 | 
827  | 
int y = e->click.pt.y - 25;  | 
|
828  | 
			if (y >= 0) {
 | 
|
829  | 
WP(w,refit_d).sel = y / 10;  | 
|
830  | 
SetWindowDirty(w);  | 
|
831  | 
}  | 
|
832  | 
} break;  | 
|
833  | 
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
 | 
834  | 
			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
 | 
835  | 
const Vehicle *v = GetVehicle(w->window_number);  | 
| 0 | 836  | 
if (DoCommandP(v->tile, v->index, WP(w,refit_d).cargo, NULL, CMD_REFIT_RAIL_VEHICLE | CMD_MSG(STR_RAIL_CAN_T_REFIT_VEHICLE)))  | 
837  | 
DeleteWindow(w);  | 
|
838  | 
}  | 
|
839  | 
break;  | 
|
840  | 
}  | 
|
841  | 
break;  | 
|
842  | 
}  | 
|
843  | 
}  | 
|
844  | 
||
845  | 
||
846  | 
static const Widget _rail_vehicle_refit_widgets[] = {
 | 
|
| 
2725
 
775e3e14ca46
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
 
peter1138 
parents: 
2676 
diff
changeset
 | 
847  | 
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,							STR_018B_CLOSE_WINDOW},
 | 
| 
867
 
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
 
truelight 
parents: 
842 
diff
changeset
 | 
848  | 
{    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
 | 
849  | 
{     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
 | 
850  | 
{     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
 | 
851  | 
{ 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
 | 
852  | 
{   WIDGETS_END},
 | 
| 0 | 853  | 
};  | 
854  | 
||
855  | 
static const WindowDesc _rail_vehicle_refit_desc = {
 | 
|
856  | 
-1,-1, 240, 170,  | 
|
857  | 
WC_VEHICLE_REFIT,WC_VEHICLE_VIEW,  | 
|
858  | 
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,  | 
|
859  | 
_rail_vehicle_refit_widgets,  | 
|
860  | 
RailVehicleRefitWndProc,  | 
|
861  | 
};  | 
|
862  | 
||
863  | 
static void ShowRailVehicleRefitWindow(Vehicle *v)  | 
|
864  | 
{
 | 
|
865  | 
Window *w;  | 
|
866  | 
DeleteWindowById(WC_VEHICLE_REFIT, v->index);  | 
|
867  | 
_alloc_wnd_parent_num = v->index;  | 
|
868  | 
w = AllocateWindowDesc(&_rail_vehicle_refit_desc);  | 
|
869  | 
w->window_number = v->index;  | 
|
870  | 
w->caption_color = v->owner;  | 
|
871  | 
WP(w,refit_d).sel = -1;  | 
|
872  | 
}  | 
|
873  | 
||
| 
2275
 
11a1dac70c45
(svn r2799) Make the only two non-const widget lists const
 
tron 
parents: 
2261 
diff
changeset
 | 
874  | 
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
 | 
875  | 
{ 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
 | 
876  | 
{ 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
 | 
877  | 
{ 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
 | 
878  | 
{ 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
 | 
879  | 
{ 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
 | 
880  | 
{ 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
 | 
881  | 
{ 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
 | 
882  | 
{ 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
 | 
883  | 
{ 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
 | 
884  | 
{ 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
 | 
885  | 
{ 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
 | 
886  | 
{ 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
 | 
887  | 
{ WWT_PUSHIMGBTN, RESIZE_LR,    14, 232, 249,  68,  85, 0x2B4,    STR_RAIL_REFIT_VEHICLE_TO_CARRY },
 | 
| 2244 | 888  | 
{ 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
 | 
889  | 
{ 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
 | 
890  | 
{ 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
 | 
891  | 
{ WIDGETS_END }
 | 
| 0 | 892  | 
};  | 
893  | 
||
| 
2561
 
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
 
tron 
parents: 
2549 
diff
changeset
 | 
894  | 
static void ShowTrainDetailsWindow(const Vehicle* v);  | 
| 
 
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
 
tron 
parents: 
2549 
diff
changeset
 | 
895  | 
|
| 0 | 896  | 
static void TrainViewWndProc(Window *w, WindowEvent *e)  | 
897  | 
{
 | 
|
| 
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
 | 
898  | 
	switch (e->event) {
 | 
| 0 | 899  | 
	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
 | 
900  | 
const Vehicle *v, *u;  | 
| 0 | 901  | 
StringID str;  | 
902  | 
||
| 
919
 
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
 
truelight 
parents: 
914 
diff
changeset
 | 
903  | 
v = GetVehicle(w->window_number);  | 
| 
193
 
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
 
truelight 
parents: 
176 
diff
changeset
 | 
904  | 
|
| 
2867
 
91ee491df4ec
(svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
 
peter1138 
parents: 
2840 
diff
changeset
 | 
905  | 
		if (v->owner != _local_player) {
 | 
| 
 
91ee491df4ec
(svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
 
peter1138 
parents: 
2840 
diff
changeset
 | 
906  | 
w->disabled_state = 0x3380;  | 
| 
 
91ee491df4ec
(svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
 
peter1138 
parents: 
2840 
diff
changeset
 | 
907  | 
		} else {
 | 
| 
 
91ee491df4ec
(svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
 
peter1138 
parents: 
2840 
diff
changeset
 | 
908  | 
w->disabled_state = 0;  | 
| 
1387
 
bc0131072af9
(svn r1891) -Fix: [ 1143587 ] carriages of newgrfs can be refitted again
 
celestar 
parents: 
1330 
diff
changeset
 | 
909  | 
|
| 
2867
 
91ee491df4ec
(svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
 
peter1138 
parents: 
2840 
diff
changeset
 | 
910  | 
SETBIT(w->disabled_state, 12);  | 
| 
 
91ee491df4ec
(svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
 
peter1138 
parents: 
2840 
diff
changeset
 | 
911  | 
|
| 
 
91ee491df4ec
(svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
 
peter1138 
parents: 
2840 
diff
changeset
 | 
912  | 
/* See if any vehicle can be refitted */  | 
| 
 
91ee491df4ec
(svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
 
peter1138 
parents: 
2840 
diff
changeset
 | 
913  | 
			for (u = v; u != NULL; u = u->next) {
 | 
| 
 
91ee491df4ec
(svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
 
peter1138 
parents: 
2840 
diff
changeset
 | 
914  | 
if (_engine_info[u->engine_type].refit_mask != 0 ||  | 
| 
 
91ee491df4ec
(svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
 
peter1138 
parents: 
2840 
diff
changeset
 | 
915  | 
						(!(RailVehInfo(v->engine_type)->flags & RVI_WAGON) && v->cargo_cap != 0)) {
 | 
| 
 
91ee491df4ec
(svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
 
peter1138 
parents: 
2840 
diff
changeset
 | 
916  | 
CLRBIT(w->disabled_state, 12);  | 
| 
 
91ee491df4ec
(svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
 
peter1138 
parents: 
2840 
diff
changeset
 | 
917  | 
/* We have a refittable carriage, bail out */  | 
| 
 
91ee491df4ec
(svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
 
peter1138 
parents: 
2840 
diff
changeset
 | 
918  | 
break;  | 
| 
 
91ee491df4ec
(svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
 
peter1138 
parents: 
2840 
diff
changeset
 | 
919  | 
}  | 
| 
1387
 
bc0131072af9
(svn r1891) -Fix: [ 1143587 ] carriages of newgrfs can be refitted again
 
celestar 
parents: 
1330 
diff
changeset
 | 
920  | 
}  | 
| 
 
bc0131072af9
(svn r1891) -Fix: [ 1143587 ] carriages of newgrfs can be refitted again
 
celestar 
parents: 
1330 
diff
changeset
 | 
921  | 
}  | 
| 
 
bc0131072af9
(svn r1891) -Fix: [ 1143587 ] carriages of newgrfs can be refitted again
 
celestar 
parents: 
1330 
diff
changeset
 | 
922  | 
|
| 0 | 923  | 
/* draw widgets & caption */  | 
| 
534
 
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
 
tron 
parents: 
524 
diff
changeset
 | 
924  | 
SetDParam(0, v->string_id);  | 
| 
2261
 
d3554e5d3e86
(svn r2781) Fix some of the issues with variables in .h files.
 
ludde 
parents: 
2252 
diff
changeset
 | 
925  | 
SetDParam(1, v->unitnumber);  | 
| 0 | 926  | 
DrawWindowWidgets(w);  | 
927  | 
||
928  | 
		if (v->u.rail.crash_anim_pos != 0) {
 | 
|
929  | 
str = STR_8863_CRASHED;  | 
|
930  | 
		} else if (v->breakdown_ctr == 1) {
 | 
|
931  | 
str = STR_885C_BROKEN_DOWN;  | 
|
932  | 
		} else if (v->vehstatus & VS_STOPPED) {
 | 
|
933  | 
			if (v->u.rail.last_speed == 0) {
 | 
|
934  | 
str = STR_8861_STOPPED;  | 
|
935  | 
			} else {
 | 
|
| 
534
 
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
 
tron 
parents: 
524 
diff
changeset
 | 
936  | 
SetDParam(0, v->u.rail.last_speed * 10 >> 4);  | 
| 0 | 937  | 
str = STR_TRAIN_STOPPING + _patches.vehicle_speed;  | 
938  | 
}  | 
|
939  | 
		} else {
 | 
|
| 
555
 
02df8a1b7f33
(svn r955) Replace uint16 for orders with struct Order
 
tron 
parents: 
543 
diff
changeset
 | 
940  | 
			switch (v->current_order.type) {
 | 
| 0 | 941  | 
			case OT_GOTO_STATION: {
 | 
942  | 
str = STR_HEADING_FOR_STATION + _patches.vehicle_speed;  | 
|
| 
555
 
02df8a1b7f33
(svn r955) Replace uint16 for orders with struct Order
 
tron 
parents: 
543 
diff
changeset
 | 
943  | 
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
 | 
944  | 
SetDParam(1, v->u.rail.last_speed * 10 >> 4);  | 
| 0 | 945  | 
} break;  | 
946  | 
||
947  | 
			case OT_GOTO_DEPOT: {
 | 
|
| 
1313
 
f1013ec3d318
(svn r1817) -Codechange: Moved depot-functions to depot.c
 
truelight 
parents: 
1299 
diff
changeset
 | 
948  | 
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
 | 
949  | 
SetDParam(0, dep->town_index);  | 
| 0 | 950  | 
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
 | 
951  | 
SetDParam(1, v->u.rail.last_speed * 10 >> 4);  | 
| 0 | 952  | 
} break;  | 
953  | 
||
954  | 
case OT_LOADING:  | 
|
955  | 
case OT_LEAVESTATION:  | 
|
956  | 
str = STR_882F_LOADING_UNLOADING;  | 
|
957  | 
break;  | 
|
958  | 
||
| 
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
 | 
959  | 
			case OT_GOTO_WAYPOINT: {
 | 
| 
555
 
02df8a1b7f33
(svn r955) Replace uint16 for orders with struct Order
 
tron 
parents: 
543 
diff
changeset
 | 
960  | 
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
 | 
961  | 
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
 | 
962  | 
SetDParam(1, v->u.rail.last_speed * 10 >> 4);  | 
| 0 | 963  | 
break;  | 
964  | 
}  | 
|
| 
193
 
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
 
truelight 
parents: 
176 
diff
changeset
 | 
965  | 
|
| 0 | 966  | 
default:  | 
967  | 
				if (v->num_orders == 0) {
 | 
|
968  | 
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
 | 
969  | 
SetDParam(0, v->u.rail.last_speed * 10 >> 4);  | 
| 0 | 970  | 
} else  | 
971  | 
str = STR_EMPTY;  | 
|
972  | 
break;  | 
|
973  | 
}  | 
|
974  | 
}  | 
|
975  | 
||
| 
2103
 
a2b3106d33d5
(svn r2613) - Truncate savegames, and vehicle-texts in their window.
 
Darkvater 
parents: 
2084 
diff
changeset
 | 
976  | 
/* draw the flag plus orders */  | 
| 
2517
 
6e3832ddd0f6
(svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
 
tron 
parents: 
2498 
diff
changeset
 | 
977  | 
DrawSprite(v->vehstatus & VS_STOPPED ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, 2, w->widget[5].top + 1);  | 
| 
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
 | 
978  | 
DrawStringCenteredTruncated(w->widget[5].left + 8, w->widget[5].right, w->widget[5].top + 1, str, 0);  | 
| 0 | 979  | 
DrawWindowViewport(w);  | 
980  | 
} break;  | 
|
981  | 
||
982  | 
	case WE_CLICK: {
 | 
|
983  | 
int wid = e->click.widget;  | 
|
| 
919
 
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
 
truelight 
parents: 
914 
diff
changeset
 | 
984  | 
Vehicle *v = GetVehicle(w->window_number);  | 
| 0 | 985  | 
|
| 2952 | 986  | 
		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
 | 
987  | 
case 5: /* start/stop train */  | 
| 
193
 
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
 
truelight 
parents: 
176 
diff
changeset
 | 
988  | 
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_TRAIN | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN));  | 
| 0 | 989  | 
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
 | 
990  | 
case 6: /* center main view */  | 
| 0 | 991  | 
ScrollMainWindowTo(v->x_pos, v->y_pos);  | 
992  | 
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
 | 
993  | 
case 7: /* goto depot */  | 
| 
601
 
3d15c18e3a8e
(svn r1025) -Fix: [Network] [ 1083687 ] Sending to depot caused desync because the
 
truelight 
parents: 
588 
diff
changeset
 | 
994  | 
/* 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
 | 
995  | 
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 | 996  | 
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
 | 
997  | 
case 8: /* force proceed */  | 
| 
193
 
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
 
truelight 
parents: 
176 
diff
changeset
 | 
998  | 
DoCommandP(v->tile, v->index, 0, NULL, CMD_FORCE_TRAIN_PROCEED | CMD_MSG(STR_8862_CAN_T_MAKE_TRAIN_PASS_SIGNAL));  | 
| 0 | 999  | 
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
 | 
1000  | 
case 9: /* reverse direction */  | 
| 
193
 
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
 
truelight 
parents: 
176 
diff
changeset
 | 
1001  | 
DoCommandP(v->tile, v->index, 0, NULL, CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_8869_CAN_T_REVERSE_DIRECTION));  | 
| 0 | 1002  | 
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
 | 
1003  | 
case 10: /* show train orders */  | 
| 0 | 1004  | 
ShowOrdersWindow(v);  | 
1005  | 
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
 | 
1006  | 
case 11: /* show train details */  | 
| 0 | 1007  | 
ShowTrainDetailsWindow(v);  | 
1008  | 
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
 | 
1009  | 
case 12:  | 
| 0 | 1010  | 
ShowRailVehicleRefitWindow(v);  | 
1011  | 
break;  | 
|
| 2244 | 1012  | 
case 13:  | 
1013  | 
DoCommandP(v->tile, v->index, _ctrl_pressed ? 1 : 0, NULL, CMD_CLONE_VEHICLE | CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE));  | 
|
1014  | 
break;  | 
|
| 0 | 1015  | 
}  | 
1016  | 
} break;  | 
|
1017  | 
||
| 
1485
 
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
 
tron 
parents: 
1402 
diff
changeset
 | 
1018  | 
case WE_RESIZE:  | 
| 
 
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
 
tron 
parents: 
1402 
diff
changeset
 | 
1019  | 
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
 | 
1020  | 
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
 | 
1021  | 
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
 | 
1022  | 
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
 | 
1023  | 
break;  | 
| 
 
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
 
tron 
parents: 
1402 
diff
changeset
 | 
1024  | 
|
| 0 | 1025  | 
case WE_DESTROY:  | 
| 
338
 
37500d4214f3
(svn r514) -Fix: [1053397] Refit Train Window Stays Open
 
tron 
parents: 
243 
diff
changeset
 | 
1026  | 
DeleteWindowById(WC_VEHICLE_REFIT, w->window_number);  | 
| 0 | 1027  | 
DeleteWindowById(WC_VEHICLE_ORDERS, w->window_number);  | 
1028  | 
DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number);  | 
|
1029  | 
break;  | 
|
1030  | 
||
1031  | 
	case WE_MOUSELOOP: {
 | 
|
1032  | 
Vehicle *v;  | 
|
1033  | 
uint32 h;  | 
|
1034  | 
||
| 
919
 
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
 
truelight 
parents: 
914 
diff
changeset
 | 
1035  | 
v = GetVehicle(w->window_number);  | 
| 0 | 1036  | 
assert(v->type == VEH_Train);  | 
| 2244 | 1037  | 
h = CheckTrainStoppedInDepot(v) >= 0 ? (1 << 9)| (1 << 7) : (1 << 12) | (1 << 13);  | 
| 0 | 1038  | 
		if (h != w->hidden_state) {
 | 
1039  | 
w->hidden_state = h;  | 
|
1040  | 
SetWindowDirty(w);  | 
|
1041  | 
}  | 
|
1042  | 
break;  | 
|
1043  | 
}  | 
|
1044  | 
||
1045  | 
}  | 
|
1046  | 
}  | 
|
1047  | 
||
1048  | 
static const WindowDesc _train_view_desc = {
 | 
|
1049  | 
-1,-1, 250, 134,  | 
|
1050  | 
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
 | 
1051  | 
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,  | 
| 0 | 1052  | 
_train_view_widgets,  | 
1053  | 
TrainViewWndProc  | 
|
1054  | 
};  | 
|
1055  | 
||
| 
2561
 
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
 
tron 
parents: 
2549 
diff
changeset
 | 
1056  | 
void ShowTrainViewWindow(const Vehicle* v)  | 
| 0 | 1057  | 
{
 | 
| 
2561
 
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
 
tron 
parents: 
2549 
diff
changeset
 | 
1058  | 
Window* w = AllocateWindowDescFront(&_train_view_desc,v->index);  | 
| 0 | 1059  | 
|
| 
2561
 
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
 
tron 
parents: 
2549 
diff
changeset
 | 
1060  | 
	if (w != NULL) {
 | 
| 0 | 1061  | 
w->caption_color = v->owner;  | 
1062  | 
AssignWindowViewport(w, 3, 17, 0xE2, 0x66, w->window_number | (1 << 31), 0);  | 
|
1063  | 
}  | 
|
1064  | 
}  | 
|
1065  | 
||
| 
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
 | 
1066  | 
static void TrainDetailsCargoTab(const Vehicle *v, int x, int y)  | 
| 0 | 1067  | 
{
 | 
1068  | 
int num;  | 
|
1069  | 
StringID str;  | 
|
1070  | 
||
1071  | 
	if (v->cargo_cap != 0) {
 | 
|
1072  | 
num = v->cargo_count;  | 
|
1073  | 
str = STR_8812_EMPTY;  | 
|
1074  | 
		if (num != 0) {
 | 
|
| 
534
 
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
 
tron 
parents: 
524 
diff
changeset
 | 
1075  | 
SetDParam(0, v->cargo_type);  | 
| 
 
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
 
tron 
parents: 
524 
diff
changeset
 | 
1076  | 
SetDParam(1, num);  | 
| 
 
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
 
tron 
parents: 
524 
diff
changeset
 | 
1077  | 
SetDParam(2, v->cargo_source);  | 
| 0 | 1078  | 
str = STR_8813_FROM;  | 
1079  | 
}  | 
|
1080  | 
DrawString(x, y, str, 0);  | 
|
1081  | 
}  | 
|
1082  | 
}  | 
|
1083  | 
||
| 
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
 | 
1084  | 
static void TrainDetailsInfoTab(const Vehicle *v, int x, int y)  | 
| 0 | 1085  | 
{
 | 
| 
540
 
2987d7976ea2
(svn r924) Use RailVehInfo() instead of &_rail_vehicle_info[]
 
tron 
parents: 
539 
diff
changeset
 | 
1086  | 
const RailVehicleInfo *rvi = RailVehInfo(v->engine_type);  | 
| 0 | 1087  | 
|
1088  | 
	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
 | 
1089  | 
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
 | 
1090  | 
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
 | 
1091  | 
SetDParam(2, v->value);  | 
| 0 | 1092  | 
DrawString(x, y, STR_882C_BUILT_VALUE, 0x10);  | 
1093  | 
	} else {
 | 
|
| 
534
 
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
 
tron 
parents: 
524 
diff
changeset
 | 
1094  | 
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
 | 
1095  | 
SetDParam(1, v->value);  | 
| 0 | 1096  | 
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
 | 
1097  | 
}  | 
| 0 | 1098  | 
}  | 
1099  | 
||
| 
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
 | 
1100  | 
static void TrainDetailsCapacityTab(const Vehicle *v, int x, int y)  | 
| 0 | 1101  | 
{
 | 
1102  | 
	if (v->cargo_cap != 0) {
 | 
|
| 
2084
 
65639f898a50
(svn r2594) Fix: [strgen] Misc updates to the string system.
 
ludde 
parents: 
2049 
diff
changeset
 | 
1103  | 
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
 | 
1104  | 
SetDParam(1, v->cargo_cap);  | 
| 0 | 1105  | 
DrawString(x, y, STR_013F_CAPACITY, 0);  | 
1106  | 
}  | 
|
1107  | 
}  | 
|
1108  | 
||
| 
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
 | 
1109  | 
typedef void TrainDetailsDrawerProc(const Vehicle *v, int x, int y);  | 
| 0 | 1110  | 
|
1111  | 
static TrainDetailsDrawerProc * const _train_details_drawer_proc[3] = {
 | 
|
1112  | 
TrainDetailsCargoTab,  | 
|
1113  | 
TrainDetailsInfoTab,  | 
|
1114  | 
TrainDetailsCapacityTab,  | 
|
1115  | 
};  | 
|
1116  | 
||
1117  | 
static void DrawTrainDetailsWindow(Window *w)  | 
|
1118  | 
{
 | 
|
| 
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
 | 
1119  | 
const Vehicle *v, *u;  | 
| 0 | 1120  | 
uint16 tot_cargo[NUM_CARGO][2]; // count total cargo ([0]-actual cargo, [1]-total cargo)  | 
1121  | 
int i,num,x,y,sel;  | 
|
1122  | 
byte det_tab = WP(w, traindetails_d).tab;  | 
|
1123  | 
||
1124  | 
/* Count number of vehicles */  | 
|
1125  | 
num = 0;  | 
|
1126  | 
||
1127  | 
// det_tab == 3 <-- Total Cargo tab  | 
|
1128  | 
if (det_tab == 3) // reset tot_cargo array to 0 values  | 
|
1129  | 
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
 | 
1130  | 
|
| 
919
 
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
 
truelight 
parents: 
914 
diff
changeset
 | 
1131  | 
u = v = GetVehicle(w->window_number);  | 
| 0 | 1132  | 
	do {
 | 
1133  | 
if (det_tab != 3)  | 
|
1134  | 
num++;  | 
|
1135  | 
		else {
 | 
|
1136  | 
tot_cargo[u->cargo_type][0] += u->cargo_count;  | 
|
1137  | 
tot_cargo[u->cargo_type][1] += u->cargo_cap;  | 
|
1138  | 
}  | 
|
| 
2602
 
1a6561c9a408
(svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
 
peter1138 
parents: 
2593 
diff
changeset
 | 
1139  | 
} while ((u = GetNextVehicle(u)) != NULL);  | 
| 0 | 1140  | 
|
1141  | 
/* set scroll-amount seperately from counting, as to not  | 
|
1142  | 
compute num double for more carriages of the same type  | 
|
1143  | 
*/  | 
|
1144  | 
	if (det_tab == 3) {
 | 
|
1145  | 
		for (i = 0; i != NUM_CARGO; i++) {
 | 
|
1146  | 
if (tot_cargo[i][1] > 0) // only count carriages that the train has  | 
|
1147  | 
num++;  | 
|
1148  | 
}  | 
|
1149  | 
num++; // needs one more because first line is description string  | 
|
1150  | 
}  | 
|
1151  | 
||
1152  | 
SetVScrollCount(w, num);  | 
|
1153  | 
||
1154  | 
w->disabled_state = 1 << (det_tab + 9);  | 
|
1155  | 
if (v->owner != _local_player)  | 
|
1156  | 
w->disabled_state |= (1 << 2);  | 
|
1157  | 
||
| 
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
 | 
1158  | 
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
 | 
1159  | 
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
 | 
1160  | 
|
| 
534
 
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
 
tron 
parents: 
524 
diff
changeset
 | 
1161  | 
SetDParam(0, v->string_id);  | 
| 
 
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
 
tron 
parents: 
524 
diff
changeset
 | 
1162  | 
SetDParam(1, v->unitnumber);  | 
| 0 | 1163  | 
DrawWindowWidgets(w);  | 
1164  | 
||
1165  | 
num = v->age / 366;  | 
|
| 
534
 
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
 
tron 
parents: 
524 
diff
changeset
 | 
1166  | 
SetDParam(1, num);  | 
| 
193
 
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
 
truelight 
parents: 
176 
diff
changeset
 | 
1167  | 
|
| 0 | 1168  | 
x = 2;  | 
| 
193
 
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
 
truelight 
parents: 
176 
diff
changeset
 | 
1169  | 
|
| 
2252
 
6df2bfd7a077
(svn r2772) Simplify the age notice in the vehicle details window
 
tron 
parents: 
2244 
diff
changeset
 | 
1170  | 
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
 | 
1171  | 
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
 | 
1172  | 
SetDParam(3, GetTrainRunningCost(v) >> 8);  | 
| 0 | 1173  | 
DrawString(x, 15, STR_885D_AGE_RUNNING_COST_YR, 0);  | 
1174  | 
||
| 
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
 | 
1175  | 
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
 | 
1176  | 
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
 | 
1177  | 
SetDParam(0, v->u.rail.cached_weight);  | 
| 0 | 1178  | 
DrawString(x, 25, STR_885E_WEIGHT_T_POWER_HP_MAX_SPEED, 0);  | 
1179  | 
||
| 
534
 
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
 
tron 
parents: 
524 
diff
changeset
 | 
1180  | 
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
 | 
1181  | 
SetDParam(1, v->profit_last_year);  | 
| 0 | 1182  | 
DrawString(x, 35, STR_885F_PROFIT_THIS_YEAR_LAST_YEAR, 0);  | 
1183  | 
||
| 
534
 
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
 
tron 
parents: 
524 
diff
changeset
 | 
1184  | 
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
 | 
1185  | 
SetDParam(1, v->breakdowns_since_last_service);  | 
| 0 | 1186  | 
DrawString(x, 45, STR_8860_RELIABILITY_BREAKDOWNS, 0);  | 
1187  | 
||
| 
534
 
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
 
tron 
parents: 
524 
diff
changeset
 | 
1188  | 
SetDParam(0, v->service_interval);  | 
| 
 
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
 
tron 
parents: 
524 
diff
changeset
 | 
1189  | 
SetDParam(1, v->date_of_last_service);  | 
| 
2959
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1190  | 
DrawString(x + 11, 57 + (w->vscroll.cap * 14), _patches.servint_ispercent ? STR_SERVICING_INTERVAL_PERCENT : STR_883C_SERVICING_INTERVAL_DAYS, 0);  | 
| 0 | 1191  | 
|
1192  | 
y = 57;  | 
|
1193  | 
sel = w->vscroll.pos;  | 
|
| 
193
 
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
 
truelight 
parents: 
176 
diff
changeset
 | 
1194  | 
|
| 0 | 1195  | 
// draw the first 3 details tabs  | 
1196  | 
	if (det_tab != 3) {
 | 
|
| 
2822
 
3685b5c83c57
(svn r3370) Improve alignment of text within total cargo tab of train view window
 
peter1138 
parents: 
2819 
diff
changeset
 | 
1197  | 
x = 1;  | 
| 2952 | 1198  | 
		for (;;) {
 | 
| 
2959
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1199  | 
			if (--sel < 0 && sel >= -w->vscroll.cap) {
 | 
| 
2602
 
1a6561c9a408
(svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
 
peter1138 
parents: 
2593 
diff
changeset
 | 
1200  | 
int dx = 0;  | 
| 
 
1a6561c9a408
(svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
 
peter1138 
parents: 
2593 
diff
changeset
 | 
1201  | 
u = v;  | 
| 
 
1a6561c9a408
(svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
 
peter1138 
parents: 
2593 
diff
changeset
 | 
1202  | 
				do {
 | 
| 
 
1a6561c9a408
(svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
 
peter1138 
parents: 
2593 
diff
changeset
 | 
1203  | 
DrawTrainImage(u, x + WagonLengthToPixels(dx), y, 1, 0, INVALID_VEHICLE);  | 
| 
 
1a6561c9a408
(svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
 
peter1138 
parents: 
2593 
diff
changeset
 | 
1204  | 
dx += u->u.rail.cached_veh_length;  | 
| 
 
1a6561c9a408
(svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
 
peter1138 
parents: 
2593 
diff
changeset
 | 
1205  | 
u = u->next;  | 
| 
2676
 
59b65b4fb480
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
 
bjarni 
parents: 
2639 
diff
changeset
 | 
1206  | 
} while (u != NULL && IsArticulatedPart(u));  | 
| 
2602
 
1a6561c9a408
(svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
 
peter1138 
parents: 
2593 
diff
changeset
 | 
1207  | 
_train_details_drawer_proc[WP(w,traindetails_d).tab](v, x + WagonLengthToPixels(dx) + 2, y + 2);  | 
| 0 | 1208  | 
y += 14;  | 
1209  | 
}  | 
|
| 
2602
 
1a6561c9a408
(svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
 
peter1138 
parents: 
2593 
diff
changeset
 | 
1210  | 
if ((v = GetNextVehicle(v)) == NULL)  | 
| 0 | 1211  | 
return;  | 
1212  | 
}  | 
|
| 
2959
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1213  | 
	} else {
 | 
| 
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1214  | 
// draw total cargo tab  | 
| 0 | 1215  | 
DrawString(x, y + 2, STR_013F_TOTAL_CAPACITY_TEXT, 0);  | 
| 
2959
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1216  | 
		for (i = 0; i != NUM_CARGO; i++) {
 | 
| 
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1217  | 
			if (tot_cargo[i][1] > 0 && --sel < 0 && sel > -w->vscroll.cap) {
 | 
| 0 | 1218  | 
y += 14;  | 
1219  | 
				// 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
 | 
1220  | 
				SetDParam(0, i);								// {CARGO} #1
 | 
| 
 
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
 
tron 
parents: 
524 
diff
changeset
 | 
1221  | 
				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
 | 
1222  | 
				SetDParam(2, i);								// {SHORTCARGO} #1
 | 
| 
 
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
 
tron 
parents: 
524 
diff
changeset
 | 
1223  | 
				SetDParam(3, tot_cargo[i][1]);	// {SHORTCARGO} #2
 | 
| 
2822
 
3685b5c83c57
(svn r3370) Improve alignment of text within total cargo tab of train view window
 
peter1138 
parents: 
2819 
diff
changeset
 | 
1224  | 
DrawString(x, y + 2, STR_013F_TOTAL_CAPACITY, 0);  | 
| 0 | 1225  | 
}  | 
| 
2959
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1226  | 
}  | 
| 0 | 1227  | 
}  | 
1228  | 
}  | 
|
1229  | 
||
1230  | 
static void TrainDetailsWndProc(Window *w, WindowEvent *e)  | 
|
1231  | 
{
 | 
|
| 
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
 | 
1232  | 
	switch (e->event) {
 | 
| 0 | 1233  | 
case WE_PAINT:  | 
1234  | 
DrawTrainDetailsWindow(w);  | 
|
1235  | 
break;  | 
|
1236  | 
	case WE_CLICK: {
 | 
|
1237  | 
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
 | 
1238  | 
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
 | 
1239  | 
		switch (e->click.widget) {
 | 
| 0 | 1240  | 
case 2: /* name train */  | 
| 
919
 
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
 
truelight 
parents: 
914 
diff
changeset
 | 
1241  | 
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
 | 
1242  | 
SetDParam(0, v->unitnumber);  | 
| 0 | 1243  | 
ShowQueryString(v->string_id, STR_8865_NAME_TRAIN, 31, 150, w->window_class, w->window_number);  | 
1244  | 
break;  | 
|
1245  | 
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
 | 
1246  | 
mod = _ctrl_pressed? 5 : 10;  | 
| 0 | 1247  | 
goto do_change_service_int;  | 
1248  | 
||
1249  | 
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
 | 
1250  | 
mod = _ctrl_pressed? -5 : -10;  | 
| 0 | 1251  | 
do_change_service_int:  | 
| 
919
 
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
 
truelight 
parents: 
914 
diff
changeset
 | 
1252  | 
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
 | 
1253  | 
|
| 
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
 | 
1254  | 
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
 | 
1255  | 
if (mod == v->service_interval) return;  | 
| 
193
 
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
 
truelight 
parents: 
176 
diff
changeset
 | 
1256  | 
|
| 
2819
 
f25fb6ee397f
(svn r3367) Unify the 4 distinct CMD_CHANGE_{AIRCRAFT,ROADVEH,SHIP,TRAIN}_SERVICE_INT commands into one CMD_CHANGE_SERVICE_INT command.
 
tron 
parents: 
2806 
diff
changeset
 | 
1257  | 
DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING));  | 
| 0 | 1258  | 
break;  | 
1259  | 
/* details buttons*/  | 
|
1260  | 
case 9: // Cargo  | 
|
1261  | 
case 10: // Information  | 
|
1262  | 
case 11: // Capacities  | 
|
1263  | 
case 12: // Total cargo  | 
|
1264  | 
CLRBIT(w->disabled_state, 9);  | 
|
1265  | 
CLRBIT(w->disabled_state, 10);  | 
|
1266  | 
CLRBIT(w->disabled_state, 11);  | 
|
1267  | 
CLRBIT(w->disabled_state, 12);  | 
|
1268  | 
SETBIT(w->disabled_state, e->click.widget);  | 
|
1269  | 
WP(w,traindetails_d).tab = e->click.widget - 9;  | 
|
1270  | 
SetWindowDirty(w);  | 
|
1271  | 
break;  | 
|
1272  | 
}  | 
|
1273  | 
} break;  | 
|
1274  | 
||
1275  | 
case WE_4:  | 
|
1276  | 
if (FindWindowById(WC_VEHICLE_VIEW, w->window_number) == NULL)  | 
|
1277  | 
DeleteWindow(w);  | 
|
1278  | 
break;  | 
|
1279  | 
||
| 
2548
 
49c8a096033f
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
 
tron 
parents: 
2520 
diff
changeset
 | 
1280  | 
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
 | 
1281  | 
		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
 | 
1282  | 
_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
 | 
1283  | 
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
 | 
1284  | 
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
 | 
1285  | 
}  | 
| 
2548
 
49c8a096033f
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
 
tron 
parents: 
2520 
diff
changeset
 | 
1286  | 
break;  | 
| 
2959
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1287  | 
|
| 
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1288  | 
case WE_RESIZE:  | 
| 
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1289  | 
if (e->sizing.diff.y == 0)  | 
| 
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1290  | 
break;  | 
| 
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1291  | 
|
| 
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1292  | 
w->vscroll.cap += e->sizing.diff.y / 14;  | 
| 
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1293  | 
w->widget[4].unkA = (w->vscroll.cap << 8) + 1;  | 
| 
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1294  | 
break;  | 
| 0 | 1295  | 
}  | 
1296  | 
}  | 
|
1297  | 
||
1298  | 
static const Widget _train_details_widgets[] = {
 | 
|
| 
2959
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1299  | 
{   WWT_CLOSEBOX, RESIZE_NONE,   14,   0,  10,   0,  13, STR_00C5,             STR_018B_CLOSE_WINDOW},
 | 
| 
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1300  | 
{    WWT_CAPTION, RESIZE_NONE,   14,  11, 329,   0,  13, STR_8802_DETAILS,     STR_018C_WINDOW_TITLE_DRAG_THIS},
 | 
| 
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1301  | 
{ WWT_PUSHTXTBTN, RESIZE_NONE,   14, 330, 369,   0,  13, STR_01AA_NAME,        STR_8867_NAME_TRAIN},
 | 
| 
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1302  | 
{      WWT_PANEL, RESIZE_NONE,   14,   0, 369,  14,  55, 0x0,                  STR_NULL},
 | 
| 
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1303  | 
{     WWT_MATRIX, RESIZE_BOTTOM, 14,   0, 357,  56, 139, 0x601,                STR_NULL},
 | 
| 
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1304  | 
{  WWT_SCROLLBAR, RESIZE_BOTTOM, 14, 358, 369,  56, 139, 0x0,                  STR_0190_SCROLL_BAR_SCROLLS_LIST},
 | 
| 
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1305  | 
{ WWT_PUSHTXTBTN, RESIZE_TB,     14,   0,  10, 140, 145, STR_0188,             STR_884D_INCREASE_SERVICING_INTERVAL},
 | 
| 
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1306  | 
{ WWT_PUSHTXTBTN, RESIZE_TB,     14,   0,  10, 146, 151, STR_0189,             STR_884E_DECREASE_SERVICING_INTERVAL},
 | 
| 
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1307  | 
{      WWT_PANEL, RESIZE_TB,     14,  11, 369, 140, 151, 0x0,                  STR_NULL},
 | 
| 
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1308  | 
{ WWT_PUSHTXTBTN, RESIZE_TB,     14,   0,  89, 152, 163, STR_013C_CARGO,       STR_884F_SHOW_DETAILS_OF_CARGO_CARRIED},
 | 
| 
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1309  | 
{ WWT_PUSHTXTBTN, RESIZE_TB,     14,  90, 178, 152, 163, STR_013D_INFORMATION, STR_8850_SHOW_DETAILS_OF_TRAIN_VEHICLES},
 | 
| 
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1310  | 
{ WWT_PUSHTXTBTN, RESIZE_TB,     14, 179, 268, 152, 163, STR_013E_CAPACITIES,  STR_8851_SHOW_CAPACITIES_OF_EACH},
 | 
| 
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1311  | 
{ WWT_PUSHTXTBTN, RESIZE_TB,     14, 269, 357, 152, 163, STR_013E_TOTAL_CARGO, STR_8852_SHOW_TOTAL_CARGO},
 | 
| 
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1312  | 
{  WWT_RESIZEBOX, RESIZE_TB,     14, 358, 369, 152, 163, 0x0,                  STR_RESIZE_BUTTON},
 | 
| 
176
 
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
 
darkvater 
parents: 
174 
diff
changeset
 | 
1313  | 
{   WIDGETS_END},
 | 
| 0 | 1314  | 
};  | 
1315  | 
||
1316  | 
||
1317  | 
static const WindowDesc _train_details_desc = {
 | 
|
1318  | 
-1,-1, 370, 164,  | 
|
1319  | 
WC_VEHICLE_DETAILS,WC_VEHICLE_VIEW,  | 
|
| 
2959
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1320  | 
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,  | 
| 0 | 1321  | 
_train_details_widgets,  | 
1322  | 
TrainDetailsWndProc  | 
|
1323  | 
};  | 
|
1324  | 
||
1325  | 
||
| 
2561
 
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
 
tron 
parents: 
2549 
diff
changeset
 | 
1326  | 
static void ShowTrainDetailsWindow(const Vehicle* v)  | 
| 0 | 1327  | 
{
 | 
1328  | 
Window *w;  | 
|
1329  | 
VehicleID veh = v->index;  | 
|
1330  | 
||
1331  | 
DeleteWindowById(WC_VEHICLE_ORDERS, veh);  | 
|
1332  | 
DeleteWindowById(WC_VEHICLE_DETAILS, veh);  | 
|
1333  | 
||
| 
193
 
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
 
truelight 
parents: 
176 
diff
changeset
 | 
1334  | 
_alloc_wnd_parent_num = veh;  | 
| 0 | 1335  | 
w = AllocateWindowDesc(&_train_details_desc);  | 
1336  | 
||
1337  | 
w->window_number = veh;  | 
|
1338  | 
w->caption_color = v->owner;  | 
|
1339  | 
w->vscroll.cap = 6;  | 
|
| 
2959
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1340  | 
w->widget[4].unkA = (w->vscroll.cap << 8) + 1;  | 
| 
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1341  | 
|
| 
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1342  | 
w->resize.step_height = 14;  | 
| 
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1343  | 
w->resize.height = w->height - 14 * 2; /* Minimum of 4 wagons in the display */  | 
| 
 
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
 
peter1138 
parents: 
2958 
diff
changeset
 | 
1344  | 
|
| 0 | 1345  | 
WP(w,traindetails_d).tab = 0;  | 
1346  | 
}  | 
|
1347  | 
||
| 
867
 
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
 
truelight 
parents: 
842 
diff
changeset
 | 
1348  | 
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
 | 
1349  | 
{   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
 | 
1350  | 
{    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
 | 
1351  | 
{  WWT_STICKYBOX,     RESIZE_LR,    14,   313,   324,     0,    13, 0x0,										STR_STICKY_BUTTON},
 | 
| 
2806
 
74949f22099e
(svn r3354) Fix a typo, which survived for about 3000 revisions: s/SRT_SORT_BY/STR_SORT_BY/ (noticed by chu)
 
tron 
parents: 
2803 
diff
changeset
 | 
1352  | 
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    80,    14,    25, STR_SORT_BY,						STR_SORT_ORDER_TIP},
 | 
| 
2803
 
c472e0d3f31a
(svn r3351) Make sort criteria selection widgets in player train list consistent with those widgets in other vehicle type lists. (Stops "Total capacity per cargo type" overflowing)
 
peter1138 
parents: 
2725 
diff
changeset
 | 
1353  | 
{      WWT_PANEL,   RESIZE_NONE,    14,    81,   235,    14,    25, 0x0,										STR_SORT_CRITERIA_TIP},
 | 
| 
 
c472e0d3f31a
(svn r3351) Make sort criteria selection widgets in player train list consistent with those widgets in other vehicle type lists. (Stops "Total capacity per cargo type" overflowing)
 
peter1138 
parents: 
2725 
diff
changeset
 | 
1354  | 
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   236,   247,    14,    25, STR_0225,							STR_SORT_CRITERIA_TIP},
 | 
| 
 
c472e0d3f31a
(svn r3351) Make sort criteria selection widgets in player train list consistent with those widgets in other vehicle type lists. (Stops "Total capacity per cargo type" overflowing)
 
peter1138 
parents: 
2725 
diff
changeset
 | 
1355  | 
{      WWT_PANEL,  RESIZE_RIGHT,    14,   248,   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
 | 
1356  | 
{     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
 | 
1357  | 
{  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
 | 
1358  | 
{ 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
 | 
1359  | 
{ 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
 | 
1360  | 
{      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
 | 
1361  | 
{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   313,   324,   208,   219, 0x0,										STR_RESIZE_BUTTON},
 | 
| 588 | 1362  | 
{   WIDGETS_END},
 | 
1363  | 
};  | 
|
| 
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
 | 
1364  | 
|
| 
867
 
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
 
truelight 
parents: 
842 
diff
changeset
 | 
1365  | 
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
 | 
1366  | 
{   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
 | 
1367  | 
{    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
 | 
1368  | 
{  WWT_STICKYBOX,     RESIZE_LR,    14,   313,   324,     0,    13, 0x0,										STR_STICKY_BUTTON},
 | 
| 
2806
 
74949f22099e
(svn r3354) Fix a typo, which survived for about 3000 revisions: s/SRT_SORT_BY/STR_SORT_BY/ (noticed by chu)
 
tron 
parents: 
2803 
diff
changeset
 | 
1369  | 
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    80,    14,    25, STR_SORT_BY,						STR_SORT_ORDER_TIP},
 | 
| 
2803
 
c472e0d3f31a
(svn r3351) Make sort criteria selection widgets in player train list consistent with those widgets in other vehicle type lists. (Stops "Total capacity per cargo type" overflowing)
 
peter1138 
parents: 
2725 
diff
changeset
 | 
1370  | 
{      WWT_PANEL,   RESIZE_NONE,    14,    81,   235,    14,    25, 0x0,										STR_SORT_CRITERIA_TIP},
 | 
| 
 
c472e0d3f31a
(svn r3351) Make sort criteria selection widgets in player train list consistent with those widgets in other vehicle type lists. (Stops "Total capacity per cargo type" overflowing)
 
peter1138 
parents: 
2725 
diff
changeset
 | 
1371  | 
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   236,   247,    14,    25, STR_0225,							STR_SORT_CRITERIA_TIP},
 | 
| 
 
c472e0d3f31a
(svn r3351) Make sort criteria selection widgets in player train list consistent with those widgets in other vehicle type lists. (Stops "Total capacity per cargo type" overflowing)
 
peter1138 
parents: 
2725 
diff
changeset
 | 
1372  | 
{      WWT_PANEL,  RESIZE_RIGHT,    14,   248,   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
 | 
1373  | 
{     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
 | 
1374  | 
{  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
 | 
1375  | 
{      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
 | 
1376  | 
{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   313,   324,   208,   219, 0x0,										STR_RESIZE_BUTTON},
 | 
| 588 | 1377  | 
{   WIDGETS_END},
 | 
1378  | 
};  | 
|
| 0 | 1379  | 
|
1380  | 
static void PlayerTrainsWndProc(Window *w, WindowEvent *e)  | 
|
1381  | 
{
 | 
|
| 
2466
 
1aa260b43faa
(svn r2992) Use PlayerID, StationID and INVALID_STATION instead of int, int and -1
 
tron 
parents: 
2456 
diff
changeset
 | 
1382  | 
StationID station = GB(w->window_number, 16, 16);  | 
| 
 
1aa260b43faa
(svn r2992) Use PlayerID, StationID and INVALID_STATION instead of int, int and -1
 
tron 
parents: 
2456 
diff
changeset
 | 
1383  | 
PlayerID owner = GB(w->window_number, 0, 8);  | 
| 588 | 1384  | 
vehiclelist_d *vl = &WP(w, vehiclelist_d);  | 
1385  | 
||
| 2952 | 1386  | 
	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
 | 
1387  | 
	case WE_PAINT: {
 | 
| 588 | 1388  | 
int x = 2;  | 
1389  | 
int y = PLY_WND_PRC__OFFSET_TOP_WIDGET;  | 
|
1390  | 
int max;  | 
|
1391  | 
int i;  | 
|
| 
243
 
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
 
darkvater 
parents: 
193 
diff
changeset
 | 
1392  | 
|
| 588 | 1393  | 
BuildVehicleList(vl, VEH_Train, owner, station);  | 
1394  | 
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
 | 
1395  | 
|
| 588 | 1396  | 
SetVScrollCount(w, vl->list_length);  | 
1397  | 
||
1398  | 
// disable 'Sort By' tooltip on Unsorted sorting criteria  | 
|
1399  | 
if (vl->sort_type == SORT_BY_UNSORTED)  | 
|
| 757 | 1400  | 
w->disabled_state |= (1 << 3);  | 
| 
193
 
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
 
truelight 
parents: 
176 
diff
changeset
 | 
1401  | 
|
| 0 | 1402  | 
/* draw the widgets */  | 
1403  | 
		{
 | 
|
| 
1962
 
8254df1b359b
(svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
 
celestar 
parents: 
1938 
diff
changeset
 | 
1404  | 
const Player *p = GetPlayer(owner);  | 
| 
2466
 
1aa260b43faa
(svn r2992) Use PlayerID, StationID and INVALID_STATION instead of int, int and -1
 
tron 
parents: 
2456 
diff
changeset
 | 
1405  | 
			if (station == INVALID_STATION) {
 | 
| 588 | 1406  | 
/* Company Name -- (###) Trains */  | 
1407  | 
SetDParam(0, p->name_1);  | 
|
1408  | 
SetDParam(1, p->name_2);  | 
|
1409  | 
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
 | 
1410  | 
w->widget[1].unkA = STR_881B_TRAINS;  | 
| 588 | 1411  | 
			} else {
 | 
1412  | 
/* 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
 | 
1413  | 
SetDParam(0, station);  | 
| 588 | 1414  | 
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
 | 
1415  | 
w->widget[1].unkA = STR_SCHEDULED_TRAINS;  | 
| 588 | 1416  | 
}  | 
| 0 | 1417  | 
DrawWindowWidgets(w);  | 
1418  | 
}  | 
|
| 
168
 
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
 
darkvater 
parents: 
164 
diff
changeset
 | 
1419  | 
/* draw sorting criteria string */  | 
| 588 | 1420  | 
DrawString(85, 15, _vehicle_sort_listing[vl->sort_type], 0x10);  | 
1421  | 
/* 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
 | 
1422  | 
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
 | 
1423  | 
|
| 588 | 1424  | 
max = min(w->vscroll.pos + w->vscroll.cap, vl->list_length);  | 
1425  | 
		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
 | 
1426  | 
Vehicle *v = GetVehicle(vl->sort_list[i].index);  | 
| 588 | 1427  | 
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
 | 
1428  | 
|
| 588 | 1429  | 
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
 | 
1430  | 
|
| 
2570
 
f86c326fda65
(svn r3107) -NewGRF: Move train y-position offset adjustment to remove code duplication, and make it apply only to vehicles with a custom image.
 
peter1138 
parents: 
2562 
diff
changeset
 | 
1431  | 
DrawTrainImage(v, x + 21, y + 6, w->hscroll.cap, 0, INVALID_VEHICLE);  | 
| 588 | 1432  | 
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
 | 
1433  | 
|
| 588 | 1434  | 
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
 | 
1435  | 
if (IsTileDepotType(v->tile, TRANSPORT_RAIL) && (v->vehstatus & VS_HIDDEN))  | 
| 588 | 1436  | 
str = STR_021F;  | 
1437  | 
else  | 
|
1438  | 
str = v->age > v->max_age - 366 ? STR_00E3 : STR_00E2;  | 
|
1439  | 
DrawString(x, y + 2, str, 0);  | 
|
1440  | 
||
1441  | 
SetDParam(0, v->profit_this_year);  | 
|
1442  | 
SetDParam(1, v->profit_last_year);  | 
|
1443  | 
DrawString(x + 21, y + 18, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 0);  | 
|
1444  | 
||
1445  | 
			if (v->string_id != STR_SV_TRAIN_NAME) {
 | 
|
1446  | 
SetDParam(0, v->string_id);  | 
|
1447  | 
DrawString(x + 21, y, STR_01AB, 0);  | 
|
| 0 | 1448  | 
}  | 
| 588 | 1449  | 
|
1450  | 
y += PLY_WND_PRC__SIZE_OF_ROW_SMALL;  | 
|
| 0 | 1451  | 
}  | 
| 588 | 1452  | 
break;  | 
1453  | 
}  | 
|
| 0 | 1454  | 
|
1455  | 
	case WE_CLICK: {
 | 
|
| 2952 | 1456  | 
		switch (e->click.widget) {
 | 
| 757 | 1457  | 
case 3: /* Flip sorting method ascending/descending */  | 
| 588 | 1458  | 
vl->flags ^= VL_DESC;  | 
1459  | 
vl->flags |= VL_RESORT;  | 
|
| 
1246
 
eb66ff34348f
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
 
darkvater 
parents: 
1179 
diff
changeset
 | 
1460  | 
_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
 | 
1461  | 
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
 | 
1462  | 
break;  | 
| 588 | 1463  | 
|
| 757 | 1464  | 
case 4: case 5:/* Select sorting criteria dropdown menu */  | 
| 842 | 1465  | 
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
 | 
1466  | 
return;  | 
| 588 | 1467  | 
|
| 757 | 1468  | 
		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
 | 
1469  | 
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
 | 
1470  | 
|
| 2549 | 1471  | 
if (id_v >= w->vscroll.cap) return; // click out of bounds  | 
| 0 | 1472  | 
|
| 
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
 | 
1473  | 
id_v += w->vscroll.pos;  | 
| 0 | 1474  | 
|
| 
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
 | 
1475  | 
			{
 | 
| 
 
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
 | 
1476  | 
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
 | 
1477  | 
|
| 588 | 1478  | 
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
 | 
1479  | 
|
| 
919
 
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
 
truelight 
parents: 
914 
diff
changeset
 | 
1480  | 
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
 | 
1481  | 
|
| 
2676
 
59b65b4fb480
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
 
bjarni 
parents: 
2639 
diff
changeset
 | 
1482  | 
assert(v->type == VEH_Train && IsFrontEngine(v) && 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
 | 
1483  | 
|
| 
 
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
 | 
1484  | 
ShowTrainViewWindow(v);  | 
| 0 | 1485  | 
}  | 
1486  | 
} break;  | 
|
1487  | 
||
| 757 | 1488  | 
		case 9: { /* Build new Vehicle */
 | 
| 
1977
 
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
 
tron 
parents: 
1962 
diff
changeset
 | 
1489  | 
TileIndex tile;  | 
| 0 | 1490  | 
|
| 
867
 
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
 
truelight 
parents: 
842 
diff
changeset
 | 
1491  | 
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
 | 
1492  | 
break;  | 
| 
 
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
 
truelight 
parents: 
842 
diff
changeset
 | 
1493  | 
|
| 0 | 1494  | 
tile = _last_built_train_depot_tile;  | 
1495  | 
			do {
 | 
|
| 2951 | 1496  | 
if (IsTileDepotType(tile, TRANSPORT_RAIL) &&  | 
1497  | 
						IsTileOwner(tile, _local_player)) {
 | 
|
| 0 | 1498  | 
ShowTrainDepotWindow(tile);  | 
1499  | 
ShowBuildTrainWindow(tile);  | 
|
1500  | 
return;  | 
|
1501  | 
}  | 
|
| 
193
 
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
 
truelight 
parents: 
176 
diff
changeset
 | 
1502  | 
|
| 0 | 1503  | 
tile = TILE_MASK(tile + 1);  | 
| 2952 | 1504  | 
} 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
 | 
1505  | 
|
| 0 | 1506  | 
ShowBuildTrainWindow(0);  | 
1507  | 
} break;  | 
|
| 842 | 1508  | 
		case 10: {
 | 
| 
886
 
3f8be7ff7b9c
(svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
 
truelight 
parents: 
878 
diff
changeset
 | 
1509  | 
if (!IsWindowOfPrototype(w, _player_trains_widgets))  | 
| 
 
3f8be7ff7b9c
(svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
 
truelight 
parents: 
878 
diff
changeset
 | 
1510  | 
break;  | 
| 
 
3f8be7ff7b9c
(svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
 
truelight 
parents: 
878 
diff
changeset
 | 
1511  | 
|
| 842 | 1512  | 
ShowReplaceVehicleWindow(VEH_Train);  | 
1513  | 
break;  | 
|
1514  | 
}  | 
|
1515  | 
||
| 0 | 1516  | 
}  | 
1517  | 
} break;  | 
|
1518  | 
||
| 
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
 | 
1519  | 
case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */  | 
| 588 | 1520  | 
		if (vl->sort_type != e->dropdown.index) {
 | 
1521  | 
// value has changed -> resort  | 
|
1522  | 
vl->flags |= VL_RESORT;  | 
|
1523  | 
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
 | 
1524  | 
_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
 | 
1525  | 
|
| 588 | 1526  | 
// enable 'Sort By' if a sorter criteria is chosen  | 
1527  | 
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
 | 
1528  | 
CLRBIT(w->disabled_state, 3);  | 
| 588 | 1529  | 
}  | 
| 
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
 | 
1530  | 
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
 | 
1531  | 
break;  | 
| 588 | 1532  | 
|
| 
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
 | 
1533  | 
case WE_CREATE: /* set up resort timer */  | 
| 588 | 1534  | 
vl->sort_list = NULL;  | 
| 
1246
 
eb66ff34348f
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
 
darkvater 
parents: 
1179 
diff
changeset
 | 
1535  | 
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
 | 
1536  | 
vl->sort_type = _sorting.train.criteria;  | 
| 588 | 1537  | 
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
 | 
1538  | 
break;  | 
| 588 | 1539  | 
|
| 767 | 1540  | 
case WE_DESTROY:  | 
1541  | 
free(vl->sort_list);  | 
|
1542  | 
break;  | 
|
1543  | 
||
| 
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
 | 
1544  | 
case WE_TICK: /* resort the list every 20 seconds orso (10 days) */  | 
| 588 | 1545  | 
		if (--vl->resort_timer == 0) {
 | 
1546  | 
			DEBUG(misc, 1) ("Periodic resort trains list player %d station %d",
 | 
|
1547  | 
owner, station);  | 
|
1548  | 
vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;  | 
|
1549  | 
vl->flags |= VL_RESORT;  | 
|
1550  | 
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
 | 
1551  | 
}  | 
| 
 
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
 | 
1552  | 
break;  | 
| 
867
 
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
 
truelight 
parents: 
842 
diff
changeset
 | 
1553  | 
|
| 
 
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
 
truelight 
parents: 
842 
diff
changeset
 | 
1554  | 
case WE_RESIZE:  | 
| 
 
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
 
truelight 
parents: 
842 
diff
changeset
 | 
1555  | 
/* Update the scroll + matrix */  | 
| 
 
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
 
truelight 
parents: 
842 
diff
changeset
 | 
1556  | 
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
 | 
1557  | 
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
 | 
1558  | 
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
 | 
1559  | 
break;  | 
| 0 | 1560  | 
}  | 
1561  | 
}  | 
|
1562  | 
||
1563  | 
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
 | 
1564  | 
-1, -1, 325, 220,  | 
| 0 | 1565  | 
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
 | 
1566  | 
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,  | 
| 0 | 1567  | 
_player_trains_widgets,  | 
1568  | 
PlayerTrainsWndProc  | 
|
1569  | 
};  | 
|
1570  | 
||
1571  | 
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
 | 
1572  | 
-1, -1, 325, 220,  | 
| 0 | 1573  | 
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
 | 
1574  | 
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,  | 
| 0 | 1575  | 
_other_player_trains_widgets,  | 
1576  | 
PlayerTrainsWndProc  | 
|
1577  | 
};  | 
|
1578  | 
||
| 
2466
 
1aa260b43faa
(svn r2992) Use PlayerID, StationID and INVALID_STATION instead of int, int and -1
 
tron 
parents: 
2456 
diff
changeset
 | 
1579  | 
void ShowPlayerTrains(PlayerID player, StationID station)  | 
| 0 | 1580  | 
{
 | 
1581  | 
Window *w;  | 
|
1582  | 
||
| 
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
 | 
1583  | 
	if (player == _local_player) {
 | 
| 588 | 1584  | 
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
 | 
1585  | 
	} else {
 | 
| 588 | 1586  | 
w = AllocateWindowDescFront(&_other_player_trains_desc, (station << 16) | player);  | 
| 0 | 1587  | 
}  | 
1588  | 
	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
 | 
1589  | 
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
 | 
1590  | 
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
 | 
1591  | 
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
 | 
1592  | 
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
 | 
1593  | 
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
 | 
1594  | 
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
 | 
1595  | 
w->resize.height = 220 - (PLY_WND_PRC__SIZE_OF_ROW_SMALL * 3); /* Minimum of 4 vehicles */  | 
| 0 | 1596  | 
}  | 
1597  | 
}  |