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