| author | richk |
| Tue, 17 Jun 2008 13:41:57 +0000 | |
| branch | NewGRF_ports |
| changeset 10995 | 311b38c7f9a7 |
| parent 10991 | d8811e327d12 |
| permissions | -rw-r--r-- |
| 2186 | 1 |
/* $Id$ */ |
2 |
||
|
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
3 |
/** @file airport_gui.cpp The GUI for airports. */ |
|
6443
b8f06d8eb7be
(svn r8853) -Cleanup: doxygen changes. Correct forgotten c files to cpp files with the @file tag as well as a few general comments style
belugas
parents:
6368
diff
changeset
|
4 |
|
| 0 | 5 |
#include "stdafx.h" |
|
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1784
diff
changeset
|
6 |
#include "openttd.h" |
|
10184
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6882
diff
changeset
|
7 |
#include "gui.h" |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
8 |
#include "window_gui.h" |
|
10184
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6882
diff
changeset
|
9 |
#include "player_func.h" |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
10 |
#include "terraform_gui.h" |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
11 |
#include "command_func.h" |
|
10184
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6882
diff
changeset
|
12 |
#include "station_gui.h" |
|
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6882
diff
changeset
|
13 |
#include "station_func.h" |
| 0 | 14 |
#include "airport.h" |
|
6722
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
6720
diff
changeset
|
15 |
#include "newgrf_callbacks.h" |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
16 |
#include "sound_func.h" |
|
10184
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6882
diff
changeset
|
17 |
#include "settings_type.h" |
|
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6882
diff
changeset
|
18 |
|
|
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6882
diff
changeset
|
19 |
#include "strings_func.h" |
|
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6882
diff
changeset
|
20 |
#include "core/alloc_func.hpp" |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
21 |
#include "window_func.h" |
|
10731
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
22 |
#include "strings_func.h" |
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
23 |
#include "settings_type.h" |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
24 |
#include "viewport_func.h" |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
25 |
#include "gfx_func.h" |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
26 |
#include "widgets/dropdown_func.h" |
|
10184
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6882
diff
changeset
|
27 |
#include "order_func.h" |
|
10242
52b4a9006029
(svn r12774) [NewGRF_ports] -Sync: with trunk r12742:12772.
richk
parents:
10192
diff
changeset
|
28 |
#include "station_type.h" |
|
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
29 |
#include "tilehighlight_func.h" |
|
6722
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
6720
diff
changeset
|
30 |
|
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
31 |
#include "table/sprites.h" |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
32 |
#include "table/strings.h" |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
33 |
|
|
6722
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
6720
diff
changeset
|
34 |
static struct {
|
|
6762
aebd7285dbc2
(svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents:
6760
diff
changeset
|
35 |
byte layout_set; |
|
6722
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
6720
diff
changeset
|
36 |
byte numtracks; |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
6720
diff
changeset
|
37 |
byte platlength; |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
6720
diff
changeset
|
38 |
bool dragdrop; |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
6720
diff
changeset
|
39 |
|
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
6720
diff
changeset
|
40 |
FSMportsClassIDByte fsmports_class; |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
6720
diff
changeset
|
41 |
byte station_type; |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
6720
diff
changeset
|
42 |
byte station_count; |
|
6768
d29ac98e3e0c
(svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents:
6765
diff
changeset
|
43 |
DirectionByte direction; |
|
6745
f45a41940079
(svn r10783) [NewGRF_ports] -Feature: Added placing FSMport in any of up to 4 different orientations. GUI now has a preview image for each orientation - not interactive, just a screenshot stored.
richk
parents:
6743
diff
changeset
|
44 |
} _airport; |
|
6722
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
6720
diff
changeset
|
45 |
|
|
10731
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
46 |
static void ShowBuildAirportPicker(Window *parent); |
| 0 | 47 |
|
48 |
||
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
49 |
void CcBuildAirport(bool success, TileIndex tile, uint32 p1, uint32 p2) |
| 0 | 50 |
{
|
51 |
if (success) {
|
|
| 541 | 52 |
SndPlayTileFx(SND_1F_SPLAT, tile); |
| 0 | 53 |
ResetObjectToPlace(); |
54 |
} |
|
55 |
} |
|
56 |
||
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
57 |
static void PlaceAirport(TileIndex tile) |
| 0 | 58 |
{
|
|
6760
d7a806a9aa44
(svn r10802) [NewGRF_ports] -Feature: Added availability dates for airports, using callbacks. Gui modified to disable unavailable airports. If no airports available at all, airport placement disabled.
richk
parents:
6757
diff
changeset
|
59 |
if (_airport.station_type != 0xFF) /*0xFF represents No Airports Available to build */ |
|
6722
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
6720
diff
changeset
|
60 |
DoCommandP(tile, |
|
6762
aebd7285dbc2
(svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents:
6760
diff
changeset
|
61 |
_airport.layout_set | (_airport.numtracks << 8) | (_airport.platlength << 16) | (_ctrl_pressed << 24), |
|
6768
d29ac98e3e0c
(svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents:
6765
diff
changeset
|
62 |
0x80 | (_airport.fsmports_class << 8) | (_airport.station_type << 16), CcBuildAirport, |
|
6870
ca3fd1fbe311
(svn r11219) [NewGRF_ports] -Sync: with trunk r11035:11218.
rubidium
parents:
6814
diff
changeset
|
63 |
CMD_BUILD_AIRPORT | CMD_MSG(STR_A001_CAN_T_BUILD_AIRPORT_HERE)); |
| 0 | 64 |
} |
65 |
||
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
66 |
enum {
|
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
67 |
ATW_AIRPORT = 3, |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
68 |
ATW_DEMOLISH = 4 |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
69 |
}; |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
70 |
|
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
71 |
|
| 0 | 72 |
static void BuildAirClick_Airport(Window *w) |
73 |
{
|
|
|
10731
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
74 |
if (HandlePlacePushButton(w, ATW_AIRPORT, SPR_CURSOR_AIRPORT, VHM_RECT, PlaceAirport)) ShowBuildAirportPicker(w); |
| 0 | 75 |
} |
76 |
||
77 |
static void BuildAirClick_Demolish(Window *w) |
|
78 |
{
|
|
|
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
79 |
HandlePlacePushButton(w, ATW_DEMOLISH, ANIMCURSOR_DEMOLISH, VHM_RECT, PlaceProc_DemolishArea); |
| 0 | 80 |
} |
81 |
||
82 |
||
83 |
typedef void OnButtonClick(Window *w); |
|
84 |
static OnButtonClick * const _build_air_button_proc[] = {
|
|
85 |
BuildAirClick_Airport, |
|
86 |
BuildAirClick_Demolish, |
|
87 |
}; |
|
88 |
||
|
10731
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
89 |
struct BuildAirToolbarWindow : Window {
|
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
90 |
BuildAirToolbarWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) |
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
91 |
{
|
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
92 |
this->FindWindowPlacementAndResize(desc); |
|
10991
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
93 |
if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this); |
|
10731
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
94 |
} |
|
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
95 |
|
|
10731
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
96 |
~BuildAirToolbarWindow() |
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
97 |
{
|
|
10991
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
98 |
if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0); |
|
10731
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
99 |
} |
|
10192
195d7f6dcf71
(svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents:
10184
diff
changeset
|
100 |
|
|
10731
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
101 |
virtual void OnPaint() |
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
102 |
{
|
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
103 |
this->DrawWidgets(); |
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
104 |
} |
|
10192
195d7f6dcf71
(svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents:
10184
diff
changeset
|
105 |
|
|
10731
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
106 |
virtual void OnClick(Point pt, int widget) |
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
107 |
{
|
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
108 |
if (widget - 3 >= 0) {
|
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
109 |
_build_air_button_proc[widget - 3](this); |
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
110 |
} |
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
111 |
} |
|
10192
195d7f6dcf71
(svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents:
10184
diff
changeset
|
112 |
|
|
195d7f6dcf71
(svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents:
10184
diff
changeset
|
113 |
|
|
10731
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
114 |
virtual EventState OnKeyPress(uint16 key, uint16 keycode) |
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
115 |
{
|
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
116 |
switch (keycode) {
|
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
117 |
case '1': BuildAirClick_Airport(this); break; |
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
118 |
case '2': BuildAirClick_Demolish(this); break; |
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
119 |
default: return ES_NOT_HANDLED; |
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
120 |
} |
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
121 |
return ES_HANDLED; |
| 0 | 122 |
} |
|
10731
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
123 |
|
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
124 |
virtual void OnPlaceObject(Point pt, TileIndex tile) |
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
125 |
{
|
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
126 |
_place_proc(tile); |
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
127 |
} |
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
128 |
|
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
129 |
virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) |
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
130 |
{
|
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
131 |
VpSelectTilesWithMethod(pt.x, pt.y, select_method); |
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
132 |
} |
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
133 |
|
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
134 |
virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) |
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
135 |
{
|
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
136 |
if (pt.x != -1 && select_proc == DDSP_DEMOLISH_AREA) {
|
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
137 |
GUIPlaceProcDragXY(select_proc, start_tile, end_tile); |
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
138 |
} |
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
139 |
} |
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
140 |
|
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
141 |
virtual void OnPlaceObjectAbort() |
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
142 |
{
|
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
143 |
this->RaiseButtons(); |
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
144 |
|
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
145 |
delete FindWindowById(WC_BUILD_STATION, 0); |
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
146 |
} |
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
147 |
}; |
| 0 | 148 |
|
149 |
static const Widget _air_toolbar_widgets[] = {
|
|
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4171
diff
changeset
|
150 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW },
|
|
5933
0835f3342b79
(svn r8143) Remove the landscaping button from the build toolbars.
tron
parents:
5838
diff
changeset
|
151 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 51, 0, 13, STR_A000_AIRPORTS, STR_018C_WINDOW_TITLE_DRAG_THIS },
|
|
0835f3342b79
(svn r8143) Remove the landscaping button from the build toolbars.
tron
parents:
5838
diff
changeset
|
152 |
{ WWT_STICKYBOX, RESIZE_NONE, 7, 52, 63, 0, 13, 0x0, STR_STICKY_BUTTON },
|
|
4937
a525d56a8d40
(svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents:
4848
diff
changeset
|
153 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 41, 14, 35, SPR_IMG_AIRPORT, STR_A01E_BUILD_AIRPORT },
|
|
a525d56a8d40
(svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents:
4848
diff
changeset
|
154 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 42, 63, 14, 35, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC },
|
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
0
diff
changeset
|
155 |
{ WIDGETS_END},
|
| 0 | 156 |
}; |
157 |
||
158 |
||
159 |
static const WindowDesc _air_toolbar_desc = {
|
|
|
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6741
diff
changeset
|
160 |
WDP_ALIGN_TBR, 22, 64, 36, 64, 36, |
|
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6111
diff
changeset
|
161 |
WC_BUILD_TOOLBAR, WC_NONE, |
|
756
d1f1dc31b6f4
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
751
diff
changeset
|
162 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON, |
| 0 | 163 |
_air_toolbar_widgets, |
164 |
}; |
|
165 |
||
| 6573 | 166 |
void ShowBuildAirToolbar() |
| 0 | 167 |
{
|
|
5005
21e84e53c732
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4968
diff
changeset
|
168 |
if (!IsValidPlayer(_current_player)) return; |
|
21e84e53c732
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4968
diff
changeset
|
169 |
|
|
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
170 |
DeleteWindowByClass(WC_BUILD_TOOLBAR); |
|
10731
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
171 |
AllocateWindowDescFront<BuildAirToolbarWindow>(&_air_toolbar_desc, TRANSPORT_AIR); |
| 0 | 172 |
} |
173 |
||
|
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
174 |
class AirportPickerWindow : public PickerWindowBase {
|
|
6874
5d69ad7a3c98
(svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents:
6872
diff
changeset
|
175 |
|
|
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
176 |
/** Enum referring to the widgets of the airport picker window */ |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
177 |
enum BuildAirportWidgets {
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
178 |
BAPW_CLOSEBOX = 0, |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
179 |
BAPW_CAPTION, |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
180 |
BAPW_BACKGROUND, |
|
6760
d7a806a9aa44
(svn r10802) [NewGRF_ports] -Feature: Added availability dates for airports, using callbacks. Gui modified to disable unavailable airports. If no airports available at all, airport placement disabled.
richk
parents:
6757
diff
changeset
|
181 |
|
|
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
182 |
BAPW_NEWAP_DROPDOWN, |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
183 |
BAPW_NEWAP_LIST, |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
184 |
BAPW_NEWAP_SCROLL, |
|
10192
195d7f6dcf71
(svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents:
10184
diff
changeset
|
185 |
|
|
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
186 |
BAPW_MINIPIC_PANEL, |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
187 |
BAPW_ORIENT_NE, |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
188 |
BAPW_ORIENT_SE, |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
189 |
BAPW_ORIENT_SW, |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
190 |
BAPW_ORIENT_NW, |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
191 |
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
192 |
BAPW_HIGHLIGHT_OFF, |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
193 |
BAPW_HIGHLIGHT_ON, |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
194 |
}; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
195 |
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
196 |
public: |
|
10731
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
197 |
AirportPickerWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) |
|
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
198 |
{
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
199 |
_airport.station_type = 0; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
200 |
_airport.layout_set = 0; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
201 |
_airport.direction = DIR_NE; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
202 |
_airport.station_count = GetNumCustomFSMports(_airport.fsmports_class); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
203 |
|
|
10991
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
204 |
if (_settings_game.economy.station_noise_level) {
|
|
10731
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
205 |
ResizeWindowForWidget(this, BAPW_BACKGROUND, 0, 10); |
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
206 |
} |
|
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
207 |
|
|
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
208 |
this->vscroll.count = _airport.station_count; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
209 |
this->vscroll.cap = 5; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
210 |
this->vscroll.pos = Clamp(_airport.station_type - 2, 0, this->vscroll.count - this->vscroll.cap); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
211 |
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
212 |
this->SetWidgetLoweredState(BAPW_HIGHLIGHT_OFF, !_station_show_coverage); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
213 |
this->SetWidgetLoweredState(BAPW_HIGHLIGHT_ON, _station_show_coverage); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
214 |
this->FindWindowPlacementAndResize(desc); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
215 |
} |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
216 |
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
217 |
virtual void OnPaint() |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
218 |
{
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
219 |
byte preview_sprite = 0xFF; |
|
10731
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
220 |
uint16 y_noise_offset = 0; |
|
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
221 |
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
222 |
FSMportsSpec *fsmportspec = GetCustomFSMportsSpec(_airport.fsmports_class, _airport.station_type); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
223 |
/* if the port is no longer available, find one that is */ |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
224 |
if ((fsmportspec == NULL) || (HasBit(fsmportspec->callbackmask, CBM_STATION_AVAIL) && GetFSMportsCallback(CBID_STATION_AVAILABILITY, 0, 0, fsmportspec, NULL, INVALID_TILE) == 0)) {
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
225 |
/* port not available, find new one*/ |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
226 |
_airport.station_type = 0xFF; //set to the invalid condition to prevent any selection if nothing is available |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
227 |
for (uint i = 0; i < _airport.station_count; i++) {
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
228 |
fsmportspec = GetCustomFSMportsSpec(_airport.fsmports_class, i); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
229 |
if (!HasBit(fsmportspec->callbackmask, CBM_STATION_AVAIL) || GetFSMportsCallback(CBID_STATION_AVAILABILITY, 0, 0, fsmportspec, NULL, INVALID_TILE) != 0) {
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
230 |
_airport.station_type = i; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
231 |
break; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
232 |
} |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
233 |
} |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
234 |
} |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
235 |
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
236 |
for (byte j = 0; j < 4; j++) {
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
237 |
this->SetWidgetDisabledState(BAPW_ORIENT_NE + j, true); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
238 |
this->RaiseWidget(BAPW_ORIENT_NE + j); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
239 |
this->widget[BAPW_ORIENT_NE + j].data = SPR_IMG_ARROW_NE_WHITE + j; //reset arrows to white |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
240 |
} |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
241 |
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
242 |
if (_airport.station_type != 0xFF) {
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
243 |
int x = fsmportspec->size_x[_airport.layout_set]; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
244 |
int y = fsmportspec->size_y[_airport.layout_set]; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
245 |
SetTileSelectSize(x, y); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
246 |
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
247 |
/* an airport is available, so read it and update screen accordingly */ |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
248 |
for (byte j = 0; j < fsmportspec->numlayouts; j++) {
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
249 |
if (fsmportspec->layouts[j] == NULL) break; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
250 |
/* enable the permitted orientations */ |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
251 |
byte *layout_ptr = (byte*)alloca(x*y + 2); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
252 |
memcpy(layout_ptr, fsmportspec->layouts[j], (x * y) + 2); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
253 |
this->SetWidgetDisabledState(BAPW_ORIENT_NE + GB((byte)*layout_ptr, 1, 2), false); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
254 |
if (j == _airport.layout_set) {
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
255 |
layout_ptr++; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
256 |
preview_sprite = *layout_ptr; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
257 |
} |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
258 |
} |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
259 |
this->LowerWidget(BAPW_ORIENT_NE + DirToDiagDir(_airport.direction)); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
260 |
this->widget[BAPW_ORIENT_NE + DirToDiagDir(_airport.direction)].data = SPR_IMG_ARROW_NE_YELLOW + DirToDiagDir(_airport.direction); //show in yellow |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
261 |
} |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
262 |
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
263 |
SetDParam(0, GetFSMportsClassName(_airport.fsmports_class)); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
264 |
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
265 |
/* strings such as 'Size' and 'Coverage Area' */ |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
266 |
|
|
10991
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
267 |
this->DrawWidgets(); |
|
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
268 |
|
|
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
269 |
/* only show the station (airport) noise, if the noise option is activated */ |
|
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
270 |
if (_settings_game.economy.station_noise_level) {
|
|
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
271 |
/* show the noise of the selected airport */ |
|
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
272 |
SetDParam(0, fsmportspec->portFSM->noise_level); |
|
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
273 |
DrawString(2, 206, STR_STATION_NOISE, 0); |
|
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
274 |
y_noise_offset = 10; |
|
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
275 |
} |
|
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
276 |
if (_airport.station_type != 0xFF) {
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
277 |
/* draw the preview image if the station is available */ |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
278 |
if (!HasBit(fsmportspec->callbackmask, CBM_STATION_AVAIL) || GetFSMportsCallback(CBID_STATION_AVAILABILITY, 0, 0, fsmportspec, NULL, INVALID_TILE) != 0) {
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
279 |
DrawFSMportsTile(9, 106, preview_sprite, _airport.fsmports_class, _airport.station_type); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
280 |
} |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
281 |
_thd.FSMportLayout = &fsmportspec->layouts[_airport.layout_set]; // irregular airport support |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
282 |
_thd.FSMportMask = NULL; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
283 |
if (fsmportspec->layout_mask != NULL) _thd.FSMportMask = &fsmportspec->layout_mask[_airport.layout_set]; // irregular airport support |
|
10991
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
284 |
int rad = _settings_game.station.modified_catchment ? fsmportspec->portFSM->catchment : 4; |
|
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
285 |
if (_station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad); |
|
10991
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
286 |
//int text_end = DrawStationCoverageAreaText(2, 206, SCT_ALL, rad, false); |
|
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
287 |
//text_end = DrawStationCoverageAreaText(2, text_end + 4, SCT_ALL, rad, true) + 4; |
|
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
288 |
int text_end = DrawStationCoverageAreaText(2, this->widget[BAPW_HIGHLIGHT_ON].bottom + 4 + y_noise_offset, SCT_ALL, rad, false); |
|
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
289 |
if (text_end > this->widget[BAPW_BACKGROUND].bottom) {
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
290 |
this->SetDirty(); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
291 |
ResizeWindowForWidget(this, BAPW_BACKGROUND, 0, text_end - this->widget[BAPW_BACKGROUND].bottom); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
292 |
this->SetDirty(); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
293 |
} |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
294 |
} else {
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
295 |
/* if nothing is selectable, draw the image of the first in the non-selectable list, but grey out the preview */ |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
296 |
fsmportspec = GetCustomFSMportsSpec(_airport.fsmports_class, 0); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
297 |
byte *layout_ptr = (byte*)alloca(fsmportspec->size_x[0] * fsmportspec->size_y[0] + 2); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
298 |
memcpy(layout_ptr, fsmportspec->layouts[0], (fsmportspec->size_x[0] * fsmportspec->size_y[0]) + 2); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
299 |
layout_ptr++; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
300 |
preview_sprite = *layout_ptr; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
301 |
DrawFSMportsTile(9, 106, preview_sprite, _airport.fsmports_class, 0); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
302 |
GfxFillRect(8, 106, 105, 172, (1 << PALETTE_MODIFIER_GREYOUT)); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
303 |
_thd.FSMportLayout = NULL; // ensure irregular airport support disabled |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
304 |
_thd.FSMportMask = NULL; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
305 |
SetTileSelectSize(1,1); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
306 |
} |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
307 |
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
308 |
for (uint16 i = this->vscroll.pos, y = 35; i < _airport.station_count && i < (uint)(this->vscroll.pos + this->vscroll.cap); i++, y += 14) {
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
309 |
const FSMportsSpec *fsmportspec = GetCustomFSMportsSpec(_airport.fsmports_class, i); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
310 |
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
311 |
if (fsmportspec != NULL && fsmportspec->name != 0) {
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
312 |
if (HasBit(fsmportspec->callbackmask, CBM_STATION_AVAIL) && GetFSMportsCallback(CBID_STATION_AVAILABILITY, 0, 0, fsmportspec, NULL, INVALID_TILE) == 0) {
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
313 |
GfxFillRect(8, y - 2, 127, y + 10, (1 << PALETTE_MODIFIER_GREYOUT)); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
314 |
} |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
315 |
DrawStringTruncated(9, y, fsmportspec->name, i == _airport.station_type ? 12 : 16, 118); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
316 |
} else {
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
317 |
DrawStringTruncated(9, y, STR_STAT_CLASS_DFLT, i == _airport.station_type ? 12 : 16, 118); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
318 |
} |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
319 |
} |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
320 |
} |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
321 |
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
322 |
virtual void OnClick(Point pt, int widget) |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
323 |
{
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
324 |
switch (widget) {
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
325 |
case BAPW_HIGHLIGHT_OFF: case BAPW_HIGHLIGHT_ON: |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
326 |
_station_show_coverage = (widget != BAPW_HIGHLIGHT_OFF); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
327 |
this->SetWidgetLoweredState(BAPW_HIGHLIGHT_OFF, !_station_show_coverage); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
328 |
this->SetWidgetLoweredState(BAPW_HIGHLIGHT_ON, _station_show_coverage); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
329 |
SndPlayFx(SND_15_BEEP); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
330 |
this->SetDirty(); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
331 |
break; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
332 |
case BAPW_NEWAP_DROPDOWN: |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
333 |
ShowDropDownList(this, BuildFSMportsClassDropdown(), _airport.fsmports_class, BAPW_NEWAP_DROPDOWN); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
334 |
break; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
335 |
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
336 |
case BAPW_NEWAP_LIST: {
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
337 |
const FSMportsSpec *fsmportspec; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
338 |
int y = (pt.y - 32) / 14; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
339 |
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
340 |
if (y >= this->vscroll.cap) return; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
341 |
y += this->vscroll.pos; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
342 |
if (y >= _airport.station_count) return; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
343 |
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
344 |
/* Check station availability callback */ |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
345 |
fsmportspec = GetCustomFSMportsSpec(_airport.fsmports_class, y); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
346 |
if (fsmportspec != NULL && |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
347 |
HasBit(fsmportspec->callbackmask, CBM_STATION_AVAIL) && |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
348 |
GetFSMportsCallback(CBID_STATION_AVAILABILITY, 0, 0, fsmportspec, NULL, INVALID_TILE) == 0) return; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
349 |
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
350 |
_airport.station_type = y; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
351 |
_airport.layout_set = 0; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
352 |
_airport.platlength= fsmportspec->size_y[_airport.layout_set]; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
353 |
_airport.numtracks = fsmportspec->size_x[_airport.layout_set]; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
354 |
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
355 |
SndPlayFx(SND_15_BEEP); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
356 |
this->SetDirty(); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
357 |
break; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
358 |
} |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
359 |
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
360 |
case BAPW_ORIENT_NE: |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
361 |
case BAPW_ORIENT_SE: |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
362 |
case BAPW_ORIENT_SW: |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
363 |
case BAPW_ORIENT_NW: |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
364 |
this->widget[BAPW_ORIENT_NE + DirToDiagDir(_airport.direction)].data = SPR_IMG_ARROW_NE_WHITE + DirToDiagDir(_airport.direction); //reset arrow to white |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
365 |
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
366 |
/* find the layout_set that corresponds to the selected orientation */ |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
367 |
FSMportsSpec *fsmportspec = GetCustomFSMportsSpec(_airport.fsmports_class, _airport.station_type); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
368 |
_airport.layout_set = 0; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
369 |
_airport.direction = DiagDirToDir((DiagDirection)(widget - BAPW_ORIENT_NE)); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
370 |
for (byte j = 0; j < fsmportspec->numlayouts; j++) {
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
371 |
int x = fsmportspec->size_x[j]; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
372 |
int y = fsmportspec->size_y[j]; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
373 |
if (fsmportspec->layouts[j] == NULL) break; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
374 |
/* enable the permitted orientations */ |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
375 |
byte *layout_ptr = (byte*)alloca(x * y + 2); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
376 |
memcpy(layout_ptr, fsmportspec->layouts[j], (x * y) + 2); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
377 |
if (*layout_ptr == _airport.direction) {
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
378 |
_airport.layout_set = j; |
|
10192
195d7f6dcf71
(svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents:
10184
diff
changeset
|
379 |
break; |
|
195d7f6dcf71
(svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents:
10184
diff
changeset
|
380 |
} |
|
6760
d7a806a9aa44
(svn r10802) [NewGRF_ports] -Feature: Added availability dates for airports, using callbacks. Gui modified to disable unavailable airports. If no airports available at all, airport placement disabled.
richk
parents:
6757
diff
changeset
|
381 |
} |
|
10192
195d7f6dcf71
(svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents:
10184
diff
changeset
|
382 |
|
|
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
383 |
this->SetWidgetLoweredState( BAPW_ORIENT_NE, (_airport.direction == DIR_NE)); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
384 |
this->SetWidgetLoweredState( BAPW_ORIENT_SE, (_airport.direction == DIR_SE)); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
385 |
this->SetWidgetLoweredState( BAPW_ORIENT_SW, (_airport.direction == DIR_SW)); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
386 |
this->SetWidgetLoweredState( BAPW_ORIENT_NW, (_airport.direction == DIR_NW)); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
387 |
SndPlayFx(SND_15_BEEP); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
388 |
this->SetDirty(); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
389 |
break; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
390 |
} |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
391 |
} |
|
10192
195d7f6dcf71
(svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents:
10184
diff
changeset
|
392 |
|
|
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
393 |
virtual void OnDropdownSelect(int widget, int index) |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
394 |
{
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
395 |
if (_airport.fsmports_class != index) {
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
396 |
_airport.fsmports_class = (FSMportsClassID)index; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
397 |
_airport.station_type = 0; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
398 |
_airport.layout_set = 0; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
399 |
_airport.direction = DIR_NE; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
400 |
_airport.station_count = GetNumCustomFSMports(_airport.fsmports_class); |
|
10192
195d7f6dcf71
(svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents:
10184
diff
changeset
|
401 |
|
|
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
402 |
this->vscroll.count = _airport.station_count; |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
403 |
this->vscroll.pos = _airport.station_type; |
|
6760
d7a806a9aa44
(svn r10802) [NewGRF_ports] -Feature: Added availability dates for airports, using callbacks. Gui modified to disable unavailable airports. If no airports available at all, airport placement disabled.
richk
parents:
6757
diff
changeset
|
404 |
} |
| 0 | 405 |
|
|
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
406 |
SndPlayFx(SND_15_BEEP); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
407 |
this->SetDirty(); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
408 |
} |
|
6762
aebd7285dbc2
(svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents:
6760
diff
changeset
|
409 |
|
|
10192
195d7f6dcf71
(svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents:
10184
diff
changeset
|
410 |
|
|
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
411 |
virtual void OnTick() |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
412 |
{
|
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
413 |
CheckRedrawStationCoverage(this); |
|
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
414 |
} |
|
6762
aebd7285dbc2
(svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents:
6760
diff
changeset
|
415 |
|
|
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
416 |
}; |
| 0 | 417 |
|
418 |
static const Widget _build_airport_picker_widgets[] = {
|
|
|
4345
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
419 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
420 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_3001_AIRPORT_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
6768
d29ac98e3e0c
(svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents:
6765
diff
changeset
|
421 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 147, 14, 239, 0x0, STR_NULL},
|
|
6874
5d69ad7a3c98
(svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents:
6872
diff
changeset
|
422 |
{ WWT_DROPDOWNIN, RESIZE_NONE, 14, 7, 140, 17, 28, STR_02BD, STR_SELECT_STATION_CLASS_TIP}, // BAPW_NEWAP_DROPDOWN
|
|
6768
d29ac98e3e0c
(svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents:
6765
diff
changeset
|
423 |
{ WWT_MATRIX, RESIZE_NONE, 14, 7, 128, 32, 102, 0x501, STR_SELECT_STATION_TYPE_TIP},
|
|
d29ac98e3e0c
(svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents:
6765
diff
changeset
|
424 |
{ WWT_SCROLLBAR, RESIZE_NONE, 14, 129, 140, 32, 102, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
|
d29ac98e3e0c
(svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents:
6765
diff
changeset
|
425 |
{ WWT_INSET, RESIZE_NONE, 7, 7, 107, 104, 173, 0x0, STR_NULL},
|
|
d29ac98e3e0c
(svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents:
6765
diff
changeset
|
426 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 109, 140, 104, 119, SPR_IMG_ARROW_NE_WHITE, STR_NULL},
|
|
d29ac98e3e0c
(svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents:
6765
diff
changeset
|
427 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 109, 140, 122, 137, SPR_IMG_ARROW_SE_WHITE, STR_NULL},
|
|
d29ac98e3e0c
(svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents:
6765
diff
changeset
|
428 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 109, 140, 140, 155, SPR_IMG_ARROW_SW_WHITE, STR_NULL},
|
|
d29ac98e3e0c
(svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents:
6765
diff
changeset
|
429 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 109, 140, 158, 173, SPR_IMG_ARROW_NW_WHITE, STR_NULL},
|
|
4345
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
430 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 14, 73, 191, 202, STR_02DB_OFF, STR_3065_DON_T_HIGHLIGHT_COVERAGE},
|
|
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
431 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 74, 133, 191, 202, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA},
|
|
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
432 |
{ WWT_LABEL, RESIZE_NONE, 7, 0, 147, 178, 191, STR_3066_COVERAGE_AREA_HIGHLIGHT, STR_NULL},
|
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
0
diff
changeset
|
433 |
{ WIDGETS_END},
|
| 0 | 434 |
}; |
435 |
||
436 |
static const WindowDesc _build_airport_desc = {
|
|
|
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6741
diff
changeset
|
437 |
WDP_AUTO, WDP_AUTO, 148, 240, 148, 240, |
|
5070
0bbf5264bfb7
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
438 |
WC_BUILD_STATION, WC_BUILD_TOOLBAR, |
| 0 | 439 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
440 |
_build_airport_picker_widgets, |
|
441 |
}; |
|
442 |
||
|
10731
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
443 |
static void ShowBuildAirportPicker(Window *parent) |
| 0 | 444 |
{
|
|
10731
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
445 |
new AirportPickerWindow(&_build_airport_desc, parent); |
| 0 | 446 |
} |
447 |
||
| 6573 | 448 |
void InitializeAirportGui() |
| 0 | 449 |
{
|
450 |
} |