author | tron |
Sat, 13 Nov 2004 18:15:03 +0000 | |
changeset 380 | 87faf9e3216f |
parent 374 | 0309a855fc66 |
child 507 | 04b5403aaf6b |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
2 |
#include "ttd.h" |
|
3 |
||
4 |
#include "window.h" |
|
5 |
#include "gui.h" |
|
6 |
#include "gfx.h" |
|
7 |
#include "vehicle.h" |
|
8 |
#include "viewport.h" |
|
9 |
#include "station.h" |
|
10 |
#include "command.h" |
|
11 |
#include "player.h" |
|
12 |
#include "engine.h" |
|
13 |
||
14 |
static void DrawRoadVehImage(Vehicle *v, int x, int y, VehicleID selection) |
|
15 |
{ |
|
16 |
int image = GetRoadVehImage(v, 6); |
|
17 |
uint32 ormod = SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)); |
|
18 |
if (v->vehstatus & VS_CRASHED) ormod = 0x3248000; |
|
19 |
DrawSprite(image | ormod, x+14, y+6); |
|
20 |
||
21 |
if (v->index == selection) { |
|
22 |
DrawFrameRect(x-1, y-1, x+28, y+12, 15, 0x10); |
|
23 |
} |
|
24 |
} |
|
25 |
||
26 |
static void RoadVehDetailsWndProc(Window *w, WindowEvent *e) |
|
27 |
{ |
|
28 |
Vehicle *v = &_vehicles[w->window_number]; |
|
29 |
StringID str; |
|
30 |
int mod; |
|
31 |
||
32 |
switch(e->event) { |
|
33 |
case WE_PAINT: |
|
34 |
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
|
35 |
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
|
36 |
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
|
37 |
|
0 | 38 |
SET_DPARAM16(0, v->string_id); |
39 |
SET_DPARAM16(1, v->unitnumber); |
|
40 |
DrawWindowWidgets(w); |
|
41 |
||
42 |
/* Draw running cost */ |
|
43 |
{ |
|
44 |
int year = v->age / 366; |
|
45 |
StringID str; |
|
46 |
||
47 |
SET_DPARAM16(1, year); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
48 |
|
0 | 49 |
str = STR_0199_YEAR; |
50 |
if (year != 1) { |
|
51 |
str++; |
|
52 |
if (v->max_age - 366 < v->age) |
|
53 |
str++; |
|
54 |
} |
|
55 |
SET_DPARAM16(0, str); |
|
56 |
SET_DPARAM16(2, v->max_age / 366); |
|
374
0309a855fc66
(svn r562) newgrf: Merge most of the road vehicle info to a single
celestar
parents:
339
diff
changeset
|
57 |
SET_DPARAM32(3, road_vehicle_info(v->engine_type)->running_cost * _price.roadveh_running >> 8); |
0 | 58 |
DrawString(2, 15, STR_900D_AGE_RUNNING_COST_YR, 0); |
59 |
} |
|
60 |
||
61 |
/* Draw max speed */ |
|
62 |
{ |
|
63 |
SET_DPARAM16(0, v->max_speed * 10 >> 5); |
|
64 |
DrawString(2, 25, STR_900E_MAX_SPEED, 0); |
|
65 |
} |
|
66 |
||
67 |
/* Draw profit */ |
|
68 |
{ |
|
69 |
SET_DPARAM32(0, v->profit_this_year); |
|
70 |
SET_DPARAM32(1, v->profit_last_year); |
|
71 |
DrawString(2, 35, STR_900F_PROFIT_THIS_YEAR_LAST_YEAR, 0); |
|
72 |
} |
|
73 |
||
74 |
/* Draw breakdown & reliability */ |
|
75 |
{ |
|
76 |
SET_DPARAM8(0, v->reliability * 100 >> 16); |
|
77 |
SET_DPARAM16(1, v->breakdowns_since_last_service); |
|
78 |
DrawString(2, 45, STR_9010_RELIABILITY_BREAKDOWNS, 0); |
|
79 |
} |
|
80 |
||
81 |
/* Draw service interval text */ |
|
82 |
{ |
|
83 |
SET_DPARAM16(0, v->service_interval); |
|
84 |
SET_DPARAM16(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
|
85 |
DrawString(13, 90, _patches.servint_ispercent?STR_SERVICING_INTERVAL_PERCENT:STR_883C_SERVICING_INTERVAL_DAYS, 0); |
0 | 86 |
} |
87 |
||
88 |
DrawRoadVehImage(v, 3, 57, INVALID_VEHICLE); |
|
89 |
||
90 |
SET_DPARAM16(0, GetCustomEngineName(v->engine_type)); |
|
91 |
SET_DPARAM16(1, 1920 + v->build_year); |
|
92 |
SET_DPARAM32(2, v->value); |
|
93 |
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
|
94 |
|
0 | 95 |
SET_DPARAM16(0, _cargoc.names_long_p[v->cargo_type]); |
96 |
SET_DPARAM16(1, v->cargo_cap); |
|
97 |
DrawString(34, 67, STR_9012_CAPACITY, 0); |
|
98 |
||
99 |
str = STR_8812_EMPTY; |
|
100 |
if (v->cargo_count != 0) { |
|
101 |
SET_DPARAM8(0, v->cargo_type); |
|
102 |
SET_DPARAM16(1, v->cargo_count); |
|
103 |
SET_DPARAM16(2, v->cargo_source); |
|
104 |
str = STR_8813_FROM; |
|
105 |
} |
|
106 |
DrawString(34, 78, str, 0); |
|
107 |
break; |
|
108 |
||
109 |
case WE_CLICK: |
|
110 |
switch(e->click.widget) { |
|
111 |
case 2: /* rename */ |
|
112 |
SET_DPARAM16(0, v->unitnumber); |
|
113 |
ShowQueryString(v->string_id, STR_902C_NAME_ROAD_VEHICLE, 31, 150, w->window_class, w->window_number); |
|
114 |
break; |
|
115 |
||
116 |
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
|
117 |
mod = _ctrl_pressed? 5 : 10; |
0 | 118 |
goto change_int; |
119 |
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
|
120 |
mod = _ctrl_pressed? -5 : -10; |
0 | 121 |
change_int: |
122 |
mod += v->service_interval; |
|
156
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
10
diff
changeset
|
123 |
|
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
|
124 |
/* %-based service interval max 5%-90% |
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
|
125 |
day-based service interval max 30-800 days */ |
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
|
126 |
mod = _patches.servint_ispercent ? clamp(mod, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : clamp(mod, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS+1); |
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
|
127 |
if (mod == v->service_interval) |
0 | 128 |
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
|
129 |
|
0 | 130 |
DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_ROADVEH_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING)); |
131 |
break; |
|
132 |
} |
|
133 |
break; |
|
134 |
||
135 |
case WE_4: |
|
136 |
if (FindWindowById(WC_VEHICLE_VIEW, w->window_number) == NULL) |
|
137 |
DeleteWindow(w); |
|
138 |
break; |
|
139 |
||
140 |
case WE_ON_EDIT_TEXT: { |
|
141 |
byte *b = e->edittext.str; |
|
142 |
if (*b == 0) |
|
143 |
return; |
|
144 |
memcpy(_decode_parameters, b, 32); |
|
145 |
DoCommandP(0, w->window_number, 0, NULL, CMD_NAME_VEHICLE | CMD_MSG(STR_902D_CAN_T_NAME_ROAD_VEHICLE)); |
|
146 |
} break; |
|
147 |
||
148 |
} |
|
149 |
} |
|
150 |
||
151 |
static const Widget _roadveh_details_widgets[] = { |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
152 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
153 |
{ WWT_CAPTION, 14, 11, 339, 0, 13, STR_900C_DETAILS,STR_018C_WINDOW_TITLE_DRAG_THIS}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
154 |
{ WWT_PUSHTXTBTN, 14, 340, 379, 0, 13, STR_01AA_NAME, STR_902E_NAME_ROAD_VEHICLE}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
155 |
{ WWT_IMGBTN, 14, 0, 379, 14, 55, 0x0, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
156 |
{ WWT_IMGBTN, 14, 0, 379, 56, 88, 0x0, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
157 |
{ WWT_PUSHTXTBTN, 14, 0, 10, 89, 94, STR_0188, STR_884D_INCREASE_SERVICING_INTERVAL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
158 |
{ WWT_PUSHTXTBTN, 14, 0, 10, 95, 100, STR_0189, STR_884E_DECREASE_SERVICING_INTERVAL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
159 |
{ WWT_IMGBTN, 14, 11, 379, 89, 100, 0x0, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
160 |
{ WIDGETS_END}, |
0 | 161 |
}; |
162 |
||
163 |
static const WindowDesc _roadveh_details_desc = { |
|
164 |
-1,-1, 380, 101, |
|
165 |
WC_VEHICLE_DETAILS,WC_VEHICLE_VIEW, |
|
166 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
167 |
_roadveh_details_widgets, |
|
168 |
RoadVehDetailsWndProc |
|
169 |
}; |
|
170 |
||
171 |
static void ShowRoadVehDetailsWindow(Vehicle *v) |
|
172 |
{ |
|
173 |
Window *w; |
|
174 |
VehicleID veh = v->index; |
|
175 |
DeleteWindowById(WC_VEHICLE_ORDERS, veh); |
|
176 |
DeleteWindowById(WC_VEHICLE_DETAILS, veh); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
177 |
_alloc_wnd_parent_num = veh; |
0 | 178 |
w = AllocateWindowDesc(&_roadveh_details_desc); |
179 |
w->window_number = veh; |
|
180 |
w->caption_color = v->owner; |
|
181 |
} |
|
182 |
||
183 |
static void RoadVehViewWndProc(Window *w, WindowEvent *e) |
|
184 |
{ |
|
185 |
switch(e->event) { |
|
186 |
case WE_PAINT: { |
|
187 |
Vehicle *v = &_vehicles[w->window_number]; |
|
188 |
StringID str; |
|
189 |
||
190 |
w->disabled_state = (v->owner != _local_player) ? (1<<7 | 1<<6) : 0; |
|
191 |
||
192 |
/* draw widgets & caption */ |
|
193 |
SET_DPARAM16(0, v->string_id); |
|
194 |
SET_DPARAM16(1, v->unitnumber); |
|
195 |
DrawWindowWidgets(w); |
|
196 |
||
197 |
/* draw the flag */ |
|
198 |
DrawSprite((v->vehstatus & VS_STOPPED) ? 0xC12 : 0xC13, 2, 105); |
|
199 |
||
200 |
if (v->u.road.crashed_ctr != 0) { |
|
201 |
str = STR_8863_CRASHED; |
|
202 |
} else if (v->breakdown_ctr == 1) { |
|
203 |
str = STR_885C_BROKEN_DOWN; |
|
204 |
} else if (v->vehstatus & VS_STOPPED) { |
|
205 |
str = STR_8861_STOPPED; |
|
206 |
} else { |
|
207 |
switch(v->next_order & OT_MASK) { |
|
208 |
case OT_GOTO_STATION: { |
|
209 |
SET_DPARAM16(0, v->next_order_param); |
|
210 |
SET_DPARAM16(1, v->cur_speed * 10 >> 5); |
|
211 |
str = STR_HEADING_FOR_STATION + _patches.vehicle_speed; |
|
212 |
} break; |
|
213 |
||
214 |
case OT_GOTO_DEPOT: { |
|
215 |
Depot *dep = &_depots[v->next_order_param]; |
|
216 |
SET_DPARAM16(0, dep->town_index); |
|
217 |
SET_DPARAM16(1, v->cur_speed * 10 >> 5); |
|
218 |
str = STR_HEADING_FOR_ROAD_DEPOT + _patches.vehicle_speed; |
|
219 |
} break; |
|
220 |
||
221 |
case OT_LOADING: |
|
222 |
case OT_LEAVESTATION: |
|
223 |
str = STR_882F_LOADING_UNLOADING; |
|
224 |
break; |
|
225 |
||
226 |
default: |
|
227 |
if (v->num_orders == 0) { |
|
228 |
str = STR_NO_ORDERS + _patches.vehicle_speed; |
|
229 |
SET_DPARAM16(0, v->cur_speed * 10 >> 5); |
|
230 |
} else |
|
231 |
str = STR_EMPTY; |
|
232 |
break; |
|
233 |
} |
|
234 |
} |
|
235 |
||
236 |
DrawStringCentered(125, 105, str, 0); |
|
237 |
DrawWindowViewport(w); |
|
238 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
239 |
|
0 | 240 |
case WE_CLICK: { |
241 |
Vehicle *v = &_vehicles[w->window_number]; |
|
242 |
||
243 |
switch(e->click.widget) { |
|
244 |
case 4: /* start stop */ |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
245 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_ROADVEH | CMD_MSG(STR_9015_CAN_T_STOP_START_ROAD_VEHICLE)); |
0 | 246 |
break; |
247 |
case 5: /* center main view */ |
|
248 |
ScrollMainWindowTo(v->x_pos, v->y_pos); |
|
249 |
break; |
|
250 |
case 6: /* goto hangar */ |
|
251 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_SEND_ROADVEH_TO_DEPOT | CMD_MSG(STR_9018_CAN_T_SEND_VEHICLE_TO_DEPOT)); |
|
252 |
break; |
|
253 |
case 7: /* turn around */ |
|
254 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_TURN_ROADVEH | CMD_MSG(STR_9033_CAN_T_MAKE_VEHICLE_TURN)); |
|
255 |
break; |
|
256 |
case 8: /* show orders */ |
|
257 |
ShowOrdersWindow(v); |
|
258 |
break; |
|
259 |
case 9: /* show details */ |
|
260 |
ShowRoadVehDetailsWindow(v); |
|
261 |
break; |
|
262 |
} |
|
263 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
264 |
|
0 | 265 |
case WE_DESTROY: |
266 |
DeleteWindowById(WC_VEHICLE_ORDERS, w->window_number); |
|
267 |
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
|
268 |
break; |
0 | 269 |
} |
270 |
} |
|
271 |
||
272 |
static const Widget _roadveh_view_widgets[] = { |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
273 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
274 |
{ WWT_CAPTION, 14, 11, 249, 0, 13, STR_9002, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
275 |
{ WWT_IMGBTN, 14, 0, 231, 14, 103, 0x0, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
276 |
{ WWT_6, 14, 2, 229, 16, 101, 0x0, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
277 |
{ WWT_PUSHIMGBTN, 14, 0, 249, 104, 115, 0x0, STR_901C_CURRENT_VEHICLE_ACTION}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
278 |
{ WWT_PUSHIMGBTN, 14, 232, 249, 14, 31, 0x2AB, STR_901E_CENTER_MAIN_VIEW_ON_VEHICLE}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
279 |
{ WWT_PUSHIMGBTN, 14, 232, 249, 32, 49, 0x2AE, STR_901F_SEND_VEHICLE_TO_DEPOT}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
280 |
{ WWT_PUSHIMGBTN, 14, 232, 249, 50, 67, 0x2CB, STR_9020_FORCE_VEHICLE_TO_TURN_AROUND}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
281 |
{ WWT_PUSHIMGBTN, 14, 232, 249, 68, 85, 0x2B2, STR_901D_SHOW_VEHICLE_S_ORDERS}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
282 |
{ WWT_PUSHIMGBTN, 14, 232, 249, 86, 103, 0x2B3, STR_9021_SHOW_ROAD_VEHICLE_DETAILS}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
283 |
{ WIDGETS_END}, |
0 | 284 |
}; |
285 |
||
286 |
static const WindowDesc _roadveh_view_desc = { |
|
287 |
-1,-1, 250, 116, |
|
288 |
WC_VEHICLE_VIEW,0, |
|
289 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
290 |
_roadveh_view_widgets, |
|
291 |
RoadVehViewWndProc, |
|
292 |
}; |
|
293 |
||
294 |
void ShowRoadVehViewWindow(Vehicle *v) |
|
295 |
{ |
|
296 |
Window *w; |
|
297 |
||
298 |
w = AllocateWindowDescFront(&_roadveh_view_desc, v->index); |
|
299 |
if (w) { |
|
300 |
w->caption_color = v->owner; |
|
301 |
AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), 0); |
|
302 |
} |
|
303 |
} |
|
304 |
||
305 |
||
306 |
static void DrawNewRoadVehWindow(Window *w) |
|
307 |
{ |
|
308 |
YearMonthDay ymd; |
|
309 |
||
310 |
if (w->window_number == 0) |
|
311 |
w->disabled_state = 1 << 5; |
|
312 |
||
313 |
// setup scroller |
|
314 |
{ |
|
315 |
int count = 0; |
|
316 |
int num = NUM_ROAD_ENGINES; |
|
317 |
Engine *e = &_engines[ROAD_ENGINES_INDEX]; |
|
318 |
do { |
|
319 |
if (HASBIT(e->player_avail, _local_player)) |
|
320 |
count++; |
|
321 |
} while (++e,--num); |
|
322 |
SetVScrollCount(w, count); |
|
323 |
} |
|
324 |
||
325 |
DrawWindowWidgets(w); |
|
326 |
||
327 |
{ |
|
328 |
int num = NUM_ROAD_ENGINES; |
|
329 |
Engine *e = &_engines[ROAD_ENGINES_INDEX]; |
|
330 |
int x = 1; |
|
331 |
int y = 15; |
|
332 |
int sel = WP(w,buildtrain_d).sel_index; |
|
333 |
int pos = w->vscroll.pos; |
|
334 |
int engine_id = ROAD_ENGINES_INDEX; |
|
335 |
int selected_id = -1; |
|
336 |
||
337 |
do { |
|
338 |
if (HASBIT(e->player_avail, _local_player)) { |
|
339 |
if (sel==0) selected_id = engine_id; |
|
340 |
if (IS_INT_INSIDE(--pos, -8, 0)) { |
|
341 |
DrawString(x+59, y+2, GetCustomEngineName(engine_id), sel==0 ? 0xC : 0x10); |
|
342 |
DrawRoadVehEngine(x+29, y+6, engine_id, SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player))); |
|
343 |
y += 14; |
|
344 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
345 |
sel--; |
0 | 346 |
} |
347 |
} while (++engine_id, ++e,--num); |
|
348 |
||
349 |
WP(w,buildtrain_d).sel_engine = selected_id; |
|
350 |
if (selected_id != -1) { |
|
351 |
Engine *e; |
|
352 |
||
374
0309a855fc66
(svn r562) newgrf: Merge most of the road vehicle info to a single
celestar
parents:
339
diff
changeset
|
353 |
SET_DPARAM32(0, road_vehicle_info(selected_id)->base_cost * (_price.roadveh_base>>3)>>5); |
0309a855fc66
(svn r562) newgrf: Merge most of the road vehicle info to a single
celestar
parents:
339
diff
changeset
|
354 |
SET_DPARAM16(1, road_vehicle_info(selected_id)->max_speed * 10 >> 5); |
0309a855fc66
(svn r562) newgrf: Merge most of the road vehicle info to a single
celestar
parents:
339
diff
changeset
|
355 |
SET_DPARAM32(2, road_vehicle_info(selected_id)->running_cost * _price.roadveh_running >> 8); |
0309a855fc66
(svn r562) newgrf: Merge most of the road vehicle info to a single
celestar
parents:
339
diff
changeset
|
356 |
SET_DPARAM16(4, road_vehicle_info(selected_id)->capacity); |
0309a855fc66
(svn r562) newgrf: Merge most of the road vehicle info to a single
celestar
parents:
339
diff
changeset
|
357 |
SET_DPARAM16(3, _cargoc.names_long_p[road_vehicle_info(selected_id)->cargo_type]); |
0 | 358 |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
359 |
e = &_engines[selected_id]; |
0 | 360 |
SET_DPARAM16(6, e->lifelength); |
361 |
SET_DPARAM8(7, e->reliability * 100 >> 16); |
|
362 |
ConvertDayToYMD(&ymd, e->intro_date); |
|
363 |
SET_DPARAM16(5, ymd.year + 1920); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
364 |
|
0 | 365 |
DrawString(2, 127, STR_9008_COST_SPEED_RUNNING_COST, 0); |
366 |
} |
|
367 |
} |
|
368 |
} |
|
369 |
||
370 |
static void CcBuildRoadVeh(bool success, uint tile, uint32 p1, uint32 p2) |
|
371 |
{ |
|
372 |
Vehicle *v; |
|
373 |
||
374 |
if (!success) return; |
|
375 |
||
376 |
v = &_vehicles[_new_roadveh_id]; |
|
377 |
if (v->tile == _backup_orders_tile) { |
|
378 |
_backup_orders_tile = 0; |
|
379 |
RestoreVehicleOrders(v, _backup_orders_data); |
|
380 |
} |
|
381 |
ShowRoadVehViewWindow(v); |
|
382 |
} |
|
383 |
||
384 |
static void NewRoadVehWndProc(Window *w, WindowEvent *e) |
|
385 |
{ |
|
386 |
switch(e->event) { |
|
387 |
case WE_PAINT: |
|
388 |
DrawNewRoadVehWindow(w); |
|
389 |
break; |
|
390 |
||
391 |
case WE_CLICK: |
|
392 |
switch(e->click.widget) { |
|
393 |
case 2: { /* listbox */ |
|
394 |
uint i = (e->click.pt.y - 14) / 14; |
|
395 |
if (i < 8) { |
|
396 |
WP(w,buildtrain_d).sel_index = i + w->vscroll.pos; |
|
397 |
SetWindowDirty(w); |
|
398 |
} |
|
399 |
} break; |
|
400 |
||
401 |
case 5: { /* build */ |
|
402 |
int sel_eng = WP(w,buildtrain_d).sel_engine; |
|
403 |
if (sel_eng != -1) |
|
404 |
DoCommandP(w->window_number, sel_eng, 0, CcBuildRoadVeh, CMD_BUILD_ROAD_VEH | CMD_MSG(STR_9009_CAN_T_BUILD_ROAD_VEHICLE)); |
|
405 |
} break; |
|
406 |
||
407 |
case 6: /* rename */ |
|
408 |
WP(w,buildtrain_d).rename_engine = WP(w,buildtrain_d).sel_engine; |
|
409 |
ShowQueryString( |
|
410 |
GetCustomEngineName(WP(w,buildtrain_d).sel_engine), |
|
411 |
STR_9036_RENAME_ROAD_VEHICLE_TYPE, |
|
412 |
31, |
|
413 |
160, |
|
414 |
w->window_class, |
|
415 |
w->window_number); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
416 |
break; |
0 | 417 |
} |
418 |
break; |
|
419 |
||
420 |
case WE_4: |
|
421 |
if (w->window_number != 0 && !FindWindowById(WC_VEHICLE_DEPOT, w->window_number)) { |
|
422 |
DeleteWindow(w); |
|
423 |
} |
|
424 |
break; |
|
425 |
||
426 |
case WE_ON_EDIT_TEXT: { |
|
427 |
byte *b = e->edittext.str; |
|
428 |
if (*b == 0) |
|
429 |
return; |
|
430 |
memcpy(_decode_parameters, b, 32); |
|
431 |
DoCommandP(0, WP(w,buildtrain_d).rename_engine, 0, NULL, CMD_RENAME_ENGINE | CMD_MSG(STR_9037_CAN_T_RENAME_ROAD_VEHICLE)); |
|
432 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
433 |
|
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
434 |
} |
0 | 435 |
} |
436 |
||
437 |
static const Widget _new_road_veh_widgets[] = { |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
438 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
0 | 439 |
{ WWT_CAPTION, 14, 11, 247, 0, 13, STR_9006_NEW_ROAD_VEHICLES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
440 |
{ WWT_MATRIX, 14, 0, 236, 14, 125, 0x801, STR_9026_ROAD_VEHICLE_SELECTION}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
441 |
{ WWT_SCROLLBAR, 14, 237, 247, 14, 125, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
442 |
{ WWT_IMGBTN, 14, 0, 247, 126, 177, 0x0, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
443 |
{ WWT_PUSHTXTBTN, 14, 0, 123, 178, 189, STR_9007_BUILD_VEHICLE,STR_9027_BUILD_THE_HIGHLIGHTED_ROAD}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
444 |
{ WWT_PUSHTXTBTN, 14, 124, 247, 178, 189, STR_9034_RENAME, STR_9035_RENAME_ROAD_VEHICLE_TYPE}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
445 |
{ WIDGETS_END}, |
0 | 446 |
}; |
447 |
||
448 |
static const WindowDesc _new_road_veh_desc = { |
|
449 |
-1, -1, 248, 190, |
|
450 |
WC_BUILD_VEHICLE,0, |
|
451 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
452 |
_new_road_veh_widgets, |
|
453 |
NewRoadVehWndProc |
|
454 |
}; |
|
455 |
||
456 |
static void ShowBuildRoadVehWindow(TileIndex tile) |
|
457 |
{ |
|
458 |
Window *w; |
|
459 |
||
460 |
DeleteWindowById(WC_BUILD_VEHICLE, tile); |
|
461 |
||
462 |
w = AllocateWindowDesc(&_new_road_veh_desc); |
|
463 |
w->window_number = tile; |
|
464 |
w->vscroll.cap = 8; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
465 |
|
0 | 466 |
if (tile != 0) { |
467 |
w->caption_color = _map_owner[tile]; |
|
468 |
} else { |
|
469 |
w->caption_color = _local_player; |
|
470 |
} |
|
471 |
} |
|
472 |
||
473 |
static void DrawRoadDepotWindow(Window *w) |
|
474 |
{ |
|
475 |
uint tile; |
|
476 |
Vehicle *v; |
|
477 |
int num,x,y; |
|
478 |
Depot *d; |
|
479 |
||
480 |
tile = w->window_number; |
|
481 |
||
482 |
/* setup disabled buttons */ |
|
483 |
w->disabled_state = (_map_owner[tile]==_local_player) ? 0 : ((1<<3)|(1<<5)); |
|
484 |
||
485 |
/* determine amount of items for scroller */ |
|
486 |
num = 0; |
|
487 |
FOR_ALL_VEHICLES(v) { |
|
488 |
if (v->type == VEH_Road && v->u.road.state == 254 && |
|
489 |
v->tile == (TileIndex)tile) |
|
490 |
num++; |
|
491 |
} |
|
492 |
SetVScrollCount(w, (num + 4) / 5); |
|
493 |
||
494 |
/* locate the depot struct */ |
|
495 |
for(d=_depots; d->xy != (TileIndex)tile; d++) {} |
|
496 |
||
497 |
SET_DPARAM16(0, d->town_index); |
|
498 |
DrawWindowWidgets(w); |
|
499 |
||
500 |
x = 2; |
|
501 |
y = 15; |
|
502 |
num = w->vscroll.pos * 5; |
|
503 |
||
504 |
FOR_ALL_VEHICLES(v) { |
|
505 |
if (v->type == VEH_Road && |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
506 |
v->u.road.state == 254 && |
0 | 507 |
v->tile == (TileIndex)tile && |
508 |
--num < 0 && num >= -15) { |
|
509 |
||
510 |
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
|
511 |
|
0 | 512 |
SET_DPARAM16(0, v->unitnumber); |
513 |
DrawString(x, y+2, (uint16)(v->max_age-366) >= v->age ? STR_00E2 : STR_00E3, 0); |
|
514 |
||
515 |
DrawSprite( (v->vehstatus & VS_STOPPED) ? 0xC12 : 0xC13, x + 16, y); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
516 |
|
0 | 517 |
if ((x+=56) == 2+56*5) { |
518 |
x = 2; |
|
519 |
y += 14; |
|
520 |
} |
|
521 |
} |
|
522 |
} |
|
523 |
} |
|
524 |
||
525 |
static int GetVehicleFromRoadDepotWndPt(Window *w, int x, int y, Vehicle **veh) |
|
526 |
{ |
|
527 |
uint xt,yt,xm; |
|
528 |
TileIndex tile; |
|
529 |
Vehicle *v; |
|
530 |
int pos; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
531 |
|
0 | 532 |
xt = x / 56; |
533 |
xm = x % 56; |
|
534 |
if (xt >= 5) |
|
535 |
return 1; |
|
536 |
||
537 |
yt = (y - 14) / 14; |
|
538 |
if (yt >= 3) |
|
539 |
return 1; |
|
540 |
||
541 |
pos = (yt + w->vscroll.pos) * 5 + xt; |
|
542 |
||
543 |
tile = w->window_number; |
|
544 |
FOR_ALL_VEHICLES(v) { |
|
545 |
if (v->type == VEH_Road && |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
546 |
v->u.road.state == 254 && |
0 | 547 |
v->tile == (TileIndex)tile && |
548 |
--pos < 0) { |
|
549 |
*veh = v; |
|
550 |
if (xm >= 24) |
|
551 |
return 0; |
|
552 |
||
553 |
if (xm <= 16) |
|
554 |
return -1; /* show window */ |
|
555 |
||
556 |
return -2; /* start stop */ |
|
557 |
} |
|
558 |
} |
|
559 |
||
560 |
return 1; /* outside */ |
|
561 |
} |
|
562 |
||
563 |
static void RoadDepotClickVeh(Window *w, int x, int y) |
|
564 |
{ |
|
565 |
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
|
566 |
int mode; |
0 | 567 |
|
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
|
568 |
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
|
569 |
if (mode > 0) return; |
0 | 570 |
|
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
|
571 |
// 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
|
572 |
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
|
573 |
|
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
|
574 |
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
|
575 |
case 0: // start dragging of vehicle |
0 | 576 |
if (v != NULL) { |
577 |
WP(w,traindepot_d).sel = v->index; |
|
578 |
SetWindowDirty(w); |
|
579 |
SetObjectToPlaceWnd( SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)) + GetRoadVehImage(v, 6), 4, w); |
|
580 |
} |
|
581 |
break; |
|
582 |
||
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
|
583 |
case -1: // show info window |
0 | 584 |
ShowRoadVehViewWindow(v); |
585 |
break; |
|
586 |
||
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
|
587 |
case -2: // click start/stop flag |
0 | 588 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_ROADVEH | CMD_MSG(STR_9015_CAN_T_STOP_START_ROAD_VEHICLE)); |
589 |
break; |
|
590 |
||
591 |
default: |
|
592 |
NOT_REACHED(); |
|
593 |
} |
|
594 |
} |
|
595 |
||
596 |
static void RoadDepotWndProc(Window *w, WindowEvent *e) |
|
597 |
{ |
|
598 |
switch(e->event) { |
|
599 |
case WE_PAINT: |
|
600 |
DrawRoadDepotWindow(w); |
|
601 |
break; |
|
602 |
||
603 |
case WE_CLICK: { |
|
604 |
switch(e->click.widget) { |
|
605 |
case 2: |
|
606 |
RoadDepotClickVeh(w, e->click.pt.x, e->click.pt.y); |
|
607 |
break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
608 |
|
0 | 609 |
case 5: |
610 |
ShowBuildRoadVehWindow(w->window_number); |
|
611 |
break; |
|
612 |
||
613 |
case 6: /* scroll to tile */ |
|
614 |
ScrollMainWindowToTile(w->window_number); |
|
615 |
break; |
|
616 |
} |
|
617 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
618 |
|
0 | 619 |
case WE_DESTROY: |
620 |
DeleteWindowById(WC_BUILD_VEHICLE, w->window_number); |
|
621 |
break; |
|
622 |
||
623 |
case WE_DRAGDROP: { |
|
624 |
switch(e->click.widget) { |
|
625 |
case 2: { |
|
626 |
Vehicle *v; |
|
627 |
VehicleID sel = WP(w,traindepot_d).sel; |
|
628 |
||
629 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
630 |
SetWindowDirty(w); |
|
631 |
||
632 |
if (GetVehicleFromRoadDepotWndPt(w, e->dragdrop.pt.x, e->dragdrop.pt.y, &v) == 0 && |
|
633 |
v != NULL && |
|
634 |
sel == v->index) { |
|
635 |
ShowRoadVehViewWindow(v); |
|
636 |
} |
|
637 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
638 |
|
0 | 639 |
case 3: |
640 |
if (!HASBIT(w->disabled_state, 3) && |
|
641 |
WP(w,traindepot_d).sel != INVALID_VEHICLE) { |
|
642 |
Vehicle *v; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
643 |
|
0 | 644 |
HandleButtonClick(w, 3); |
645 |
||
646 |
v = &_vehicles[WP(w,traindepot_d).sel]; |
|
647 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
648 |
||
649 |
_backup_orders_tile = v->tile; |
|
650 |
BackupVehicleOrders(v, _backup_orders_data); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
651 |
|
0 | 652 |
if (!DoCommandP(v->tile, v->index, 0, NULL, CMD_SELL_ROAD_VEH | CMD_MSG(STR_9014_CAN_T_SELL_ROAD_VEHICLE))) |
653 |
_backup_orders_tile = 0; |
|
654 |
} |
|
655 |
break; |
|
656 |
default: |
|
657 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
658 |
SetWindowDirty(w); |
|
659 |
} |
|
660 |
break; |
|
661 |
} |
|
662 |
break; |
|
663 |
||
664 |
} |
|
665 |
||
666 |
} |
|
667 |
||
668 |
static const Widget _road_depot_widgets[] = { |
|
669 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
|
670 |
{ WWT_CAPTION, 14, 11, 314, 0, 13, STR_9003_ROAD_VEHICLE_DEPOT, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
|
671 |
{ WWT_MATRIX, 14, 0, 279, 14, 55, 0x305, STR_9022_VEHICLES_CLICK_ON_VEHICLE}, |
|
672 |
{ WWT_IMGBTN, 14, 280, 303, 14, 55, 0x2A9, STR_9024_DRAG_ROAD_VEHICLE_TO_HERE}, |
|
673 |
{ WWT_SCROLLBAR, 14, 304, 314, 14, 55, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
|
674 |
{ WWT_PUSHTXTBTN, 14, 0, 156, 56, 67, STR_9004_NEW_VEHICLES, STR_9023_BUILD_NEW_ROAD_VEHICLE}, |
|
675 |
{ WWT_PUSHTXTBTN, 14, 157, 314, 56, 67, STR_00E4_LOCATION, STR_9025_CENTER_MAIN_VIEW_ON_ROAD}, |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
676 |
{ WIDGETS_END}, |
0 | 677 |
}; |
678 |
||
679 |
static const WindowDesc _road_depot_desc = { |
|
680 |
-1, -1, 315, 68, |
|
681 |
WC_VEHICLE_DEPOT,0, |
|
682 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
683 |
_road_depot_widgets, |
|
684 |
RoadDepotWndProc |
|
685 |
}; |
|
686 |
||
687 |
void ShowRoadDepotWindow(uint tile) |
|
688 |
{ |
|
689 |
Window *w; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
690 |
|
0 | 691 |
w = AllocateWindowDescFront(&_road_depot_desc, tile); |
692 |
if (w) { |
|
693 |
w->caption_color = _map_owner[w->window_number]; |
|
694 |
w->vscroll.cap = 3; |
|
695 |
WP(w,traindepot_d).sel = -1; |
|
696 |
_backup_orders_tile = 0; |
|
697 |
} |
|
698 |
} |
|
699 |
||
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
|
700 |
// used to get a sorted list of the vehicles |
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
|
701 |
static SortStruct _road_sort[NUM_NORMAL_VEHICLES]; |
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
|
702 |
static uint16 _num_road_sort[MAX_PLAYERS]; |
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
|
703 |
|
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
704 |
static void GlobalSortRoadVehList() |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
705 |
{ |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
706 |
const Vehicle *v; |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
707 |
uint16 *i; |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
708 |
uint32 n = 0; |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
709 |
|
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
710 |
// reset #-of roadvehicles to 0 because ++ is used for value-assignment |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
711 |
for (i = _num_road_sort; i != endof(_num_road_sort); i++) {*i = 0;} |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
712 |
|
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
713 |
FOR_ALL_VEHICLES(v) { |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
714 |
if(v->type == VEH_Road) { |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
715 |
_road_sort[n].index = v->index; |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
716 |
_road_sort[n++].owner = v->owner; |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
717 |
_num_road_sort[v->owner]++; // add number of roadvehicless of player |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
718 |
} |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
719 |
} |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
720 |
|
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
721 |
// create cumulative roadvehicle-ownership |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
722 |
// roads are stored as a cummulative index, eg 25, 41, 43. This means |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
723 |
// Player0: 25; Player1: (41-25) 16; Player2: (43-41) 2 |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
724 |
for (i = &_num_road_sort[1]; i != endof(_num_road_sort); i++) {*i += *(i-1);} |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
725 |
|
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
726 |
qsort(_road_sort, n, sizeof(_road_sort[0]), GeneralOwnerSorter); // sort by owner |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
727 |
|
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
728 |
// since indexes are messed up after adding/removing a station, mark all lists dirty |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
729 |
memset(_road_sort_dirty, true, sizeof(_road_sort_dirty)); |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
730 |
_vehicle_sort_dirty[VEHROAD] = false; |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
731 |
|
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
732 |
DEBUG(misc, 1) ("Resorting global roadvehicles list..."); |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
733 |
} |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
734 |
|
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
735 |
static void MakeSortedRoadVehList(byte 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
|
736 |
{ |
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
|
737 |
SortStruct *firstelement; |
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
|
738 |
uint32 n = 0; |
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
|
739 |
|
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
|
740 |
if (owner == 0) { // first element starts at 0th element and has n elements as described above |
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
|
741 |
firstelement = &_road_sort[0]; |
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
|
742 |
n = _num_road_sort[0]; |
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
|
743 |
} else { // nth element starts at the end of the previous one, and has n elements as described above |
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
|
744 |
firstelement = &_road_sort[_num_road_sort[owner-1]]; |
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
|
745 |
n = _num_road_sort[owner] - _num_road_sort[owner-1]; |
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
|
746 |
} |
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
|
747 |
|
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
|
748 |
_internal_sort_order = _road_sort_order[owner]; |
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
|
749 |
_internal_name_sorter_id = STR_SV_ROADVEH_NAME; |
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
750 |
_last_vehicle_idx = 0; // used for "cache" in namesorting |
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
751 |
qsort(firstelement, n, sizeof(_road_sort[0]), _vehicle_sorter[_road_sort_type[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
|
752 |
|
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
753 |
_road_sort_dirty[owner] = false; |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
754 |
|
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
|
755 |
DEBUG(misc, 1) ("Resorting Roadvehicles list player %d...", owner+1); |
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
|
756 |
} |
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
|
757 |
|
0 | 758 |
static void PlayerRoadVehWndProc(Window *w, WindowEvent *e) |
759 |
{ |
|
760 |
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
|
761 |
case WE_PAINT: { |
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
|
762 |
uint32 i; |
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
|
763 |
const byte window_number = (byte)w->window_number; |
0 | 764 |
|
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
|
765 |
if (_road_sort_type[window_number] == SORT_BY_UNSORTED) // disable 'Sort By' tooltip on Unsorted sorting criteria |
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
766 |
w->disabled_state |= (1 << 2); |
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
|
767 |
|
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
768 |
// resort roadvehicles window if roadvehicles have been added/removed |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
769 |
if (_vehicle_sort_dirty[VEHROAD]) |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
770 |
GlobalSortRoadVehList(); |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
771 |
|
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
772 |
if (_road_sort_dirty[window_number]) { |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
773 |
MakeSortedRoadVehList(window_number); |
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
|
774 |
/* reset sorting timeout */ |
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
|
775 |
w->custom[0] = DAY_TICKS; |
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
|
776 |
w->custom[1] = PERIODIC_RESORT_DAYS; |
0 | 777 |
} |
778 |
||
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
|
779 |
// roads are stored as a cummulative index, eg 25, 41, 43. This means |
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
|
780 |
// Player0: 25; Player1: (41-25) 16; Player2: (43-41) 2 roads |
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
|
781 |
i = (window_number == 0) ? 0 : _num_road_sort[window_number-1]; |
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
|
782 |
SetVScrollCount(w, _num_road_sort[window_number] - i); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
783 |
|
0 | 784 |
/* draw the widgets */ |
785 |
{ |
|
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
|
786 |
Player *p = DEREF_PLAYER(window_number); |
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
|
787 |
/* Company Name -- (###) Roadvehicles */ |
0 | 788 |
SET_DPARAM16(0, p->name_1); |
789 |
SET_DPARAM32(1, p->name_2); |
|
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
|
790 |
SET_DPARAM16(2, w->vscroll.count); |
0 | 791 |
DrawWindowWidgets(w); |
792 |
} |
|
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
793 |
/* draw sorting criteria string */ |
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
794 |
DrawString(85, 15, _vehicle_sort_listing[_road_sort_type[window_number]], 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
|
795 |
/* draw arrow pointing up/down for ascending/descending soring */ |
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
796 |
DoDrawString(_road_sort_order[window_number] & 1 ? "\xAA" : "\xA0", 69, 15, 0x10); |
0 | 797 |
|
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
|
798 |
/* draw the roadvehicles */ |
0 | 799 |
{ |
800 |
Vehicle *v; |
|
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
|
801 |
int n = 0; |
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
|
802 |
const int x = 2; // offset from left side of widget |
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
|
803 |
int y = PLY_WND_PRC__OFFSET_TOP_WIDGET; // offset from top of widget |
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
|
804 |
i += w->vscroll.pos; // offset from sorted roads list of current player |
0 | 805 |
|
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
|
806 |
while (i < _num_road_sort[window_number]) { |
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
|
807 |
StringID str; |
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
|
808 |
v = DEREF_VEHICLE(_road_sort[i].index); |
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
|
809 |
|
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
|
810 |
assert(v->type == VEH_Road && v->owner == window_number); |
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
168
diff
changeset
|
811 |
|
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
|
812 |
DrawRoadVehImage(v, x + 22, y + 6, INVALID_VEHICLE); |
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
|
813 |
DrawVehicleProfitButton(v, x, y+13); |
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
|
814 |
|
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
|
815 |
SET_DPARAM16(0, v->unitnumber); |
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
|
816 |
if (IsRoadDepotTile(v->tile)) { |
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
|
817 |
str = STR_021F; |
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
|
818 |
} else { |
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
|
819 |
str = v->age > v->max_age - 366 ? STR_00E3 : STR_00E2; |
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
|
820 |
} |
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
|
821 |
DrawString(x, y+2, str, 0); |
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
|
822 |
|
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
|
823 |
SET_DPARAM32(0, v->profit_this_year); |
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
|
824 |
SET_DPARAM32(1, v->profit_last_year); |
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
|
825 |
DrawString(x + 24, y + 18, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 0); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
826 |
|
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
|
827 |
if (v->string_id != STR_SV_ROADVEH_NAME) { |
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
|
828 |
SET_DPARAM16(0, v->string_id); |
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
|
829 |
DrawString(x+24, y, STR_01AB, 0); |
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
|
830 |
} |
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
|
831 |
|
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
|
832 |
y += PLY_WND_PRC__SIZE_OF_ROW_SMALL; |
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
|
833 |
i++; // next road |
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
|
834 |
if (++n == w->vscroll.cap) { break;} // max number of roads in the window |
0 | 835 |
} |
836 |
} |
|
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
|
837 |
} break; |
0 | 838 |
|
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
|
839 |
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
|
840 |
switch(e->click.widget) { |
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
841 |
case 2: /* Flip sorting method ascending/descending */ |
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
|
842 |
_road_sort_order[(byte)w->window_number] ^= 1; |
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
|
843 |
_road_sort_dirty[(byte)w->window_number] = true; |
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
|
844 |
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
|
845 |
break; |
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
846 |
case 3: case 4:/* Select sorting criteria dropdown menu */ |
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
847 |
ShowDropDownMenu(w, _vehicle_sort_listing, _road_sort_type[(byte)w->window_number], 4, 0); // do it for widget 4 |
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
|
848 |
return; |
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
|
849 |
case 6: { /* 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
|
850 |
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
|
851 |
|
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
|
852 |
if (id_v >= w->vscroll.cap) { return;} // click out of bounds |
0 | 853 |
|
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
|
854 |
id_v += w->vscroll.pos; |
0 | 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 |
{ |
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
|
857 |
const byte owner = (byte)w->window_number; |
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
|
858 |
Vehicle *v; |
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
|
859 |
id_v += (owner == 0) ? 0 : _num_road_sort[owner - 1]; // first element in list |
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
|
860 |
|
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
|
861 |
if (id_v >= _num_road_sort[owner]) { return;} // click out of vehicle 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
|
862 |
|
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
|
863 |
v = DEREF_VEHICLE(_road_sort[id_v].index); // add the offset id_x to that |
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
|
864 |
|
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
|
865 |
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
|
866 |
|
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
|
867 |
ShowRoadVehViewWindow(v); |
0 | 868 |
} |
869 |
} break; |
|
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 |
case 8: { /* Build new Vehicle */ |
0 | 872 |
uint tile; |
873 |
||
874 |
tile = _last_built_road_depot_tile; |
|
875 |
do { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
876 |
if (_map_owner[tile] == _local_player && IsRoadDepotTile(tile)) { |
0 | 877 |
ShowRoadDepotWindow(tile); |
878 |
ShowBuildRoadVehWindow(tile); |
|
879 |
return; |
|
880 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
881 |
|
0 | 882 |
tile = TILE_MASK(tile + 1); |
883 |
} 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
|
884 |
|
0 | 885 |
ShowBuildRoadVehWindow(0); |
886 |
} break; |
|
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
|
887 |
} |
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
|
888 |
} 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
|
889 |
|
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
|
890 |
case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */ |
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
|
891 |
if (_road_sort_type[(byte)w->window_number] != e->dropdown.index) // if value hasn't changed, dont resort list |
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
|
892 |
_road_sort_dirty[(byte)w->window_number] = true; |
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
|
893 |
|
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
|
894 |
_road_sort_type[(byte)w->window_number] = e->dropdown.index; |
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
|
895 |
|
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
|
896 |
if (_road_sort_type[(byte)w->window_number] != SORT_BY_UNSORTED) // enable 'Sort By' if a sorter criteria is chosen |
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
897 |
w->disabled_state &= ~(1 << 2); |
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
|
898 |
|
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
|
899 |
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
|
900 |
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
|
901 |
case WE_CREATE: /* set up resort timer */ |
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
|
902 |
w->custom[0] = DAY_TICKS; |
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
|
903 |
w->custom[1] = PERIODIC_RESORT_DAYS; |
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
|
904 |
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
|
905 |
case WE_TICK: /* resort the list every 20 seconds orso (10 days) */ |
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
|
906 |
if (--w->custom[0] == 0) { |
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
|
907 |
w->custom[0] = DAY_TICKS; |
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
|
908 |
if (--w->custom[1] == 0) { |
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
|
909 |
w->custom[1] = PERIODIC_RESORT_DAYS; |
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
|
910 |
_road_sort_dirty[(byte)w->window_number] = true; |
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
|
911 |
DEBUG(misc, 1) ("Periodic resort Roadvehicles list player %d...", w->window_number+1); |
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
|
912 |
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
|
913 |
} |
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
|
914 |
} |
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 |
break; |
0 | 916 |
} |
917 |
} |
|
918 |
||
919 |
static const Widget _player_roadveh_widgets[] = { |
|
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 |
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
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
|
921 |
{ WWT_CAPTION, 14, 11, 259, 0, 13, STR_9001_ROAD_VEHICLES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
922 |
{ WWT_PUSHTXTBTN, 14, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_TIP}, |
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
923 |
{ WWT_PANEL, 14, 81, 237, 14, 25, 0x0, STR_SORT_TIP}, |
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
924 |
{ WWT_CLOSEBOX, 14, 238, 248, 14, 25, STR_0225, STR_SORT_TIP}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
925 |
{ WWT_PANEL, 14, 249, 259, 14, 25, 0x0, STR_NULL}, |
339
f378769765a6
(svn r515) -Fix: [1050993] Incorrect Tooltip in Road Vehicle List. Already fixed in /map branch
darkvater
parents:
243
diff
changeset
|
926 |
{ WWT_MATRIX, 14, 0, 248, 26, 207, 0x701, STR_901A_ROAD_VEHICLES_CLICK_ON}, |
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
|
927 |
{ WWT_SCROLLBAR, 14, 249, 259, 26, 207, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
339
f378769765a6
(svn r515) -Fix: [1050993] Incorrect Tooltip in Road Vehicle List. Already fixed in /map branch
darkvater
parents:
243
diff
changeset
|
928 |
/* only for our road list, a 'Build Vehicle' button that opens the depot of the last built depot */ |
f378769765a6
(svn r515) -Fix: [1050993] Incorrect Tooltip in Road Vehicle List. Already fixed in /map branch
darkvater
parents:
243
diff
changeset
|
929 |
{ WWT_PUSHTXTBTN, 14, 0, 129, 208, 219, STR_8815_NEW_VEHICLES, STR_901B_BUILD_NEW_ROAD_VEHICLES}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
930 |
{ WWT_PANEL, 14, 130, 259, 208, 219, 0x0, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
931 |
{ WIDGETS_END}, |
0 | 932 |
}; |
933 |
||
934 |
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
|
935 |
-1, -1, 260, 220, |
0 | 936 |
WC_ROADVEH_LIST,0, |
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
937 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
0 | 938 |
_player_roadveh_widgets, |
939 |
PlayerRoadVehWndProc |
|
940 |
}; |
|
941 |
||
942 |
static const Widget _other_player_roadveh_widgets[] = { |
|
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
|
943 |
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
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 |
{ WWT_CAPTION, 14, 11, 259, 0, 13, STR_9001_ROAD_VEHICLES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
945 |
{ WWT_PUSHTXTBTN, 14, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_TIP}, |
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
946 |
{ WWT_PANEL, 14, 81, 237, 14, 25, 0x0, STR_SORT_TIP}, |
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
947 |
{ WWT_CLOSEBOX, 14, 238, 248, 14, 25, STR_0225, STR_SORT_TIP}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
948 |
{ WWT_PANEL, 14, 249, 259, 14, 25, 0x0, STR_NULL}, |
339
f378769765a6
(svn r515) -Fix: [1050993] Incorrect Tooltip in Road Vehicle List. Already fixed in /map branch
darkvater
parents:
243
diff
changeset
|
949 |
{ WWT_MATRIX, 14, 0, 248, 26, 207, 0x701, STR_901A_ROAD_VEHICLES_CLICK_ON}, |
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
|
950 |
{ WWT_SCROLLBAR, 14, 249, 259, 26, 207, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
951 |
{ WIDGETS_END}, |
0 | 952 |
}; |
953 |
||
954 |
static const WindowDesc _other_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
|
955 |
-1, -1, 260, 208, |
0 | 956 |
WC_ROADVEH_LIST,0, |
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
957 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
0 | 958 |
_other_player_roadveh_widgets, |
959 |
PlayerRoadVehWndProc |
|
960 |
}; |
|
961 |
||
962 |
||
963 |
void ShowPlayerRoadVehicles(int player) |
|
964 |
{ |
|
965 |
Window *w; |
|
966 |
||
967 |
if ( player == _local_player) { |
|
968 |
w = AllocateWindowDescFront(&_player_roadveh_desc, player); |
|
969 |
} else { |
|
970 |
w = AllocateWindowDescFront(&_other_player_roadveh_desc, player); |
|
971 |
} |
|
972 |
if (w) { |
|
973 |
w->caption_color = player; |
|
974 |
w->vscroll.cap = 7; |
|
975 |
} |
|
976 |
} |