author | darkvater |
Sun, 23 Jan 2005 21:24:33 +0000 | |
changeset 1125 | 34615a848111 |
parent 982 | be834034b331 |
child 1151 | 614cbcb5b9fe |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
2 |
#include "ttd.h" |
|
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
374
diff
changeset
|
3 |
#include "table/strings.h" |
679
e959706a3e4d
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
671
diff
changeset
|
4 |
#include "map.h" |
0 | 5 |
#include "window.h" |
6 |
#include "gui.h" |
|
7 |
#include "gfx.h" |
|
8 |
#include "vehicle.h" |
|
9 |
#include "viewport.h" |
|
10 |
#include "station.h" |
|
11 |
#include "command.h" |
|
12 |
#include "player.h" |
|
13 |
#include "engine.h" |
|
14 |
||
842 | 15 |
void Set_DPARAM_Road_Veh_Build_Window(uint16 engine_number) |
16 |
{ |
|
17 |
const RoadVehicleInfo *rvi = RoadVehInfo(engine_number); |
|
18 |
Engine *e; |
|
19 |
YearMonthDay ymd; |
|
20 |
||
21 |
SetDParam(0, rvi->base_cost * (_price.roadveh_base>>3)>>5); |
|
22 |
SetDParam(1, rvi->max_speed * 10 >> 5); |
|
23 |
SetDParam(2, rvi->running_cost * _price.roadveh_running >> 8); |
|
24 |
SetDParam(4, rvi->capacity); |
|
25 |
SetDParam(3, _cargoc.names_long_p[rvi->cargo_type]); |
|
26 |
||
27 |
e = &_engines[engine_number]; |
|
28 |
SetDParam(6, e->lifelength); |
|
29 |
SetDParam(7, e->reliability * 100 >> 16); |
|
30 |
ConvertDayToYMD(&ymd, e->intro_date); |
|
31 |
SetDParam(5, ymd.year + 1920); |
|
32 |
} |
|
33 |
||
0 | 34 |
static void DrawRoadVehImage(Vehicle *v, int x, int y, VehicleID selection) |
35 |
{ |
|
36 |
int image = GetRoadVehImage(v, 6); |
|
37 |
uint32 ormod = SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)); |
|
38 |
if (v->vehstatus & VS_CRASHED) ormod = 0x3248000; |
|
39 |
DrawSprite(image | ormod, x+14, y+6); |
|
40 |
||
41 |
if (v->index == selection) { |
|
42 |
DrawFrameRect(x-1, y-1, x+28, y+12, 15, 0x10); |
|
43 |
} |
|
44 |
} |
|
45 |
||
46 |
static void RoadVehDetailsWndProc(Window *w, WindowEvent *e) |
|
47 |
{ |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
48 |
Vehicle *v = GetVehicle(w->window_number); |
0 | 49 |
StringID str; |
50 |
int mod; |
|
51 |
||
52 |
switch(e->event) { |
|
53 |
case WE_PAINT: |
|
54 |
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
|
55 |
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
|
56 |
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
|
57 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
58 |
SetDParam(0, v->string_id); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
59 |
SetDParam(1, v->unitnumber); |
0 | 60 |
DrawWindowWidgets(w); |
61 |
||
62 |
/* Draw running cost */ |
|
63 |
{ |
|
64 |
int year = v->age / 366; |
|
65 |
StringID str; |
|
66 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
67 |
SetDParam(1, year); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
68 |
|
0 | 69 |
str = STR_0199_YEAR; |
70 |
if (year != 1) { |
|
71 |
str++; |
|
72 |
if (v->max_age - 366 < v->age) |
|
73 |
str++; |
|
74 |
} |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
75 |
SetDParam(0, str); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
76 |
SetDParam(2, v->max_age / 366); |
538
5dd99f3b7eca
(svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents:
534
diff
changeset
|
77 |
SetDParam(3, RoadVehInfo(v->engine_type)->running_cost * _price.roadveh_running >> 8); |
0 | 78 |
DrawString(2, 15, STR_900D_AGE_RUNNING_COST_YR, 0); |
79 |
} |
|
80 |
||
81 |
/* Draw max speed */ |
|
82 |
{ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
83 |
SetDParam(0, v->max_speed * 10 >> 5); |
0 | 84 |
DrawString(2, 25, STR_900E_MAX_SPEED, 0); |
85 |
} |
|
86 |
||
87 |
/* Draw profit */ |
|
88 |
{ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
89 |
SetDParam(0, v->profit_this_year); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
90 |
SetDParam(1, v->profit_last_year); |
0 | 91 |
DrawString(2, 35, STR_900F_PROFIT_THIS_YEAR_LAST_YEAR, 0); |
92 |
} |
|
93 |
||
94 |
/* Draw breakdown & reliability */ |
|
95 |
{ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
96 |
SetDParam(0, v->reliability * 100 >> 16); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
97 |
SetDParam(1, v->breakdowns_since_last_service); |
0 | 98 |
DrawString(2, 45, STR_9010_RELIABILITY_BREAKDOWNS, 0); |
99 |
} |
|
100 |
||
101 |
/* Draw service interval text */ |
|
102 |
{ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
103 |
SetDParam(0, v->service_interval); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
104 |
SetDParam(1, v->date_of_last_service); |
156
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
10
diff
changeset
|
105 |
DrawString(13, 90, _patches.servint_ispercent?STR_SERVICING_INTERVAL_PERCENT:STR_883C_SERVICING_INTERVAL_DAYS, 0); |
0 | 106 |
} |
107 |
||
108 |
DrawRoadVehImage(v, 3, 57, INVALID_VEHICLE); |
|
109 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
110 |
SetDParam(0, GetCustomEngineName(v->engine_type)); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
111 |
SetDParam(1, 1920 + v->build_year); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
112 |
SetDParam(2, v->value); |
0 | 113 |
DrawString(34, 57, STR_9011_BUILT_VALUE, 0); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
114 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
115 |
SetDParam(0, _cargoc.names_long_p[v->cargo_type]); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
116 |
SetDParam(1, v->cargo_cap); |
0 | 117 |
DrawString(34, 67, STR_9012_CAPACITY, 0); |
118 |
||
119 |
str = STR_8812_EMPTY; |
|
120 |
if (v->cargo_count != 0) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
121 |
SetDParam(0, v->cargo_type); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
122 |
SetDParam(1, v->cargo_count); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
123 |
SetDParam(2, v->cargo_source); |
0 | 124 |
str = STR_8813_FROM; |
125 |
} |
|
126 |
DrawString(34, 78, str, 0); |
|
127 |
break; |
|
128 |
||
129 |
case WE_CLICK: |
|
130 |
switch(e->click.widget) { |
|
131 |
case 2: /* rename */ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
132 |
SetDParam(0, v->unitnumber); |
0 | 133 |
ShowQueryString(v->string_id, STR_902C_NAME_ROAD_VEHICLE, 31, 150, w->window_class, w->window_number); |
134 |
break; |
|
135 |
||
136 |
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
|
137 |
mod = _ctrl_pressed? 5 : 10; |
0 | 138 |
goto change_int; |
139 |
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
|
140 |
mod = _ctrl_pressed? -5 : -10; |
0 | 141 |
change_int: |
142 |
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
|
143 |
|
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
|
144 |
/* %-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
|
145 |
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
|
146 |
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
|
147 |
if (mod == v->service_interval) |
0 | 148 |
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
|
149 |
|
0 | 150 |
DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_ROADVEH_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING)); |
151 |
break; |
|
152 |
} |
|
153 |
break; |
|
154 |
||
155 |
case WE_4: |
|
156 |
if (FindWindowById(WC_VEHICLE_VIEW, w->window_number) == NULL) |
|
157 |
DeleteWindow(w); |
|
158 |
break; |
|
159 |
||
160 |
case WE_ON_EDIT_TEXT: { |
|
161 |
byte *b = e->edittext.str; |
|
162 |
if (*b == 0) |
|
163 |
return; |
|
164 |
memcpy(_decode_parameters, b, 32); |
|
165 |
DoCommandP(0, w->window_number, 0, NULL, CMD_NAME_VEHICLE | CMD_MSG(STR_902D_CAN_T_NAME_ROAD_VEHICLE)); |
|
166 |
} break; |
|
167 |
||
168 |
} |
|
169 |
} |
|
170 |
||
171 |
static const Widget _roadveh_details_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
172 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
173 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 339, 0, 13, STR_900C_DETAILS,STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
174 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 340, 379, 0, 13, STR_01AA_NAME, STR_902E_NAME_ROAD_VEHICLE}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
175 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 379, 14, 55, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
176 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 379, 56, 88, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
177 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 10, 89, 94, STR_0188, STR_884D_INCREASE_SERVICING_INTERVAL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
178 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 10, 95, 100, STR_0189, STR_884E_DECREASE_SERVICING_INTERVAL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
179 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 11, 379, 89, 100, 0x0, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
180 |
{ WIDGETS_END}, |
0 | 181 |
}; |
182 |
||
183 |
static const WindowDesc _roadveh_details_desc = { |
|
184 |
-1,-1, 380, 101, |
|
185 |
WC_VEHICLE_DETAILS,WC_VEHICLE_VIEW, |
|
186 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
187 |
_roadveh_details_widgets, |
|
188 |
RoadVehDetailsWndProc |
|
189 |
}; |
|
190 |
||
191 |
static void ShowRoadVehDetailsWindow(Vehicle *v) |
|
192 |
{ |
|
193 |
Window *w; |
|
194 |
VehicleID veh = v->index; |
|
195 |
DeleteWindowById(WC_VEHICLE_ORDERS, veh); |
|
196 |
DeleteWindowById(WC_VEHICLE_DETAILS, veh); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
197 |
_alloc_wnd_parent_num = veh; |
0 | 198 |
w = AllocateWindowDesc(&_roadveh_details_desc); |
199 |
w->window_number = veh; |
|
200 |
w->caption_color = v->owner; |
|
201 |
} |
|
202 |
||
203 |
static void RoadVehViewWndProc(Window *w, WindowEvent *e) |
|
204 |
{ |
|
205 |
switch(e->event) { |
|
206 |
case WE_PAINT: { |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
207 |
Vehicle *v = GetVehicle(w->window_number); |
0 | 208 |
StringID str; |
209 |
||
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
210 |
w->disabled_state = (v->owner != _local_player) ? (1<<8 | 1<<7) : 0; |
0 | 211 |
|
212 |
/* draw widgets & caption */ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
213 |
SetDParam(0, v->string_id); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
214 |
SetDParam(1, v->unitnumber); |
0 | 215 |
DrawWindowWidgets(w); |
216 |
||
217 |
/* draw the flag */ |
|
218 |
DrawSprite((v->vehstatus & VS_STOPPED) ? 0xC12 : 0xC13, 2, 105); |
|
219 |
||
220 |
if (v->u.road.crashed_ctr != 0) { |
|
221 |
str = STR_8863_CRASHED; |
|
222 |
} else if (v->breakdown_ctr == 1) { |
|
223 |
str = STR_885C_BROKEN_DOWN; |
|
224 |
} else if (v->vehstatus & VS_STOPPED) { |
|
225 |
str = STR_8861_STOPPED; |
|
226 |
} else { |
|
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
227 |
switch (v->current_order.type) { |
0 | 228 |
case OT_GOTO_STATION: { |
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
229 |
SetDParam(0, v->current_order.station); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
230 |
SetDParam(1, v->cur_speed * 10 >> 5); |
0 | 231 |
str = STR_HEADING_FOR_STATION + _patches.vehicle_speed; |
232 |
} break; |
|
233 |
||
234 |
case OT_GOTO_DEPOT: { |
|
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
235 |
Depot *dep = &_depots[v->current_order.station]; |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
236 |
SetDParam(0, dep->town_index); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
237 |
SetDParam(1, v->cur_speed * 10 >> 5); |
0 | 238 |
str = STR_HEADING_FOR_ROAD_DEPOT + _patches.vehicle_speed; |
239 |
} break; |
|
240 |
||
241 |
case OT_LOADING: |
|
242 |
case OT_LEAVESTATION: |
|
243 |
str = STR_882F_LOADING_UNLOADING; |
|
244 |
break; |
|
245 |
||
246 |
default: |
|
247 |
if (v->num_orders == 0) { |
|
248 |
str = STR_NO_ORDERS + _patches.vehicle_speed; |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
249 |
SetDParam(0, v->cur_speed * 10 >> 5); |
0 | 250 |
} else |
251 |
str = STR_EMPTY; |
|
252 |
break; |
|
253 |
} |
|
254 |
} |
|
255 |
||
256 |
DrawStringCentered(125, 105, str, 0); |
|
257 |
DrawWindowViewport(w); |
|
258 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
259 |
|
0 | 260 |
case WE_CLICK: { |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
261 |
Vehicle *v = GetVehicle(w->window_number); |
0 | 262 |
|
263 |
switch(e->click.widget) { |
|
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
264 |
case 5: /* start stop */ |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
265 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_ROADVEH | CMD_MSG(STR_9015_CAN_T_STOP_START_ROAD_VEHICLE)); |
0 | 266 |
break; |
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
267 |
case 6: /* center main view */ |
0 | 268 |
ScrollMainWindowTo(v->x_pos, v->y_pos); |
269 |
break; |
|
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
270 |
case 7: /* goto hangar */ |
0 | 271 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_SEND_ROADVEH_TO_DEPOT | CMD_MSG(STR_9018_CAN_T_SEND_VEHICLE_TO_DEPOT)); |
272 |
break; |
|
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
273 |
case 8: /* turn around */ |
0 | 274 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_TURN_ROADVEH | CMD_MSG(STR_9033_CAN_T_MAKE_VEHICLE_TURN)); |
275 |
break; |
|
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
276 |
case 9: /* show orders */ |
0 | 277 |
ShowOrdersWindow(v); |
278 |
break; |
|
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
279 |
case 10: /* show details */ |
0 | 280 |
ShowRoadVehDetailsWindow(v); |
281 |
break; |
|
282 |
} |
|
283 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
284 |
|
0 | 285 |
case WE_DESTROY: |
286 |
DeleteWindowById(WC_VEHICLE_ORDERS, w->window_number); |
|
287 |
DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
288 |
break; |
0 | 289 |
} |
290 |
} |
|
291 |
||
292 |
static const Widget _roadveh_view_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
293 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
294 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 237, 0, 13, STR_9002, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
295 |
{ WWT_STICKYBOX, RESIZE_NONE, 14, 238, 249, 0, 13, 0x0, STR_STICKY_BUTTON}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
296 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 231, 14, 103, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
297 |
{ WWT_6, RESIZE_NONE, 14, 2, 229, 16, 101, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
298 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 0, 249, 104, 115, 0x0, STR_901C_CURRENT_VEHICLE_ACTION}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
299 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 232, 249, 14, 31, 0x2AB, STR_901E_CENTER_MAIN_VIEW_ON_VEHICLE}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
300 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 232, 249, 32, 49, 0x2AE, STR_901F_SEND_VEHICLE_TO_DEPOT}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
301 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 232, 249, 50, 67, 0x2CB, STR_9020_FORCE_VEHICLE_TO_TURN_AROUND}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
302 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 232, 249, 68, 85, 0x2B2, STR_901D_SHOW_VEHICLE_S_ORDERS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
303 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 232, 249, 86, 103, 0x2B3, STR_9021_SHOW_ROAD_VEHICLE_DETAILS}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
304 |
{ WIDGETS_END}, |
0 | 305 |
}; |
306 |
||
307 |
static const WindowDesc _roadveh_view_desc = { |
|
308 |
-1,-1, 250, 116, |
|
309 |
WC_VEHICLE_VIEW,0, |
|
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
310 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, |
0 | 311 |
_roadveh_view_widgets, |
312 |
RoadVehViewWndProc, |
|
313 |
}; |
|
314 |
||
315 |
void ShowRoadVehViewWindow(Vehicle *v) |
|
316 |
{ |
|
317 |
Window *w; |
|
318 |
||
319 |
w = AllocateWindowDescFront(&_roadveh_view_desc, v->index); |
|
320 |
if (w) { |
|
321 |
w->caption_color = v->owner; |
|
322 |
AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), 0); |
|
323 |
} |
|
324 |
} |
|
325 |
||
326 |
||
327 |
static void DrawNewRoadVehWindow(Window *w) |
|
328 |
{ |
|
329 |
if (w->window_number == 0) |
|
330 |
w->disabled_state = 1 << 5; |
|
331 |
||
332 |
// setup scroller |
|
333 |
{ |
|
334 |
int count = 0; |
|
335 |
int num = NUM_ROAD_ENGINES; |
|
336 |
Engine *e = &_engines[ROAD_ENGINES_INDEX]; |
|
337 |
do { |
|
338 |
if (HASBIT(e->player_avail, _local_player)) |
|
339 |
count++; |
|
340 |
} while (++e,--num); |
|
341 |
SetVScrollCount(w, count); |
|
342 |
} |
|
343 |
||
344 |
DrawWindowWidgets(w); |
|
345 |
||
346 |
{ |
|
347 |
int num = NUM_ROAD_ENGINES; |
|
348 |
Engine *e = &_engines[ROAD_ENGINES_INDEX]; |
|
349 |
int x = 1; |
|
350 |
int y = 15; |
|
351 |
int sel = WP(w,buildtrain_d).sel_index; |
|
352 |
int pos = w->vscroll.pos; |
|
353 |
int engine_id = ROAD_ENGINES_INDEX; |
|
354 |
int selected_id = -1; |
|
355 |
||
356 |
do { |
|
357 |
if (HASBIT(e->player_avail, _local_player)) { |
|
358 |
if (sel==0) selected_id = engine_id; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
359 |
if (IS_INT_INSIDE(--pos, -w->vscroll.cap, 0)) { |
0 | 360 |
DrawString(x+59, y+2, GetCustomEngineName(engine_id), sel==0 ? 0xC : 0x10); |
361 |
DrawRoadVehEngine(x+29, y+6, engine_id, SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player))); |
|
362 |
y += 14; |
|
363 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
364 |
sel--; |
0 | 365 |
} |
366 |
} while (++engine_id, ++e,--num); |
|
367 |
||
368 |
WP(w,buildtrain_d).sel_engine = selected_id; |
|
369 |
if (selected_id != -1) { |
|
842 | 370 |
Set_DPARAM_Road_Veh_Build_Window(selected_id); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
371 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
372 |
DrawString(2, w->widget[4].top + 1, STR_9008_COST_SPEED_RUNNING_COST, 0); |
0 | 373 |
} |
374 |
} |
|
375 |
} |
|
376 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
538
diff
changeset
|
377 |
void CcBuildRoadVeh(bool success, uint tile, uint32 p1, uint32 p2) |
0 | 378 |
{ |
379 |
Vehicle *v; |
|
380 |
||
381 |
if (!success) return; |
|
382 |
||
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
383 |
v = GetVehicle(_new_roadveh_id); |
0 | 384 |
if (v->tile == _backup_orders_tile) { |
385 |
_backup_orders_tile = 0; |
|
386 |
RestoreVehicleOrders(v, _backup_orders_data); |
|
387 |
} |
|
388 |
ShowRoadVehViewWindow(v); |
|
389 |
} |
|
390 |
||
391 |
static void NewRoadVehWndProc(Window *w, WindowEvent *e) |
|
392 |
{ |
|
393 |
switch(e->event) { |
|
394 |
case WE_PAINT: |
|
395 |
DrawNewRoadVehWindow(w); |
|
396 |
break; |
|
397 |
||
398 |
case WE_CLICK: |
|
399 |
switch(e->click.widget) { |
|
400 |
case 2: { /* listbox */ |
|
401 |
uint i = (e->click.pt.y - 14) / 14; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
402 |
if (i < w->vscroll.cap) { |
0 | 403 |
WP(w,buildtrain_d).sel_index = i + w->vscroll.pos; |
404 |
SetWindowDirty(w); |
|
405 |
} |
|
406 |
} break; |
|
407 |
||
408 |
case 5: { /* build */ |
|
409 |
int sel_eng = WP(w,buildtrain_d).sel_engine; |
|
410 |
if (sel_eng != -1) |
|
411 |
DoCommandP(w->window_number, sel_eng, 0, CcBuildRoadVeh, CMD_BUILD_ROAD_VEH | CMD_MSG(STR_9009_CAN_T_BUILD_ROAD_VEHICLE)); |
|
412 |
} break; |
|
413 |
||
968
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
414 |
case 6: { /* rename */ |
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
415 |
int sel_eng = WP(w,buildtrain_d).sel_engine; |
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
416 |
if (sel_eng != -1) { |
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
417 |
WP(w,buildtrain_d).rename_engine = sel_eng; |
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
418 |
ShowQueryString(GetCustomEngineName(sel_eng), |
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
419 |
STR_9036_RENAME_ROAD_VEHICLE_TYPE, 31, 160, w->window_class, w->window_number); |
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
420 |
} |
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
421 |
} break; |
0 | 422 |
} |
423 |
break; |
|
424 |
||
425 |
case WE_4: |
|
426 |
if (w->window_number != 0 && !FindWindowById(WC_VEHICLE_DEPOT, w->window_number)) { |
|
427 |
DeleteWindow(w); |
|
428 |
} |
|
429 |
break; |
|
430 |
||
431 |
case WE_ON_EDIT_TEXT: { |
|
432 |
byte *b = e->edittext.str; |
|
433 |
if (*b == 0) |
|
434 |
return; |
|
435 |
memcpy(_decode_parameters, b, 32); |
|
436 |
DoCommandP(0, WP(w,buildtrain_d).rename_engine, 0, NULL, CMD_RENAME_ENGINE | CMD_MSG(STR_9037_CAN_T_RENAME_ROAD_VEHICLE)); |
|
437 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
438 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
439 |
case WE_RESIZE: { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
440 |
if (e->sizing.diff.y == 0) |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
441 |
break; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
442 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
443 |
w->vscroll.cap += e->sizing.diff.y / 14; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
444 |
w->widget[2].unkA = (w->vscroll.cap << 8) + 1; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
445 |
} break; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
446 |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
447 |
} |
0 | 448 |
} |
449 |
||
450 |
static const Widget _new_road_veh_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
451 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
452 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 247, 0, 13, STR_9006_NEW_ROAD_VEHICLES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
453 |
{ WWT_MATRIX, RESIZE_BOTTOM, 14, 0, 235, 14, 125, 0x801, STR_9026_ROAD_VEHICLE_SELECTION}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
454 |
{ WWT_SCROLLBAR, RESIZE_BOTTOM, 14, 236, 247, 14, 125, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
455 |
{ WWT_IMGBTN, RESIZE_TB, 14, 0, 247, 126, 177, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
456 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 117, 178, 189, STR_9007_BUILD_VEHICLE,STR_9027_BUILD_THE_HIGHLIGHTED_ROAD}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
457 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 118, 235, 178, 189, STR_9034_RENAME, STR_9035_RENAME_ROAD_VEHICLE_TYPE}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
458 |
{ WWT_RESIZEBOX, RESIZE_TB, 14, 236, 247, 178, 189, 0x0, STR_RESIZE_BUTTON}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
459 |
{ WIDGETS_END}, |
0 | 460 |
}; |
461 |
||
462 |
static const WindowDesc _new_road_veh_desc = { |
|
463 |
-1, -1, 248, 190, |
|
464 |
WC_BUILD_VEHICLE,0, |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
465 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
0 | 466 |
_new_road_veh_widgets, |
467 |
NewRoadVehWndProc |
|
468 |
}; |
|
469 |
||
470 |
static void ShowBuildRoadVehWindow(TileIndex tile) |
|
471 |
{ |
|
472 |
Window *w; |
|
473 |
||
474 |
DeleteWindowById(WC_BUILD_VEHICLE, tile); |
|
475 |
||
476 |
w = AllocateWindowDesc(&_new_road_veh_desc); |
|
477 |
w->window_number = tile; |
|
478 |
w->vscroll.cap = 8; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
479 |
w->widget[2].unkA = (w->vscroll.cap << 8) + 1; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
480 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
481 |
w->resize.step_height = 14; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
482 |
w->resize.height = w->height - 14 * 4; /* Minimum of 4 vehicles in the display */ |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
483 |
|
0 | 484 |
if (tile != 0) { |
485 |
w->caption_color = _map_owner[tile]; |
|
486 |
} else { |
|
487 |
w->caption_color = _local_player; |
|
488 |
} |
|
489 |
} |
|
490 |
||
491 |
static void DrawRoadDepotWindow(Window *w) |
|
492 |
{ |
|
493 |
uint tile; |
|
494 |
Vehicle *v; |
|
495 |
int num,x,y; |
|
496 |
Depot *d; |
|
497 |
||
498 |
tile = w->window_number; |
|
499 |
||
500 |
/* setup disabled buttons */ |
|
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
501 |
w->disabled_state = (_map_owner[tile]==_local_player) ? 0 : ((1<<4)|(1<<7)); |
0 | 502 |
|
503 |
/* determine amount of items for scroller */ |
|
504 |
num = 0; |
|
505 |
FOR_ALL_VEHICLES(v) { |
|
506 |
if (v->type == VEH_Road && v->u.road.state == 254 && |
|
507 |
v->tile == (TileIndex)tile) |
|
508 |
num++; |
|
509 |
} |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
510 |
SetVScrollCount(w, (num + w->hscroll.cap - 1) / w->hscroll.cap); |
0 | 511 |
|
512 |
/* locate the depot struct */ |
|
877
a0849f41e748
(svn r1358) Assert bounds of depot list when searching for a depot
tron
parents:
867
diff
changeset
|
513 |
for (d = _depots; d->xy != (TileIndex)tile; d++) { |
878 | 514 |
assert(d < endof(_depots)); |
877
a0849f41e748
(svn r1358) Assert bounds of depot list when searching for a depot
tron
parents:
867
diff
changeset
|
515 |
} |
0 | 516 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
517 |
SetDParam(0, d->town_index); |
0 | 518 |
DrawWindowWidgets(w); |
519 |
||
520 |
x = 2; |
|
521 |
y = 15; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
522 |
num = w->vscroll.pos * w->hscroll.cap; |
0 | 523 |
|
524 |
FOR_ALL_VEHICLES(v) { |
|
525 |
if (v->type == VEH_Road && |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
526 |
v->u.road.state == 254 && |
0 | 527 |
v->tile == (TileIndex)tile && |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
528 |
--num < 0 && num >= -w->vscroll.cap * w->hscroll.cap) { |
0 | 529 |
|
530 |
DrawRoadVehImage(v, x+24, y, WP(w,traindepot_d).sel); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
531 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
532 |
SetDParam(0, v->unitnumber); |
0 | 533 |
DrawString(x, y+2, (uint16)(v->max_age-366) >= v->age ? STR_00E2 : STR_00E3, 0); |
534 |
||
535 |
DrawSprite( (v->vehstatus & VS_STOPPED) ? 0xC12 : 0xC13, x + 16, y); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
536 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
537 |
if ((x+=56) == 2 + 56 * w->hscroll.cap) { |
0 | 538 |
x = 2; |
539 |
y += 14; |
|
540 |
} |
|
541 |
} |
|
542 |
} |
|
543 |
} |
|
544 |
||
545 |
static int GetVehicleFromRoadDepotWndPt(Window *w, int x, int y, Vehicle **veh) |
|
546 |
{ |
|
969
8c4bede35fcc
(svn r1464) -Fix: [1099106] Resizeable portion of bus/air/rail depots window unclickable
darkvater
parents:
968
diff
changeset
|
547 |
uint xt,row,xm; |
0 | 548 |
TileIndex tile; |
549 |
Vehicle *v; |
|
550 |
int pos; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
551 |
|
0 | 552 |
xt = x / 56; |
553 |
xm = x % 56; |
|
971
1b6f956d8ac5
(svn r1466) -Fix: oops, depot windows can of course also scroll horizontally. Thanks si-m1.
darkvater
parents:
969
diff
changeset
|
554 |
if (xt >= w->hscroll.cap) |
0 | 555 |
return 1; |
556 |
||
969
8c4bede35fcc
(svn r1464) -Fix: [1099106] Resizeable portion of bus/air/rail depots window unclickable
darkvater
parents:
968
diff
changeset
|
557 |
row = (y - 14) / 14; |
8c4bede35fcc
(svn r1464) -Fix: [1099106] Resizeable portion of bus/air/rail depots window unclickable
darkvater
parents:
968
diff
changeset
|
558 |
if (row >= w->vscroll.cap) |
0 | 559 |
return 1; |
560 |
||
971
1b6f956d8ac5
(svn r1466) -Fix: oops, depot windows can of course also scroll horizontally. Thanks si-m1.
darkvater
parents:
969
diff
changeset
|
561 |
pos = (row + w->vscroll.pos) * w->hscroll.cap + xt; |
0 | 562 |
|
563 |
tile = w->window_number; |
|
564 |
FOR_ALL_VEHICLES(v) { |
|
565 |
if (v->type == VEH_Road && |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
566 |
v->u.road.state == 254 && |
0 | 567 |
v->tile == (TileIndex)tile && |
568 |
--pos < 0) { |
|
569 |
*veh = v; |
|
570 |
if (xm >= 24) |
|
571 |
return 0; |
|
572 |
||
573 |
if (xm <= 16) |
|
574 |
return -1; /* show window */ |
|
575 |
||
576 |
return -2; /* start stop */ |
|
577 |
} |
|
578 |
} |
|
579 |
||
580 |
return 1; /* outside */ |
|
581 |
} |
|
582 |
||
583 |
static void RoadDepotClickVeh(Window *w, int x, int y) |
|
584 |
{ |
|
585 |
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
|
586 |
int mode; |
0 | 587 |
|
10
c35ab8426202
(svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents:
0
diff
changeset
|
588 |
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
|
589 |
if (mode > 0) return; |
0 | 590 |
|
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
|
591 |
// 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
|
592 |
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
|
593 |
|
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
|
594 |
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
|
595 |
case 0: // start dragging of vehicle |
0 | 596 |
if (v != NULL) { |
597 |
WP(w,traindepot_d).sel = v->index; |
|
598 |
SetWindowDirty(w); |
|
599 |
SetObjectToPlaceWnd( SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)) + GetRoadVehImage(v, 6), 4, w); |
|
600 |
} |
|
601 |
break; |
|
602 |
||
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
|
603 |
case -1: // show info window |
0 | 604 |
ShowRoadVehViewWindow(v); |
605 |
break; |
|
606 |
||
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
|
607 |
case -2: // click start/stop flag |
0 | 608 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_ROADVEH | CMD_MSG(STR_9015_CAN_T_STOP_START_ROAD_VEHICLE)); |
609 |
break; |
|
610 |
||
611 |
default: |
|
612 |
NOT_REACHED(); |
|
613 |
} |
|
614 |
} |
|
615 |
||
616 |
static void RoadDepotWndProc(Window *w, WindowEvent *e) |
|
617 |
{ |
|
618 |
switch(e->event) { |
|
619 |
case WE_PAINT: |
|
620 |
DrawRoadDepotWindow(w); |
|
621 |
break; |
|
622 |
||
623 |
case WE_CLICK: { |
|
624 |
switch(e->click.widget) { |
|
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
625 |
case 5: |
0 | 626 |
RoadDepotClickVeh(w, e->click.pt.x, e->click.pt.y); |
627 |
break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
628 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
629 |
case 7: |
0 | 630 |
ShowBuildRoadVehWindow(w->window_number); |
631 |
break; |
|
632 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
633 |
case 8: /* scroll to tile */ |
0 | 634 |
ScrollMainWindowToTile(w->window_number); |
635 |
break; |
|
636 |
} |
|
637 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
638 |
|
0 | 639 |
case WE_DESTROY: |
640 |
DeleteWindowById(WC_BUILD_VEHICLE, w->window_number); |
|
641 |
break; |
|
642 |
||
643 |
case WE_DRAGDROP: { |
|
644 |
switch(e->click.widget) { |
|
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
645 |
case 5: { |
0 | 646 |
Vehicle *v; |
647 |
VehicleID sel = WP(w,traindepot_d).sel; |
|
648 |
||
649 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
650 |
SetWindowDirty(w); |
|
651 |
||
652 |
if (GetVehicleFromRoadDepotWndPt(w, e->dragdrop.pt.x, e->dragdrop.pt.y, &v) == 0 && |
|
653 |
v != NULL && |
|
654 |
sel == v->index) { |
|
655 |
ShowRoadVehViewWindow(v); |
|
656 |
} |
|
657 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
658 |
|
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
659 |
case 4: |
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
660 |
if (!HASBIT(w->disabled_state, 4) && |
0 | 661 |
WP(w,traindepot_d).sel != INVALID_VEHICLE) { |
662 |
Vehicle *v; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
663 |
|
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
664 |
HandleButtonClick(w, 4); |
0 | 665 |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
666 |
v = GetVehicle(WP(w,traindepot_d).sel); |
0 | 667 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
668 |
||
669 |
_backup_orders_tile = v->tile; |
|
670 |
BackupVehicleOrders(v, _backup_orders_data); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
671 |
|
0 | 672 |
if (!DoCommandP(v->tile, v->index, 0, NULL, CMD_SELL_ROAD_VEH | CMD_MSG(STR_9014_CAN_T_SELL_ROAD_VEHICLE))) |
673 |
_backup_orders_tile = 0; |
|
674 |
} |
|
675 |
break; |
|
676 |
default: |
|
677 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
678 |
SetWindowDirty(w); |
|
679 |
} |
|
680 |
break; |
|
681 |
} |
|
682 |
break; |
|
683 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
684 |
case WE_RESIZE: { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
685 |
/* Update the scroll + matrix */ |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
686 |
w->vscroll.cap += e->sizing.diff.y / 14; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
687 |
w->hscroll.cap += e->sizing.diff.x / 56; |
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
688 |
w->widget[5].unkA = (w->vscroll.cap << 8) + w->hscroll.cap; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
689 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
690 |
} break; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
691 |
|
0 | 692 |
} |
693 |
||
694 |
} |
|
695 |
||
696 |
static const Widget _road_depot_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
697 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
698 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 302, 0, 13, STR_9003_ROAD_VEHICLE_DEPOT, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
699 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 303, 314, 0, 13, 0x0, STR_STICKY_BUTTON}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
700 |
{ WWT_PANEL, RESIZE_LRB, 14, 280, 302, 14, 13, 0x0, STR_NULL}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
701 |
{ WWT_IMGBTN, RESIZE_LRTB, 14, 280, 302, 14, 55, 0x2A9, STR_9024_DRAG_ROAD_VEHICLE_TO_HERE}, |
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
702 |
|
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
703 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 279, 14, 55, 0x305, STR_9022_VEHICLES_CLICK_ON_VEHICLE}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
704 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 303, 314, 14, 55, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
705 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 150, 56, 67, STR_9004_NEW_VEHICLES, STR_9023_BUILD_NEW_ROAD_VEHICLE}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
706 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 151, 302, 56, 67, STR_00E4_LOCATION, STR_9025_CENTER_MAIN_VIEW_ON_ROAD}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
707 |
{ WWT_PANEL, RESIZE_RTB, 14, 303, 302, 56, 67, 0x0, STR_NULL}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
708 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 303, 314, 56, 67, 0x0, STR_RESIZE_BUTTON}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
709 |
{ WIDGETS_END}, |
0 | 710 |
}; |
711 |
||
712 |
static const WindowDesc _road_depot_desc = { |
|
713 |
-1, -1, 315, 68, |
|
714 |
WC_VEHICLE_DEPOT,0, |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
715 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 716 |
_road_depot_widgets, |
717 |
RoadDepotWndProc |
|
718 |
}; |
|
719 |
||
720 |
void ShowRoadDepotWindow(uint tile) |
|
721 |
{ |
|
722 |
Window *w; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
723 |
|
0 | 724 |
w = AllocateWindowDescFront(&_road_depot_desc, tile); |
725 |
if (w) { |
|
726 |
w->caption_color = _map_owner[w->window_number]; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
727 |
w->hscroll.cap = 5; |
0 | 728 |
w->vscroll.cap = 3; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
729 |
w->resize.step_width = 56; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
730 |
w->resize.step_height = 14; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
731 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
0 | 732 |
_backup_orders_tile = 0; |
733 |
} |
|
734 |
} |
|
735 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
736 |
static const Widget _player_roadveh_widgets[] = { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
737 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
738 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 247, 0, 13, STR_9001_ROAD_VEHICLES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
739 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
740 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_ORDER_TIP}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
741 |
{ WWT_PANEL, RESIZE_NONE, 14, 81, 235, 14, 25, 0x0, STR_SORT_CRITERIA_TIP}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
742 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 236, 247, 14, 25, STR_0225, STR_SORT_CRITERIA_TIP}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
743 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 248, 259, 14, 25, 0x0, STR_NULL}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
744 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 247, 26, 207, 0x701, STR_901A_ROAD_VEHICLES_CLICK_ON}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
745 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 248, 259, 26, 207, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
588 | 746 |
/* only for our road list, a 'Build Vehicle' button that opens the depot of the last built depot */ |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
747 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 124, 208, 219, STR_8815_NEW_VEHICLES, STR_901B_BUILD_NEW_ROAD_VEHICLES}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
748 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 125, 247, 208, 219, STR_REPLACE_VEHICLES, STR_REPLACE_HELP}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
749 |
{ WWT_PANEL, RESIZE_RTB, 14, 248, 247, 208, 219, 0x0, STR_NULL}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
750 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 248, 259, 208, 219, 0x0, STR_RESIZE_BUTTON}, |
588 | 751 |
{ WIDGETS_END}, |
752 |
}; |
|
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
|
753 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
754 |
static const Widget _other_player_roadveh_widgets[] = { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
755 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
756 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 247, 0, 13, STR_9001_ROAD_VEHICLES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
757 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
758 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_ORDER_TIP}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
759 |
{ WWT_PANEL, RESIZE_NONE, 14, 81, 235, 14, 25, 0x0, STR_SORT_CRITERIA_TIP}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
760 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 236, 247, 14, 25, STR_0225, STR_SORT_CRITERIA_TIP}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
761 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 248, 259, 14, 25, 0x0, STR_NULL}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
762 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 247, 26, 207, 0x701, STR_901A_ROAD_VEHICLES_CLICK_ON}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
763 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 248, 259, 26, 207, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
764 |
{ WWT_PANEL, RESIZE_RTB, 14, 0, 247, 208, 219, 0x0, STR_NULL}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
765 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 248, 259, 208, 219, 0x0, STR_RESIZE_BUTTON}, |
588 | 766 |
{ WIDGETS_END}, |
767 |
}; |
|
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
|
768 |
|
0 | 769 |
static void PlayerRoadVehWndProc(Window *w, WindowEvent *e) |
770 |
{ |
|
588 | 771 |
int station = (int)w->window_number >> 16; |
772 |
int owner = w->window_number & 0xff; |
|
773 |
vehiclelist_d *vl = &WP(w, vehiclelist_d); |
|
774 |
||
0 | 775 |
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
|
776 |
case WE_PAINT: { |
588 | 777 |
int x = 2; |
778 |
int y = PLY_WND_PRC__OFFSET_TOP_WIDGET; |
|
779 |
int max; |
|
780 |
int i; |
|
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
781 |
|
588 | 782 |
BuildVehicleList(vl, VEH_Road, owner, station); |
783 |
SortVehicleList(vl); |
|
0 | 784 |
|
588 | 785 |
SetVScrollCount(w, vl->list_length); |
786 |
||
787 |
// disable 'Sort By' tooltip on Unsorted sorting criteria |
|
788 |
if (vl->sort_type == SORT_BY_UNSORTED) |
|
757 | 789 |
w->disabled_state |= (1 << 3); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
790 |
|
0 | 791 |
/* draw the widgets */ |
792 |
{ |
|
588 | 793 |
const Player *p = DEREF_PLAYER(owner); |
794 |
if (station == -1) { |
|
795 |
/* Company Name -- (###) Road vehicles */ |
|
796 |
SetDParam(0, p->name_1); |
|
797 |
SetDParam(1, p->name_2); |
|
798 |
SetDParam(2, w->vscroll.count); |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
799 |
w->widget[1].unkA = STR_9001_ROAD_VEHICLES; |
588 | 800 |
} else { |
801 |
/* Station Name -- (###) Road vehicles */ |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
802 |
SetDParam(0, GetStation(station)->index); |
588 | 803 |
SetDParam(1, w->vscroll.count); |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
804 |
w->widget[1].unkA = STR_SCHEDULED_ROAD_VEHICLES; |
588 | 805 |
} |
0 | 806 |
DrawWindowWidgets(w); |
807 |
} |
|
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
808 |
/* draw sorting criteria string */ |
588 | 809 |
DrawString(85, 15, _vehicle_sort_listing[vl->sort_type], 0x10); |
810 |
/* draw arrow pointing up/down for ascending/descending sorting */ |
|
811 |
DoDrawString( |
|
812 |
vl->flags & VL_DESC ? "\xAA" : "\xA0", 69, 15, 0x10); |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
813 |
|
588 | 814 |
max = min(w->vscroll.pos + w->vscroll.cap, vl->list_length); |
815 |
for (i = w->vscroll.pos; i < max; ++i) { |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
816 |
Vehicle *v = GetVehicle(vl->sort_list[i].index); |
588 | 817 |
StringID str; |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
818 |
|
588 | 819 |
assert(v->type == VEH_Road && v->owner == owner); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
820 |
|
588 | 821 |
DrawRoadVehImage(v, x + 22, y + 6, INVALID_VEHICLE); |
822 |
DrawVehicleProfitButton(v, x, y + 13); |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
823 |
|
588 | 824 |
SetDParam(0, v->unitnumber); |
825 |
if (IsRoadDepotTile(v->tile)) |
|
826 |
str = STR_021F; |
|
827 |
else |
|
828 |
str = v->age > v->max_age - 366 ? STR_00E3 : STR_00E2; |
|
829 |
DrawString(x, y + 2, str, 0); |
|
830 |
||
831 |
SetDParam(0, v->profit_this_year); |
|
832 |
SetDParam(1, v->profit_last_year); |
|
833 |
DrawString(x + 24, y + 18, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 0); |
|
834 |
||
671
ca04afdfdf43
(svn r1109) Fix c&p bug: In vehicle lists a name was displayed for road vehicles even if they had none
tron
parents:
588
diff
changeset
|
835 |
if (v->string_id != STR_SV_ROADVEH_NAME) { |
588 | 836 |
SetDParam(0, v->string_id); |
837 |
DrawString(x + 24, y, STR_01AB, 0); |
|
0 | 838 |
} |
588 | 839 |
|
840 |
y += PLY_WND_PRC__SIZE_OF_ROW_SMALL; |
|
0 | 841 |
} |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
842 |
} break; |
0 | 843 |
|
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
|
844 |
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
|
845 |
switch(e->click.widget) { |
757 | 846 |
case 3: /* Flip sorting method ascending/descending */ |
588 | 847 |
vl->flags ^= VL_DESC; |
848 |
vl->flags |= VL_RESORT; |
|
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 |
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
|
850 |
break; |
588 | 851 |
|
757 | 852 |
case 4: case 5:/* Select sorting criteria dropdown menu */ |
842 | 853 |
ShowDropDownMenu(w, _vehicle_sort_listing, vl->sort_type, 5, 0, 0); |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
854 |
return; |
757 | 855 |
case 7: { /* Matrix to show vehicles */ |
174
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
168
diff
changeset
|
856 |
uint32 id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_SMALL; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
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 |
if (id_v >= w->vscroll.cap) { return;} // click out of bounds |
0 | 859 |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
860 |
id_v += w->vscroll.pos; |
0 | 861 |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
862 |
{ |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
863 |
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
|
864 |
|
588 | 865 |
if (id_v >= vl->list_length) return; // click out of list bound |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
866 |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
867 |
v = GetVehicle(vl->sort_list[id_v].index); |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
868 |
|
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
|
869 |
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
|
870 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 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 |
ShowRoadVehViewWindow(v); |
0 | 872 |
} |
873 |
} break; |
|
874 |
||
757 | 875 |
case 9: { /* Build new Vehicle */ |
0 | 876 |
uint tile; |
877 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
878 |
if (!IsWindowOfPrototype(w, _player_roadveh_widgets)) |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
879 |
break; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
880 |
|
0 | 881 |
tile = _last_built_road_depot_tile; |
882 |
do { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
883 |
if (_map_owner[tile] == _local_player && IsRoadDepotTile(tile)) { |
0 | 884 |
ShowRoadDepotWindow(tile); |
885 |
ShowBuildRoadVehWindow(tile); |
|
886 |
return; |
|
887 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
888 |
|
0 | 889 |
tile = TILE_MASK(tile + 1); |
890 |
} while(tile != _last_built_road_depot_tile); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
891 |
|
0 | 892 |
ShowBuildRoadVehWindow(0); |
893 |
} break; |
|
842 | 894 |
case 10: { |
886
4442d7859ea7
(svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight
parents:
878
diff
changeset
|
895 |
if (!IsWindowOfPrototype(w, _player_roadveh_widgets)) |
4442d7859ea7
(svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight
parents:
878
diff
changeset
|
896 |
break; |
4442d7859ea7
(svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight
parents:
878
diff
changeset
|
897 |
|
842 | 898 |
ShowReplaceVehicleWindow(VEH_Road); |
899 |
break; |
|
900 |
} |
|
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
|
901 |
} |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 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 |
} 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
|
903 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 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 |
case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */ |
588 | 905 |
if (vl->sort_type != e->dropdown.index) { |
906 |
// value has changed -> resort |
|
907 |
vl->flags |= VL_RESORT; |
|
908 |
vl->sort_type = e->dropdown.index; |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
909 |
|
588 | 910 |
// enable 'Sort By' if a sorter criteria is chosen |
911 |
if (vl->sort_type != SORT_BY_UNSORTED) |
|
757 | 912 |
w->disabled_state &= ~(1 << 3); |
588 | 913 |
} |
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
|
914 |
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
|
915 |
break; |
588 | 916 |
|
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
|
917 |
case WE_CREATE: /* set up resort timer */ |
588 | 918 |
vl->sort_list = NULL; |
919 |
vl->flags = VL_REBUILD; |
|
920 |
vl->sort_type = SORT_BY_UNSORTED; |
|
921 |
vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
922 |
break; |
588 | 923 |
|
767 | 924 |
case WE_DESTROY: |
925 |
free(vl->sort_list); |
|
926 |
break; |
|
927 |
||
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
|
928 |
case WE_TICK: /* resort the list every 20 seconds orso (10 days) */ |
588 | 929 |
if (--vl->resort_timer == 0) { |
930 |
DEBUG(misc, 1) ("Periodic resort road vehicles list player %d station %d", |
|
931 |
owner, station); |
|
932 |
vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; |
|
933 |
vl->flags |= VL_RESORT; |
|
934 |
SetWindowDirty(w); |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
935 |
} |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
936 |
break; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
937 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
938 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
939 |
case WE_RESIZE: |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
940 |
/* Update the scroll + matrix */ |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
941 |
w->vscroll.cap += e->sizing.diff.y / PLY_WND_PRC__SIZE_OF_ROW_SMALL; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
942 |
w->widget[7].unkA = (w->vscroll.cap << 8) + 1; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
943 |
break; |
0 | 944 |
} |
945 |
} |
|
946 |
||
947 |
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
|
948 |
-1, -1, 260, 220, |
0 | 949 |
WC_ROADVEH_LIST,0, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
950 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 951 |
_player_roadveh_widgets, |
952 |
PlayerRoadVehWndProc |
|
953 |
}; |
|
954 |
||
955 |
static const WindowDesc _other_player_roadveh_desc = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
956 |
-1, -1, 260, 220, |
0 | 957 |
WC_ROADVEH_LIST,0, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
958 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 959 |
_other_player_roadveh_widgets, |
960 |
PlayerRoadVehWndProc |
|
961 |
}; |
|
962 |
||
963 |
||
588 | 964 |
void ShowPlayerRoadVehicles(int player, int station) |
0 | 965 |
{ |
966 |
Window *w; |
|
967 |
||
968 |
if ( player == _local_player) { |
|
588 | 969 |
w = AllocateWindowDescFront(&_player_roadveh_desc, (station << 16) | player); |
0 | 970 |
} else { |
588 | 971 |
w = AllocateWindowDescFront(&_other_player_roadveh_desc, (station << 16) | player); |
0 | 972 |
} |
973 |
if (w) { |
|
974 |
w->caption_color = player; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
975 |
w->vscroll.cap = 7; // maximum number of vehicles shown |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
976 |
w->widget[7].unkA = (w->vscroll.cap << 8) + 1; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
977 |
w->resize.step_height = PLY_WND_PRC__SIZE_OF_ROW_SMALL; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
978 |
w->resize.height = 220 - (PLY_WND_PRC__SIZE_OF_ROW_SMALL * 3); /* Minimum of 4 vehicles */ |
0 | 979 |
} |
980 |
} |