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