author | tron |
Sat, 29 Oct 2005 20:28:43 +0000 | |
changeset 2562 | 9397cf08c273 |
parent 2561 | c78c3d248897 |
child 2630 | 35249d2ded3e |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1820
diff
changeset
|
4 |
#include "openttd.h" |
1299
0a6510cc889b
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1294
diff
changeset
|
5 |
#include "debug.h" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
6 |
#include "functions.h" |
1922
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1907
diff
changeset
|
7 |
#include "table/sprites.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
374
diff
changeset
|
8 |
#include "table/strings.h" |
679
e959706a3e4d
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
671
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" |
|
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1299
diff
changeset
|
19 |
#include "depot.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2113
diff
changeset
|
20 |
#include "vehicle_gui.h" |
0 | 21 |
|
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
22 |
/** |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
23 |
* Draw the purchase info details of road vehicle at a given location. |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
24 |
* @param x,y location where to draw the info |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
25 |
* @param engine_number the engine of which to draw the info of |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
26 |
*/ |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
27 |
void DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number) |
842 | 28 |
{ |
29 |
const RoadVehicleInfo *rvi = RoadVehInfo(engine_number); |
|
1926
68d60188a22f
(svn r2432) Use GetEngine() instead of DEREF_ENGINE() or even _engines[]
tron
parents:
1922
diff
changeset
|
30 |
const Engine* e = GetEngine(engine_number); |
842 | 31 |
YearMonthDay ymd; |
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
32 |
ConvertDayToYMD(&ymd, e->intro_date); |
842 | 33 |
|
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
34 |
/* Purchase cost - Max speed */ |
842 | 35 |
SetDParam(0, rvi->base_cost * (_price.roadveh_base>>3)>>5); |
36 |
SetDParam(1, rvi->max_speed * 10 >> 5); |
|
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
37 |
DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, 0); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
38 |
y += 10; |
842 | 39 |
|
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
40 |
/* Running cost */ |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
41 |
SetDParam(0, rvi->running_cost * _price.roadveh_running >> 8); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
42 |
DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, 0); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
43 |
y += 10; |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
44 |
|
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
45 |
/* Cargo type + capacity */ |
2084
d67790a49f78
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
1986
diff
changeset
|
46 |
SetDParam(0, _cargoc.names_long[rvi->cargo_type]); |
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
47 |
SetDParam(1, rvi->capacity); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
48 |
SetDParam(2, STR_EMPTY); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
49 |
DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, 0); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
50 |
y += 10; |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
51 |
|
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
52 |
/* Design date - Life length */ |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
53 |
SetDParam(0, ymd.year + 1920); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
54 |
SetDParam(1, e->lifelength); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
55 |
DrawString(x, y, STR_PURCHASE_INFO_DESIGNED_LIFE, 0); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
56 |
y += 10; |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
57 |
|
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
58 |
/* Reliability */ |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
59 |
SetDParam(0, e->reliability * 100 >> 16); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
60 |
DrawString(x, y, STR_PURCHASE_INFO_RELIABILITY, 0); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
61 |
y += 10; |
842 | 62 |
} |
63 |
||
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
64 |
static void DrawRoadVehImage(const Vehicle *v, int x, int y, VehicleID selection) |
0 | 65 |
{ |
66 |
int image = GetRoadVehImage(v, 6); |
|
67 |
uint32 ormod = SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)); |
|
1922
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1907
diff
changeset
|
68 |
if (v->vehstatus & VS_CRASHED) |
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1907
diff
changeset
|
69 |
ormod = PALETTE_CRASH; |
0 | 70 |
DrawSprite(image | ormod, x+14, y+6); |
71 |
||
72 |
if (v->index == selection) { |
|
1938
21bd6ef5f85e
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1926
diff
changeset
|
73 |
DrawFrameRect(x-1, y-1, x+28, y+12, 15, FR_BORDERONLY); |
0 | 74 |
} |
75 |
} |
|
76 |
||
77 |
static void RoadVehDetailsWndProc(Window *w, WindowEvent *e) |
|
78 |
{ |
|
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
79 |
switch (e->event) { |
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
80 |
case WE_PAINT: { |
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
81 |
const Vehicle *v = GetVehicle(w->window_number); |
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
82 |
StringID str; |
0 | 83 |
|
84 |
w->disabled_state = v->owner == _local_player ? 0 : (1 << 2); |
|
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:
10
diff
changeset
|
85 |
if (!_patches.servint_roadveh) // 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:
10
diff
changeset
|
86 |
w->disabled_state |= (1 << 5) | (1 << 6); |
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:
10
diff
changeset
|
87 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
88 |
SetDParam(0, v->string_id); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
89 |
SetDParam(1, v->unitnumber); |
0 | 90 |
DrawWindowWidgets(w); |
91 |
||
92 |
/* Draw running cost */ |
|
93 |
{ |
|
94 |
int year = v->age / 366; |
|
95 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
96 |
SetDParam(1, year); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
97 |
|
2261
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2252
diff
changeset
|
98 |
SetDParam(0, (v->age + 365 < v->max_age) ? STR_AGE : STR_AGE_RED); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
99 |
SetDParam(2, v->max_age / 366); |
538
5dd99f3b7eca
(svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents:
534
diff
changeset
|
100 |
SetDParam(3, RoadVehInfo(v->engine_type)->running_cost * _price.roadveh_running >> 8); |
0 | 101 |
DrawString(2, 15, STR_900D_AGE_RUNNING_COST_YR, 0); |
102 |
} |
|
103 |
||
104 |
/* Draw max speed */ |
|
105 |
{ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
106 |
SetDParam(0, v->max_speed * 10 >> 5); |
0 | 107 |
DrawString(2, 25, STR_900E_MAX_SPEED, 0); |
108 |
} |
|
109 |
||
110 |
/* Draw profit */ |
|
111 |
{ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
112 |
SetDParam(0, v->profit_this_year); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
113 |
SetDParam(1, v->profit_last_year); |
0 | 114 |
DrawString(2, 35, STR_900F_PROFIT_THIS_YEAR_LAST_YEAR, 0); |
115 |
} |
|
116 |
||
117 |
/* Draw breakdown & reliability */ |
|
118 |
{ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
119 |
SetDParam(0, v->reliability * 100 >> 16); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
120 |
SetDParam(1, v->breakdowns_since_last_service); |
0 | 121 |
DrawString(2, 45, STR_9010_RELIABILITY_BREAKDOWNS, 0); |
122 |
} |
|
123 |
||
124 |
/* Draw service interval text */ |
|
125 |
{ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
126 |
SetDParam(0, v->service_interval); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
127 |
SetDParam(1, v->date_of_last_service); |
156
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
10
diff
changeset
|
128 |
DrawString(13, 90, _patches.servint_ispercent?STR_SERVICING_INTERVAL_PERCENT:STR_883C_SERVICING_INTERVAL_DAYS, 0); |
0 | 129 |
} |
130 |
||
131 |
DrawRoadVehImage(v, 3, 57, INVALID_VEHICLE); |
|
132 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
133 |
SetDParam(0, GetCustomEngineName(v->engine_type)); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
134 |
SetDParam(1, 1920 + v->build_year); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
135 |
SetDParam(2, v->value); |
0 | 136 |
DrawString(34, 57, STR_9011_BUILT_VALUE, 0); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
137 |
|
2084
d67790a49f78
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
1986
diff
changeset
|
138 |
SetDParam(0, _cargoc.names_long[v->cargo_type]); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
139 |
SetDParam(1, v->cargo_cap); |
0 | 140 |
DrawString(34, 67, STR_9012_CAPACITY, 0); |
141 |
||
142 |
str = STR_8812_EMPTY; |
|
143 |
if (v->cargo_count != 0) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
144 |
SetDParam(0, v->cargo_type); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
145 |
SetDParam(1, v->cargo_count); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
146 |
SetDParam(2, v->cargo_source); |
0 | 147 |
str = STR_8813_FROM; |
148 |
} |
|
149 |
DrawString(34, 78, str, 0); |
|
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
150 |
} break; |
0 | 151 |
|
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
152 |
case WE_CLICK: { |
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
153 |
int mod; |
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
154 |
const Vehicle *v; |
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
155 |
switch (e->click.widget) { |
0 | 156 |
case 2: /* rename */ |
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
157 |
v = GetVehicle(w->window_number); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
158 |
SetDParam(0, v->unitnumber); |
0 | 159 |
ShowQueryString(v->string_id, STR_902C_NAME_ROAD_VEHICLE, 31, 150, w->window_class, w->window_number); |
160 |
break; |
|
161 |
||
162 |
case 5: /* increase int */ |
|
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:
10
diff
changeset
|
163 |
mod = _ctrl_pressed? 5 : 10; |
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
164 |
goto do_change_service_int; |
0 | 165 |
case 6: /* decrease int */ |
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:
10
diff
changeset
|
166 |
mod = _ctrl_pressed? -5 : -10; |
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
167 |
do_change_service_int: |
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
168 |
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:
10
diff
changeset
|
169 |
|
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
170 |
mod = GetServiceIntervalClamped(mod + v->service_interval); |
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
171 |
if (mod == v->service_interval) return; |
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:
10
diff
changeset
|
172 |
|
0 | 173 |
DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_ROADVEH_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING)); |
174 |
break; |
|
175 |
} |
|
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
176 |
} break; |
0 | 177 |
|
178 |
case WE_4: |
|
179 |
if (FindWindowById(WC_VEHICLE_VIEW, w->window_number) == NULL) |
|
180 |
DeleteWindow(w); |
|
181 |
break; |
|
182 |
||
183 |
case WE_ON_EDIT_TEXT: { |
|
1820
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1790
diff
changeset
|
184 |
if (e->edittext.str[0] != '\0') { |
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1790
diff
changeset
|
185 |
_cmd_text = e->edittext.str; |
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1790
diff
changeset
|
186 |
DoCommandP(0, w->window_number, 0, NULL, |
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1790
diff
changeset
|
187 |
CMD_NAME_VEHICLE | CMD_MSG(STR_902D_CAN_T_NAME_ROAD_VEHICLE)); |
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1790
diff
changeset
|
188 |
} |
0 | 189 |
} break; |
190 |
||
191 |
} |
|
192 |
} |
|
193 |
||
194 |
static const Widget _roadveh_details_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
195 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
196 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 339, 0, 13, STR_900C_DETAILS,STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
197 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 340, 379, 0, 13, STR_01AA_NAME, STR_902E_NAME_ROAD_VEHICLE}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
198 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 379, 14, 55, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
199 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 379, 56, 88, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
200 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 10, 89, 94, STR_0188, STR_884D_INCREASE_SERVICING_INTERVAL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
201 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 10, 95, 100, STR_0189, STR_884E_DECREASE_SERVICING_INTERVAL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
202 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 11, 379, 89, 100, 0x0, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
203 |
{ WIDGETS_END}, |
0 | 204 |
}; |
205 |
||
206 |
static const WindowDesc _roadveh_details_desc = { |
|
207 |
-1,-1, 380, 101, |
|
208 |
WC_VEHICLE_DETAILS,WC_VEHICLE_VIEW, |
|
209 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
210 |
_roadveh_details_widgets, |
|
211 |
RoadVehDetailsWndProc |
|
212 |
}; |
|
213 |
||
2561
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
214 |
static void ShowRoadVehDetailsWindow(const Vehicle* v) |
0 | 215 |
{ |
216 |
Window *w; |
|
217 |
VehicleID veh = v->index; |
|
218 |
DeleteWindowById(WC_VEHICLE_ORDERS, veh); |
|
219 |
DeleteWindowById(WC_VEHICLE_DETAILS, veh); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
220 |
_alloc_wnd_parent_num = veh; |
0 | 221 |
w = AllocateWindowDesc(&_roadveh_details_desc); |
222 |
w->window_number = veh; |
|
223 |
w->caption_color = v->owner; |
|
224 |
} |
|
225 |
||
2244 | 226 |
void CcCloneRoadVeh(bool success, uint tile, uint32 p1, uint32 p2) |
227 |
{ |
|
2561
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
228 |
if (success) { |
2562 | 229 |
const Vehicle* v = GetVehicle(_new_roadveh_id); |
2244 | 230 |
|
2561
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
231 |
ShowRoadVehViewWindow(v); |
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
232 |
} |
2244 | 233 |
} |
234 |
||
0 | 235 |
static void RoadVehViewWndProc(Window *w, WindowEvent *e) |
236 |
{ |
|
237 |
switch(e->event) { |
|
238 |
case WE_PAINT: { |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
239 |
Vehicle *v = GetVehicle(w->window_number); |
0 | 240 |
StringID str; |
241 |
||
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
242 |
w->disabled_state = (v->owner != _local_player) ? (1<<8 | 1<<7) : 0; |
0 | 243 |
|
244 |
/* draw widgets & caption */ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
245 |
SetDParam(0, v->string_id); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
246 |
SetDParam(1, v->unitnumber); |
0 | 247 |
DrawWindowWidgets(w); |
248 |
||
249 |
if (v->u.road.crashed_ctr != 0) { |
|
250 |
str = STR_8863_CRASHED; |
|
251 |
} else if (v->breakdown_ctr == 1) { |
|
252 |
str = STR_885C_BROKEN_DOWN; |
|
253 |
} else if (v->vehstatus & VS_STOPPED) { |
|
254 |
str = STR_8861_STOPPED; |
|
255 |
} else { |
|
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
256 |
switch (v->current_order.type) { |
0 | 257 |
case OT_GOTO_STATION: { |
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
258 |
SetDParam(0, v->current_order.station); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
259 |
SetDParam(1, v->cur_speed * 10 >> 5); |
0 | 260 |
str = STR_HEADING_FOR_STATION + _patches.vehicle_speed; |
261 |
} break; |
|
262 |
||
263 |
case OT_GOTO_DEPOT: { |
|
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1299
diff
changeset
|
264 |
Depot *depot = GetDepot(v->current_order.station); |
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1299
diff
changeset
|
265 |
SetDParam(0, depot->town_index); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
266 |
SetDParam(1, v->cur_speed * 10 >> 5); |
0 | 267 |
str = STR_HEADING_FOR_ROAD_DEPOT + _patches.vehicle_speed; |
268 |
} break; |
|
269 |
||
270 |
case OT_LOADING: |
|
271 |
case OT_LEAVESTATION: |
|
272 |
str = STR_882F_LOADING_UNLOADING; |
|
273 |
break; |
|
274 |
||
275 |
default: |
|
276 |
if (v->num_orders == 0) { |
|
277 |
str = STR_NO_ORDERS + _patches.vehicle_speed; |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
278 |
SetDParam(0, v->cur_speed * 10 >> 5); |
0 | 279 |
} else |
280 |
str = STR_EMPTY; |
|
281 |
break; |
|
282 |
} |
|
283 |
} |
|
284 |
||
2103
9266bb2ac29d
(svn r2613) - Truncate savegames, and vehicle-texts in their window.
Darkvater
parents:
2084
diff
changeset
|
285 |
/* draw the flag plus orders */ |
2517
b90693227193
(svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents:
2498
diff
changeset
|
286 |
DrawSprite(v->vehstatus & VS_STOPPED ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, 2, w->widget[5].top + 1); |
2113
f228b399da01
(svn r2623) - CodeChange: rework DrawStringCenteredTruncated() a bit. Instead of giving center + width you give the coordinates of the bounding box (left, right) it has to fit in (ludde)
Darkvater
parents:
2103
diff
changeset
|
287 |
DrawStringCenteredTruncated(w->widget[5].left + 8, w->widget[5].right, w->widget[5].top + 1, str, 0); |
0 | 288 |
DrawWindowViewport(w); |
289 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
290 |
|
0 | 291 |
case WE_CLICK: { |
2561
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
292 |
const Vehicle* v = GetVehicle(w->window_number); |
0 | 293 |
|
2561
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
294 |
switch (e->click.widget) { |
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
295 |
case 5: /* start stop */ |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
296 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_ROADVEH | CMD_MSG(STR_9015_CAN_T_STOP_START_ROAD_VEHICLE)); |
0 | 297 |
break; |
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
298 |
case 6: /* center main view */ |
0 | 299 |
ScrollMainWindowTo(v->x_pos, v->y_pos); |
300 |
break; |
|
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
301 |
case 7: /* goto hangar */ |
0 | 302 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_SEND_ROADVEH_TO_DEPOT | CMD_MSG(STR_9018_CAN_T_SEND_VEHICLE_TO_DEPOT)); |
303 |
break; |
|
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
304 |
case 8: /* turn around */ |
0 | 305 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_TURN_ROADVEH | CMD_MSG(STR_9033_CAN_T_MAKE_VEHICLE_TURN)); |
306 |
break; |
|
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
307 |
case 9: /* show orders */ |
0 | 308 |
ShowOrdersWindow(v); |
309 |
break; |
|
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
310 |
case 10: /* show details */ |
0 | 311 |
ShowRoadVehDetailsWindow(v); |
312 |
break; |
|
2244 | 313 |
case 11: { |
314 |
/* clone vehicle */ |
|
315 |
DoCommandP(v->tile, v->index, _ctrl_pressed ? 1 : 0, CcCloneRoadVeh, CMD_CLONE_VEHICLE | CMD_MSG(STR_9009_CAN_T_BUILD_ROAD_VEHICLE)); |
|
316 |
} break; |
|
0 | 317 |
} |
318 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
319 |
|
1485
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
320 |
case WE_RESIZE: |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
321 |
w->viewport->width += e->sizing.diff.x; |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
322 |
w->viewport->height += e->sizing.diff.y; |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
323 |
w->viewport->virtual_width += e->sizing.diff.x; |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
324 |
w->viewport->virtual_height += e->sizing.diff.y; |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
325 |
break; |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
326 |
|
0 | 327 |
case WE_DESTROY: |
328 |
DeleteWindowById(WC_VEHICLE_ORDERS, w->window_number); |
|
329 |
DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
330 |
break; |
2244 | 331 |
|
332 |
case WE_MOUSELOOP: |
|
333 |
{ |
|
334 |
Vehicle *v; |
|
335 |
uint32 h; |
|
336 |
v = GetVehicle(w->window_number); |
|
337 |
h = IsTileDepotType(v->tile, TRANSPORT_ROAD) && (v->vehstatus&VS_STOPPED) ? (1<< 7) : (1 << 11); |
|
338 |
if (h != w->hidden_state) { |
|
339 |
w->hidden_state = h; |
|
340 |
SetWindowDirty(w); |
|
341 |
} |
|
342 |
} |
|
0 | 343 |
} |
344 |
} |
|
345 |
||
346 |
static const Widget _roadveh_view_widgets[] = { |
|
1485
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
347 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
348 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 237, 0, 13, STR_9002, STR_018C_WINDOW_TITLE_DRAG_THIS }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
349 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 238, 249, 0, 13, 0x0, STR_STICKY_BUTTON }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
350 |
{ WWT_IMGBTN, RESIZE_RB, 14, 0, 231, 14, 103, 0x0, STR_NULL }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
351 |
{ WWT_6, RESIZE_RB, 14, 2, 229, 16, 101, 0x0, STR_NULL }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
352 |
{ WWT_PUSHIMGBTN, RESIZE_RTB, 14, 0, 237, 104, 115, 0x0, STR_901C_CURRENT_VEHICLE_ACTION }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
353 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 14, 31, 0x2AB, STR_901E_CENTER_MAIN_VIEW_ON_VEHICLE }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
354 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 32, 49, 0x2AE, STR_901F_SEND_VEHICLE_TO_DEPOT }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
355 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 50, 67, 0x2CB, STR_9020_FORCE_VEHICLE_TO_TURN_AROUND }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
356 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 68, 85, 0x2B2, STR_901D_SHOW_VEHICLE_S_ORDERS }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
357 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 86, 103, 0x2B3, STR_9021_SHOW_ROAD_VEHICLE_DETAILS }, |
2244 | 358 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 32, 49, SPR_CLONE_ROADVEH, STR_CLONE_ROAD_VEHICLE_INFO }, |
1485
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
359 |
{ WWT_PANEL, RESIZE_LRB, 14, 232, 249, 104, 103, 0x0, STR_NULL }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
360 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 238, 249, 104, 115, 0x0, STR_NULL }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
361 |
{ WIDGETS_END } |
0 | 362 |
}; |
363 |
||
364 |
static const WindowDesc _roadveh_view_desc = { |
|
365 |
-1,-1, 250, 116, |
|
366 |
WC_VEHICLE_VIEW,0, |
|
1485
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
367 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 368 |
_roadveh_view_widgets, |
369 |
RoadVehViewWndProc, |
|
370 |
}; |
|
371 |
||
2561
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
372 |
void ShowRoadVehViewWindow(const Vehicle* v) |
0 | 373 |
{ |
2561
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
374 |
Window* w = AllocateWindowDescFront(&_roadveh_view_desc, v->index); |
0 | 375 |
|
2561
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
376 |
if (w != NULL) { |
0 | 377 |
w->caption_color = v->owner; |
378 |
AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), 0); |
|
379 |
} |
|
380 |
} |
|
381 |
||
382 |
||
383 |
static void DrawNewRoadVehWindow(Window *w) |
|
384 |
{ |
|
385 |
if (w->window_number == 0) |
|
386 |
w->disabled_state = 1 << 5; |
|
387 |
||
388 |
// setup scroller |
|
389 |
{ |
|
390 |
int count = 0; |
|
391 |
int num = NUM_ROAD_ENGINES; |
|
1926
68d60188a22f
(svn r2432) Use GetEngine() instead of DEREF_ENGINE() or even _engines[]
tron
parents:
1922
diff
changeset
|
392 |
const Engine* e = GetEngine(ROAD_ENGINES_INDEX); |
68d60188a22f
(svn r2432) Use GetEngine() instead of DEREF_ENGINE() or even _engines[]
tron
parents:
1922
diff
changeset
|
393 |
|
0 | 394 |
do { |
395 |
if (HASBIT(e->player_avail, _local_player)) |
|
396 |
count++; |
|
397 |
} while (++e,--num); |
|
398 |
SetVScrollCount(w, count); |
|
399 |
} |
|
400 |
||
401 |
DrawWindowWidgets(w); |
|
402 |
||
403 |
{ |
|
404 |
int num = NUM_ROAD_ENGINES; |
|
1926
68d60188a22f
(svn r2432) Use GetEngine() instead of DEREF_ENGINE() or even _engines[]
tron
parents:
1922
diff
changeset
|
405 |
const Engine* e = GetEngine(ROAD_ENGINES_INDEX); |
0 | 406 |
int x = 1; |
407 |
int y = 15; |
|
408 |
int sel = WP(w,buildtrain_d).sel_index; |
|
409 |
int pos = w->vscroll.pos; |
|
2477
d454d5152386
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2466
diff
changeset
|
410 |
EngineID engine_id = ROAD_ENGINES_INDEX; |
2498
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
411 |
EngineID selected_id = INVALID_ENGINE; |
0 | 412 |
|
413 |
do { |
|
414 |
if (HASBIT(e->player_avail, _local_player)) { |
|
415 |
if (sel==0) selected_id = engine_id; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
416 |
if (IS_INT_INSIDE(--pos, -w->vscroll.cap, 0)) { |
0 | 417 |
DrawString(x+59, y+2, GetCustomEngineName(engine_id), sel==0 ? 0xC : 0x10); |
418 |
DrawRoadVehEngine(x+29, y+6, engine_id, SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player))); |
|
419 |
y += 14; |
|
420 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
421 |
sel--; |
0 | 422 |
} |
423 |
} while (++engine_id, ++e,--num); |
|
424 |
||
425 |
WP(w,buildtrain_d).sel_engine = selected_id; |
|
2498
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
426 |
if (selected_id != INVALID_ENGINE) { |
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
427 |
DrawRoadVehPurchaseInfo(2, w->widget[4].top + 1, selected_id); |
0 | 428 |
} |
429 |
} |
|
430 |
} |
|
431 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
432 |
void CcBuildRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 433 |
{ |
434 |
Vehicle *v; |
|
435 |
||
436 |
if (!success) return; |
|
437 |
||
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
438 |
v = GetVehicle(_new_roadveh_id); |
0 | 439 |
if (v->tile == _backup_orders_tile) { |
440 |
_backup_orders_tile = 0; |
|
441 |
RestoreVehicleOrders(v, _backup_orders_data); |
|
442 |
} |
|
443 |
ShowRoadVehViewWindow(v); |
|
444 |
} |
|
445 |
||
446 |
static void NewRoadVehWndProc(Window *w, WindowEvent *e) |
|
447 |
{ |
|
448 |
switch(e->event) { |
|
449 |
case WE_PAINT: |
|
450 |
DrawNewRoadVehWindow(w); |
|
451 |
break; |
|
452 |
||
453 |
case WE_CLICK: |
|
454 |
switch(e->click.widget) { |
|
455 |
case 2: { /* listbox */ |
|
456 |
uint i = (e->click.pt.y - 14) / 14; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
457 |
if (i < w->vscroll.cap) { |
0 | 458 |
WP(w,buildtrain_d).sel_index = i + w->vscroll.pos; |
459 |
SetWindowDirty(w); |
|
460 |
} |
|
461 |
} break; |
|
462 |
||
463 |
case 5: { /* build */ |
|
2498
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
464 |
EngineID sel_eng = WP(w,buildtrain_d).sel_engine; |
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
465 |
if (sel_eng != INVALID_ENGINE) |
0 | 466 |
DoCommandP(w->window_number, sel_eng, 0, CcBuildRoadVeh, CMD_BUILD_ROAD_VEH | CMD_MSG(STR_9009_CAN_T_BUILD_ROAD_VEHICLE)); |
467 |
} break; |
|
468 |
||
968
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
469 |
case 6: { /* rename */ |
2498
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
470 |
EngineID sel_eng = WP(w,buildtrain_d).sel_engine; |
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
471 |
if (sel_eng != INVALID_ENGINE) { |
968
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
472 |
WP(w,buildtrain_d).rename_engine = sel_eng; |
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
473 |
ShowQueryString(GetCustomEngineName(sel_eng), |
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
474 |
STR_9036_RENAME_ROAD_VEHICLE_TYPE, 31, 160, w->window_class, w->window_number); |
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
475 |
} |
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
476 |
} break; |
0 | 477 |
} |
478 |
break; |
|
479 |
||
480 |
case WE_4: |
|
481 |
if (w->window_number != 0 && !FindWindowById(WC_VEHICLE_DEPOT, w->window_number)) { |
|
482 |
DeleteWindow(w); |
|
483 |
} |
|
484 |
break; |
|
485 |
||
2548
97ada3bd2702
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2517
diff
changeset
|
486 |
case WE_ON_EDIT_TEXT: |
1820
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1790
diff
changeset
|
487 |
if (e->edittext.str[0] != '\0') { |
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1790
diff
changeset
|
488 |
_cmd_text = e->edittext.str; |
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1790
diff
changeset
|
489 |
DoCommandP(0, WP(w, buildtrain_d).rename_engine, 0, NULL, |
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1790
diff
changeset
|
490 |
CMD_RENAME_ENGINE | CMD_MSG(STR_9037_CAN_T_RENAME_ROAD_VEHICLE)); |
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1790
diff
changeset
|
491 |
} |
2548
97ada3bd2702
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2517
diff
changeset
|
492 |
break; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
493 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
494 |
case WE_RESIZE: { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
495 |
if (e->sizing.diff.y == 0) |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
496 |
break; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
497 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
498 |
w->vscroll.cap += e->sizing.diff.y / 14; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
499 |
w->widget[2].unkA = (w->vscroll.cap << 8) + 1; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
500 |
} break; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
501 |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
502 |
} |
0 | 503 |
} |
504 |
||
505 |
static const Widget _new_road_veh_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
506 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
507 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 247, 0, 13, STR_9006_NEW_ROAD_VEHICLES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
508 |
{ WWT_MATRIX, RESIZE_BOTTOM, 14, 0, 235, 14, 125, 0x801, STR_9026_ROAD_VEHICLE_SELECTION}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
509 |
{ WWT_SCROLLBAR, RESIZE_BOTTOM, 14, 236, 247, 14, 125, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
510 |
{ WWT_IMGBTN, RESIZE_TB, 14, 0, 247, 126, 177, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
511 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 117, 178, 189, STR_9007_BUILD_VEHICLE,STR_9027_BUILD_THE_HIGHLIGHTED_ROAD}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
512 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 118, 235, 178, 189, STR_9034_RENAME, STR_9035_RENAME_ROAD_VEHICLE_TYPE}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
513 |
{ WWT_RESIZEBOX, RESIZE_TB, 14, 236, 247, 178, 189, 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
|
514 |
{ WIDGETS_END}, |
0 | 515 |
}; |
516 |
||
517 |
static const WindowDesc _new_road_veh_desc = { |
|
518 |
-1, -1, 248, 190, |
|
519 |
WC_BUILD_VEHICLE,0, |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
520 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
0 | 521 |
_new_road_veh_widgets, |
522 |
NewRoadVehWndProc |
|
523 |
}; |
|
524 |
||
525 |
static void ShowBuildRoadVehWindow(TileIndex tile) |
|
526 |
{ |
|
527 |
Window *w; |
|
528 |
||
529 |
DeleteWindowById(WC_BUILD_VEHICLE, tile); |
|
530 |
||
531 |
w = AllocateWindowDesc(&_new_road_veh_desc); |
|
532 |
w->window_number = tile; |
|
533 |
w->vscroll.cap = 8; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
534 |
w->widget[2].unkA = (w->vscroll.cap << 8) + 1; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
535 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
536 |
w->resize.step_height = 14; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
537 |
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
|
538 |
|
0 | 539 |
if (tile != 0) { |
1901
fb05044cf5c3
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
540 |
w->caption_color = GetTileOwner(tile); |
0 | 541 |
} else { |
542 |
w->caption_color = _local_player; |
|
543 |
} |
|
544 |
} |
|
545 |
||
546 |
static void DrawRoadDepotWindow(Window *w) |
|
547 |
{ |
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
548 |
TileIndex tile; |
0 | 549 |
Vehicle *v; |
550 |
int num,x,y; |
|
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1299
diff
changeset
|
551 |
Depot *depot; |
0 | 552 |
|
553 |
tile = w->window_number; |
|
554 |
||
555 |
/* setup disabled buttons */ |
|
1901
fb05044cf5c3
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
556 |
w->disabled_state = |
2244 | 557 |
IsTileOwner(tile, _local_player) ? 0 : ((1<<4) | (1<<7) | (1<<8)); |
0 | 558 |
|
559 |
/* determine amount of items for scroller */ |
|
560 |
num = 0; |
|
561 |
FOR_ALL_VEHICLES(v) { |
|
1986
5dd3db2b86d7
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
562 |
if (v->type == VEH_Road && v->u.road.state == 254 && v->tile == tile) |
5dd3db2b86d7
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
563 |
num++; |
0 | 564 |
} |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
565 |
SetVScrollCount(w, (num + w->hscroll.cap - 1) / w->hscroll.cap); |
0 | 566 |
|
567 |
/* locate the depot struct */ |
|
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1299
diff
changeset
|
568 |
depot = GetDepotByTile(tile); |
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1299
diff
changeset
|
569 |
assert(depot != NULL); |
0 | 570 |
|
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1299
diff
changeset
|
571 |
SetDParam(0, depot->town_index); |
0 | 572 |
DrawWindowWidgets(w); |
573 |
||
574 |
x = 2; |
|
575 |
y = 15; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
576 |
num = w->vscroll.pos * w->hscroll.cap; |
0 | 577 |
|
578 |
FOR_ALL_VEHICLES(v) { |
|
1986
5dd3db2b86d7
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
579 |
if (v->type == VEH_Road && v->u.road.state == 254 && v->tile == tile && |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
580 |
--num < 0 && num >= -w->vscroll.cap * w->hscroll.cap) { |
0 | 581 |
DrawRoadVehImage(v, x+24, y, WP(w,traindepot_d).sel); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
582 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
583 |
SetDParam(0, v->unitnumber); |
0 | 584 |
DrawString(x, y+2, (uint16)(v->max_age-366) >= v->age ? STR_00E2 : STR_00E3, 0); |
585 |
||
2517
b90693227193
(svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents:
2498
diff
changeset
|
586 |
DrawSprite((v->vehstatus & VS_STOPPED) ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, x + 16, y); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
587 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
588 |
if ((x+=56) == 2 + 56 * w->hscroll.cap) { |
0 | 589 |
x = 2; |
590 |
y += 14; |
|
591 |
} |
|
592 |
} |
|
593 |
} |
|
594 |
} |
|
595 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2406
diff
changeset
|
596 |
static int GetVehicleFromRoadDepotWndPt(const Window *w, int x, int y, Vehicle **veh) |
0 | 597 |
{ |
969
8c4bede35fcc
(svn r1464) -Fix: [1099106] Resizeable portion of bus/air/rail depots window unclickable
darkvater
parents:
968
diff
changeset
|
598 |
uint xt,row,xm; |
0 | 599 |
TileIndex tile; |
600 |
Vehicle *v; |
|
601 |
int pos; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
602 |
|
0 | 603 |
xt = x / 56; |
604 |
xm = x % 56; |
|
971
1b6f956d8ac5
(svn r1466) -Fix: oops, depot windows can of course also scroll horizontally. Thanks si-m1.
darkvater
parents:
969
diff
changeset
|
605 |
if (xt >= w->hscroll.cap) |
0 | 606 |
return 1; |
607 |
||
969
8c4bede35fcc
(svn r1464) -Fix: [1099106] Resizeable portion of bus/air/rail depots window unclickable
darkvater
parents:
968
diff
changeset
|
608 |
row = (y - 14) / 14; |
8c4bede35fcc
(svn r1464) -Fix: [1099106] Resizeable portion of bus/air/rail depots window unclickable
darkvater
parents:
968
diff
changeset
|
609 |
if (row >= w->vscroll.cap) |
0 | 610 |
return 1; |
611 |
||
971
1b6f956d8ac5
(svn r1466) -Fix: oops, depot windows can of course also scroll horizontally. Thanks si-m1.
darkvater
parents:
969
diff
changeset
|
612 |
pos = (row + w->vscroll.pos) * w->hscroll.cap + xt; |
0 | 613 |
|
614 |
tile = w->window_number; |
|
615 |
FOR_ALL_VEHICLES(v) { |
|
1986
5dd3db2b86d7
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
616 |
if (v->type == VEH_Road && v->u.road.state == 254 && v->tile == tile && |
0 | 617 |
--pos < 0) { |
1986
5dd3db2b86d7
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
618 |
*veh = v; |
5dd3db2b86d7
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
619 |
if (xm >= 24) return 0; |
5dd3db2b86d7
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
620 |
if (xm <= 16) return -1; /* show window */ |
5dd3db2b86d7
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
621 |
return -2; /* start stop */ |
5dd3db2b86d7
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
622 |
} |
0 | 623 |
} |
624 |
||
625 |
return 1; /* outside */ |
|
626 |
} |
|
627 |
||
628 |
static void RoadDepotClickVeh(Window *w, int x, int y) |
|
629 |
{ |
|
630 |
Vehicle *v; |
|
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
|
631 |
int mode; |
0 | 632 |
|
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
|
633 |
mode = GetVehicleFromRoadDepotWndPt(w, x, y, &v); |
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
|
634 |
if (mode > 0) return; |
0 | 635 |
|
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
|
636 |
// share / copy orders |
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
|
637 |
if (_thd.place_mode && mode <= 0) { _place_clicked_vehicle = v; return; } |
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
|
638 |
|
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
|
639 |
switch (mode) { |
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
|
640 |
case 0: // start dragging of vehicle |
0 | 641 |
if (v != NULL) { |
642 |
WP(w,traindepot_d).sel = v->index; |
|
643 |
SetWindowDirty(w); |
|
644 |
SetObjectToPlaceWnd( SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)) + GetRoadVehImage(v, 6), 4, w); |
|
645 |
} |
|
646 |
break; |
|
647 |
||
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
|
648 |
case -1: // show info window |
0 | 649 |
ShowRoadVehViewWindow(v); |
650 |
break; |
|
651 |
||
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
|
652 |
case -2: // click start/stop flag |
0 | 653 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_ROADVEH | CMD_MSG(STR_9015_CAN_T_STOP_START_ROAD_VEHICLE)); |
654 |
break; |
|
655 |
||
656 |
default: |
|
657 |
NOT_REACHED(); |
|
658 |
} |
|
659 |
} |
|
660 |
||
2244 | 661 |
/** |
662 |
* Clones a road vehicle |
|
663 |
* @param *v is the original vehicle to clone |
|
664 |
* @param *w is the window of the depot where the clone is build |
|
665 |
*/ |
|
2561
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
666 |
static void HandleCloneVehClick(const Vehicle* v, const Window* w) |
2244 | 667 |
{ |
2561
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
668 |
if (v == NULL || v->type != VEH_Road) return; |
2244 | 669 |
|
2561
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
670 |
DoCommandP(w->window_number, v->index, _ctrl_pressed ? 1 : 0, CcCloneRoadVeh, |
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
671 |
CMD_CLONE_VEHICLE | CMD_MSG(STR_9009_CAN_T_BUILD_ROAD_VEHICLE) |
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
672 |
); |
2244 | 673 |
|
674 |
ResetObjectToPlace(); |
|
675 |
} |
|
676 |
||
2561
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
677 |
static void ClonePlaceObj(TileIndex tile, const Window* w) |
2244 | 678 |
{ |
2561
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
679 |
const Vehicle* v = CheckMouseOverVehicle(); |
2244 | 680 |
|
2561
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
681 |
if (v != NULL) HandleCloneVehClick(v, w); |
2244 | 682 |
} |
683 |
||
0 | 684 |
static void RoadDepotWndProc(Window *w, WindowEvent *e) |
685 |
{ |
|
686 |
switch(e->event) { |
|
687 |
case WE_PAINT: |
|
688 |
DrawRoadDepotWindow(w); |
|
689 |
break; |
|
690 |
||
691 |
case WE_CLICK: { |
|
692 |
switch(e->click.widget) { |
|
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
693 |
case 5: |
0 | 694 |
RoadDepotClickVeh(w, e->click.pt.x, e->click.pt.y); |
695 |
break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
696 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
697 |
case 7: |
2244 | 698 |
ResetObjectToPlace(); |
0 | 699 |
ShowBuildRoadVehWindow(w->window_number); |
700 |
break; |
|
2261
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2252
diff
changeset
|
701 |
|
2244 | 702 |
case 8: /* clone button */ |
703 |
InvalidateWidget(w, 8); |
|
704 |
TOGGLEBIT(w->click_state, 8); |
|
2261
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2252
diff
changeset
|
705 |
|
2244 | 706 |
if (HASBIT(w->click_state, 8)) { |
707 |
_place_clicked_vehicle = NULL; |
|
708 |
SetObjectToPlaceWnd(SPR_CURSOR_CLONE, VHM_RECT, w); |
|
709 |
} else { |
|
710 |
ResetObjectToPlace(); |
|
711 |
} |
|
712 |
break; |
|
2261
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2252
diff
changeset
|
713 |
|
2244 | 714 |
case 9: /* scroll to tile */ |
715 |
ResetObjectToPlace(); |
|
716 |
ScrollMainWindowToTile(w->window_number); |
|
717 |
break; |
|
718 |
} |
|
719 |
} break; |
|
2261
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2252
diff
changeset
|
720 |
|
2561
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
721 |
case WE_PLACE_OBJ: { |
2244 | 722 |
ClonePlaceObj(e->place.tile, w); |
723 |
} break; |
|
0 | 724 |
|
2244 | 725 |
case WE_ABORT_PLACE_OBJ: { |
726 |
CLRBIT(w->click_state, 8); |
|
727 |
InvalidateWidget(w, 8); |
|
728 |
} break; |
|
2261
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2252
diff
changeset
|
729 |
|
2244 | 730 |
// check if a vehicle in a depot was clicked.. |
731 |
case WE_MOUSELOOP: { |
|
2561
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
732 |
const Vehicle* v = _place_clicked_vehicle; |
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
733 |
|
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
734 |
// since OTTD checks all open depot windows, we will make sure that it triggers the one with a clicked clone button |
2244 | 735 |
if (v != NULL && HASBIT(w->click_state, 8)) { |
736 |
_place_clicked_vehicle = NULL; |
|
2561
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
737 |
HandleCloneVehClick(v, w); |
0 | 738 |
} |
739 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
740 |
|
0 | 741 |
case WE_DESTROY: |
742 |
DeleteWindowById(WC_BUILD_VEHICLE, w->window_number); |
|
743 |
break; |
|
744 |
||
745 |
case WE_DRAGDROP: { |
|
746 |
switch(e->click.widget) { |
|
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
747 |
case 5: { |
0 | 748 |
Vehicle *v; |
749 |
VehicleID sel = WP(w,traindepot_d).sel; |
|
750 |
||
751 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
752 |
SetWindowDirty(w); |
|
753 |
||
754 |
if (GetVehicleFromRoadDepotWndPt(w, e->dragdrop.pt.x, e->dragdrop.pt.y, &v) == 0 && |
|
755 |
v != NULL && |
|
756 |
sel == v->index) { |
|
757 |
ShowRoadVehViewWindow(v); |
|
758 |
} |
|
759 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
760 |
|
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
761 |
case 4: |
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
762 |
if (!HASBIT(w->disabled_state, 4) && |
0 | 763 |
WP(w,traindepot_d).sel != INVALID_VEHICLE) { |
764 |
Vehicle *v; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
765 |
|
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
766 |
HandleButtonClick(w, 4); |
0 | 767 |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
768 |
v = GetVehicle(WP(w,traindepot_d).sel); |
0 | 769 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
770 |
||
771 |
_backup_orders_tile = v->tile; |
|
772 |
BackupVehicleOrders(v, _backup_orders_data); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
773 |
|
0 | 774 |
if (!DoCommandP(v->tile, v->index, 0, NULL, CMD_SELL_ROAD_VEH | CMD_MSG(STR_9014_CAN_T_SELL_ROAD_VEHICLE))) |
775 |
_backup_orders_tile = 0; |
|
776 |
} |
|
777 |
break; |
|
778 |
default: |
|
779 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
780 |
SetWindowDirty(w); |
|
781 |
} |
|
782 |
break; |
|
783 |
} |
|
784 |
break; |
|
785 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
786 |
case WE_RESIZE: { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
787 |
/* Update the scroll + matrix */ |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
788 |
w->vscroll.cap += e->sizing.diff.y / 14; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
789 |
w->hscroll.cap += e->sizing.diff.x / 56; |
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
790 |
w->widget[5].unkA = (w->vscroll.cap << 8) + w->hscroll.cap; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
791 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
792 |
} break; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
793 |
|
0 | 794 |
} |
795 |
||
796 |
} |
|
797 |
||
798 |
static const Widget _road_depot_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
799 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
800 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 302, 0, 13, STR_9003_ROAD_VEHICLE_DEPOT, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
801 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 303, 314, 0, 13, 0x0, STR_STICKY_BUTTON}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
802 |
{ WWT_PANEL, RESIZE_LRB, 14, 280, 302, 14, 13, 0x0, STR_NULL}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
803 |
{ WWT_IMGBTN, RESIZE_LRTB, 14, 280, 302, 14, 55, 0x2A9, STR_9024_DRAG_ROAD_VEHICLE_TO_HERE}, |
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
804 |
|
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
805 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 279, 14, 55, 0x305, STR_9022_VEHICLES_CLICK_ON_VEHICLE}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
806 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 303, 314, 14, 55, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
2244 | 807 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 100, 56, 67, STR_9004_NEW_VEHICLES, STR_9023_BUILD_NEW_ROAD_VEHICLE}, |
808 |
{WWT_NODISTXTBTN, RESIZE_TB, 14, 101, 200, 56, 67, STR_CLONE_ROAD_VEHICLE, STR_CLONE_ROAD_VEHICLE_DEPOT_INFO}, |
|
809 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 201, 302, 56, 67, STR_00E4_LOCATION, STR_9025_CENTER_MAIN_VIEW_ON_ROAD}, |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
810 |
{ WWT_PANEL, RESIZE_RTB, 14, 303, 302, 56, 67, 0x0, STR_NULL}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
811 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 303, 314, 56, 67, 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
|
812 |
{ WIDGETS_END}, |
0 | 813 |
}; |
814 |
||
815 |
static const WindowDesc _road_depot_desc = { |
|
816 |
-1, -1, 315, 68, |
|
817 |
WC_VEHICLE_DEPOT,0, |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
818 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 819 |
_road_depot_widgets, |
820 |
RoadDepotWndProc |
|
821 |
}; |
|
822 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
823 |
void ShowRoadDepotWindow(TileIndex tile) |
0 | 824 |
{ |
825 |
Window *w; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
826 |
|
0 | 827 |
w = AllocateWindowDescFront(&_road_depot_desc, tile); |
828 |
if (w) { |
|
1901
fb05044cf5c3
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
829 |
w->caption_color = GetTileOwner(w->window_number); |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
830 |
w->hscroll.cap = 5; |
0 | 831 |
w->vscroll.cap = 3; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
832 |
w->resize.step_width = 56; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
833 |
w->resize.step_height = 14; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
834 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
0 | 835 |
_backup_orders_tile = 0; |
836 |
} |
|
837 |
} |
|
838 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
839 |
static const Widget _player_roadveh_widgets[] = { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
840 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
841 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 247, 0, 13, STR_9001_ROAD_VEHICLES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
842 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
843 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_ORDER_TIP}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
844 |
{ WWT_PANEL, RESIZE_NONE, 14, 81, 235, 14, 25, 0x0, STR_SORT_CRITERIA_TIP}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
845 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 236, 247, 14, 25, STR_0225, STR_SORT_CRITERIA_TIP}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
846 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 248, 259, 14, 25, 0x0, STR_NULL}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
847 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 247, 26, 207, 0x701, STR_901A_ROAD_VEHICLES_CLICK_ON}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
848 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 248, 259, 26, 207, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
588 | 849 |
/* only for our road list, a 'Build Vehicle' button that opens the depot of the last built depot */ |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
850 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 124, 208, 219, STR_8815_NEW_VEHICLES, STR_901B_BUILD_NEW_ROAD_VEHICLES}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
851 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 125, 247, 208, 219, STR_REPLACE_VEHICLES, STR_REPLACE_HELP}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
852 |
{ WWT_PANEL, RESIZE_RTB, 14, 248, 247, 208, 219, 0x0, STR_NULL}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
853 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 248, 259, 208, 219, 0x0, STR_RESIZE_BUTTON}, |
588 | 854 |
{ WIDGETS_END}, |
855 |
}; |
|
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
|
856 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
857 |
static const Widget _other_player_roadveh_widgets[] = { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
858 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
859 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 247, 0, 13, STR_9001_ROAD_VEHICLES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
860 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
861 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_ORDER_TIP}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
862 |
{ WWT_PANEL, RESIZE_NONE, 14, 81, 235, 14, 25, 0x0, STR_SORT_CRITERIA_TIP}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
863 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 236, 247, 14, 25, STR_0225, STR_SORT_CRITERIA_TIP}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
864 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 248, 259, 14, 25, 0x0, STR_NULL}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
865 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 247, 26, 207, 0x701, STR_901A_ROAD_VEHICLES_CLICK_ON}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
866 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 248, 259, 26, 207, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
867 |
{ WWT_PANEL, RESIZE_RTB, 14, 0, 247, 208, 219, 0x0, STR_NULL}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
868 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 248, 259, 208, 219, 0x0, STR_RESIZE_BUTTON}, |
588 | 869 |
{ WIDGETS_END}, |
870 |
}; |
|
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
|
871 |
|
0 | 872 |
static void PlayerRoadVehWndProc(Window *w, WindowEvent *e) |
873 |
{ |
|
2466
2774132ebb9a
(svn r2992) Use PlayerID, StationID and INVALID_STATION instead of int, int and -1
tron
parents:
2436
diff
changeset
|
874 |
StationID station = GB(w->window_number, 16, 16); |
2774132ebb9a
(svn r2992) Use PlayerID, StationID and INVALID_STATION instead of int, int and -1
tron
parents:
2436
diff
changeset
|
875 |
PlayerID owner = GB(w->window_number, 0, 8); |
588 | 876 |
vehiclelist_d *vl = &WP(w, vehiclelist_d); |
877 |
||
0 | 878 |
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
|
879 |
case WE_PAINT: { |
588 | 880 |
int x = 2; |
881 |
int y = PLY_WND_PRC__OFFSET_TOP_WIDGET; |
|
882 |
int max; |
|
883 |
int i; |
|
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
884 |
|
588 | 885 |
BuildVehicleList(vl, VEH_Road, owner, station); |
886 |
SortVehicleList(vl); |
|
0 | 887 |
|
588 | 888 |
SetVScrollCount(w, vl->list_length); |
889 |
||
890 |
// disable 'Sort By' tooltip on Unsorted sorting criteria |
|
891 |
if (vl->sort_type == SORT_BY_UNSORTED) |
|
757 | 892 |
w->disabled_state |= (1 << 3); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
893 |
|
0 | 894 |
/* draw the widgets */ |
895 |
{ |
|
1962
51ee4f459268
(svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar
parents:
1938
diff
changeset
|
896 |
const Player *p = GetPlayer(owner); |
2466
2774132ebb9a
(svn r2992) Use PlayerID, StationID and INVALID_STATION instead of int, int and -1
tron
parents:
2436
diff
changeset
|
897 |
if (station == INVALID_STATION) { |
588 | 898 |
/* Company Name -- (###) Road vehicles */ |
899 |
SetDParam(0, p->name_1); |
|
900 |
SetDParam(1, p->name_2); |
|
901 |
SetDParam(2, w->vscroll.count); |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
902 |
w->widget[1].unkA = STR_9001_ROAD_VEHICLES; |
588 | 903 |
} else { |
904 |
/* Station Name -- (###) Road vehicles */ |
|
1294
bc831562148e
(svn r1798) GetFoo(i)->index is per definition i, so replace the former with the latter
tron
parents:
1246
diff
changeset
|
905 |
SetDParam(0, station); |
588 | 906 |
SetDParam(1, w->vscroll.count); |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
907 |
w->widget[1].unkA = STR_SCHEDULED_ROAD_VEHICLES; |
588 | 908 |
} |
0 | 909 |
DrawWindowWidgets(w); |
910 |
} |
|
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
911 |
/* draw sorting criteria string */ |
588 | 912 |
DrawString(85, 15, _vehicle_sort_listing[vl->sort_type], 0x10); |
913 |
/* draw arrow pointing up/down for ascending/descending sorting */ |
|
2406
be5cfb8cd20d
(svn r2932) Give the strings consisting of an up/a down arrow symbolic names
tron
parents:
2273
diff
changeset
|
914 |
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
|
915 |
|
588 | 916 |
max = min(w->vscroll.pos + w->vscroll.cap, vl->list_length); |
917 |
for (i = w->vscroll.pos; i < max; ++i) { |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
918 |
Vehicle *v = GetVehicle(vl->sort_list[i].index); |
588 | 919 |
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
|
920 |
|
588 | 921 |
assert(v->type == VEH_Road && v->owner == owner); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
922 |
|
588 | 923 |
DrawRoadVehImage(v, x + 22, y + 6, INVALID_VEHICLE); |
924 |
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
|
925 |
|
588 | 926 |
SetDParam(0, v->unitnumber); |
1330
8a67d04016ce
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1323
diff
changeset
|
927 |
if (IsTileDepotType(v->tile, TRANSPORT_ROAD) && (v->vehstatus & VS_HIDDEN)) |
588 | 928 |
str = STR_021F; |
929 |
else |
|
930 |
str = v->age > v->max_age - 366 ? STR_00E3 : STR_00E2; |
|
931 |
DrawString(x, y + 2, str, 0); |
|
932 |
||
933 |
SetDParam(0, v->profit_this_year); |
|
934 |
SetDParam(1, v->profit_last_year); |
|
935 |
DrawString(x + 24, y + 18, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 0); |
|
936 |
||
671
ca04afdfdf43
(svn r1109) Fix c&p bug: In vehicle lists a name was displayed for road vehicles even if they had none
tron
parents:
588
diff
changeset
|
937 |
if (v->string_id != STR_SV_ROADVEH_NAME) { |
588 | 938 |
SetDParam(0, v->string_id); |
939 |
DrawString(x + 24, y, STR_01AB, 0); |
|
0 | 940 |
} |
588 | 941 |
|
942 |
y += PLY_WND_PRC__SIZE_OF_ROW_SMALL; |
|
0 | 943 |
} |
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
|
944 |
} break; |
0 | 945 |
|
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
|
946 |
case WE_CLICK: { |
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
|
947 |
switch(e->click.widget) { |
757 | 948 |
case 3: /* Flip sorting method ascending/descending */ |
588 | 949 |
vl->flags ^= VL_DESC; |
950 |
vl->flags |= VL_RESORT; |
|
1246
45f15251412b
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents:
1151
diff
changeset
|
951 |
_sorting.roadveh.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
|
952 |
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
|
953 |
break; |
588 | 954 |
|
757 | 955 |
case 4: case 5:/* Select sorting criteria dropdown menu */ |
842 | 956 |
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
|
957 |
return; |
757 | 958 |
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
|
959 |
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
|
960 |
|
2549 | 961 |
if (id_v >= w->vscroll.cap) return; // click out of bounds |
0 | 962 |
|
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
|
963 |
id_v += w->vscroll.pos; |
0 | 964 |
|
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
|
965 |
{ |
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
|
966 |
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
|
967 |
|
588 | 968 |
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
|
969 |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
970 |
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
|
971 |
|
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
|
972 |
assert(v->type == VEH_Road && 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
|
973 |
|
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
|
974 |
ShowRoadVehViewWindow(v); |
0 | 975 |
} |
976 |
} break; |
|
977 |
||
757 | 978 |
case 9: { /* Build new Vehicle */ |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
979 |
TileIndex tile; |
0 | 980 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
981 |
if (!IsWindowOfPrototype(w, _player_roadveh_widgets)) |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
982 |
break; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
983 |
|
0 | 984 |
tile = _last_built_road_depot_tile; |
985 |
do { |
|
1906
f5ae1d8ad052
(svn r2412) - Fix: [ 1214948 ] building vehicles without depot crashes game. (Chris Huebsch)
hackykid
parents:
1901
diff
changeset
|
986 |
if (IsTileDepotType(tile, TRANSPORT_ROAD) && IsTileOwner(tile, _local_player)) { |
0 | 987 |
ShowRoadDepotWindow(tile); |
988 |
ShowBuildRoadVehWindow(tile); |
|
989 |
return; |
|
990 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
991 |
|
0 | 992 |
tile = TILE_MASK(tile + 1); |
993 |
} while(tile != _last_built_road_depot_tile); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
994 |
|
0 | 995 |
ShowBuildRoadVehWindow(0); |
996 |
} break; |
|
842 | 997 |
case 10: { |
886
4442d7859ea7
(svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight
parents:
878
diff
changeset
|
998 |
if (!IsWindowOfPrototype(w, _player_roadveh_widgets)) |
4442d7859ea7
(svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight
parents:
878
diff
changeset
|
999 |
break; |
4442d7859ea7
(svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight
parents:
878
diff
changeset
|
1000 |
|
842 | 1001 |
ShowReplaceVehicleWindow(VEH_Road); |
1002 |
break; |
|
1003 |
} |
|
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
|
1004 |
} |
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
|
1005 |
} break; |
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
|
1006 |
|
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
|
1007 |
case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */ |
588 | 1008 |
if (vl->sort_type != e->dropdown.index) { |
1009 |
// value has changed -> resort |
|
1010 |
vl->flags |= VL_RESORT; |
|
1011 |
vl->sort_type = e->dropdown.index; |
|
1246
45f15251412b
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents:
1151
diff
changeset
|
1012 |
_sorting.roadveh.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
|
1013 |
|
588 | 1014 |
// enable 'Sort By' if a sorter criteria is chosen |
1015 |
if (vl->sort_type != SORT_BY_UNSORTED) |
|
1246
45f15251412b
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents:
1151
diff
changeset
|
1016 |
CLRBIT(w->disabled_state, 3); |
588 | 1017 |
} |
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
|
1018 |
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
|
1019 |
break; |
588 | 1020 |
|
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
|
1021 |
case WE_CREATE: /* set up resort timer */ |
588 | 1022 |
vl->sort_list = NULL; |
1246
45f15251412b
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents:
1151
diff
changeset
|
1023 |
vl->flags = VL_REBUILD | (_sorting.roadveh.order << (VL_DESC - 1)); |
45f15251412b
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents:
1151
diff
changeset
|
1024 |
vl->sort_type = _sorting.roadveh.criteria; |
588 | 1025 |
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
|
1026 |
break; |
588 | 1027 |
|
767 | 1028 |
case WE_DESTROY: |
1029 |
free(vl->sort_list); |
|
1030 |
break; |
|
1031 |
||
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
|
1032 |
case WE_TICK: /* resort the list every 20 seconds orso (10 days) */ |
588 | 1033 |
if (--vl->resort_timer == 0) { |
1034 |
DEBUG(misc, 1) ("Periodic resort road vehicles list player %d station %d", |
|
1035 |
owner, station); |
|
1036 |
vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; |
|
1037 |
vl->flags |= VL_RESORT; |
|
1038 |
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
|
1039 |
} |
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
|
1040 |
break; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1041 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1042 |
case WE_RESIZE: |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1043 |
/* Update the scroll + matrix */ |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1044 |
w->vscroll.cap += e->sizing.diff.y / PLY_WND_PRC__SIZE_OF_ROW_SMALL; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1045 |
w->widget[7].unkA = (w->vscroll.cap << 8) + 1; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1046 |
break; |
0 | 1047 |
} |
1048 |
} |
|
1049 |
||
1050 |
static const WindowDesc _player_roadveh_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
|
1051 |
-1, -1, 260, 220, |
0 | 1052 |
WC_ROADVEH_LIST,0, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1053 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 1054 |
_player_roadveh_widgets, |
1055 |
PlayerRoadVehWndProc |
|
1056 |
}; |
|
1057 |
||
1058 |
static const WindowDesc _other_player_roadveh_desc = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1059 |
-1, -1, 260, 220, |
0 | 1060 |
WC_ROADVEH_LIST,0, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1061 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 1062 |
_other_player_roadveh_widgets, |
1063 |
PlayerRoadVehWndProc |
|
1064 |
}; |
|
1065 |
||
1066 |
||
2466
2774132ebb9a
(svn r2992) Use PlayerID, StationID and INVALID_STATION instead of int, int and -1
tron
parents:
2436
diff
changeset
|
1067 |
void ShowPlayerRoadVehicles(PlayerID player, StationID station) |
0 | 1068 |
{ |
1069 |
Window *w; |
|
1070 |
||
1071 |
if ( player == _local_player) { |
|
588 | 1072 |
w = AllocateWindowDescFront(&_player_roadveh_desc, (station << 16) | player); |
0 | 1073 |
} else { |
588 | 1074 |
w = AllocateWindowDescFront(&_other_player_roadveh_desc, (station << 16) | player); |
0 | 1075 |
} |
1076 |
if (w) { |
|
1077 |
w->caption_color = player; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1078 |
w->vscroll.cap = 7; // maximum number of vehicles shown |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1079 |
w->widget[7].unkA = (w->vscroll.cap << 8) + 1; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1080 |
w->resize.step_height = PLY_WND_PRC__SIZE_OF_ROW_SMALL; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1081 |
w->resize.height = 220 - (PLY_WND_PRC__SIZE_OF_ROW_SMALL * 3); /* Minimum of 4 vehicles */ |
0 | 1082 |
} |
1083 |
} |