197 * There are 9 buildable airports |
198 * There are 9 buildable airports |
198 * XXX TODO : all airports should be held in arrays, with all relevant data. |
199 * XXX TODO : all airports should be held in arrays, with all relevant data. |
199 * This should be part of newgrf-airports, i suppose |
200 * This should be part of newgrf-airports, i suppose |
200 */ |
201 */ |
201 for (i = 0; i < 9; i++) SetWindowWidgetDisabledState(w, i + 7, !HASBIT(avail_airports, i)); |
202 for (i = 0; i < 9; i++) SetWindowWidgetDisabledState(w, i + 7, !HASBIT(avail_airports, i)); |
202 |
|
203 airport = GetAirport(_selected_airport_type); |
203 airport = GetAirport(_selected_airport_type); |
204 |
204 |
205 if (_railstation.newstation_selected) { |
205 //if (_airport.newstation_selected) { |
206 int x = _railstation.platlength; |
206 int x = fsmportspec->size_x[_airport.orientation]; |
207 int y = _railstation.numtracks; |
207 int y = fsmportspec->size_y[_airport.orientation]; |
208 if (_railstation.orientation == 0) Swap(x, y); |
208 //if (_airport.orientation == 0) Swap(x, y); |
209 SetTileSelectSize(x, y); |
209 SetTileSelectSize(x, y); |
210 } else { |
210 |
211 |
211 for (byte j = 0; j < 4; j++) |
212 // select default the coverage area to 'Off' (16) |
212 { |
213 SetTileSelectSize(airport->size_x, airport->size_y); |
213 SetWindowWidgetDisabledState(w, 28 + j, true); |
214 } |
214 RaiseWindowWidget(w, 28 + j); |
|
215 w->widget[28 + _airport.orientation].data = SPR_IMG_ARROW_NE_WHITE + j; //reset arrows to white |
|
216 } |
|
217 |
|
218 |
|
219 byte preview_sprite = 0xFF; |
|
220 for (byte j = 0; j < fsmportspec->numlayouts; j++) |
|
221 { |
|
222 if (fsmportspec->layouts[j] == NULL) break; |
|
223 /* enable the permitted orientations */ |
|
224 byte *layout_ptr = (byte*)alloca(x*y + 1); |
|
225 memcpy(layout_ptr, fsmportspec->layouts[j], (x * y) + 1); |
|
226 SetWindowWidgetDisabledState(w, 28 + GB((byte)*layout_ptr,1,2), false); |
|
227 if (j == _airport.orientation) { |
|
228 layout_ptr++; |
|
229 preview_sprite = *layout_ptr; |
|
230 } |
|
231 } |
|
232 LowerWindowWidget(w, 28 + _airport.orientation); |
|
233 w->widget[28 + _airport.orientation].data = SPR_IMG_ARROW_NE_YELLOW + _airport.orientation; //show in yellow |
215 |
234 |
216 _thd.airport = _selected_airport_type; |
235 _thd.airport = _selected_airport_type; |
217 _thd.airport_template = true; |
236 _thd.airport_template = true; |
218 |
237 |
219 int rad = _patches.modified_catchment ? ((_railstation.newstation_selected)? fsmportspec->portFSM->catchment : airport->catchment) : 4; |
238 int rad = _patches.modified_catchment ? ((_airport.newstation_selected)? fsmportspec->portFSM->catchment : airport->catchment) : 4; |
220 |
239 |
221 if (_station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad); |
240 if (_station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad); |
222 |
241 |
223 SetDParam(0, GetFSMportsClassName(_railstation.fsmports_class)); |
242 SetDParam(0, GetFSMportsClassName(_airport.fsmports_class)); |
224 DrawWindowWidgets(w); |
243 DrawWindowWidgets(w); |
225 |
244 |
226 y_offset = newstations ? 90 : 0; |
245 /* Set up a clipping area for the preview */ |
|
246 DrawFSMportsTile(9, 106, preview_sprite, _airport.fsmports_class, _airport.station_type); |
|
247 |
|
248 //if (FillDrawPixelInfo(&tmp_dpi, 9, 106, 96, 64)) { |
|
249 //old_dpi = _cur_dpi; |
|
250 //_cur_dpi = &tmp_dpi; |
|
251 //if (!DrawStationTile(32, 16, _cur_railtype, AXIS_X, _airport.station_class, _airport.station_type)) { |
|
252 // StationPickerDrawSprite(32, 16, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 2); |
|
253 //} |
|
254 //_cur_dpi = old_dpi; |
|
255 //} |
|
256 |
|
257 y_offset = newstations ? 170 : 0; |
227 |
258 |
228 // strings such as 'Size' and 'Coverage Area' |
259 // strings such as 'Size' and 'Coverage Area' |
229 // 'Coverage Area' |
260 // 'Coverage Area' |
230 DrawStationCoverageAreaText(2, 206 + y_offset, SCT_ALL, rad); |
261 DrawStationCoverageAreaText(2, 206 + y_offset, SCT_ALL, rad); |
231 |
262 |
232 if (newstations) { |
263 if (newstations) { |
233 uint16 i; |
264 uint16 i; |
234 uint y = 35; |
265 uint y = 35; |
235 |
266 |
236 for (i = w->vscroll.pos; i < _railstation.station_count && i < (uint)(w->vscroll.pos + w->vscroll.cap); i++) { |
267 for (i = w->vscroll.pos; i < _airport.station_count && i < (uint)(w->vscroll.pos + w->vscroll.cap); i++) { |
237 const FSMportsSpec *fsmportspec = GetCustomFSMportsSpec(_railstation.fsmports_class, i); |
268 const FSMportsSpec *fsmportspec = GetCustomFSMportsSpec(_airport.fsmports_class, i); |
238 |
269 |
239 if (fsmportspec != NULL && fsmportspec->name != 0) { |
270 if (fsmportspec != NULL && fsmportspec->name != 0) { |
240 if (HASBIT(fsmportspec->callbackmask, CBM_STATION_AVAIL) && GetFSMportsCallback(CBID_STATION_AVAILABILITY, 0, 0, fsmportspec, NULL, INVALID_TILE) == 0) { |
271 if (HASBIT(fsmportspec->callbackmask, CBM_STATION_AVAIL) && GetFSMportsCallback(CBID_STATION_AVAILABILITY, 0, 0, fsmportspec, NULL, INVALID_TILE) == 0) { |
241 GfxFillRect(8, y - 2, 127, y + 10, (1 << PALETTE_MODIFIER_GREYOUT)); |
272 GfxFillRect(8, y - 2, 127, y + 10, (1 << PALETTE_MODIFIER_GREYOUT)); |
242 } |
273 } |
243 |
274 |
244 DrawStringTruncated(9, y, fsmportspec->name, i == _railstation.station_type ? 12 : 16, 118); |
275 DrawStringTruncated(9, y, fsmportspec->name, i == _airport.station_type ? 12 : 16, 118); |
245 } else { |
276 } else { |
246 DrawStringTruncated(9, y, STR_STAT_CLASS_DFLT, i == _railstation.station_type ? 12 : 16, 118); |
277 DrawStringTruncated(9, y, STR_STAT_CLASS_DFLT, i == _airport.station_type ? 12 : 16, 118); |
247 } |
278 } |
248 |
279 |
249 y += 14; |
280 y += 14; |
250 } |
281 } |
251 } |
282 } |
271 SndPlayFx(SND_15_BEEP); |
302 SndPlayFx(SND_15_BEEP); |
272 SetWindowDirty(w); |
303 SetWindowDirty(w); |
273 break; |
304 break; |
274 case 23: |
305 case 23: |
275 case 24: |
306 case 24: |
276 ShowDropDownMenu(w, BuildFSMportsClassDropdown(), _railstation.fsmports_class, 24, 0, 1 << FSMPORTS_CLASS_WAYP); |
307 ShowDropDownMenu(w, BuildFSMportsClassDropdown(), _airport.fsmports_class, 24, 0, 1 << FSMPORTS_CLASS_WAYP); |
277 break; |
308 break; |
278 |
309 |
279 case 25: { |
310 case 25: { |
280 const FSMportsSpec *fsmportspec; |
311 const FSMportsSpec *fsmportspec; |
281 int y = (e->we.click.pt.y - 32) / 14; |
312 int y = (e->we.click.pt.y - 32) / 14; |
282 |
313 |
283 if (y >= w->vscroll.cap) return; |
314 if (y >= w->vscroll.cap) return; |
284 y += w->vscroll.pos; |
315 y += w->vscroll.pos; |
285 if (y >= _railstation.station_count) return; |
316 if (y >= _airport.station_count) return; |
286 |
317 |
287 /* Check station availability callback */ |
318 /* Check station availability callback */ |
288 fsmportspec = GetCustomFSMportsSpec(_railstation.fsmports_class, y); |
319 fsmportspec = GetCustomFSMportsSpec(_airport.fsmports_class, y); |
289 if (fsmportspec != NULL && |
320 if (fsmportspec != NULL && |
290 HASBIT(fsmportspec->callbackmask, CBM_STATION_AVAIL) && |
321 HASBIT(fsmportspec->callbackmask, CBM_STATION_AVAIL) && |
291 GetFSMportsCallback(CBID_STATION_AVAILABILITY, 0, 0, fsmportspec, NULL, INVALID_TILE) == 0) return; |
322 GetFSMportsCallback(CBID_STATION_AVAILABILITY, 0, 0, fsmportspec, NULL, INVALID_TILE) == 0) return; |
292 |
323 |
293 _railstation.station_type = y; |
324 _airport.station_type = y; |
294 _railstation.numtracks = fsmportspec->width; |
325 _airport.platlength= fsmportspec->size_y[_airport.orientation]; |
295 _railstation.platlength = fsmportspec->lengths; |
326 _airport.numtracks = fsmportspec->size_x[_airport.orientation]; |
296 _railstation.newstation_selected = true; |
327 _airport.newstation_selected = true; |
297 |
328 |
298 SndPlayFx(SND_15_BEEP); |
329 SndPlayFx(SND_15_BEEP); |
299 SetWindowDirty(w); |
330 SetWindowDirty(w); |
300 break; |
331 break; |
301 } |
332 } |
|
333 case 28: case 29: case 30: case 31: |
|
334 w->widget[28 + _airport.orientation].data = SPR_IMG_ARROW_NE_WHITE + _airport.orientation; //reset arrow to white |
|
335 _airport.orientation = (e->we.click.widget - 28); |
|
336 SetWindowWidgetLoweredState(w, 28, (_airport.orientation == 0)); |
|
337 SetWindowWidgetLoweredState(w, 29, (_airport.orientation == 1)); |
|
338 SetWindowWidgetLoweredState(w, 30, (_airport.orientation == 2)); |
|
339 SetWindowWidgetLoweredState(w, 31, (_airport.orientation == 3)); |
|
340 SndPlayFx(SND_15_BEEP); |
|
341 SetWindowDirty(w); |
|
342 break; |
302 } |
343 } |
303 } break; |
344 } break; |
304 |
345 |
305 case WE_DROPDOWN_SELECT: { |
346 case WE_DROPDOWN_SELECT: { |
306 if (_railstation.fsmports_class != e->we.dropdown.index) { |
347 if (_airport.fsmports_class != e->we.dropdown.index) { |
307 _railstation.fsmports_class = (FSMportsClassID)e->we.dropdown.index; |
348 _airport.fsmports_class = (FSMportsClassID)e->we.dropdown.index; |
308 _railstation.station_type = 0; |
349 _airport.station_type = 0; |
309 _railstation.station_count = GetNumCustomFSMports(_railstation.fsmports_class); |
350 _airport.station_count = GetNumCustomFSMports(_airport.fsmports_class); |
310 |
351 |
311 w->vscroll.count = _railstation.station_count; |
352 w->vscroll.count = _airport.station_count; |
312 w->vscroll.pos = _railstation.station_type; |
353 w->vscroll.pos = _airport.station_type; |
313 } |
354 } |
314 |
355 |
315 SndPlayFx(SND_15_BEEP); |
356 SndPlayFx(SND_15_BEEP); |
316 SetWindowDirty(w); |
357 SetWindowDirty(w); |
317 } break; |
358 } break; |
360 }; |
401 }; |
361 |
402 |
362 static const Widget _newports_build_airport_picker_widgets[] = { |
403 static const Widget _newports_build_airport_picker_widgets[] = { |
363 { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
404 { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
364 { WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_3001_AIRPORT_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
405 { WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_3001_AIRPORT_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
365 { WWT_PANEL, RESIZE_NONE, 7, 0, 147, 14, 142, 0x0, STR_NULL}, |
406 { WWT_PANEL, RESIZE_NONE, 7, 0, 147, 14, 222, 0x0, STR_NULL}, |
366 { WWT_PANEL, RESIZE_NONE, 7, 0, 147, 143, 179, 0x0, STR_NULL}, |
407 { WWT_PANEL, RESIZE_NONE, 7, 0, 147, 223, 259, 0x0, STR_NULL}, |
367 { WWT_PANEL, RESIZE_NONE, 7, 0, 147, 180, 217, 0x0, STR_NULL}, |
408 { WWT_PANEL, RESIZE_NONE, 7, 0, 147, 260, 297, 0x0, STR_NULL}, |
368 { WWT_PANEL, RESIZE_NONE, 7, 0, 147, 218, 267, 0x0, STR_NULL}, |
409 { WWT_PANEL, RESIZE_NONE, 7, 0, 147, 298, 347, 0x0, STR_NULL}, |
369 { WWT_PANEL, RESIZE_NONE, 7, 0, 147, 268, 329, 0x0, STR_NULL}, |
410 { WWT_PANEL, RESIZE_NONE, 7, 0, 147, 348, 409, 0x0, STR_NULL}, |
370 { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 117, 128, STR_SMALL_AIRPORT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
411 { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 197, 208, STR_SMALL_AIRPORT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
371 { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 155, 166, STR_CITY_AIRPORT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
412 { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 235, 246, STR_CITY_AIRPORT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
372 { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 231, 242, STR_HELIPORT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
413 { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 311, 322, STR_HELIPORT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
373 { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 167, 178, STR_METRO_AIRPORT , STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
414 { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 247, 258, STR_METRO_AIRPORT , STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
374 { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 193, 204, STR_INTERNATIONAL_AIRPORT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
415 { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 273, 284, STR_INTERNATIONAL_AIRPORT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
375 { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 129, 140, STR_COMMUTER_AIRPORT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
416 { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 209, 220, STR_COMMUTER_AIRPORT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
376 { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 255, 266, STR_HELIDEPOT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
417 { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 335, 346, STR_HELIDEPOT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
377 { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 205, 216, STR_INTERCONTINENTAL_AIRPORT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
418 { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 285, 296, STR_INTERCONTINENTAL_AIRPORT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
378 { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 243, 254, STR_HELISTATION, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
419 { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 323, 334, STR_HELISTATION, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
379 { WWT_TEXTBTN, RESIZE_NONE, 14, 14, 73, 281, 292, STR_02DB_OFF, STR_3065_DON_T_HIGHLIGHT_COVERAGE}, |
420 { WWT_TEXTBTN, RESIZE_NONE, 14, 14, 73, 361, 372, STR_02DB_OFF, STR_3065_DON_T_HIGHLIGHT_COVERAGE}, |
380 { WWT_TEXTBTN, RESIZE_NONE, 14, 74, 133, 281, 292, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA}, |
421 { WWT_TEXTBTN, RESIZE_NONE, 14, 74, 133, 361, 372, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA}, |
381 { WWT_LABEL, RESIZE_NONE, 7, 0, 147, 104, 117, STR_SMALL_AIRPORTS, STR_NULL}, |
422 { WWT_LABEL, RESIZE_NONE, 7, 0, 147, 184, 197, STR_SMALL_AIRPORTS, STR_NULL}, |
382 { WWT_LABEL, RESIZE_NONE, 7, 0, 147, 142, 155, STR_LARGE_AIRPORTS, STR_NULL}, |
423 { WWT_LABEL, RESIZE_NONE, 7, 0, 147, 222, 235, STR_LARGE_AIRPORTS, STR_NULL}, |
383 { WWT_LABEL, RESIZE_NONE, 7, 0, 147, 180, 193, STR_HUB_AIRPORTS, STR_NULL}, |
424 { WWT_LABEL, RESIZE_NONE, 7, 0, 147, 260, 273, STR_HUB_AIRPORTS, STR_NULL}, |
384 { WWT_LABEL, RESIZE_NONE, 7, 0, 147, 218, 231, STR_HELIPORTS, STR_NULL}, |
425 { WWT_LABEL, RESIZE_NONE, 7, 0, 147, 298, 311, STR_HELIPORTS, STR_NULL}, |
385 { WWT_LABEL, RESIZE_NONE, 7, 0, 147, 268, 281, STR_3066_COVERAGE_AREA_HIGHLIGHT, STR_NULL}, |
426 { WWT_LABEL, RESIZE_NONE, 7, 0, 147, 348, 361, STR_3066_COVERAGE_AREA_HIGHLIGHT, STR_NULL}, |
386 /* newstations gui additions */ |
427 /* newstations gui additions */ |
387 //TODO: modify for airport specific texts |
428 //TODO: modify for airport specific texts |
388 { WWT_INSET, RESIZE_NONE, 14, 7, 140, 17, 28, STR_02BD, STR_SELECT_STATION_CLASS_TIP}, |
429 { WWT_INSET, RESIZE_NONE, 14, 7, 140, 17, 28, STR_02BD, STR_SELECT_STATION_CLASS_TIP}, |
389 { WWT_TEXTBTN, RESIZE_NONE, 14, 129, 139, 18, 27, STR_0225, STR_SELECT_STATION_CLASS_TIP}, |
430 { WWT_TEXTBTN, RESIZE_NONE, 14, 129, 139, 18, 27, STR_0225, STR_SELECT_STATION_CLASS_TIP}, |
390 { WWT_MATRIX, RESIZE_NONE, 14, 7, 128, 32, 102, 0x501, STR_SELECT_STATION_TYPE_TIP}, |
431 { WWT_MATRIX, RESIZE_NONE, 14, 7, 128, 32, 102, 0x501, STR_SELECT_STATION_TYPE_TIP}, |
391 { WWT_SCROLLBAR, RESIZE_NONE, 14, 129, 140, 32, 102, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
432 { WWT_SCROLLBAR, RESIZE_NONE, 14, 129, 140, 32, 102, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
|
433 { WWT_INSET, RESIZE_NONE, 7, 7, 107, 104, 172, 0x0, STR_NULL}, |
|
434 { WWT_IMGBTN, RESIZE_NONE, 14, 109, 140, 104, 119, SPR_IMG_ARROW_NE_WHITE, STR_NULL}, |
|
435 { WWT_IMGBTN, RESIZE_NONE, 14, 109, 140, 120, 135, SPR_IMG_ARROW_SE_WHITE, STR_NULL}, |
|
436 { WWT_IMGBTN, RESIZE_NONE, 14, 109, 140, 136, 151, SPR_IMG_ARROW_SW_WHITE, STR_NULL}, |
|
437 { WWT_IMGBTN, RESIZE_NONE, 14, 109, 140, 152, 167, SPR_IMG_ARROW_NW_WHITE, STR_NULL}, |
|
438 |
|
439 |
392 { WIDGETS_END}, |
440 { WIDGETS_END}, |
393 }; |
441 }; |
394 |
442 |
395 static const WindowDesc _build_airport_desc = { |
443 static const WindowDesc _build_airport_desc = { |
396 WDP_AUTO, WDP_AUTO, 148, 240, 148, 240, |
444 WDP_AUTO, WDP_AUTO, 148, 240, 148, 240, |