author | tron |
Mon, 03 Jan 2005 22:07:40 +0000 | |
changeset 877 | a0849f41e748 |
parent 867 | 581154a08a78 |
child 878 | 8f4f2ef6f674 |
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:
243
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:
588
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_Ship_Build_Window(uint16 engine_number) |
16 |
{ |
|
17 |
YearMonthDay ymd; |
|
18 |
const ShipVehicleInfo *svi = ShipVehInfo(engine_number); |
|
19 |
Engine *e; |
|
20 |
||
21 |
SetDParam(0, svi->base_cost * (_price.ship_base>>3)>>5); |
|
22 |
SetDParam(1, svi->max_speed * 10 >> 5); |
|
23 |
SetDParam(2, _cargoc.names_long_p[svi->cargo_type]); |
|
24 |
SetDParam(3, svi->capacity); |
|
25 |
SetDParam(4, svi->refittable ? STR_9842_REFITTABLE : STR_EMPTY); |
|
26 |
SetDParam(5, svi->running_cost * _price.ship_running >> 8); |
|
27 |
||
28 |
e = &_engines[engine_number]; |
|
29 |
SetDParam(7, e->lifelength); |
|
30 |
SetDParam(8, e->reliability * 100 >> 16); |
|
31 |
ConvertDayToYMD(&ymd, e->intro_date); |
|
32 |
SetDParam(6, ymd.year + 1920); |
|
33 |
} |
|
0 | 34 |
|
35 |
static void DrawShipImage(Vehicle *v, int x, int y, VehicleID selection); |
|
36 |
||
37 |
||
38 |
const byte _ship_refit_types[4][16] = { |
|
39 |
{CT_MAIL, CT_COAL, CT_LIVESTOCK, CT_GOODS, CT_GRAIN, CT_WOOD, CT_IRON_ORE, CT_STEEL, CT_VALUABLES, 255}, |
|
40 |
{CT_MAIL, CT_COAL, CT_LIVESTOCK, CT_GOODS, CT_GRAIN, CT_WOOD, CT_PAPER, CT_FOOD, CT_VALUABLES, 255}, |
|
41 |
{CT_MAIL, CT_FRUIT, CT_GOODS, CT_COPPER_ORE, CT_GRAIN, CT_WOOD, CT_WATER, CT_VALUABLES, 255}, |
|
42 |
{CT_MAIL, CT_SUGAR, CT_TOYS, CT_CANDY, CT_COLA, CT_COTTON_CANDY, CT_BUBBLES, CT_TOFFEE, CT_BATTERIES, CT_PLASTIC, CT_FIZZY_DRINKS, 255}, |
|
43 |
}; |
|
44 |
||
45 |
static void ShipRefitWndProc(Window *w, WindowEvent *e) |
|
46 |
{ |
|
47 |
switch(e->event) { |
|
48 |
case WE_PAINT: { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
49 |
Vehicle *v = &_vehicles[w->window_number]; |
0 | 50 |
const byte *b; |
51 |
int sel; |
|
52 |
int x,y; |
|
53 |
byte color; |
|
54 |
int cargo; |
|
55 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
56 |
SetDParam(0, v->string_id); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
57 |
SetDParam(1, v->unitnumber); |
0 | 58 |
DrawWindowWidgets(w); |
59 |
||
60 |
DrawString(1, 15, STR_983F_SELECT_CARGO_TYPE_TO_CARRY, 0); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
61 |
|
0 | 62 |
cargo = -1; |
63 |
x = 6; |
|
64 |
y = 25; |
|
65 |
sel = WP(w,refit_d).sel; |
|
66 |
||
67 |
#define show_cargo(ctype) { \ |
|
68 |
color = 16; \ |
|
69 |
if (sel == 0) { \ |
|
70 |
cargo = ctype; \ |
|
71 |
color = 12; \ |
|
72 |
} \ |
|
73 |
sel--; \ |
|
74 |
DrawString(x, y, _cargoc.names_s[ctype], color); \ |
|
75 |
y += 10; \ |
|
76 |
} |
|
77 |
||
78 |
if (_engine_refit_masks[v->engine_type]) { |
|
79 |
uint32 mask = _engine_refit_masks[v->engine_type]; |
|
80 |
int cid = 0; |
|
81 |
||
82 |
for (; mask; mask >>= 1, cid++) { |
|
83 |
if (!(mask & 1)) // not this cid |
|
84 |
continue; |
|
85 |
if (!(_local_cargo_id_landscape[cid] & (1 << _opt.landscape))) // not in this landscape |
|
86 |
continue; |
|
87 |
||
88 |
show_cargo(_local_cargo_id_ctype[cid]); |
|
89 |
} |
|
90 |
||
91 |
} else { // generic refit list |
|
92 |
b = _ship_refit_types[_opt.landscape]; |
|
93 |
do { |
|
94 |
show_cargo(*b); |
|
95 |
} while (*++b != 255); |
|
96 |
} |
|
97 |
||
98 |
#undef show_cargo |
|
99 |
||
100 |
WP(w,refit_d).cargo = cargo; |
|
101 |
||
102 |
if (cargo != -1) { |
|
103 |
int32 cost = DoCommandByTile(v->tile, v->index, cargo, 0, CMD_REFIT_SHIP); |
|
104 |
if (cost != CMD_ERROR) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
105 |
SetDParam(2, cost); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
106 |
SetDParam(0, _cargoc.names_long_p[cargo]); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
107 |
SetDParam(1, v->cargo_cap); |
0 | 108 |
DrawString(1, 137, STR_9840_NEW_CAPACITY_COST_OF_REFIT, 0); |
109 |
} |
|
110 |
} |
|
111 |
||
112 |
break; |
|
113 |
} |
|
114 |
||
115 |
case WE_CLICK: |
|
116 |
switch(e->click.widget) { |
|
117 |
case 2: { /* listbox */ |
|
118 |
int y = e->click.pt.y - 25; |
|
119 |
if (y >= 0) { |
|
120 |
WP(w,refit_d).sel = y / 10; |
|
121 |
SetWindowDirty(w); |
|
122 |
} |
|
123 |
} break; |
|
124 |
case 4: /* refit button */ |
|
125 |
if (WP(w,refit_d).cargo != 0xFF) { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
126 |
Vehicle *v = &_vehicles[w->window_number]; |
0 | 127 |
if (DoCommandP(v->tile, v->index, WP(w,refit_d).cargo, NULL, CMD_REFIT_SHIP | CMD_MSG(STR_9841_CAN_T_REFIT_SHIP))) |
128 |
DeleteWindow(w); |
|
129 |
} |
|
130 |
break; |
|
131 |
} |
|
132 |
break; |
|
133 |
} |
|
134 |
} |
|
135 |
||
136 |
||
137 |
static const Widget _ship_refit_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
138 |
{ 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
|
139 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 239, 0, 13, STR_983B_REFIT, 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
|
140 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 239, 14, 135, 0x0, STR_983D_SELECT_TYPE_OF_CARGO_FOR}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
141 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 239, 136, 157, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
142 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 239, 158, 169, STR_983C_REFIT_SHIP, STR_983E_REFIT_SHIP_TO_CARRY_HIGHLIGHTED}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
143 |
{ WIDGETS_END}, |
0 | 144 |
}; |
145 |
||
146 |
static const WindowDesc _ship_refit_desc = { |
|
147 |
-1,-1, 240, 170, |
|
148 |
WC_VEHICLE_REFIT,WC_VEHICLE_VIEW, |
|
149 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
150 |
_ship_refit_widgets, |
|
151 |
ShipRefitWndProc, |
|
152 |
}; |
|
153 |
||
154 |
static void ShowShipRefitWindow(Vehicle *v) |
|
155 |
{ |
|
156 |
Window *w; |
|
157 |
||
158 |
DeleteWindowById(WC_VEHICLE_REFIT, v->index); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
159 |
|
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
160 |
_alloc_wnd_parent_num = v->index; |
0 | 161 |
w = AllocateWindowDesc(&_ship_refit_desc); |
162 |
w->window_number = v->index; |
|
163 |
w->caption_color = v->owner; |
|
164 |
WP(w,refit_d).sel = -1; |
|
165 |
} |
|
166 |
||
167 |
static void ShipDetailsWndProc(Window *w, WindowEvent *e) |
|
168 |
{ |
|
169 |
Vehicle *v = &_vehicles[w->window_number]; |
|
170 |
StringID str; |
|
171 |
int mod; |
|
172 |
||
173 |
switch(e->event) { |
|
174 |
case WE_PAINT: |
|
175 |
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
|
176 |
if (!_patches.servint_ships) // 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
|
177 |
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
|
178 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
179 |
SetDParam(0, v->string_id); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
180 |
SetDParam(1, v->unitnumber); |
0 | 181 |
DrawWindowWidgets(w); |
182 |
||
183 |
/* Draw running cost */ |
|
184 |
{ |
|
185 |
int year = v->age / 366; |
|
186 |
StringID str; |
|
187 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
188 |
SetDParam(1, year); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
189 |
|
0 | 190 |
str = STR_0199_YEAR; |
191 |
if (year != 1) { |
|
192 |
str++; |
|
193 |
if (v->max_age - 366 < v->age) |
|
194 |
str++; |
|
195 |
} |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
196 |
SetDParam(0, str); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
197 |
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
|
198 |
SetDParam(3, ShipVehInfo(v->engine_type)->running_cost * _price.ship_running >> 8); |
0 | 199 |
DrawString(2, 15, STR_9812_AGE_RUNNING_COST_YR, 0); |
200 |
} |
|
201 |
||
202 |
/* Draw max speed */ |
|
203 |
{ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
204 |
SetDParam(0, v->max_speed * 10 >> 5); |
0 | 205 |
DrawString(2, 25, STR_9813_MAX_SPEED, 0); |
206 |
} |
|
207 |
||
208 |
/* Draw profit */ |
|
209 |
{ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
210 |
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
|
211 |
SetDParam(1, v->profit_last_year); |
0 | 212 |
DrawString(2, 35, STR_9814_PROFIT_THIS_YEAR_LAST_YEAR, 0); |
213 |
} |
|
214 |
||
215 |
/* Draw breakdown & reliability */ |
|
216 |
{ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
217 |
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
|
218 |
SetDParam(1, v->breakdowns_since_last_service); |
0 | 219 |
DrawString(2, 45, STR_9815_RELIABILITY_BREAKDOWNS, 0); |
220 |
} |
|
221 |
||
222 |
/* Draw service interval text */ |
|
223 |
{ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
224 |
SetDParam(0, v->service_interval); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
225 |
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
|
226 |
DrawString(13, 90, _patches.servint_ispercent?STR_SERVICING_INTERVAL_PERCENT:STR_883C_SERVICING_INTERVAL_DAYS, 0); |
0 | 227 |
} |
228 |
||
229 |
DrawShipImage(v, 3, 57, INVALID_VEHICLE); |
|
230 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
231 |
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
|
232 |
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
|
233 |
SetDParam(2, v->value); |
0 | 234 |
DrawString(74, 57, STR_9816_BUILT_VALUE, 0); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
235 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
236 |
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
|
237 |
SetDParam(1, v->cargo_cap); |
0 | 238 |
DrawString(74, 67, STR_9817_CAPACITY, 0); |
239 |
||
240 |
str = STR_8812_EMPTY; |
|
241 |
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
|
242 |
SetDParam(0, v->cargo_type); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
243 |
SetDParam(1, v->cargo_count); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
244 |
SetDParam(2, v->cargo_source); |
0 | 245 |
str = STR_8813_FROM; |
246 |
} |
|
247 |
DrawString(74, 78, str, 0); |
|
248 |
break; |
|
249 |
||
250 |
case WE_CLICK: |
|
251 |
switch(e->click.widget) { |
|
252 |
case 2: /* rename */ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
253 |
SetDParam(0, v->unitnumber); |
0 | 254 |
ShowQueryString(v->string_id, STR_9831_NAME_SHIP, 31, 150, w->window_class, w->window_number); |
255 |
break; |
|
256 |
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
|
257 |
mod = _ctrl_pressed? 5 : 10; |
0 | 258 |
goto change_int; |
259 |
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
|
260 |
mod = _ctrl_pressed?- 5 : -10; |
0 | 261 |
change_int: |
262 |
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
|
263 |
|
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
|
264 |
/* %-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
|
265 |
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
|
266 |
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
|
267 |
if (mod == v->service_interval) |
0 | 268 |
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
|
269 |
|
0 | 270 |
DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_SHIP_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING)); |
271 |
break; |
|
272 |
} |
|
273 |
break; |
|
274 |
||
275 |
case WE_4: |
|
276 |
if (FindWindowById(WC_VEHICLE_VIEW, w->window_number) == NULL) |
|
277 |
DeleteWindow(w); |
|
278 |
break; |
|
279 |
||
280 |
case WE_ON_EDIT_TEXT: { |
|
281 |
byte *b = e->edittext.str; |
|
282 |
if (*b == 0) |
|
283 |
return; |
|
284 |
memcpy(_decode_parameters, b, 32); |
|
285 |
DoCommandP(0, w->window_number, 0, NULL, CMD_NAME_VEHICLE | CMD_MSG(STR_9832_CAN_T_NAME_SHIP)); |
|
286 |
} break; |
|
287 |
||
288 |
} |
|
289 |
} |
|
290 |
||
291 |
||
292 |
static const Widget _ship_details_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, 364, 0, 13, STR_9811_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
|
295 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 365, 404, 0, 13, STR_01AA_NAME, STR_982F_NAME_SHIP}, |
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, 404, 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
|
297 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 404, 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
|
298 |
{ 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
|
299 |
{ 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
|
300 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 11, 404, 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
|
301 |
{ WIDGETS_END}, |
0 | 302 |
}; |
303 |
||
304 |
static const WindowDesc _ship_details_desc = { |
|
305 |
-1,-1, 405, 101, |
|
306 |
WC_VEHICLE_DETAILS,WC_VEHICLE_VIEW, |
|
307 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
308 |
_ship_details_widgets, |
|
309 |
ShipDetailsWndProc |
|
310 |
}; |
|
311 |
||
312 |
static void ShowShipDetailsWindow(Vehicle *v) |
|
313 |
{ |
|
314 |
Window *w; |
|
315 |
VehicleID veh = v->index; |
|
316 |
DeleteWindowById(WC_VEHICLE_ORDERS, veh); |
|
317 |
DeleteWindowById(WC_VEHICLE_DETAILS, veh); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
318 |
_alloc_wnd_parent_num = veh; |
0 | 319 |
w = AllocateWindowDesc(&_ship_details_desc); |
320 |
w->window_number = veh; |
|
321 |
w->caption_color = v->owner; |
|
322 |
} |
|
323 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
538
diff
changeset
|
324 |
void CcBuildShip(bool success, uint tile, uint32 p1, uint32 p2) |
0 | 325 |
{ |
326 |
Vehicle *v; |
|
327 |
if (!success) return; |
|
328 |
||
329 |
v = &_vehicles[_new_ship_id]; |
|
330 |
if (v->tile == _backup_orders_tile) { |
|
331 |
_backup_orders_tile = 0; |
|
332 |
RestoreVehicleOrders(v, _backup_orders_data); |
|
333 |
} |
|
334 |
ShowShipViewWindow(v); |
|
335 |
} |
|
336 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
337 |
static void NewShipWndProc(Window *w, WindowEvent *e) |
0 | 338 |
{ |
339 |
switch(e->event) { |
|
340 |
case WE_PAINT: |
|
341 |
if (w->window_number == 0) |
|
342 |
w->disabled_state = 1 << 5; |
|
343 |
||
344 |
// Setup scroll count |
|
345 |
{ |
|
346 |
int count = 0; |
|
347 |
int num = NUM_SHIP_ENGINES; |
|
348 |
Engine *e = &_engines[SHIP_ENGINES_INDEX]; |
|
349 |
do { |
|
350 |
if (HASBIT(e->player_avail, _local_player)) |
|
351 |
count++; |
|
352 |
} while (++e,--num); |
|
353 |
SetVScrollCount(w, count); |
|
354 |
} |
|
355 |
||
356 |
DrawWindowWidgets(w); |
|
357 |
||
358 |
{ |
|
359 |
int num = NUM_SHIP_ENGINES; |
|
360 |
Engine *e = &_engines[SHIP_ENGINES_INDEX]; |
|
361 |
int x = 2; |
|
362 |
int y = 15; |
|
363 |
int sel = WP(w,buildtrain_d).sel_index; |
|
364 |
int pos = w->vscroll.pos; |
|
365 |
int engine_id = SHIP_ENGINES_INDEX; |
|
366 |
int selected_id = -1; |
|
367 |
||
368 |
do { |
|
369 |
if (HASBIT(e->player_avail, _local_player)) { |
|
370 |
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
|
371 |
if (IS_INT_INSIDE(--pos, -w->vscroll.cap, 0)) { |
0 | 372 |
DrawString(x+75, y+7, GetCustomEngineName(engine_id), sel==0 ? 0xC : 0x10); |
373 |
DrawShipEngine(x+35, y+10, engine_id, SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player))); |
|
374 |
y += 24; |
|
375 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
376 |
sel--; |
0 | 377 |
} |
378 |
} while (++engine_id, ++e,--num); |
|
379 |
||
380 |
WP(w,buildtrain_d).sel_engine = selected_id; |
|
381 |
||
382 |
if (selected_id != -1) { |
|
842 | 383 |
Set_DPARAM_Ship_Build_Window(selected_id); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
384 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
385 |
DrawString(2, w->widget[4].top + 1, STR_980A_COST_SPEED_CAPACITY_RUNNING, 0); |
0 | 386 |
} |
387 |
} |
|
388 |
break; |
|
389 |
||
390 |
case WE_CLICK: |
|
391 |
switch(e->click.widget) { |
|
392 |
case 2: { /* listbox */ |
|
393 |
uint i = (e->click.pt.y - 14) / 24; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
394 |
if (i < w->vscroll.cap) { |
0 | 395 |
WP(w,buildtrain_d).sel_index = i + w->vscroll.pos; |
396 |
SetWindowDirty(w); |
|
397 |
} |
|
398 |
} break; |
|
399 |
case 5: { /* build */ |
|
400 |
int sel_eng = WP(w,buildtrain_d).sel_engine; |
|
401 |
if (sel_eng != -1) |
|
402 |
DoCommandP(w->window_number, sel_eng, 0, CcBuildShip, CMD_BUILD_SHIP | CMD_MSG(STR_980D_CAN_T_BUILD_SHIP)); |
|
403 |
} break; |
|
404 |
||
405 |
case 6: /* rename */ |
|
406 |
WP(w,buildtrain_d).rename_engine = WP(w,buildtrain_d).sel_engine; |
|
407 |
ShowQueryString( |
|
408 |
GetCustomEngineName(WP(w,buildtrain_d).sel_engine), |
|
409 |
STR_9838_RENAME_SHIP_TYPE, |
|
410 |
31, |
|
411 |
160, |
|
412 |
w->window_class, |
|
413 |
w->window_number); |
|
414 |
break; |
|
415 |
||
416 |
} |
|
417 |
break; |
|
418 |
||
419 |
case WE_4: |
|
420 |
if (w->window_number != 0 && !FindWindowById(WC_VEHICLE_DEPOT, w->window_number)) { |
|
421 |
DeleteWindow(w); |
|
422 |
} |
|
423 |
break; |
|
424 |
||
425 |
case WE_ON_EDIT_TEXT: { |
|
426 |
byte *b = e->edittext.str; |
|
427 |
if (*b == 0) |
|
428 |
return; |
|
429 |
memcpy(_decode_parameters, b, 32); |
|
430 |
DoCommandP(0, WP(w,buildtrain_d).rename_engine, 0, NULL, CMD_RENAME_ENGINE | CMD_MSG(STR_9839_CAN_T_RENAME_SHIP_TYPE)); |
|
431 |
} break; |
|
432 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
433 |
case WE_RESIZE: |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
434 |
w->vscroll.cap += e->sizing.diff.y / 24; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
435 |
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
|
436 |
break; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
437 |
|
0 | 438 |
} |
439 |
} |
|
440 |
||
441 |
static const Widget _new_ship_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
442 |
{ 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
|
443 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 254, 0, 13, STR_9808_NEW_SHIPS, 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
|
444 |
{ WWT_MATRIX, RESIZE_BOTTOM, 14, 0, 243, 14, 109, 0x401, STR_9825_SHIP_SELECTION_LIST_CLICK}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
445 |
{ WWT_SCROLLBAR, RESIZE_BOTTOM, 14, 244, 254, 14, 109, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
446 |
{ WWT_IMGBTN, RESIZE_TB, 14, 0, 254, 110, 161, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
447 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 121, 162, 173, STR_9809_BUILD_SHIP, STR_9826_BUILD_THE_HIGHLIGHTED_SHIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
448 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 122, 243, 162, 173, STR_9836_RENAME, STR_9837_RENAME_SHIP_TYPE}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
449 |
{ WWT_RESIZEBOX, RESIZE_TB, 14, 244, 254, 162, 173, 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
|
450 |
{ WIDGETS_END}, |
0 | 451 |
}; |
452 |
||
453 |
static const WindowDesc _new_ship_desc = { |
|
454 |
-1, -1, 255, 174, |
|
455 |
WC_BUILD_VEHICLE,0, |
|
456 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
457 |
_new_ship_widgets, |
|
458 |
NewShipWndProc |
|
459 |
}; |
|
460 |
||
461 |
||
462 |
static void ShowBuildShipWindow(TileIndex tile) |
|
463 |
{ |
|
464 |
Window *w; |
|
465 |
||
466 |
DeleteWindowById(WC_BUILD_VEHICLE, tile); |
|
467 |
||
468 |
w = AllocateWindowDesc(&_new_ship_desc); |
|
469 |
w->window_number = tile; |
|
470 |
w->vscroll.cap = 4; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
471 |
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
|
472 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
473 |
w->resize.step_height = 24; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
474 |
|
0 | 475 |
if (tile != 0) { |
476 |
w->caption_color = _map_owner[tile]; |
|
477 |
} else { |
|
478 |
w->caption_color = _local_player; |
|
479 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
480 |
|
0 | 481 |
} |
482 |
||
483 |
||
484 |
static void ShipViewWndProc(Window *w, WindowEvent *e) { |
|
485 |
switch(e->event) { |
|
486 |
case WE_PAINT: { |
|
487 |
Vehicle *v = &_vehicles[w->window_number]; |
|
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
|
488 |
uint32 disabled = 1<<8; |
0 | 489 |
StringID str; |
490 |
||
491 |
// Possible to refit? |
|
538
5dd99f3b7eca
(svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents:
534
diff
changeset
|
492 |
if (ShipVehInfo(v->engine_type)->refittable && |
0 | 493 |
v->vehstatus&VS_STOPPED && |
494 |
v->u.ship.state == 0x80 && |
|
495 |
IsShipDepotTile(v->tile)) |
|
496 |
disabled = 0; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
497 |
|
0 | 498 |
if (v->owner != _local_player) |
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
|
499 |
disabled |= 1<<8 | 1<<7; |
0 | 500 |
w->disabled_state = disabled; |
501 |
||
502 |
/* draw widgets & caption */ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
503 |
SetDParam(0, v->string_id); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
504 |
SetDParam(1, v->unitnumber); |
0 | 505 |
DrawWindowWidgets(w); |
506 |
||
507 |
/* draw the flag */ |
|
508 |
DrawSprite((v->vehstatus & VS_STOPPED) ? 0xC12 : 0xC13, 2, 105); |
|
509 |
||
510 |
if (v->breakdown_ctr == 1) { |
|
511 |
str = STR_885C_BROKEN_DOWN; |
|
512 |
} else if (v->vehstatus & VS_STOPPED) { |
|
513 |
str = STR_8861_STOPPED; |
|
514 |
} else { |
|
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
515 |
switch (v->current_order.type) { |
0 | 516 |
case OT_GOTO_STATION: { |
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
517 |
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
|
518 |
SetDParam(1, v->cur_speed * 10 >> 5); |
0 | 519 |
str = STR_HEADING_FOR_STATION + _patches.vehicle_speed; |
520 |
} break; |
|
521 |
||
522 |
case OT_GOTO_DEPOT: { |
|
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
523 |
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
|
524 |
SetDParam(0, dep->town_index); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
525 |
SetDParam(1, v->cur_speed * 10 >> 5); |
0 | 526 |
str = STR_HEADING_FOR_SHIP_DEPOT + _patches.vehicle_speed; |
527 |
} break; |
|
528 |
||
529 |
case OT_LOADING: |
|
530 |
case OT_LEAVESTATION: |
|
531 |
str = STR_882F_LOADING_UNLOADING; |
|
532 |
break; |
|
533 |
||
534 |
default: |
|
535 |
if (v->num_orders == 0) { |
|
536 |
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
|
537 |
SetDParam(0, v->cur_speed * 10 >> 5); |
0 | 538 |
} else |
539 |
str = STR_EMPTY; |
|
540 |
break; |
|
541 |
} |
|
542 |
} |
|
543 |
||
544 |
DrawStringCentered(125, 105, str, 0); |
|
545 |
DrawWindowViewport(w); |
|
546 |
} break; |
|
547 |
||
548 |
case WE_CLICK: { |
|
549 |
Vehicle *v = &_vehicles[w->window_number]; |
|
550 |
||
551 |
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
|
552 |
case 5: /* start stop */ |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
553 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_SHIP | CMD_MSG(STR_9818_CAN_T_STOP_START_SHIP)); |
0 | 554 |
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
|
555 |
case 6: /* center main view */ |
0 | 556 |
ScrollMainWindowTo(v->x_pos, v->y_pos); |
557 |
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
|
558 |
case 7: /* goto hangar */ |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
559 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_SEND_SHIP_TO_DEPOT | CMD_MSG(STR_9819_CAN_T_SEND_SHIP_TO_DEPOT)); |
0 | 560 |
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
|
561 |
case 8: /* refit */ |
0 | 562 |
ShowShipRefitWindow(v); |
563 |
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
|
564 |
case 9: /* show orders */ |
0 | 565 |
ShowOrdersWindow(v); |
566 |
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
|
567 |
case 10: /* show details */ |
0 | 568 |
ShowShipDetailsWindow(v); |
569 |
break; |
|
570 |
} |
|
571 |
} break; |
|
572 |
||
573 |
case WE_DESTROY: |
|
574 |
DeleteWindowById(WC_VEHICLE_ORDERS, w->window_number); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
575 |
DeleteWindowById(WC_VEHICLE_REFIT, w->window_number); |
0 | 576 |
DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number); |
577 |
break; |
|
578 |
} |
|
579 |
} |
|
580 |
||
581 |
static const Widget _ship_view_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
582 |
{ 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
|
583 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 237, 0, 13, STR_980F, 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
|
584 |
{ 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
|
585 |
{ 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
|
586 |
{ 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
|
587 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 0, 249, 104, 115, 0x0, STR_9827_CURRENT_SHIP_ACTION_CLICK}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
588 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 232, 249, 14, 31, 0x2AB, STR_9829_CENTER_MAIN_VIEW_ON_SHIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
589 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 232, 249, 32, 49, 0x2B0, STR_982A_SEND_SHIP_TO_DEPOT}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
590 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 232, 249, 50, 67, 0x2B4, STR_983A_REFIT_CARGO_SHIP_TO_CARRY}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
591 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 232, 249, 68, 85, 0x2B2, STR_9828_SHOW_SHIP_S_ORDERS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
592 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 232, 249, 86, 103, 0x2B3, STR_982B_SHOW_SHIP_DETAILS}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
593 |
{ WIDGETS_END}, |
0 | 594 |
}; |
595 |
||
596 |
static const WindowDesc _ship_view_desc = { |
|
597 |
-1,-1, 250, 116, |
|
598 |
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
|
599 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, |
0 | 600 |
_ship_view_widgets, |
601 |
ShipViewWndProc |
|
602 |
}; |
|
603 |
||
604 |
void ShowShipViewWindow(Vehicle *v) |
|
605 |
{ |
|
606 |
Window *w; |
|
607 |
||
608 |
w = AllocateWindowDescFront(&_ship_view_desc, v->index); |
|
609 |
if (w) { |
|
610 |
w->caption_color = v->owner; |
|
611 |
AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), 0); |
|
612 |
} |
|
613 |
} |
|
614 |
||
615 |
||
616 |
static void DrawShipImage(Vehicle *v, int x, int y, VehicleID selection) |
|
617 |
{ |
|
618 |
int image = GetShipImage(v, 6); |
|
619 |
uint32 ormod = SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)); |
|
620 |
DrawSprite(image | ormod, x+32, y+10); |
|
621 |
||
622 |
if (v->index == selection) { |
|
623 |
DrawFrameRect(x-5, y-1, x+67, y+21, 15, 0x10); |
|
624 |
} |
|
625 |
} |
|
626 |
||
627 |
static void DrawShipDepotWindow(Window *w) |
|
628 |
{ |
|
629 |
uint tile; |
|
630 |
Vehicle *v; |
|
631 |
int num,x,y; |
|
632 |
Depot *d; |
|
633 |
||
634 |
tile = w->window_number; |
|
635 |
||
636 |
/* setup disabled buttons */ |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
637 |
w->disabled_state = (_map_owner[tile]==_local_player) ? 0 : ((1<<4)|(1<<7)); |
0 | 638 |
|
639 |
/* determine amount of items for scroller */ |
|
640 |
num = 0; |
|
641 |
FOR_ALL_VEHICLES(v) { |
|
642 |
if (v->type == VEH_Ship && v->u.ship.state == 0x80 && |
|
643 |
v->tile == (TileIndex)tile) |
|
644 |
num++; |
|
645 |
} |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
646 |
SetVScrollCount(w, (num + w->hscroll.cap - 1) / w->hscroll.cap); |
0 | 647 |
|
648 |
/* locate the depot struct */ |
|
877
a0849f41e748
(svn r1358) Assert bounds of depot list when searching for a depot
tron
parents:
867
diff
changeset
|
649 |
for (d = _depots; d->xy != (TileIndex)tile; d++) { |
a0849f41e748
(svn r1358) Assert bounds of depot list when searching for a depot
tron
parents:
867
diff
changeset
|
650 |
assert(d < endof(_depots); |
a0849f41e748
(svn r1358) Assert bounds of depot list when searching for a depot
tron
parents:
867
diff
changeset
|
651 |
} |
0 | 652 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
653 |
SetDParam(0, d->town_index); |
0 | 654 |
DrawWindowWidgets(w); |
655 |
||
656 |
x = 2; |
|
657 |
y = 15; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
658 |
num = w->vscroll.pos * w->hscroll.cap; |
0 | 659 |
|
660 |
FOR_ALL_VEHICLES(v) { |
|
661 |
if (v->type == VEH_Ship && |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
662 |
v->u.ship.state == 0x80 && |
0 | 663 |
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
|
664 |
--num < 0 && num >= -w->vscroll.cap * w->hscroll.cap) { |
0 | 665 |
|
666 |
DrawShipImage(v, x+19, y, WP(w,traindepot_d).sel); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
667 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
668 |
SetDParam(0, v->unitnumber); |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
669 |
DrawString(x, y+2, (uint16)(v->max_age-366) >= v->age ? STR_00E2 : STR_00E3, 0); |
0 | 670 |
|
671 |
DrawSprite( (v->vehstatus & VS_STOPPED) ? 0xC12 : 0xC13, x, y + 9); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
672 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
673 |
if ((x+=90) == 2 + 90 * w->hscroll.cap) { |
0 | 674 |
x = 2; |
675 |
y += 24; |
|
676 |
} |
|
677 |
} |
|
678 |
} |
|
679 |
} |
|
680 |
||
681 |
static int GetVehicleFromShipDepotWndPt(Window *w, int x, int y, Vehicle **veh) |
|
682 |
{ |
|
683 |
uint xt,yt,xm,ym; |
|
684 |
TileIndex tile; |
|
685 |
Vehicle *v; |
|
686 |
int pos; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
687 |
|
0 | 688 |
xt = x / 90; |
689 |
xm = x % 90; |
|
690 |
if (xt >= 5) |
|
691 |
return 1; |
|
692 |
||
693 |
yt = (y - 14) / 24; |
|
694 |
ym = (y - 14) % 24; |
|
695 |
if (yt >= 2) |
|
696 |
return 1; |
|
697 |
||
698 |
pos = (yt + w->vscroll.pos) * 3 + xt; |
|
699 |
||
700 |
tile = w->window_number; |
|
701 |
FOR_ALL_VEHICLES(v) { |
|
702 |
if (v->type == VEH_Ship && |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
703 |
v->vehstatus&VS_HIDDEN && |
0 | 704 |
v->tile == (TileIndex)tile && |
705 |
--pos < 0) { |
|
706 |
*veh = v; |
|
707 |
if (xm >= 19) |
|
708 |
return 0; |
|
709 |
if (ym <= 10) |
|
710 |
return -1; /* show window */ |
|
711 |
return -2; /* start stop */ |
|
712 |
} |
|
713 |
} |
|
714 |
||
715 |
return 1; /* outside */ |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
716 |
|
0 | 717 |
} |
718 |
||
719 |
static void ShipDepotClick(Window *w, int x, int y) |
|
720 |
{ |
|
721 |
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
|
722 |
int mode = GetVehicleFromShipDepotWndPt(w, x, y, &v); |
0 | 723 |
|
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
|
724 |
// 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
|
725 |
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
|
726 |
|
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
|
727 |
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
|
728 |
case 1: // invalid |
0 | 729 |
return; |
730 |
||
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
|
731 |
case 0: // start dragging of vehicle |
0 | 732 |
if (v != NULL) { |
733 |
WP(w,traindepot_d).sel = v->index; |
|
734 |
SetWindowDirty(w); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
735 |
SetObjectToPlaceWnd( SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)) + |
0 | 736 |
GetShipImage(v, 6), 4, w); |
737 |
} |
|
738 |
break; |
|
739 |
||
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
|
740 |
case -1: // show info window |
0 | 741 |
ShowShipViewWindow(v); |
742 |
break; |
|
743 |
||
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
|
744 |
case -2: // click start/stop flag |
0 | 745 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_SHIP | CMD_MSG(STR_9818_CAN_T_STOP_START_SHIP)); |
746 |
break; |
|
747 |
||
748 |
default: |
|
749 |
NOT_REACHED(); |
|
750 |
} |
|
751 |
} |
|
752 |
||
753 |
static void ShipDepotWndProc(Window *w, WindowEvent *e) { |
|
754 |
switch(e->event) { |
|
755 |
case WE_PAINT: |
|
756 |
DrawShipDepotWindow(w); |
|
757 |
break; |
|
758 |
||
759 |
case WE_CLICK: |
|
760 |
switch(e->click.widget) { |
|
757 | 761 |
case 3: |
0 | 762 |
ShipDepotClick(w, e->click.pt.x, e->click.pt.y); |
763 |
break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
764 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
765 |
case 7: |
0 | 766 |
ShowBuildShipWindow(w->window_number); |
767 |
break; |
|
768 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
769 |
case 8: /* scroll to tile */ |
0 | 770 |
ScrollMainWindowToTile(w->window_number); |
771 |
break; |
|
772 |
} |
|
773 |
break; |
|
774 |
||
775 |
case WE_DESTROY: |
|
776 |
DeleteWindowById(WC_BUILD_VEHICLE, w->window_number); |
|
777 |
break; |
|
778 |
||
779 |
case WE_DRAGDROP: { |
|
780 |
switch(e->click.widget) { |
|
757 | 781 |
case 3: { |
0 | 782 |
Vehicle *v; |
783 |
VehicleID sel = WP(w,traindepot_d).sel; |
|
784 |
||
785 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
786 |
SetWindowDirty(w); |
|
787 |
||
788 |
if (GetVehicleFromShipDepotWndPt(w, e->dragdrop.pt.x, e->dragdrop.pt.y, &v) == 0 && |
|
789 |
v != NULL && |
|
790 |
sel == v->index) { |
|
791 |
ShowShipViewWindow(v); |
|
792 |
} |
|
793 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
794 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
795 |
case 5: |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
796 |
if (!HASBIT(w->disabled_state, 5) && |
0 | 797 |
WP(w,traindepot_d).sel != INVALID_VEHICLE) { |
798 |
Vehicle *v; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
799 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
800 |
HandleButtonClick(w, 5); |
0 | 801 |
|
802 |
v = &_vehicles[WP(w,traindepot_d).sel]; |
|
803 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
804 |
||
805 |
_backup_orders_tile = v->tile; |
|
806 |
BackupVehicleOrders(v, _backup_orders_data); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
807 |
|
0 | 808 |
if (!DoCommandP(v->tile, v->index, 0, NULL, CMD_SELL_SHIP | CMD_MSG(STR_980C_CAN_T_SELL_SHIP))) |
809 |
_backup_orders_tile = 0; |
|
810 |
} |
|
811 |
break; |
|
812 |
default: |
|
813 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
814 |
SetWindowDirty(w); |
|
815 |
} |
|
816 |
break; |
|
817 |
} |
|
818 |
break; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
819 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
820 |
case WE_RESIZE: |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
821 |
w->vscroll.cap += e->sizing.diff.y / 24; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
822 |
w->hscroll.cap += e->sizing.diff.x / 90; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
823 |
w->widget[3].unkA = (w->vscroll.cap << 8) + w->hscroll.cap; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
824 |
break; |
0 | 825 |
} |
826 |
} |
|
827 |
||
828 |
static const Widget _ship_depot_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
829 |
{ 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
|
830 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 292, 0, 13, STR_9803_SHIP_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
|
831 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 293, 304, 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
|
832 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 269, 14, 61, 0x203, STR_981F_SHIPS_CLICK_ON_SHIP_FOR}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
833 |
{ WWT_PANEL, RESIZE_LRB, 14, 270, 293, 14, 13, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
834 |
{ WWT_IMGBTN, RESIZE_LRTB, 14, 270, 293, 14, 61, 0x2A9, STR_9821_DRAG_SHIP_TO_HERE_TO_SELL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
835 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 294, 304, 14, 61, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
836 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 146, 62, 73, STR_9804_NEW_SHIPS, STR_9820_BUILD_NEW_SHIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
837 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 147, 293, 62, 73, STR_00E4_LOCATION, STR_9822_CENTER_MAIN_VIEW_ON_SHIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
838 |
{ WWT_PANEL, RESIZE_RTB, 14, 294, 293, 62, 73, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
839 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 294, 304, 62, 73, 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
|
840 |
{ WIDGETS_END}, |
0 | 841 |
}; |
842 |
||
843 |
static const WindowDesc _ship_depot_desc = { |
|
844 |
-1, -1, 305, 74, |
|
845 |
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
|
846 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 847 |
_ship_depot_widgets, |
848 |
ShipDepotWndProc |
|
849 |
}; |
|
850 |
||
851 |
void ShowShipDepotWindow(uint tile) |
|
852 |
{ |
|
853 |
Window *w; |
|
854 |
||
855 |
w = AllocateWindowDescFront(&_ship_depot_desc,tile); |
|
856 |
if (w) { |
|
857 |
w->caption_color = _map_owner[w->window_number]; |
|
858 |
w->vscroll.cap = 2; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
859 |
w->hscroll.cap = 3; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
860 |
w->resize.step_width = 90; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
861 |
w->resize.step_height = 24; |
0 | 862 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
863 |
_backup_orders_tile = 0; |
|
864 |
} |
|
865 |
} |
|
866 |
||
867 |
||
868 |
static void DrawSmallShipSchedule(Vehicle *v, int x, int y) { |
|
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
869 |
Order *sched; |
0 | 870 |
int sel; |
871 |
Station *st; |
|
872 |
int i = 0; |
|
873 |
||
874 |
sel = v->cur_order_index; |
|
875 |
||
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
876 |
for (sched = v->schedule_ptr; sched->type != OT_NOTHING; ++sched) { |
0 | 877 |
if (sel == 0) { |
878 |
_stringwidth_base = 0xE0; |
|
879 |
DoDrawString( "\xAF", x-6, y, 16); |
|
880 |
_stringwidth_base = 0; |
|
881 |
} |
|
882 |
sel--; |
|
883 |
||
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
884 |
if (sched->type == OT_GOTO_STATION) { |
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
885 |
st = DEREF_STATION(sched->station); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
886 |
|
0 | 887 |
if (!(st->had_vehicle_of_type & HVOT_BUOY)) { |
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
888 |
SetDParam(0, sched->station); |
0 | 889 |
DrawString(x, y, STR_A036, 0); |
890 |
||
891 |
y += 6; |
|
892 |
if (++i == 4) |
|
893 |
break; |
|
894 |
} |
|
895 |
} |
|
896 |
} |
|
897 |
} |
|
898 |
||
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
899 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
900 |
static const Widget _player_ships_widgets[] = { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
901 |
{ 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
|
902 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 247, 0, 13, STR_9805_SHIPS, 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
|
903 |
{ 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
|
904 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_ORDER_TIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
905 |
{ WWT_PANEL, RESIZE_NONE, 14, 81, 232, 14, 25, 0x0, STR_SORT_CRITERIA_TIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
906 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 233, 243, 14, 25, STR_0225, STR_SORT_CRITERIA_TIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
907 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 244, 259, 14, 25, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
908 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 248, 26, 169, 0x401, STR_9823_SHIPS_CLICK_ON_SHIP_FOR}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
909 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 249, 259, 26, 169, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
910 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 124, 170, 181, STR_9804_NEW_SHIPS, STR_9824_BUILD_NEW_SHIPS_REQUIRES}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
911 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 125, 248, 170, 181, STR_REPLACE_VEHICLES, STR_REPLACE_HELP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
912 |
{ WWT_PANEL, RESIZE_RTB, 14, 249, 248, 170, 181, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
913 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 249, 259, 170, 181, 0x0, STR_RESIZE_BUTTON}, |
588 | 914 |
{ WIDGETS_END}, |
915 |
}; |
|
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
|
916 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
917 |
static const Widget _other_player_ships_widgets[] = { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
918 |
{ 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
|
919 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 247, 0, 13, STR_9805_SHIPS, 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
|
920 |
{ 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
|
921 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_ORDER_TIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
922 |
{ WWT_PANEL, RESIZE_NONE, 14, 81, 232, 14, 25, 0x0, STR_SORT_CRITERIA_TIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
923 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 233, 243, 14, 25, STR_0225, STR_SORT_CRITERIA_TIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
924 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 244, 259, 14, 25, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
925 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 248, 26, 169, 0x401, STR_9823_SHIPS_CLICK_ON_SHIP_FOR}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
926 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 249, 259, 26, 169, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
927 |
{ WWT_PANEL, RESIZE_RTB, 14, 249, 248, 170, 181, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
928 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 249, 259, 170, 181, 0x0, STR_RESIZE_BUTTON}, |
588 | 929 |
{ WIDGETS_END}, |
930 |
}; |
|
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
|
931 |
|
0 | 932 |
static void PlayerShipsWndProc(Window *w, WindowEvent *e) |
933 |
{ |
|
588 | 934 |
int station = (int)w->window_number >> 16; |
935 |
int owner = w->window_number & 0xff; |
|
936 |
vehiclelist_d *vl = &WP(w, vehiclelist_d); |
|
937 |
||
0 | 938 |
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
|
939 |
case WE_PAINT: { |
588 | 940 |
int x = 2; |
941 |
int y = PLY_WND_PRC__OFFSET_TOP_WIDGET; |
|
942 |
int max; |
|
943 |
int i; |
|
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
944 |
|
588 | 945 |
BuildVehicleList(vl, VEH_Ship, owner, station); |
946 |
SortVehicleList(vl); |
|
0 | 947 |
|
588 | 948 |
SetVScrollCount(w, vl->list_length); |
949 |
||
950 |
// disable 'Sort By' tooltip on Unsorted sorting criteria |
|
951 |
if (vl->sort_type == SORT_BY_UNSORTED) |
|
757 | 952 |
w->disabled_state |= (1 << 3); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
953 |
|
0 | 954 |
/* draw the widgets */ |
955 |
{ |
|
588 | 956 |
const Player *p = DEREF_PLAYER(owner); |
957 |
if (station == -1) { |
|
958 |
/* Company Name -- (###) Trains */ |
|
959 |
SetDParam(0, p->name_1); |
|
960 |
SetDParam(1, p->name_2); |
|
961 |
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
|
962 |
w->widget[1].unkA = STR_9805_SHIPS; |
588 | 963 |
} else { |
964 |
/* Station Name -- (###) Trains */ |
|
965 |
SetDParam(0, DEREF_STATION(station)->index); |
|
966 |
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
|
967 |
w->widget[1].unkA = STR_SCHEDULED_SHIPS; |
588 | 968 |
} |
0 | 969 |
DrawWindowWidgets(w); |
970 |
} |
|
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
971 |
/* draw sorting criteria string */ |
588 | 972 |
DrawString(85, 15, _vehicle_sort_listing[vl->sort_type], 0x10); |
973 |
/* draw arrow pointing up/down for ascending/descending sorting */ |
|
974 |
DoDrawString( |
|
975 |
vl->flags & VL_DESC ? "\xAA" : "\xA0", 69, 15, 0x10); |
|
0 | 976 |
|
588 | 977 |
max = min(w->vscroll.pos + w->vscroll.cap, vl->list_length); |
978 |
for (i = w->vscroll.pos; i < max; ++i) { |
|
979 |
Vehicle *v = DEREF_VEHICLE(vl->sort_list[i].index); |
|
980 |
StringID str; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
981 |
|
588 | 982 |
assert(v->type == VEH_Ship); |
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
|
983 |
|
588 | 984 |
DrawShipImage(v, x + 19, y + 6, INVALID_VEHICLE); |
985 |
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
|
986 |
|
588 | 987 |
SetDParam(0, v->unitnumber); |
988 |
if (IsShipDepotTile(v->tile)) |
|
989 |
str = STR_021F; |
|
990 |
else |
|
991 |
str = v->age > v->max_age - 366 ? STR_00E3 : STR_00E2; |
|
992 |
DrawString(x, y + 2, str, 0); |
|
993 |
||
994 |
SetDParam(0, v->profit_this_year); |
|
995 |
SetDParam(1, v->profit_last_year); |
|
996 |
DrawString(x + 12, y + 28, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 0); |
|
997 |
||
998 |
if (v->string_id != STR_SV_SHIP_NAME) { |
|
999 |
SetDParam(0, v->string_id); |
|
1000 |
DrawString(x + 12, y, STR_01AB, 0); |
|
0 | 1001 |
} |
588 | 1002 |
|
1003 |
DrawSmallShipSchedule(v, x + 138, y); |
|
1004 |
||
1005 |
y += PLY_WND_PRC__SIZE_OF_ROW_BIG; |
|
0 | 1006 |
} |
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
|
1007 |
} break; |
0 | 1008 |
|
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
|
1009 |
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
|
1010 |
switch(e->click.widget) { |
757 | 1011 |
case 3: /* Flip sorting method ascending/descending */ |
588 | 1012 |
vl->flags ^= VL_DESC; |
1013 |
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
|
1014 |
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
|
1015 |
break; |
757 | 1016 |
case 4: case 5:/* Select sorting criteria dropdown menu */ |
842 | 1017 |
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
|
1018 |
return; |
757 | 1019 |
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
|
1020 |
uint32 id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_BIG; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1021 |
|
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
|
1022 |
if (id_v >= w->vscroll.cap) { return;} // click out of bounds |
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
|
1023 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1024 |
id_v += w->vscroll.pos; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1025 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1026 |
{ |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1027 |
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
|
1028 |
|
588 | 1029 |
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
|
1030 |
|
588 | 1031 |
v = DEREF_VEHICLE(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
|
1032 |
|
588 | 1033 |
assert(v->type == VEH_Ship); |
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
|
1034 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1035 |
ShowShipViewWindow(v); |
0 | 1036 |
} |
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
|
1037 |
} 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
|
1038 |
|
757 | 1039 |
case 9: { /* Build new Vehicle */ |
0 | 1040 |
uint tile; |
1041 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1042 |
if (!IsWindowOfPrototype(w, _player_ships_widgets)) |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1043 |
break; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1044 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1045 |
|
0 | 1046 |
tile = _last_built_ship_depot_tile; |
1047 |
do { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1048 |
if (_map_owner[tile] == _local_player && IsShipDepotTile(tile)) { |
0 | 1049 |
ShowShipDepotWindow(tile); |
1050 |
ShowBuildShipWindow(tile); |
|
1051 |
return; |
|
1052 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1053 |
|
0 | 1054 |
tile = TILE_MASK(tile + 1); |
1055 |
} while(tile != _last_built_ship_depot_tile); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1056 |
|
0 | 1057 |
ShowBuildShipWindow(0); |
1058 |
} break; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1059 |
|
842 | 1060 |
case 10: { |
1061 |
ShowReplaceVehicleWindow(VEH_Ship); |
|
1062 |
break; |
|
0 | 1063 |
} |
842 | 1064 |
} |
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
|
1065 |
} 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
|
1066 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1067 |
case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */ |
588 | 1068 |
if (vl->sort_type != e->dropdown.index) { |
1069 |
// value has changed -> resort |
|
1070 |
vl->flags |= VL_RESORT; |
|
1071 |
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
|
1072 |
|
588 | 1073 |
// enable 'Sort By' if a sorter criteria is chosen |
1074 |
if (vl->sort_type != SORT_BY_UNSORTED) |
|
757 | 1075 |
w->disabled_state &= ~(1 << 3); |
588 | 1076 |
} |
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
|
1077 |
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
|
1078 |
break; |
588 | 1079 |
|
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
|
1080 |
case WE_CREATE: /* set up resort timer */ |
588 | 1081 |
vl->sort_list = NULL; |
1082 |
vl->flags = VL_REBUILD; |
|
1083 |
vl->sort_type = SORT_BY_UNSORTED; |
|
1084 |
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
|
1085 |
break; |
588 | 1086 |
|
767 | 1087 |
case WE_DESTROY: |
1088 |
free(vl->sort_list); |
|
1089 |
break; |
|
1090 |
||
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
|
1091 |
case WE_TICK: /* resort the list every 20 seconds orso (10 days) */ |
588 | 1092 |
if (--vl->resort_timer == 0) { |
1093 |
DEBUG(misc, 1) ("Periodic resort ships list player %d station %d", |
|
1094 |
owner, station); |
|
1095 |
vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; |
|
1096 |
vl->flags |= VL_RESORT; |
|
1097 |
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
|
1098 |
} |
0 | 1099 |
break; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1100 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1101 |
case WE_RESIZE: |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1102 |
/* Update the scroll + matrix */ |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1103 |
w->vscroll.cap += e->sizing.diff.y / PLY_WND_PRC__SIZE_OF_ROW_BIG; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1104 |
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
|
1105 |
break; |
0 | 1106 |
} |
1107 |
} |
|
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
1108 |
|
0 | 1109 |
static const WindowDesc _player_ships_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
|
1110 |
-1, -1, 260, 182, |
0 | 1111 |
WC_SHIPS_LIST,0, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1112 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 1113 |
_player_ships_widgets, |
1114 |
PlayerShipsWndProc |
|
1115 |
}; |
|
1116 |
||
1117 |
static const WindowDesc _other_player_ships_desc = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1118 |
-1, -1, 260, 182, |
0 | 1119 |
WC_SHIPS_LIST,0, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1120 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 1121 |
_other_player_ships_widgets, |
1122 |
PlayerShipsWndProc |
|
1123 |
}; |
|
1124 |
||
1125 |
||
588 | 1126 |
void ShowPlayerShips(int player, int station) |
0 | 1127 |
{ |
1128 |
Window *w; |
|
1129 |
||
1130 |
if ( player == _local_player) { |
|
588 | 1131 |
w = AllocateWindowDescFront(&_player_ships_desc, (station << 16) | player); |
0 | 1132 |
} else { |
588 | 1133 |
w = AllocateWindowDescFront(&_other_player_ships_desc, (station << 16) | player); |
0 | 1134 |
} |
1135 |
if (w) { |
|
1136 |
w->caption_color = w->window_number; |
|
1137 |
w->vscroll.cap = 4; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1138 |
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
|
1139 |
w->resize.step_height = PLY_WND_PRC__SIZE_OF_ROW_BIG; |
0 | 1140 |
} |
1141 |
} |