author | bjarni |
Sat, 22 Jan 2005 23:55:45 +0000 | |
changeset 1099 | ad7522bd5c1c |
parent 1055 | cc4f60cc9102 |
child 1209 | 2e00193652b2 |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
2 |
#include "ttd.h" |
|
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
382
diff
changeset
|
3 |
#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
|
4 |
#include "map.h" |
0 | 5 |
#include "window.h" |
6 |
#include "gui.h" |
|
7 |
#include "vehicle.h" |
|
8 |
#include "gfx.h" |
|
9 |
#include "station.h" |
|
10 |
#include "command.h" |
|
11 |
#include "engine.h" |
|
12 |
#include "viewport.h" |
|
13 |
#include "player.h" |
|
14 |
||
15 |
||
842 | 16 |
void Set_DPARAM_Aircraft_Build_Window(uint16 engine_number) |
17 |
{ |
|
18 |
const AircraftVehicleInfo *avi = AircraftVehInfo(engine_number); |
|
19 |
Engine *e; |
|
20 |
YearMonthDay ymd; |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
21 |
|
842 | 22 |
SetDParam(0, avi->base_cost * (_price.aircraft_base>>3)>>5); |
23 |
SetDParam(1, avi->max_speed * 8); |
|
922
10035216cbaf
(svn r1410) Replaced all occurences of 'passanger' by 'passenger' in the code
celestar
parents:
919
diff
changeset
|
24 |
SetDParam(2, avi->passenger_capacity); |
842 | 25 |
SetDParam(3, avi->mail_capacity); |
26 |
SetDParam(4, avi->running_cost * _price.aircraft_running >> 8); |
|
27 |
||
28 |
e = &_engines[engine_number]; |
|
29 |
SetDParam(6, e->lifelength); |
|
30 |
SetDParam(7, e->reliability * 100 >> 16); |
|
31 |
ConvertDayToYMD(&ymd, e->intro_date); |
|
32 |
SetDParam(5, ymd.year + 1920); |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
33 |
|
842 | 34 |
} |
35 |
||
0 | 36 |
static void DrawAircraftImage(Vehicle *v, int x, int y, VehicleID selection) |
37 |
{ |
|
38 |
int image = GetAircraftImage(v, 6); |
|
39 |
uint32 ormod = SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)); |
|
40 |
if (v->vehstatus & VS_CRASHED) ormod = 0x3248000; |
|
41 |
DrawSprite(image | ormod, x+25, y+10); |
|
42 |
if (v->subtype == 0) |
|
43 |
DrawSprite(0xF3D, x+25, y+5); |
|
44 |
if (v->index == selection) { |
|
45 |
DrawFrameRect(x-1, y-1, x+58, y+21, 0xF, 0x10); |
|
46 |
} |
|
47 |
} |
|
48 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
538
diff
changeset
|
49 |
void CcBuildAircraft(bool success, uint tile, uint32 p1, uint32 p2) |
0 | 50 |
{ |
51 |
Vehicle *v; |
|
52 |
||
53 |
if (success) { |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
54 |
v = GetVehicle(_new_aircraft_id); |
0 | 55 |
if (v->tile == _backup_orders_tile) { |
56 |
_backup_orders_tile = 0; |
|
57 |
RestoreVehicleOrders(v, _backup_orders_data); |
|
58 |
} |
|
59 |
ShowAircraftViewWindow(v); |
|
60 |
} |
|
61 |
} |
|
62 |
||
63 |
||
64 |
static void NewAircraftWndProc(Window *w, WindowEvent *e) |
|
65 |
{ |
|
66 |
switch(e->event) { |
|
67 |
||
68 |
case WE_PAINT: { |
|
69 |
if (w->window_number == 0) |
|
70 |
SETBIT(w->disabled_state, 5); |
|
71 |
||
72 |
{ |
|
73 |
int count = 0; |
|
74 |
int num = NUM_AIRCRAFT_ENGINES; |
|
75 |
Engine *e = &_engines[AIRCRAFT_ENGINES_INDEX]; |
|
76 |
do { |
|
77 |
if (HASBIT(e->player_avail, _local_player)) |
|
78 |
count++; |
|
79 |
} while (++e,--num); |
|
80 |
SetVScrollCount(w, count); |
|
81 |
} |
|
82 |
||
83 |
DrawWindowWidgets(w); |
|
84 |
||
85 |
{ |
|
86 |
int num = NUM_AIRCRAFT_ENGINES; |
|
87 |
Engine *e = &_engines[AIRCRAFT_ENGINES_INDEX]; |
|
88 |
int x = 2; |
|
89 |
int y = 15; |
|
90 |
int sel = WP(w,buildtrain_d).sel_index; |
|
91 |
int pos = w->vscroll.pos; |
|
92 |
int engine_id = AIRCRAFT_ENGINES_INDEX; |
|
93 |
int selected_id = -1; |
|
94 |
||
95 |
do { |
|
96 |
if (HASBIT(e->player_avail, _local_player)) { |
|
97 |
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
|
98 |
if (IS_INT_INSIDE(--pos, -w->vscroll.cap, 0)) { |
0 | 99 |
DrawString(x+62, y+7, GetCustomEngineName(engine_id), sel==0 ? 0xC : 0x10); |
100 |
DrawAircraftEngine(x+29, y+10, engine_id, SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player))); |
|
101 |
y += 24; |
|
102 |
} |
|
103 |
sel--; |
|
104 |
} |
|
105 |
} while (++engine_id, ++e,--num); |
|
106 |
||
107 |
WP(w,buildtrain_d).sel_engine = selected_id; |
|
108 |
||
109 |
if (selected_id != -1) { |
|
842 | 110 |
Set_DPARAM_Aircraft_Build_Window(selected_id); |
0 | 111 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
112 |
DrawString(2, w->widget[4].top + 1, STR_A007_COST_SPEED_CAPACITY_PASSENGERS, 0); |
0 | 113 |
} |
114 |
} |
|
115 |
} break; |
|
116 |
||
117 |
case WE_CLICK: |
|
118 |
switch(e->click.widget) { |
|
119 |
case 2: { /* listbox */ |
|
120 |
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
|
121 |
if (i < w->vscroll.cap) { |
0 | 122 |
WP(w,buildtrain_d).sel_index = i + w->vscroll.pos; |
123 |
SetWindowDirty(w); |
|
124 |
} |
|
125 |
} break; |
|
126 |
||
127 |
case 5: { /* build */ |
|
128 |
int sel_eng = WP(w,buildtrain_d).sel_engine; |
|
129 |
if (sel_eng != -1) |
|
130 |
DoCommandP(w->window_number, sel_eng, 0, CcBuildAircraft, CMD_BUILD_AIRCRAFT | CMD_MSG(STR_A008_CAN_T_BUILD_AIRCRAFT)); |
|
131 |
} break; |
|
132 |
||
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:
924
diff
changeset
|
133 |
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:
924
diff
changeset
|
134 |
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:
924
diff
changeset
|
135 |
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:
924
diff
changeset
|
136 |
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:
924
diff
changeset
|
137 |
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:
924
diff
changeset
|
138 |
STR_A039_RENAME_AIRCRAFT_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:
924
diff
changeset
|
139 |
} |
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:
924
diff
changeset
|
140 |
} break; |
0 | 141 |
} |
142 |
break; |
|
143 |
||
144 |
case WE_4: |
|
145 |
if (w->window_number != 0 && !FindWindowById(WC_VEHICLE_DEPOT, w->window_number)) { |
|
146 |
DeleteWindow(w); |
|
147 |
} |
|
148 |
break; |
|
149 |
||
150 |
case WE_ON_EDIT_TEXT: { |
|
151 |
byte *b = e->edittext.str; |
|
152 |
if (*b == 0) |
|
153 |
return; |
|
154 |
memcpy(_decode_parameters, b, 32); |
|
155 |
DoCommandP(0, WP(w,buildtrain_d).rename_engine, 0, NULL, CMD_RENAME_ENGINE | CMD_MSG(STR_A03A_CAN_T_RENAME_AIRCRAFT_TYPE)); |
|
156 |
} break; |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
157 |
|
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
158 |
case WE_RESIZE: |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
159 |
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
|
160 |
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
|
161 |
break; |
0 | 162 |
} |
163 |
} |
|
164 |
||
165 |
static const Widget _new_aircraft_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
166 |
{ 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
|
167 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 239, 0, 13, STR_A005_NEW_AIRCRAFT, 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
|
168 |
{ WWT_MATRIX, RESIZE_BOTTOM, 14, 0, 227, 14, 109, 0x401, STR_A025_AIRCRAFT_SELECTION_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
|
169 |
{ WWT_SCROLLBAR, RESIZE_BOTTOM, 14, 228, 239, 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
|
170 |
{ WWT_IMGBTN, RESIZE_TB, 14, 0, 239, 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
|
171 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 114, 162, 173, STR_A006_BUILD_AIRCRAFT, STR_A026_BUILD_THE_HIGHLIGHTED_AIRCRAFT}, |
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
|
172 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 115, 227, 162, 173, STR_A037_RENAME, STR_A038_RENAME_AIRCRAFT_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
|
173 |
{ WWT_RESIZEBOX, RESIZE_TB, 14, 228, 239, 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
|
174 |
{ WIDGETS_END}, |
0 | 175 |
}; |
176 |
||
177 |
static const WindowDesc _new_aircraft_desc = { |
|
178 |
-1, -1, 240, 174, |
|
179 |
WC_BUILD_VEHICLE,0, |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
180 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
0 | 181 |
_new_aircraft_widgets, |
182 |
NewAircraftWndProc |
|
183 |
}; |
|
184 |
||
185 |
static void ShowBuildAircraftWindow(uint tile) |
|
186 |
{ |
|
187 |
Window *w; |
|
188 |
||
189 |
DeleteWindowById(WC_BUILD_VEHICLE, tile); |
|
190 |
||
191 |
w = AllocateWindowDesc(&_new_aircraft_desc); |
|
192 |
w->window_number = tile; |
|
193 |
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
|
194 |
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
|
195 |
|
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
196 |
w->resize.step_height = 24; |
0 | 197 |
|
198 |
if (tile != 0) { |
|
199 |
w->caption_color = _map_owner[tile]; |
|
200 |
} else { |
|
201 |
w->caption_color = _local_player; |
|
202 |
} |
|
203 |
} |
|
204 |
||
924
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
205 |
#define MAX_REFIT 0xFF |
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
206 |
|
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
982
diff
changeset
|
207 |
const byte _aircraft_refit_normal[] = { |
924
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
208 |
CT_PASSENGERS, |
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
209 |
CT_MAIL, |
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
210 |
CT_GOODS, |
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
211 |
CT_VALUABLES, |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
982
diff
changeset
|
212 |
MAX_REFIT |
924
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
213 |
}; |
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
214 |
|
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
982
diff
changeset
|
215 |
const byte _aircraft_refit_arctic[] = { |
924
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
216 |
CT_PASSENGERS, |
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
217 |
CT_MAIL, |
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
218 |
CT_GOODS, |
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
219 |
CT_FOOD, |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
982
diff
changeset
|
220 |
MAX_REFIT |
924
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
221 |
}; |
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
222 |
|
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
982
diff
changeset
|
223 |
const byte _aircraft_refit_desert[] = { |
924
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
224 |
CT_PASSENGERS, |
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
225 |
CT_MAIL, |
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
226 |
CT_FRUIT, |
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
227 |
CT_GOODS, |
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
228 |
CT_DIAMONDS, |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
982
diff
changeset
|
229 |
MAX_REFIT |
924
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
230 |
}; |
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
231 |
|
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
982
diff
changeset
|
232 |
const byte _aircraft_refit_candy[] = { |
924
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
233 |
CT_PASSENGERS, |
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
234 |
CT_SUGAR, |
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
235 |
CT_TOYS, |
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
236 |
CT_CANDY, |
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
237 |
CT_COLA, |
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
238 |
CT_COTTON_CANDY, |
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
239 |
CT_BUBBLES, |
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
240 |
CT_TOFFEE, |
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
241 |
CT_BATTERIES, |
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
242 |
CT_PLASTIC, |
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
243 |
CT_FIZZY_DRINKS, |
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
244 |
MAX_REFIT |
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
245 |
}; |
0 | 246 |
|
247 |
const byte * const _aircraft_refit_types[4] = { |
|
248 |
_aircraft_refit_normal, _aircraft_refit_arctic, _aircraft_refit_desert, _aircraft_refit_candy |
|
249 |
}; |
|
250 |
||
924
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
251 |
#undef MAX_REFIT |
6fbd4419db2a
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents:
922
diff
changeset
|
252 |
|
0 | 253 |
static void AircraftRefitWndProc(Window *w, WindowEvent *e) |
254 |
{ |
|
255 |
switch(e->event) { |
|
256 |
case WE_PAINT: { |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
257 |
Vehicle *v = GetVehicle(w->window_number); |
0 | 258 |
const byte *b; |
259 |
int sel; |
|
260 |
int x,y; |
|
261 |
byte color; |
|
262 |
int cargo; |
|
263 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
264 |
SetDParam(0, v->string_id); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
265 |
SetDParam(1, v->unitnumber); |
0 | 266 |
DrawWindowWidgets(w); |
267 |
||
268 |
DrawString(1, 15, STR_A040_SELECT_CARGO_TYPE_TO_CARRY, 0); |
|
269 |
||
381
527e47c8feec
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
243
diff
changeset
|
270 |
/* TODO: Support for custom GRFSpecial-specified refitting! --pasky */ |
527e47c8feec
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
243
diff
changeset
|
271 |
|
0 | 272 |
cargo = -1; |
273 |
x = 6; |
|
274 |
y = 25; |
|
275 |
sel = WP(w,refit_d).sel; |
|
382
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
276 |
|
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
277 |
#define show_cargo(ctype) { \ |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
278 |
color = 16; \ |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
279 |
if (sel == 0) { \ |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
280 |
cargo = ctype; \ |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
281 |
color = 12; \ |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
282 |
} \ |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
283 |
sel--; \ |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
284 |
DrawString(x, y, _cargoc.names_s[ctype], color); \ |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
285 |
y += 10; \ |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
286 |
} |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
287 |
|
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
288 |
if (_engine_refit_masks[v->engine_type]) { |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
289 |
uint32 mask = _engine_refit_masks[v->engine_type]; |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
290 |
int cid = 0; |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
291 |
|
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
292 |
for (; mask; mask >>= 1, cid++) { |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
293 |
if (!(mask & 1)) // not this cid |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
294 |
continue; |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
295 |
if (!(_local_cargo_id_landscape[cid] & (1 << _opt.landscape))) // not in this landscape |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
296 |
continue; |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
297 |
|
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
298 |
show_cargo(_local_cargo_id_ctype[cid]); |
0 | 299 |
} |
382
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
300 |
|
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
301 |
} else { // generic refit list |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
302 |
b = _aircraft_refit_types[_opt.landscape]; |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
303 |
do { |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
304 |
show_cargo(*b); |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
305 |
} while (*++b != 0xFF); |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
306 |
} |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
307 |
|
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
308 |
#undef show_cargo |
0 | 309 |
|
310 |
WP(w,refit_d).cargo = cargo; |
|
311 |
||
312 |
if (cargo != -1) { |
|
313 |
int32 cost = DoCommandByTile(v->tile, v->index, cargo, DC_QUERY_COST, CMD_REFIT_AIRCRAFT); |
|
314 |
if (cost != CMD_ERROR) { |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
315 |
SetDParam(2, cost); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
316 |
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
|
317 |
SetDParam(1, _aircraft_refit_capacity); |
0 | 318 |
DrawString(1, 137, STR_A041_NEW_CAPACITY_COST_OF_REFIT, 0); |
319 |
} |
|
320 |
} |
|
321 |
||
322 |
break; |
|
323 |
} |
|
324 |
||
325 |
case WE_CLICK: |
|
326 |
switch(e->click.widget) { |
|
327 |
case 2: { /* listbox */ |
|
328 |
int y = e->click.pt.y - 25; |
|
329 |
if (y >= 0) { |
|
330 |
WP(w,refit_d).sel = y / 10; |
|
331 |
SetWindowDirty(w); |
|
332 |
} |
|
333 |
} break; |
|
334 |
case 4: /* refit button */ |
|
335 |
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
|
336 |
Vehicle *v = GetVehicle(w->window_number); |
0 | 337 |
if (DoCommandP(v->tile, v->index, WP(w,refit_d).cargo, NULL, CMD_REFIT_AIRCRAFT | CMD_MSG(STR_A042_CAN_T_REFIT_AIRCRAFT))) |
338 |
DeleteWindow(w); |
|
339 |
} |
|
340 |
break; |
|
341 |
} |
|
342 |
break; |
|
343 |
} |
|
344 |
} |
|
345 |
||
346 |
static const Widget _aircraft_refit_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
347 |
{ 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
|
348 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 239, 0, 13, STR_A03C_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
|
349 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 239, 14, 135, 0x0, STR_A03E_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
|
350 |
{ 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
|
351 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 239, 158, 169, STR_A03D_REFIT_AIRCRAFT, STR_A03F_REFIT_AIRCRAFT_TO_CARRY}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
352 |
{ WIDGETS_END}, |
0 | 353 |
}; |
354 |
||
355 |
static const WindowDesc _aircraft_refit_desc = { |
|
356 |
-1,-1, 240, 170, |
|
357 |
WC_VEHICLE_REFIT,WC_VEHICLE_VIEW, |
|
358 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
359 |
_aircraft_refit_widgets, |
|
360 |
AircraftRefitWndProc |
|
361 |
}; |
|
362 |
||
363 |
static void ShowAircraftRefitWindow(Vehicle *v) |
|
364 |
{ |
|
365 |
Window *w; |
|
366 |
||
367 |
DeleteWindowById(WC_VEHICLE_REFIT, v->index); |
|
368 |
||
369 |
_alloc_wnd_parent_num = v->index; |
|
370 |
w = AllocateWindowDesc(&_aircraft_refit_desc); |
|
371 |
w->window_number = v->index; |
|
372 |
w->caption_color = v->owner; |
|
373 |
WP(w,refit_d).sel = -1; |
|
374 |
} |
|
375 |
||
376 |
static void AircraftDetailsWndProc(Window *w, WindowEvent *e) |
|
377 |
{ |
|
378 |
int mod; |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
379 |
Vehicle *v = GetVehicle(w->window_number), *u; |
0 | 380 |
|
381 |
switch(e->event) { |
|
382 |
case WE_PAINT: |
|
383 |
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
|
384 |
if (!_patches.servint_aircraft) // 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
|
385 |
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
|
386 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
387 |
SetDParam(0, v->string_id); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
388 |
SetDParam(1, v->unitnumber); |
0 | 389 |
DrawWindowWidgets(w); |
390 |
||
391 |
/* Draw running cost */ |
|
392 |
{ |
|
393 |
int year = v->age / 366; |
|
394 |
StringID str; |
|
395 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
396 |
SetDParam(1, year); |
0 | 397 |
|
398 |
str = STR_0199_YEAR; |
|
399 |
if (year != 1) { |
|
400 |
str++; |
|
401 |
if (v->max_age - 366 < v->age) |
|
402 |
str++; |
|
403 |
} |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
404 |
SetDParam(0, str); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
405 |
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
|
406 |
SetDParam(3, _price.aircraft_running * AircraftVehInfo(v->engine_type)->running_cost >> 8); |
0 | 407 |
DrawString(2, 15, STR_A00D_AGE_RUNNING_COST_YR, 0); |
408 |
} |
|
409 |
||
410 |
/* Draw max speed */ |
|
411 |
{ |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
412 |
SetDParam(0, v->max_speed * 8); |
0 | 413 |
DrawString(2, 25, STR_A00E_MAX_SPEED, 0); |
414 |
} |
|
415 |
||
416 |
/* Draw profit */ |
|
417 |
{ |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
418 |
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
|
419 |
SetDParam(1, v->profit_last_year); |
0 | 420 |
DrawString(2, 35, STR_A00F_PROFIT_THIS_YEAR_LAST_YEAR, 0); |
421 |
} |
|
422 |
||
423 |
/* Draw breakdown & reliability */ |
|
424 |
{ |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
425 |
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
|
426 |
SetDParam(1, v->breakdowns_since_last_service); |
0 | 427 |
DrawString(2, 45, STR_A010_RELIABILITY_BREAKDOWNS, 0); |
428 |
} |
|
429 |
||
430 |
/* Draw service interval text */ |
|
431 |
{ |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
432 |
SetDParam(0, v->service_interval); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
433 |
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
|
434 |
DrawString(13, 103, _patches.servint_ispercent?STR_SERVICING_INTERVAL_PERCENT:STR_883C_SERVICING_INTERVAL_DAYS, 0); |
0 | 435 |
} |
436 |
||
437 |
DrawAircraftImage(v, 3, 57, INVALID_VEHICLE); |
|
438 |
||
439 |
{ |
|
440 |
int y = 57; |
|
441 |
||
442 |
do { |
|
443 |
if (v->subtype <= 2) { |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
444 |
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
|
445 |
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
|
446 |
SetDParam(2, v->value); |
0 | 447 |
DrawString(60, y, STR_A011_BUILT_VALUE, 0); |
448 |
y += 10; |
|
449 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
450 |
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
|
451 |
SetDParam(1, v->cargo_cap); |
0 | 452 |
u = v->next; |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
453 |
SetDParam(2, _cargoc.names_long_p[u->cargo_type]); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
454 |
SetDParam(3, u->cargo_cap); |
0 | 455 |
DrawString(60, y, STR_A019_CAPACITY + (u->cargo_cap == 0), 0); |
456 |
y += 14; |
|
457 |
} |
|
458 |
||
459 |
if (v->cargo_count != 0) { |
|
460 |
||
461 |
/* Cargo names (fix pluralness) */ |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
462 |
SetDParam(0, v->cargo_type); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
463 |
SetDParam(1, v->cargo_count); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
464 |
SetDParam(2, v->cargo_source); |
0 | 465 |
DrawString(60, y, STR_8813_FROM, 0); |
466 |
||
467 |
y += 10; |
|
468 |
} |
|
469 |
} while ( (v=v->next) != NULL); |
|
470 |
} |
|
471 |
break; |
|
472 |
||
473 |
case WE_CLICK: |
|
474 |
switch(e->click.widget) { |
|
475 |
case 2: /* rename */ |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
476 |
SetDParam(0, v->unitnumber); |
0 | 477 |
ShowQueryString(v->string_id, STR_A030_NAME_AIRCRAFT, 31, 150, w->window_class, w->window_number); |
478 |
break; |
|
479 |
||
480 |
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
|
481 |
mod = _ctrl_pressed? 5 : 10; |
0 | 482 |
goto change_int; |
483 |
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
|
484 |
mod = _ctrl_pressed?- 5 : -10; |
0 | 485 |
change_int: |
486 |
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
|
487 |
|
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
|
488 |
/* %-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
|
489 |
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
|
490 |
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
|
491 |
if (mod == v->service_interval) |
0 | 492 |
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
|
493 |
|
0 | 494 |
DoCommandP(v->tile, v->index, mod, NULL, |
495 |
CMD_CHANGE_AIRCRAFT_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING)); |
|
496 |
break; |
|
497 |
} |
|
498 |
break; |
|
499 |
||
500 |
case WE_4: |
|
501 |
if (FindWindowById(WC_VEHICLE_VIEW, w->window_number) == NULL) |
|
502 |
DeleteWindow(w); |
|
503 |
break; |
|
504 |
||
505 |
case WE_ON_EDIT_TEXT: { |
|
506 |
byte *b = e->edittext.str; |
|
507 |
if (*b == 0) |
|
508 |
return; |
|
509 |
memcpy(_decode_parameters, b, 32); |
|
510 |
DoCommandP(0, w->window_number, 0, NULL, CMD_NAME_VEHICLE | CMD_MSG(STR_A031_CAN_T_NAME_AIRCRAFT)); |
|
511 |
} break; |
|
512 |
||
513 |
} |
|
514 |
} |
|
515 |
||
516 |
||
517 |
static const Widget _aircraft_details_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
518 |
{ 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
|
519 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 349, 0, 13, STR_A00C_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
|
520 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 350, 389, 0, 13, STR_01AA_NAME, STR_A032_NAME_AIRCRAFT}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
521 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 389, 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
|
522 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 389, 56, 101, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
523 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 10, 102, 107, 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
|
524 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 10, 108, 113, 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
|
525 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 11, 389, 102, 113, 0x0, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
526 |
{ WIDGETS_END}, |
0 | 527 |
}; |
528 |
||
529 |
static const WindowDesc _aircraft_details_desc = { |
|
530 |
-1,-1, 390, 114, |
|
531 |
WC_VEHICLE_DETAILS,WC_VEHICLE_VIEW, |
|
532 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
533 |
_aircraft_details_widgets, |
|
534 |
AircraftDetailsWndProc |
|
535 |
}; |
|
536 |
||
537 |
||
538 |
static void ShowAircraftDetailsWindow(Vehicle *v) |
|
539 |
{ |
|
540 |
Window *w; |
|
541 |
VehicleID veh = v->index; |
|
542 |
||
543 |
DeleteWindowById(WC_VEHICLE_ORDERS, veh); |
|
544 |
DeleteWindowById(WC_VEHICLE_DETAILS, veh); |
|
545 |
||
546 |
_alloc_wnd_parent_num = veh; |
|
547 |
w = AllocateWindowDesc(&_aircraft_details_desc); |
|
548 |
w->window_number = veh; |
|
549 |
w->caption_color = v->owner; |
|
550 |
// w->vscroll.cap = 6; |
|
551 |
// w->traindetails_d.tab = 0; |
|
552 |
} |
|
553 |
||
554 |
||
555 |
static const Widget _aircraft_view_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
556 |
{ 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
|
557 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 237, 0, 13, STR_A00A, 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
|
558 |
{ WWT_STICKYBOX, RESIZE_NONE, 14, 238, 249, 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
|
559 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 231, 14, 103, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
560 |
{ WWT_6, RESIZE_NONE, 14, 2, 229, 16, 101, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
561 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 0, 249, 104, 115, 0x0, STR_A027_CURRENT_AIRCRAFT_ACTION}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
562 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 232, 249, 14, 31, 0x2AB, STR_A029_CENTER_MAIN_VIEW_ON_AIRCRAFT}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
563 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 232, 249, 32, 49, 0x2AF, STR_A02A_SEND_AIRCRAFT_TO_HANGAR}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
564 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 232, 249, 50, 67, 0x2B4, STR_A03B_REFIT_AIRCRAFT_TO_CARRY}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
565 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 232, 249, 68, 85, 0x2B2, STR_A028_SHOW_AIRCRAFT_S_ORDERS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
566 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 232, 249, 86, 103, 0x2B3, STR_A02B_SHOW_AIRCRAFT_DETAILS}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
567 |
{ WIDGETS_END}, |
0 | 568 |
}; |
569 |
||
570 |
static void AircraftViewWndProc(Window *w, WindowEvent *e) |
|
571 |
{ |
|
572 |
switch(e->event) { |
|
573 |
case WE_PAINT: { |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
574 |
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
|
575 |
uint32 disabled = 1<<8; |
0 | 576 |
StringID str; |
577 |
||
578 |
{ |
|
579 |
uint tile = v->tile; |
|
1035
812f837ee03f
(svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts
tron
parents:
1024
diff
changeset
|
580 |
if (IsTileType(tile, MP_STATION) && |
0 | 581 |
(_map5[tile] == 32 || _map5[tile] == 65) && |
582 |
v->vehstatus&VS_STOPPED) |
|
583 |
disabled = 0; |
|
584 |
} |
|
585 |
||
586 |
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
|
587 |
disabled |= 1<<8 | 1<<7; |
0 | 588 |
w->disabled_state = disabled; |
589 |
||
590 |
/* draw widgets & caption */ |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
591 |
SetDParam(0, v->string_id); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
592 |
SetDParam(1, v->unitnumber); |
0 | 593 |
DrawWindowWidgets(w); |
594 |
||
595 |
/* draw the flag */ |
|
596 |
DrawSprite((v->vehstatus & VS_STOPPED) ? 0xC12 : 0xC13, 2, 105); |
|
597 |
||
598 |
if (v->vehstatus & VS_CRASHED) { |
|
599 |
str = STR_8863_CRASHED; |
|
600 |
} else if (v->vehstatus & VS_STOPPED) { |
|
601 |
str = STR_8861_STOPPED; |
|
602 |
} else { |
|
555
02df8a1b7f33
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
603 |
switch (v->current_order.type) { |
0 | 604 |
case OT_GOTO_STATION: { |
555
02df8a1b7f33
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
605 |
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
|
606 |
SetDParam(1, v->cur_speed * 8); |
0 | 607 |
str = STR_HEADING_FOR_STATION + _patches.vehicle_speed; |
608 |
} break; |
|
609 |
||
610 |
case OT_GOTO_DEPOT: { |
|
555
02df8a1b7f33
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
611 |
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
|
612 |
SetDParam(1, v->cur_speed * 8); |
0 | 613 |
str = STR_HEADING_FOR_HANGAR + _patches.vehicle_speed; |
614 |
} break; |
|
615 |
||
616 |
case OT_LOADING: |
|
617 |
str = STR_882F_LOADING_UNLOADING; |
|
618 |
break; |
|
619 |
||
620 |
default: |
|
621 |
if (v->num_orders == 0) { |
|
622 |
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
|
623 |
SetDParam(0, v->cur_speed * 8); |
0 | 624 |
} else |
625 |
str = STR_EMPTY; |
|
626 |
break; |
|
627 |
} |
|
628 |
} |
|
629 |
||
630 |
DrawStringCentered(125, 105, str, 0); |
|
631 |
DrawWindowViewport(w); |
|
632 |
} break; |
|
633 |
||
634 |
case WE_CLICK: { |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
635 |
Vehicle *v = GetVehicle(w->window_number); |
0 | 636 |
|
637 |
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
|
638 |
case 5: /* start stop */ |
0 | 639 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_AIRCRAFT | CMD_MSG(STR_A016_CAN_T_STOP_START_AIRCRAFT)); |
640 |
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
|
641 |
case 6: /* center main view */ |
0 | 642 |
ScrollMainWindowTo(v->x_pos, v->y_pos); |
643 |
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
|
644 |
case 7: /* goto hangar */ |
0 | 645 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_SEND_AIRCRAFT_TO_HANGAR | CMD_MSG(STR_A012_CAN_T_SEND_AIRCRAFT_TO)); |
646 |
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
|
647 |
case 8: /* refit */ |
0 | 648 |
ShowAircraftRefitWindow(v); |
649 |
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
|
650 |
case 9: /* show orders */ |
0 | 651 |
ShowOrdersWindow(v); |
652 |
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
|
653 |
case 10: /* show details */ |
0 | 654 |
ShowAircraftDetailsWindow(v); |
655 |
break; |
|
656 |
} |
|
657 |
} break; |
|
658 |
||
659 |
case WE_DESTROY: |
|
660 |
DeleteWindowById(WC_VEHICLE_ORDERS, w->window_number); |
|
661 |
DeleteWindowById(WC_VEHICLE_REFIT, w->window_number); |
|
662 |
DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number); |
|
663 |
break; |
|
664 |
} |
|
665 |
} |
|
666 |
||
667 |
||
668 |
static const WindowDesc _aircraft_view_desc = { |
|
669 |
-1,-1, 250, 116, |
|
670 |
WC_VEHICLE_VIEW ,0, |
|
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
|
671 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, |
0 | 672 |
_aircraft_view_widgets, |
673 |
AircraftViewWndProc |
|
674 |
}; |
|
675 |
||
676 |
||
677 |
void ShowAircraftViewWindow(Vehicle *v) |
|
678 |
{ |
|
679 |
Window *w; |
|
680 |
||
681 |
w = AllocateWindowDescFront(&_aircraft_view_desc, v->index); |
|
682 |
if (w) { |
|
683 |
w->caption_color = v->owner; |
|
684 |
AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), 0); |
|
685 |
} |
|
686 |
} |
|
687 |
||
688 |
static void DrawAircraftDepotWindow(Window *w) |
|
689 |
{ |
|
690 |
uint tile; |
|
691 |
Vehicle *v; |
|
692 |
int num,x,y; |
|
693 |
||
694 |
tile = w->window_number; |
|
695 |
||
696 |
/* setup disabled buttons */ |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
697 |
w->disabled_state = (_map_owner[tile]==_local_player) ? 0 : ((1<<4)|(1<<7)); |
0 | 698 |
|
699 |
/* determine amount of items for scroller */ |
|
700 |
num = 0; |
|
701 |
FOR_ALL_VEHICLES(v) { |
|
702 |
if (v->type == VEH_Aircraft && v->subtype <= 2 && v->vehstatus&VS_HIDDEN && |
|
703 |
v->tile == (TileIndex)tile) |
|
704 |
num++; |
|
705 |
} |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
706 |
SetVScrollCount(w, (num + w->hscroll.cap - 1) / w->hscroll.cap); |
0 | 707 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
708 |
SetDParam(0, _map2[tile]); |
0 | 709 |
DrawWindowWidgets(w); |
710 |
||
711 |
x = 2; |
|
712 |
y = 15; |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
713 |
num = w->vscroll.pos * w->hscroll.cap; |
0 | 714 |
|
715 |
FOR_ALL_VEHICLES(v) { |
|
716 |
if (v->type == VEH_Aircraft && |
|
717 |
v->subtype <= 2 && |
|
718 |
v->vehstatus&VS_HIDDEN && |
|
719 |
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
|
720 |
--num < 0 && num >= -w->vscroll.cap * w->hscroll.cap) { |
0 | 721 |
|
722 |
DrawAircraftImage(v, x+12, y, WP(w,traindepot_d).sel); |
|
723 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
724 |
SetDParam(0, v->unitnumber); |
0 | 725 |
DrawString(x, y+2, (uint16)(v->max_age-366) >= v->age ? STR_00E2 : STR_00E3, 0); |
726 |
||
727 |
DrawSprite( (v->vehstatus & VS_STOPPED) ? 0xC12 : 0xC13, x, y+12); |
|
728 |
||
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
729 |
if ((x+=74) == 2 + 74 * w->hscroll.cap) { |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
730 |
x = 2; |
0 | 731 |
y += 24; |
732 |
} |
|
733 |
} |
|
734 |
} |
|
735 |
} |
|
736 |
||
737 |
static int GetVehicleFromAircraftDepotWndPt(Window *w, int x, int y, Vehicle **veh) { |
|
969
862685f513ca
(svn r1464) -Fix: [1099106] Resizeable portion of bus/air/rail depots window unclickable
darkvater
parents:
968
diff
changeset
|
738 |
uint xt,row,xm,ym; |
0 | 739 |
Vehicle *v; |
740 |
uint tile; |
|
741 |
int pos; |
|
742 |
||
743 |
xt = x / 74; |
|
744 |
xm = x % 74; |
|
971
374251680a61
(svn r1466) -Fix: oops, depot windows can of course also scroll horizontally. Thanks si-m1.
darkvater
parents:
969
diff
changeset
|
745 |
if (xt >= w->hscroll.cap) |
0 | 746 |
return 1; |
747 |
||
969
862685f513ca
(svn r1464) -Fix: [1099106] Resizeable portion of bus/air/rail depots window unclickable
darkvater
parents:
968
diff
changeset
|
748 |
row = (y - 14) / 24; |
0 | 749 |
ym = (y - 14) % 24; |
969
862685f513ca
(svn r1464) -Fix: [1099106] Resizeable portion of bus/air/rail depots window unclickable
darkvater
parents:
968
diff
changeset
|
750 |
if (row >= w->vscroll.cap) |
0 | 751 |
return 1; |
752 |
||
971
374251680a61
(svn r1466) -Fix: oops, depot windows can of course also scroll horizontally. Thanks si-m1.
darkvater
parents:
969
diff
changeset
|
753 |
pos = (row + w->vscroll.pos) * w->hscroll.cap + xt; |
0 | 754 |
|
755 |
tile = w->window_number; |
|
756 |
FOR_ALL_VEHICLES(v) { |
|
757 |
if (v->type == VEH_Aircraft && |
|
758 |
v->subtype <= 2 && |
|
759 |
v->vehstatus&VS_HIDDEN && |
|
760 |
v->tile == (TileIndex)tile && |
|
761 |
--pos < 0) { |
|
762 |
*veh = v; |
|
763 |
if (xm >= 12) |
|
764 |
return 0; |
|
765 |
||
766 |
if (ym <= 12) |
|
767 |
return -1; /* show window */ |
|
768 |
||
769 |
return -2; /* start stop */ |
|
770 |
} |
|
771 |
} |
|
772 |
return 1; /* outside */ |
|
773 |
} |
|
774 |
||
775 |
static void AircraftDepotClickAircraft(Window *w, int x, int y) |
|
776 |
{ |
|
777 |
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
|
778 |
int mode = GetVehicleFromAircraftDepotWndPt(w, x, y, &v); |
0 | 779 |
|
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
|
780 |
// 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
|
781 |
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
|
782 |
|
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
|
783 |
switch(mode) { |
0 | 784 |
case 1: |
785 |
return; |
|
786 |
||
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
|
787 |
case 0: // start dragging of vehicle |
0 | 788 |
if (v != NULL) { |
789 |
WP(w,traindepot_d).sel = v->index; |
|
790 |
SetWindowDirty(w); |
|
791 |
SetObjectToPlaceWnd( SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)) + GetAircraftImage(v, 6), 4, w); |
|
792 |
} |
|
793 |
break; |
|
794 |
||
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
|
795 |
case -1: // show info window |
0 | 796 |
ShowAircraftViewWindow(v); |
797 |
break; |
|
798 |
||
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
|
799 |
case -2: // click start/stop flag |
0 | 800 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_AIRCRAFT | CMD_MSG(STR_A016_CAN_T_STOP_START_AIRCRAFT)); |
801 |
break; |
|
802 |
||
803 |
default: |
|
804 |
NOT_REACHED(); |
|
805 |
} |
|
806 |
} |
|
807 |
||
808 |
static void AircraftDepotWndProc(Window *w, WindowEvent *e) |
|
809 |
{ |
|
810 |
switch(e->event) { |
|
811 |
case WE_PAINT: |
|
812 |
DrawAircraftDepotWindow(w); |
|
813 |
break; |
|
814 |
||
815 |
case WE_CLICK: |
|
816 |
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
|
817 |
case 5: /* click aircraft */ |
0 | 818 |
AircraftDepotClickAircraft(w, e->click.pt.x, e->click.pt.y); |
819 |
break; |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
820 |
case 7: /* show build aircraft window */ |
0 | 821 |
ShowBuildAircraftWindow(w->window_number); |
822 |
break; |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
823 |
case 8: /* scroll to tile */ |
0 | 824 |
ScrollMainWindowToTile(w->window_number); |
825 |
break; |
|
826 |
} |
|
827 |
break; |
|
828 |
||
829 |
case WE_DESTROY: |
|
830 |
DeleteWindowById(WC_BUILD_VEHICLE, w->window_number); |
|
831 |
break; |
|
832 |
||
833 |
case WE_DRAGDROP: { |
|
834 |
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
|
835 |
case 5: { |
0 | 836 |
Vehicle *v; |
837 |
VehicleID sel = WP(w,traindepot_d).sel; |
|
838 |
||
839 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
840 |
SetWindowDirty(w); |
|
841 |
||
842 |
if (GetVehicleFromAircraftDepotWndPt(w, e->dragdrop.pt.x, e->dragdrop.pt.y, &v) == 0 && |
|
843 |
v != NULL && |
|
844 |
sel == v->index) { |
|
845 |
ShowAircraftViewWindow(v); |
|
846 |
} |
|
847 |
} break; |
|
848 |
||
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
|
849 |
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
|
850 |
if (!HASBIT(w->disabled_state, 4) && |
0 | 851 |
WP(w,traindepot_d).sel != INVALID_VEHICLE) { |
852 |
Vehicle *v; |
|
853 |
||
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
|
854 |
HandleButtonClick(w, 4); |
0 | 855 |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
856 |
v = GetVehicle(WP(w,traindepot_d).sel); |
0 | 857 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
858 |
||
859 |
_backup_orders_tile = v->tile; |
|
860 |
BackupVehicleOrders(v, _backup_orders_data); |
|
861 |
||
862 |
if (!DoCommandP(v->tile, v->index, 0, NULL, CMD_SELL_AIRCRAFT | CMD_MSG(STR_A01C_CAN_T_SELL_AIRCRAFT))) |
|
863 |
_backup_orders_tile = 0; |
|
864 |
} |
|
865 |
break; |
|
866 |
default: |
|
867 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
868 |
SetWindowDirty(w); |
|
869 |
} |
|
870 |
break; |
|
871 |
} |
|
872 |
break; |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
873 |
|
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
874 |
case WE_RESIZE: |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
875 |
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
|
876 |
w->hscroll.cap += e->sizing.diff.x / 74; |
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
|
877 |
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
|
878 |
break; |
0 | 879 |
} |
880 |
} |
|
881 |
||
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
|
882 |
static const Widget _aircraft_depot_widgets[] = { |
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
|
883 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
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
|
884 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 318, 0, 13, STR_A002_AIRCRAFT_HANGAR, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
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
|
885 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 319, 330, 0, 13, 0x0, STR_STICKY_BUTTON}, |
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
|
886 |
{ WWT_PANEL, RESIZE_LRB, 14, 296, 318, 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
|
887 |
{ WWT_IMGBTN, RESIZE_LRTB, 14, 296, 318, 14, 61, 0x2A9, STR_A023_DRAG_AIRCRAFT_TO_HERE_TO}, |
0 | 888 |
|
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
|
889 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 295, 14, 61, 0x204, STR_A021_AIRCRAFT_CLICK_ON_AIRCRAFT}, |
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
|
890 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 319, 330, 14, 61, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
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
|
891 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 159, 62, 73, STR_A003_NEW_AIRCRAFT, STR_A022_BUILD_NEW_AIRCRAFT}, |
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
|
892 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 160, 318, 62, 73, STR_00E4_LOCATION, STR_A024_CENTER_MAIN_VIEW_ON_HANGAR}, |
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
|
893 |
{ WWT_PANEL, RESIZE_RTB, 14, 319, 318, 62, 73, 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
|
894 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 319, 330, 62, 73, 0x0, STR_RESIZE_BUTTON}, |
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
|
895 |
{ WIDGETS_END}, |
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
|
896 |
}; |
0 | 897 |
|
898 |
static const WindowDesc _aircraft_depot_desc = { |
|
899 |
-1, -1, 331, 74, |
|
900 |
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
|
901 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 902 |
_aircraft_depot_widgets, |
903 |
AircraftDepotWndProc |
|
904 |
}; |
|
905 |
||
906 |
||
907 |
void ShowAircraftDepotWindow(uint tile) |
|
908 |
{ |
|
909 |
Window *w; |
|
910 |
||
911 |
w = AllocateWindowDescFront(&_aircraft_depot_desc, tile); |
|
912 |
if (w) { |
|
913 |
w->caption_color = _map_owner[tile]; |
|
914 |
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
|
915 |
w->hscroll.cap = 4; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
916 |
w->resize.step_width = 74; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
917 |
w->resize.step_height = 24; |
0 | 918 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
919 |
_backup_orders_tile = 0; |
|
920 |
} |
|
921 |
} |
|
922 |
||
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
923 |
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:
1019
diff
changeset
|
924 |
const Order *order; |
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
925 |
int sel, i = 0; |
0 | 926 |
|
927 |
sel = v->cur_order_index; |
|
928 |
||
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
929 |
FOR_VEHICLE_ORDERS(v, order) { |
0 | 930 |
if (sel == 0) { |
931 |
_stringwidth_base = 0xE0; |
|
932 |
DoDrawString( "\xAF", x-6, y, 16); |
|
933 |
_stringwidth_base = 0; |
|
934 |
} |
|
935 |
sel--; |
|
936 |
||
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
937 |
if (order->type == OT_GOTO_STATION) { |
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
938 |
SetDParam(0, order->station); |
0 | 939 |
DrawString(x, y, STR_A036, 0); |
940 |
||
941 |
y += 6; |
|
942 |
if (++i == 4) |
|
943 |
break; |
|
944 |
} |
|
945 |
} |
|
946 |
} |
|
947 |
||
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
948 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
949 |
static const Widget _player_aircraft_widgets[] = { |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
950 |
{ 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
|
951 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 247, 0, 13, STR_A009_AIRCRAFT, 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
|
952 |
{ 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
|
953 |
{ 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
|
954 |
{ 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
|
955 |
{ 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
|
956 |
{ 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
|
957 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 247, 26, 169, 0x401, STR_A01F_AIRCRAFT_CLICK_ON_AIRCRAFT}, |
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
|
958 |
{ 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
|
959 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 124, 170, 181, STR_A003_NEW_AIRCRAFT, STR_A020_BUILD_NEW_AIRCRAFT_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
|
960 |
{ 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
|
961 |
{ 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
|
962 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 248, 259, 170, 181, 0x0, STR_RESIZE_BUTTON}, |
588 | 963 |
{ WIDGETS_END}, |
964 |
}; |
|
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
|
965 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
966 |
static const Widget _other_player_aircraft_widgets[] = { |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
967 |
{ 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
|
968 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 247, 0, 13, STR_A009_AIRCRAFT, 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
|
969 |
{ 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
|
970 |
{ 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
|
971 |
{ 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
|
972 |
{ 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
|
973 |
{ 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
|
974 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 247, 26, 169, 0x401, STR_A01F_AIRCRAFT_CLICK_ON_AIRCRAFT}, |
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
|
975 |
{ 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
|
976 |
{ 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
|
977 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 248, 259, 170, 181, 0x0, STR_RESIZE_BUTTON}, |
588 | 978 |
{ WIDGETS_END}, |
979 |
}; |
|
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
|
980 |
|
0 | 981 |
static void PlayerAircraftWndProc(Window *w, WindowEvent *e) |
982 |
{ |
|
588 | 983 |
int station = (int)w->window_number >> 16; |
984 |
int owner = w->window_number & 0xff; |
|
985 |
vehiclelist_d *vl = &WP(w, vehiclelist_d); |
|
986 |
||
0 | 987 |
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
|
988 |
case WE_PAINT: { |
588 | 989 |
int x = 2; |
990 |
int y = PLY_WND_PRC__OFFSET_TOP_WIDGET; |
|
991 |
int max; |
|
992 |
int i; |
|
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
993 |
|
588 | 994 |
BuildVehicleList(vl, VEH_Aircraft, owner, station); |
995 |
SortVehicleList(vl); |
|
0 | 996 |
|
588 | 997 |
SetVScrollCount(w, vl->list_length); |
998 |
||
999 |
// disable 'Sort By' tooltip on Unsorted sorting criteria |
|
1000 |
if (vl->sort_type == SORT_BY_UNSORTED) |
|
757 | 1001 |
w->disabled_state |= (1 << 3); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1002 |
|
0 | 1003 |
/* draw the widgets */ |
1004 |
{ |
|
588 | 1005 |
const Player *p = DEREF_PLAYER(owner); |
1006 |
if (station == -1) { |
|
1007 |
/* Company Name -- (###) Aircraft */ |
|
1008 |
SetDParam(0, p->name_1); |
|
1009 |
SetDParam(1, p->name_2); |
|
1010 |
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
|
1011 |
w->widget[1].unkA = STR_A009_AIRCRAFT; |
588 | 1012 |
} else { |
1013 |
/* Station Name -- (###) Aircraft */ |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
1014 |
SetDParam(0, GetStation(station)->index); |
588 | 1015 |
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
|
1016 |
w->widget[1].unkA = STR_SCHEDULED_AIRCRAFT; |
588 | 1017 |
} |
0 | 1018 |
DrawWindowWidgets(w); |
1019 |
} |
|
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
1020 |
/* draw sorting criteria string */ |
588 | 1021 |
DrawString(85, 15, _vehicle_sort_listing[vl->sort_type], 0x10); |
1022 |
/* draw arrow pointing up/down for ascending/descending sorting */ |
|
1023 |
DoDrawString( |
|
1024 |
vl->flags & VL_DESC ? "\xAA" : "\xA0", 69, 15, 0x10); |
|
0 | 1025 |
|
588 | 1026 |
max = min(w->vscroll.pos + w->vscroll.cap, vl->list_length); |
1027 |
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
|
1028 |
Vehicle *v = GetVehicle(vl->sort_list[i].index); |
588 | 1029 |
StringID str; |
0 | 1030 |
|
588 | 1031 |
assert(v->type == VEH_Aircraft && v->subtype <= 2); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1032 |
|
588 | 1033 |
DrawAircraftImage(v, x + 19, y + 6, INVALID_VEHICLE); |
1034 |
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
|
1035 |
|
588 | 1036 |
SetDParam(0, v->unitnumber); |
1055
cc4f60cc9102
(svn r1556) -Fix: Vehicle list updates should now really work
Celestar
parents:
1035
diff
changeset
|
1037 |
if (IsAircraftHangarTile(v->tile) && (v->vehstatus & VS_HIDDEN)) |
588 | 1038 |
str = STR_021F; |
1039 |
else |
|
1040 |
str = v->age > v->max_age - 366 ? STR_00E3 : STR_00E2; |
|
1041 |
DrawString(x, y + 2, str, 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
|
1042 |
|
588 | 1043 |
SetDParam(0, v->profit_this_year); |
1044 |
SetDParam(1, v->profit_last_year); |
|
1045 |
DrawString(x + 19, y + 28, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 0); |
|
1046 |
||
1047 |
if (v->string_id != STR_SV_AIRCRAFT_NAME) { |
|
1048 |
SetDParam(0, v->string_id); |
|
1049 |
DrawString(x + 19, y, STR_01AB, 0); |
|
0 | 1050 |
} |
588 | 1051 |
|
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
1052 |
DrawSmallOrderList(v, x + 136, y); |
588 | 1053 |
|
1054 |
y += PLY_WND_PRC__SIZE_OF_ROW_BIG; |
|
0 | 1055 |
} |
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
|
1056 |
} break; |
0 | 1057 |
|
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
|
1058 |
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
|
1059 |
switch(e->click.widget) { |
757 | 1060 |
case 3: /* Flip sorting method ascending/descending */ |
588 | 1061 |
vl->flags ^= VL_DESC; |
1062 |
vl->flags |= VL_RESORT; |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1063 |
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
|
1064 |
break; |
588 | 1065 |
|
757 | 1066 |
case 4: case 5:/* Select sorting criteria dropdown menu */ |
842 | 1067 |
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
|
1068 |
return; |
588 | 1069 |
|
757 | 1070 |
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
|
1071 |
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
|
1072 |
|
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
|
1073 |
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
|
1074 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 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 |
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
|
1076 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1077 |
{ |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1078 |
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
|
1079 |
|
588 | 1080 |
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
|
1081 |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
1082 |
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
|
1083 |
|
588 | 1084 |
assert(v->type == VEH_Aircraft && v->subtype <= 2); |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1085 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1086 |
ShowAircraftViewWindow(v); |
0 | 1087 |
} |
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
|
1088 |
} 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
|
1089 |
|
757 | 1090 |
case 9: { /* Build new Vehicle */ |
0 | 1091 |
uint tile; |
1092 |
||
886
3f8be7ff7b9c
(svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight
parents:
867
diff
changeset
|
1093 |
if (!IsWindowOfPrototype(w, _player_aircraft_widgets)) |
3f8be7ff7b9c
(svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight
parents:
867
diff
changeset
|
1094 |
break; |
3f8be7ff7b9c
(svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight
parents:
867
diff
changeset
|
1095 |
|
0 | 1096 |
tile = _last_built_aircraft_depot_tile; |
1097 |
do { |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1098 |
if (_map_owner[tile] == _local_player && IsAircraftHangarTile(tile)) { |
0 | 1099 |
ShowAircraftDepotWindow(tile); |
1100 |
ShowBuildAircraftWindow(tile); |
|
1101 |
return; |
|
1102 |
} |
|
1103 |
||
1104 |
tile = TILE_MASK(tile + 1); |
|
1105 |
} while(tile != _last_built_aircraft_depot_tile); |
|
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
|
1106 |
|
0 | 1107 |
ShowBuildAircraftWindow(0); |
1108 |
} break; |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1109 |
|
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1110 |
case 10: |
886
3f8be7ff7b9c
(svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight
parents:
867
diff
changeset
|
1111 |
if (!IsWindowOfPrototype(w, _player_aircraft_widgets)) |
3f8be7ff7b9c
(svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight
parents:
867
diff
changeset
|
1112 |
break; |
3f8be7ff7b9c
(svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight
parents:
867
diff
changeset
|
1113 |
|
842 | 1114 |
ShowReplaceVehicleWindow(VEH_Aircraft); |
1115 |
break; |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1116 |
|
0 | 1117 |
} |
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
|
1118 |
} 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
|
1119 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 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 |
case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */ |
588 | 1121 |
if (vl->sort_type != e->dropdown.index) { |
1122 |
// value has changed -> resort |
|
1123 |
vl->flags |= VL_RESORT; |
|
1124 |
vl->sort_type = e->dropdown.index; |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1125 |
|
588 | 1126 |
// enable 'Sort By' if a sorter criteria is chosen |
1127 |
if (vl->sort_type != SORT_BY_UNSORTED) |
|
757 | 1128 |
w->disabled_state &= ~(1 << 3); |
588 | 1129 |
} |
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
|
1130 |
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
|
1131 |
break; |
588 | 1132 |
|
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
|
1133 |
case WE_CREATE: /* set up resort timer */ |
588 | 1134 |
vl->sort_list = NULL; |
1135 |
vl->flags = VL_REBUILD; |
|
1136 |
vl->sort_type = SORT_BY_UNSORTED; |
|
1137 |
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
|
1138 |
break; |
588 | 1139 |
|
767 | 1140 |
case WE_DESTROY: |
1141 |
free(vl->sort_list); |
|
1142 |
break; |
|
1143 |
||
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
|
1144 |
case WE_TICK: /* resort the list every 20 seconds orso (10 days) */ |
588 | 1145 |
if (--vl->resort_timer == 0) { |
1146 |
DEBUG(misc, 1) ("Periodic resort aircraft list player %d station %d", |
|
1147 |
owner, station); |
|
1148 |
vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; |
|
1149 |
vl->flags |= VL_RESORT; |
|
1150 |
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
|
1151 |
} |
0 | 1152 |
break; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1153 |
|
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1154 |
case WE_RESIZE: |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1155 |
/* Update the scroll + matrix */ |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1156 |
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
|
1157 |
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
|
1158 |
break; |
0 | 1159 |
} |
1160 |
} |
|
1161 |
||
1162 |
static const WindowDesc _player_aircraft_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
|
1163 |
-1, -1, 260, 182, |
0 | 1164 |
WC_AIRCRAFT_LIST,0, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1165 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 1166 |
_player_aircraft_widgets, |
1167 |
PlayerAircraftWndProc |
|
1168 |
}; |
|
1169 |
||
1170 |
static const WindowDesc _other_player_aircraft_desc = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1171 |
-1, -1, 260, 182, |
0 | 1172 |
WC_AIRCRAFT_LIST,0, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1173 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 1174 |
_other_player_aircraft_widgets, |
1175 |
PlayerAircraftWndProc |
|
1176 |
}; |
|
1177 |
||
588 | 1178 |
void ShowPlayerAircraft(int player, int station) |
0 | 1179 |
{ |
1180 |
Window *w; |
|
1181 |
||
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
|
1182 |
if (player == _local_player) { |
588 | 1183 |
w = AllocateWindowDescFront(&_player_aircraft_desc, (station << 16) | player); |
0 | 1184 |
} else { |
588 | 1185 |
w = AllocateWindowDescFront(&_other_player_aircraft_desc, (station << 16) | player); |
0 | 1186 |
} |
1187 |
||
1188 |
if (w) { |
|
1189 |
w->caption_color = w->window_number; |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1190 |
w->vscroll.cap = 4; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1191 |
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
|
1192 |
w->resize.step_height = PLY_WND_PRC__SIZE_OF_ROW_BIG; |
0 | 1193 |
} |
1194 |
} |