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