src/airport_gui.cpp
author richk
Mon, 06 Aug 2007 03:18:02 +0000
branchNewGRF_ports
changeset 6764 9ba2e4d4a57f
parent 6762 aebd7285dbc2
child 6765 7e910c6a11a0
permissions -rw-r--r--
(svn r10806) [NewGRF_ports] -Change: Moved orientation buttons to match height of preview window.
Updated airports.grf with skidd13's version of daylight's arrows. Many thanks to both.
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
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
     3
/** @file airport_gui.cpp */
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     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"
1363
01d3de5d8039 (svn r1867) Include tables/sprites.h only in files which need it
tron
parents: 1313
diff changeset
     7
#include "table/sprites.h"
507
8aa8100b0b22 (svn r815) Include strings.h only in the files which need it.
tron
parents: 337
diff changeset
     8
#include "table/strings.h"
2163
637ec3c361f5 (svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents: 1977
diff changeset
     9
#include "functions.h"
679
e959706a3e4d (svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents: 606
diff changeset
    10
#include "map.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    11
#include "window.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
#include "gui.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    13
#include "viewport.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    14
#include "gfx.h"
337
66647f97e7c0 (svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents: 193
diff changeset
    15
#include "sound.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    16
#include "command.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    17
#include "vehicle.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    18
#include "station.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    19
#include "airport.h"
1313
bba6afb8a995 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents: 1116
diff changeset
    20
#include "depot.h"
6726
fc44af727904 (svn r10596) [NewGRF_ports] -Fix: missed move of SetDParam into strings.h.
richk
parents: 6724
diff changeset
    21
#include "strings.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
    22
#include "newgrf_callbacks.h"
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
    23
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
    24
//TODO: remove station.h once converted to newgrf airports. stations just used as temporary loader
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
    25
#include "station.h"
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
    26
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
    27
	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
    28
	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
    29
	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
    30
	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
    31
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
    32
	bool newstations;
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
    33
	bool newstation_selected;
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
    34
	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
    35
	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
    36
	byte station_count;
6762
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
    37
	byte 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
    38
} _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
    39
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
    40
static byte _selected_airport_type = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    41
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6443
diff changeset
    42
static void ShowBuildAirportPicker();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    43
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    44
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    45
void CcBuildAirport(bool success, TileIndex tile, uint32 p1, uint32 p2)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    46
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    47
	if (success) {
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 507
diff changeset
    48
		SndPlayTileFx(SND_1F_SPLAT, tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    49
		ResetObjectToPlace();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    50
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    51
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    52
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    53
static void PlaceAirport(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    54
{
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
    55
	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
    56
		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
    57
				_airport.layout_set | (_airport.numtracks << 8) | (_airport.platlength << 16) | (_ctrl_pressed << 24),
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
    58
				_selected_airport_type | ((_airport.newstation_selected)? 0x80 : 0x00) | (_airport.fsmports_class << 8) | (_airport.station_type << 16), CcBuildAirport,
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
    59
				CMD_BUILD_AIRPORT | CMD_NO_WATER | CMD_AUTO | CMD_MSG(STR_A001_CAN_T_BUILD_AIRPORT_HERE));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    60
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    61
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    62
static void PlaceAir_DemolishArea(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    63
{
6719
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6718
diff changeset
    64
	VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_DEMOLISH_AREA);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    65
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    66
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    67
5147
db717cde801d (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5072
diff changeset
    68
enum {
db717cde801d (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5072
diff changeset
    69
	ATW_AIRPORT  = 3,
db717cde801d (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5072
diff changeset
    70
	ATW_DEMOLISH = 4
db717cde801d (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5072
diff changeset
    71
};
db717cde801d (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5072
diff changeset
    72
db717cde801d (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5072
diff changeset
    73
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    74
static void BuildAirClick_Airport(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    75
{
5147
db717cde801d (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5072
diff changeset
    76
	if (HandlePlacePushButton(w, ATW_AIRPORT, SPR_CURSOR_AIRPORT, 1, PlaceAirport)) ShowBuildAirportPicker();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    77
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    78
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    79
static void BuildAirClick_Demolish(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    80
{
5147
db717cde801d (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5072
diff changeset
    81
	HandlePlacePushButton(w, ATW_DEMOLISH, ANIMCURSOR_DEMOLISH, 1, PlaceAir_DemolishArea);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    82
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    83
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    84
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    85
typedef void OnButtonClick(Window *w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    86
static OnButtonClick * const _build_air_button_proc[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    87
	BuildAirClick_Airport,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    88
	BuildAirClick_Demolish,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
static void BuildAirToolbWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
{
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
    93
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
	case WE_PAINT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    98
	case WE_CLICK:
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4345
diff changeset
    99
		if (e->we.click.widget - 3 >= 0)
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4345
diff changeset
   100
			_build_air_button_proc[e->we.click.widget - 3](w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   101
		break;
1019
6363b8a4273e (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 946
diff changeset
   102
937
a8dfd3eb406f (svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents: 867
diff changeset
   103
	case WE_KEYPRESS: {
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4345
diff changeset
   104
		switch (e->we.keypress.keycode) {
937
a8dfd3eb406f (svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents: 867
diff changeset
   105
			case '1': BuildAirClick_Airport(w); break;
a8dfd3eb406f (svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents: 867
diff changeset
   106
			case '2': BuildAirClick_Demolish(w); break;
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2619
diff changeset
   107
			default: return;
937
a8dfd3eb406f (svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents: 867
diff changeset
   108
		}
a8dfd3eb406f (svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents: 867
diff changeset
   109
	} break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   110
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   111
	case WE_PLACE_OBJ:
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4345
diff changeset
   112
		_place_proc(e->we.place.tile);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   113
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   114
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4059
diff changeset
   115
	case WE_PLACE_DRAG:
6719
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6718
diff changeset
   116
		VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4059
diff changeset
   117
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   118
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
	case WE_PLACE_MOUSEUP:
6719
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6718
diff changeset
   120
		if (e->we.place.pt.x != -1 && e->we.place.select_proc == DDSP_DEMOLISH_AREA) {
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4345
diff changeset
   121
			DoCommandP(e->we.place.tile, e->we.place.starttile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   122
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   123
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   124
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   125
	case WE_ABORT_PLACE_OBJ:
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   126
		RaiseWindowButtons(w);
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   127
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   128
		w = FindWindowById(WC_BUILD_STATION, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   129
		if (w != 0)
6719
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6718
diff changeset
   130
			WP(w, def_d).close = true;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   131
		break;
2619
c2f488e400b1 (svn r3157) - Feature: Added patch option to link the terraform toolbar to the rail, road, water and airport toolbars. If enabled, the terraform toolbar will open and close with those toolbars.
peter1138
parents: 2186
diff changeset
   132
c2f488e400b1 (svn r3157) - Feature: Added patch option to link the terraform toolbar to the rail, road, water and airport toolbars. If enabled, the terraform toolbar will open and close with those toolbars.
peter1138
parents: 2186
diff changeset
   133
	case WE_DESTROY:
c2f488e400b1 (svn r3157) - Feature: Added patch option to link the terraform toolbar to the rail, road, water and airport toolbars. If enabled, the terraform toolbar will open and close with those toolbars.
peter1138
parents: 2186
diff changeset
   134
		if (_patches.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
c2f488e400b1 (svn r3157) - Feature: Added patch option to link the terraform toolbar to the rail, road, water and airport toolbars. If enabled, the terraform toolbar will open and close with those toolbars.
peter1138
parents: 2186
diff changeset
   135
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   136
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   137
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   138
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   139
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
   140
{   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
   141
{    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
   142
{  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
   143
{     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
   144
{     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
   145
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   146
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   147
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   148
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   149
static const WindowDesc _air_toolbar_desc = {
6743
cabfaa4a0295 (svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents: 6741
diff changeset
   150
	WDP_ALIGN_TBR, 22, 64, 36, 64, 36,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6111
diff changeset
   151
	WC_BUILD_TOOLBAR, WC_NONE,
756
d1f1dc31b6f4 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents: 751
diff changeset
   152
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   153
	_air_toolbar_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   154
	BuildAirToolbWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   155
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   156
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6443
diff changeset
   157
void ShowBuildAirToolbar()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   158
{
5005
21e84e53c732 (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4968
diff changeset
   159
	if (!IsValidPlayer(_current_player)) return;
21e84e53c732 (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4968
diff changeset
   160
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   161
	DeleteWindowById(WC_BUILD_TOOLBAR, 0);
6111
32f6149dc192 (svn r8436) -Fix
tron
parents: 5933
diff changeset
   162
	Window *w = AllocateWindowDescFront(&_air_toolbar_desc, 0);
32f6149dc192 (svn r8436) -Fix
tron
parents: 5933
diff changeset
   163
	if (_patches.link_terraform_toolbar) ShowTerraformToolbar(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   164
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   165
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   166
static void BuildAirportPickerWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   167
{
1784
6eb3ab1bc33c (svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents: 1363
diff changeset
   168
	switch (e->event) {
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   169
	case WE_CREATE:
4727
ba5bae41b004 (svn r6639) -CodeChange : Conversion of SetWidgetLoweredState to SetWindowWidgetLoweredState, in order to follow pre-established standard
belugas
parents: 4719
diff changeset
   170
		SetWindowWidgetLoweredState(w, 16, !_station_show_coverage);
ba5bae41b004 (svn r6639) -CodeChange : Conversion of SetWidgetLoweredState to SetWindowWidgetLoweredState, in order to follow pre-established standard
belugas
parents: 4719
diff changeset
   171
		SetWindowWidgetLoweredState(w, 17, _station_show_coverage);
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   172
		LowerWindowWidget(w, _selected_airport_type + 7);
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   173
		break;
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   174
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   175
	case WE_PAINT: {
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   176
		bool newstations = (GetNumFSMportsClasses() != 0);
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
   177
		byte preview_sprite = 0xFF;
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   178
		int y_offset;
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
   179
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
   180
		FSMportsSpec *fsmportspec = newstations ? GetCustomFSMportsSpec(_airport.fsmports_class, _airport.station_type) : NULL;
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
		/* if the port is no longer available, find one that is */
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
   182
		if ((fsmportspec == NULL) || (HASBIT(fsmportspec->callbackmask, CBM_STATION_AVAIL) && GetFSMportsCallback(CBID_STATION_AVAILABILITY, 0, 0, fsmportspec, NULL, INVALID_TILE) == 0)) {
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
   183
			/* port not available, find new one*/
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
   184
			_airport.station_type = 0xFF;  //set to the invalid condition to prevent any selection if nothing is available
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
   185
			for (uint i = 0; i < _airport.station_count; i++) {
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
   186
				fsmportspec = GetCustomFSMportsSpec(_airport.fsmports_class, i);
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
   187
				if (!HASBIT(fsmportspec->callbackmask, CBM_STATION_AVAIL) || GetFSMportsCallback(CBID_STATION_AVAILABILITY, 0, 0, fsmportspec, NULL, INVALID_TILE) != 0) {
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
   188
					_airport.station_type = i;
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
   189
					break;
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
   190
				}
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
   191
			}
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
   192
		}
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   193
4709
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4634
diff changeset
   194
		int i; // airport enabling loop
1784
6eb3ab1bc33c (svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents: 1363
diff changeset
   195
		uint32 avail_airports;
6738
72d1a2997952 (svn r10683) [NewGRF_ports] -Revert: Too eager to un-const... global search/replace removed too many. Restores necessary ones... for the moment ;)
richk
parents: 6734
diff changeset
   196
		const AirportFTAClass *airport;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   197
6719
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6718
diff changeset
   198
		if (WP(w, def_d).close) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   199
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   200
		airport = GetAirport(_selected_airport_type);
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   201
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
   202
		for (byte j = 0; j < 4; j++)
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
   203
		{
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
   204
			SetWindowWidgetDisabledState(w, 28 + j, true);
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
   205
			RaiseWindowWidget(w, 28 + j);
6762
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   206
			w->widget[28 + j].data = SPR_IMG_ARROW_NE_WHITE + j;  //reset arrows to white
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   207
		}
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   208
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
   209
		if (_airport.station_type != 0xFF)
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
   210
		{
6762
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   211
			int x = fsmportspec->size_x[_airport.layout_set];
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   212
			int y = fsmportspec->size_y[_airport.layout_set];
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
   213
			SetTileSelectSize(x, y);
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
   214
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
   215
			/* an airport is available, so read it and update screen accordingly */
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
   216
			for (byte j = 0; j < fsmportspec->numlayouts; j++)
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
   217
			{
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
   218
				if (fsmportspec->layouts[j] == NULL) break;
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
   219
				/* enable the permitted orientations */
6762
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   220
				byte *layout_ptr = (byte*)alloca(x*y + 2);
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   221
				memcpy(layout_ptr, fsmportspec->layouts[j], (x * y) + 2);
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
   222
				SetWindowWidgetDisabledState(w, 28 + GB((byte)*layout_ptr,1,2), false);
6762
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   223
				if (j == _airport.layout_set) {
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
   224
					layout_ptr++;
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
   225
					preview_sprite = *layout_ptr;
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
   226
				}
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
   227
			}
6762
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   228
			LowerWindowWidget(w, 28 + ((_airport.direction - 1) / 2));
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   229
			w->widget[28 + ((_airport.direction - 1) / 2)].data = SPR_IMG_ARROW_NE_YELLOW + ((_airport.direction - 1) / 2);  //show in yellow
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
   230
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
   231
			_thd.airport = _airport.station_type;
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
   232
			_thd.airport_template = true;
568
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 543
diff changeset
   233
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
   234
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   235
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
   236
		SetDParam(0, GetFSMportsClassName(_airport.fsmports_class));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   237
		DrawWindowWidgets(w);
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   238
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
   239
		/* only draw the preview image if the station is available */
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
   240
		if (!HASBIT(fsmportspec->callbackmask, CBM_STATION_AVAIL) || GetFSMportsCallback(CBID_STATION_AVAILABILITY, 0, 0, fsmportspec, NULL, INVALID_TILE) != 0) {
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
   241
			DrawFSMportsTile(9, 106, preview_sprite, _airport.fsmports_class, _airport.station_type);
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
   242
		}
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
   243
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
   244
		y_offset = newstations ? 170 : 0;
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   245
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4059
diff changeset
   246
		// strings such as 'Size' and 'Coverage Area'
4345
dd12549ad473 (svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents: 4344
diff changeset
   247
		// 'Coverage Area'
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
   248
		if (_airport.station_type != 0xFF)
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
   249
		{
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
   250
			int rad = _patches.modified_catchment ? ((_airport.newstation_selected)? fsmportspec->portFSM->catchment : airport->catchment) : 4;
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
   251
			if (_station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
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
   252
			DrawStationCoverageAreaText(2, 206 + y_offset, SCT_ALL, rad);
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
   253
		}
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   254
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   255
		if (newstations) {
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   256
			uint16 i;
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   257
			uint y = 35;
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   258
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
   259
			for (i = w->vscroll.pos; i < _airport.station_count && i < (uint)(w->vscroll.pos + w->vscroll.cap); i++) {
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
   260
				const FSMportsSpec *fsmportspec = GetCustomFSMportsSpec(_airport.fsmports_class, i);
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   261
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   262
				if (fsmportspec != NULL && fsmportspec->name != 0) {
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   263
					if (HASBIT(fsmportspec->callbackmask, CBM_STATION_AVAIL) && GetFSMportsCallback(CBID_STATION_AVAILABILITY, 0, 0, fsmportspec, NULL, INVALID_TILE) == 0) {
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   264
						GfxFillRect(8, y - 2, 127, y + 10, (1 << PALETTE_MODIFIER_GREYOUT));
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   265
					}
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
   266
					DrawStringTruncated(9, y, fsmportspec->name, i == _airport.station_type ? 12 : 16, 118);
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   267
				} else {
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
   268
					DrawStringTruncated(9, y, STR_STAT_CLASS_DFLT, i == _airport.station_type ? 12 : 16, 118);
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   269
				}
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   270
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   271
				y += 14;
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   272
			}
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   273
		}
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   274
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   275
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   276
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   277
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   278
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   279
	case WE_CLICK: {
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4345
diff changeset
   280
		switch (e->we.click.widget) {
4059
f1442dfe1c8a (svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents: 3884
diff changeset
   281
		case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15:
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   282
			RaiseWindowWidget(w, _selected_airport_type + 7);
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4345
diff changeset
   283
			_selected_airport_type = e->we.click.widget - 7;
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
   284
			if (GetNumFSMportsClasses() == 0) _airport.newstation_selected = false;
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   285
			LowerWindowWidget(w, _selected_airport_type + 7);
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 507
diff changeset
   286
			SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   287
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   288
			break;
4059
f1442dfe1c8a (svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents: 3884
diff changeset
   289
		case 16: case 17:
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   290
			_station_show_coverage = (e->we.click.widget != 16);
4727
ba5bae41b004 (svn r6639) -CodeChange : Conversion of SetWidgetLoweredState to SetWindowWidgetLoweredState, in order to follow pre-established standard
belugas
parents: 4719
diff changeset
   291
			SetWindowWidgetLoweredState(w, 16, !_station_show_coverage);
ba5bae41b004 (svn r6639) -CodeChange : Conversion of SetWidgetLoweredState to SetWindowWidgetLoweredState, in order to follow pre-established standard
belugas
parents: 4719
diff changeset
   292
			SetWindowWidgetLoweredState(w, 17, _station_show_coverage);
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 507
diff changeset
   293
			SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   294
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   295
			break;
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   296
		case 23:
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   297
		case 24:
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
   298
			ShowDropDownMenu(w, BuildFSMportsClassDropdown(), _airport.fsmports_class, 24, 0, 1 << FSMPORTS_CLASS_WAYP);
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   299
			break;
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   300
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   301
		case 25: {
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   302
			const FSMportsSpec *fsmportspec;
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   303
			int y = (e->we.click.pt.y - 32) / 14;
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   304
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   305
			if (y >= w->vscroll.cap) return;
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   306
			y += w->vscroll.pos;
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
   307
			if (y >= _airport.station_count) return;
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   308
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   309
			/* Check station availability callback */
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
   310
			fsmportspec = GetCustomFSMportsSpec(_airport.fsmports_class, y);
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   311
			if (fsmportspec != NULL &&
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   312
				HASBIT(fsmportspec->callbackmask, CBM_STATION_AVAIL) &&
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   313
				GetFSMportsCallback(CBID_STATION_AVAILABILITY, 0, 0, fsmportspec, NULL, INVALID_TILE) == 0) return;
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   314
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
   315
			_airport.station_type = y;
6762
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   316
			_airport.layout_set = 0;
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   317
			_airport.platlength= fsmportspec->size_y[_airport.layout_set];
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   318
			_airport.numtracks = fsmportspec->size_x[_airport.layout_set];
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
   319
			_airport.newstation_selected = true;
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   320
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   321
			SndPlayFx(SND_15_BEEP);
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   322
			SetWindowDirty(w);
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   323
			break;
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   324
			}
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
   325
		case 28: case 29: case 30: case 31:
6762
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   326
			w->widget[28 + ((_airport.direction - 1) / 2)].data = SPR_IMG_ARROW_NE_WHITE + ((_airport.direction - 1) / 2);  //reset arrow to white
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   327
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   328
			/* find the layout_set that corresponds to the selected orientation */
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   329
			FSMportsSpec *fsmportspec = GetCustomFSMportsSpec(_airport.fsmports_class, _airport.station_type);
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   330
			_airport.layout_set = 0;
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   331
			_airport.direction = (byte)((e->we.click.widget - 28) * 2 + 1);
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   332
			for (byte j = 0; j < fsmportspec->numlayouts; j++)
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   333
			{
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   334
				int x = fsmportspec->size_x[j];
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   335
				int y = fsmportspec->size_y[j];
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   336
				if (fsmportspec->layouts[j] == NULL) break;
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   337
				/* enable the permitted orientations */
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   338
				byte *layout_ptr = (byte*)alloca(x*y + 2);
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   339
				memcpy(layout_ptr, fsmportspec->layouts[j], (x * y) + 2);
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   340
				if (*layout_ptr == _airport.direction) {
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   341
					_airport.layout_set = j;
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   342
					break;
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   343
				}
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   344
			}
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   345
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   346
			SetWindowWidgetLoweredState(w, 28, (_airport.direction == 01));
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   347
			SetWindowWidgetLoweredState(w, 29, (_airport.direction == 03));
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   348
			SetWindowWidgetLoweredState(w, 30, (_airport.direction == 05));
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   349
			SetWindowWidgetLoweredState(w, 31, (_airport.direction == 07));
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
   350
			SndPlayFx(SND_15_BEEP);
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
   351
			SetWindowDirty(w);
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
   352
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   353
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   354
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   355
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   356
	case WE_DROPDOWN_SELECT: {
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
   357
		if (_airport.fsmports_class != e->we.dropdown.index) {
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
   358
			_airport.fsmports_class = (FSMportsClassID)e->we.dropdown.index;
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
   359
			_airport.station_type  = 0;
6762
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   360
			_airport.layout_set = 0;
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   361
			_airport.direction = 1;
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
   362
			_airport.station_count = GetNumCustomFSMports(_airport.fsmports_class);
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   363
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
   364
			w->vscroll.count = _airport.station_count;
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
   365
			w->vscroll.pos   = _airport.station_type;
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   366
		}
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   367
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   368
		SndPlayFx(SND_15_BEEP);
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   369
		SetWindowDirty(w);
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   370
	} break;
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   371
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   372
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   373
	case WE_MOUSELOOP: {
6719
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6718
diff changeset
   374
		if (WP(w, def_d).close) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   375
			DeleteWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   376
			return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   377
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   378
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   379
		CheckRedrawStationCoverage(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   380
	} break;
1109
1bab892228cd (svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents: 1093
diff changeset
   381
1072
01bf9fc64236 (svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents: 1019
diff changeset
   382
	case WE_DESTROY:
6719
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6718
diff changeset
   383
		if (!WP(w, def_d).close) ResetObjectToPlace();
1072
01bf9fc64236 (svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents: 1019
diff changeset
   384
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   385
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   386
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   387
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   388
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
   389
{   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
   390
{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   147,     0,    13, STR_3001_AIRPORT_SELECTION,       STR_018C_WINDOW_TITLE_DRAG_THIS},
dd12549ad473 (svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents: 4344
diff changeset
   391
{      WWT_PANEL,   RESIZE_NONE,     7,     0,   147,    14,    52, 0x0,                              STR_NULL},
dd12549ad473 (svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents: 4344
diff changeset
   392
{      WWT_PANEL,   RESIZE_NONE,     7,     0,   147,    53,    89, 0x0,                              STR_NULL},
dd12549ad473 (svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents: 4344
diff changeset
   393
{      WWT_PANEL,   RESIZE_NONE,     7,     0,   147,    90,   127, 0x0,                              STR_NULL},
dd12549ad473 (svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents: 4344
diff changeset
   394
{      WWT_PANEL,   RESIZE_NONE,     7,     0,   147,   128,   177, 0x0,                              STR_NULL},
dd12549ad473 (svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents: 4344
diff changeset
   395
{      WWT_PANEL,   RESIZE_NONE,     7,     0,   147,   178,   239, 0x0,                              STR_NULL},
4968
6cfec8858f17 (svn r6971) -Fix r6961: WWT_NODISTXTBTN buttons were normal buttons not push buttons
glx
parents: 4963
diff changeset
   396
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     2,   145,    27,    38, STR_SMALL_AIRPORT,                STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
6cfec8858f17 (svn r6971) -Fix r6961: WWT_NODISTXTBTN buttons were normal buttons not push buttons
glx
parents: 4963
diff changeset
   397
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     2,   145,    65,    76, STR_CITY_AIRPORT,                 STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
6cfec8858f17 (svn r6971) -Fix r6961: WWT_NODISTXTBTN buttons were normal buttons not push buttons
glx
parents: 4963
diff changeset
   398
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     2,   145,   141,   152, STR_HELIPORT,                     STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
6cfec8858f17 (svn r6971) -Fix r6961: WWT_NODISTXTBTN buttons were normal buttons not push buttons
glx
parents: 4963
diff changeset
   399
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     2,   145,    77,    88, STR_METRO_AIRPORT ,               STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
6cfec8858f17 (svn r6971) -Fix r6961: WWT_NODISTXTBTN buttons were normal buttons not push buttons
glx
parents: 4963
diff changeset
   400
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     2,   145,   103,   114, STR_INTERNATIONAL_AIRPORT,        STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
6cfec8858f17 (svn r6971) -Fix r6961: WWT_NODISTXTBTN buttons were normal buttons not push buttons
glx
parents: 4963
diff changeset
   401
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     2,   145,    39,    50, STR_COMMUTER_AIRPORT,             STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
6cfec8858f17 (svn r6971) -Fix r6961: WWT_NODISTXTBTN buttons were normal buttons not push buttons
glx
parents: 4963
diff changeset
   402
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     2,   145,   165,   176, STR_HELIDEPOT,                    STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
6cfec8858f17 (svn r6971) -Fix r6961: WWT_NODISTXTBTN buttons were normal buttons not push buttons
glx
parents: 4963
diff changeset
   403
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     2,   145,   115,   126, STR_INTERCONTINENTAL_AIRPORT,     STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
6cfec8858f17 (svn r6971) -Fix r6961: WWT_NODISTXTBTN buttons were normal buttons not push buttons
glx
parents: 4963
diff changeset
   404
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     2,   145,   153,   164, STR_HELISTATION,                  STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
4345
dd12549ad473 (svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents: 4344
diff changeset
   405
{    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
   406
{    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
   407
{      WWT_LABEL,   RESIZE_NONE,     7,     0,   147,    14,    27, STR_SMALL_AIRPORTS,               STR_NULL},
dd12549ad473 (svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents: 4344
diff changeset
   408
{      WWT_LABEL,   RESIZE_NONE,     7,     0,   147,    52,    65, STR_LARGE_AIRPORTS,               STR_NULL},
dd12549ad473 (svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents: 4344
diff changeset
   409
{      WWT_LABEL,   RESIZE_NONE,     7,     0,   147,    90,   103, STR_HUB_AIRPORTS,                 STR_NULL},
dd12549ad473 (svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents: 4344
diff changeset
   410
{      WWT_LABEL,   RESIZE_NONE,     7,     0,   147,   128,   141, STR_HELIPORTS,                    STR_NULL},
dd12549ad473 (svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents: 4344
diff changeset
   411
{      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
   412
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   413
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   414
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   415
static const Widget _newports_build_airport_picker_widgets[] = {
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   416
{   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                         STR_018B_CLOSE_WINDOW},
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   417
{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   147,     0,    13, STR_3001_AIRPORT_SELECTION,       STR_018C_WINDOW_TITLE_DRAG_THIS},
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
   418
{      WWT_PANEL,   RESIZE_NONE,     7,     0,   147,    14,   222, 0x0,                              STR_NULL},
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
   419
{      WWT_PANEL,   RESIZE_NONE,     7,     0,   147,   223,   259, 0x0,                              STR_NULL},
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
   420
{      WWT_PANEL,   RESIZE_NONE,     7,     0,   147,   260,   297, 0x0,                              STR_NULL},
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
   421
{      WWT_PANEL,   RESIZE_NONE,     7,     0,   147,   298,   347, 0x0,                              STR_NULL},
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
   422
{      WWT_PANEL,   RESIZE_NONE,     7,     0,   147,   348,   409, 0x0,                              STR_NULL},
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
   423
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     2,   145,   197,   208, STR_SMALL_AIRPORT,                STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
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
   424
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     2,   145,   235,   246, STR_CITY_AIRPORT,                 STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
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
   425
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     2,   145,   311,   322, STR_HELIPORT,                     STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
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
   426
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     2,   145,   247,   258, STR_METRO_AIRPORT ,               STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
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
   427
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     2,   145,   273,   284, STR_INTERNATIONAL_AIRPORT,        STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
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
   428
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     2,   145,   209,   220, STR_COMMUTER_AIRPORT,             STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
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
   429
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     2,   145,   335,   346, STR_HELIDEPOT,                    STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
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
   430
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     2,   145,   285,   296, STR_INTERCONTINENTAL_AIRPORT,     STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
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
   431
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     2,   145,   323,   334, STR_HELISTATION,                  STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
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
   432
{    WWT_TEXTBTN,   RESIZE_NONE,    14,    14,    73,   361,   372, STR_02DB_OFF,                     STR_3065_DON_T_HIGHLIGHT_COVERAGE},
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
   433
{    WWT_TEXTBTN,   RESIZE_NONE,    14,    74,   133,   361,   372, STR_02DA_ON,                      STR_3064_HIGHLIGHT_COVERAGE_AREA},
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
   434
{      WWT_LABEL,   RESIZE_NONE,     7,     0,   147,   184,   197, STR_SMALL_AIRPORTS,               STR_NULL},
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
   435
{      WWT_LABEL,   RESIZE_NONE,     7,     0,   147,   222,   235, STR_LARGE_AIRPORTS,               STR_NULL},
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
   436
{      WWT_LABEL,   RESIZE_NONE,     7,     0,   147,   260,   273, STR_HUB_AIRPORTS,                 STR_NULL},
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
   437
{      WWT_LABEL,   RESIZE_NONE,     7,     0,   147,   298,   311, STR_HELIPORTS,                    STR_NULL},
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
   438
{      WWT_LABEL,   RESIZE_NONE,     7,     0,   147,   348,   361, STR_3066_COVERAGE_AREA_HIGHLIGHT, STR_NULL},
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   439
/* newstations gui additions */
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   440
//TODO: modify for airport specific texts
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   441
{      WWT_INSET,   RESIZE_NONE,    14,     7,   140,    17,    28, STR_02BD,                        STR_SELECT_STATION_CLASS_TIP},
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   442
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   129,   139,    18,    27, STR_0225,                        STR_SELECT_STATION_CLASS_TIP},
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   443
{     WWT_MATRIX,   RESIZE_NONE,    14,     7,   128,    32,   102, 0x501,                           STR_SELECT_STATION_TYPE_TIP},
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   444
{  WWT_SCROLLBAR,   RESIZE_NONE,    14,   129,   140,    32,   102, 0x0,                             STR_0190_SCROLL_BAR_SCROLLS_LIST},
6764
9ba2e4d4a57f (svn r10806) [NewGRF_ports] -Change: Moved orientation buttons to match height of preview window.
richk
parents: 6762
diff changeset
   445
{      WWT_INSET,   RESIZE_NONE,     7,     7,   107,   104,   173, 0x0,                             STR_NULL},
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
   446
{     WWT_IMGBTN,   RESIZE_NONE,    14,   109,   140,   104,   119, SPR_IMG_ARROW_NE_WHITE,          STR_NULL},
6764
9ba2e4d4a57f (svn r10806) [NewGRF_ports] -Change: Moved orientation buttons to match height of preview window.
richk
parents: 6762
diff changeset
   447
{     WWT_IMGBTN,   RESIZE_NONE,    14,   109,   140,   122,   137, SPR_IMG_ARROW_SE_WHITE,          STR_NULL},
9ba2e4d4a57f (svn r10806) [NewGRF_ports] -Change: Moved orientation buttons to match height of preview window.
richk
parents: 6762
diff changeset
   448
{     WWT_IMGBTN,   RESIZE_NONE,    14,   109,   140,   140,   155, SPR_IMG_ARROW_SW_WHITE,          STR_NULL},
9ba2e4d4a57f (svn r10806) [NewGRF_ports] -Change: Moved orientation buttons to match height of preview window.
richk
parents: 6762
diff changeset
   449
{     WWT_IMGBTN,   RESIZE_NONE,    14,   109,   140,   158,   173, SPR_IMG_ARROW_NW_WHITE,          STR_NULL},
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
   450
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
   451
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   452
{   WIDGETS_END},
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   453
};
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   454
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   455
static const WindowDesc _build_airport_desc = {
6743
cabfaa4a0295 (svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents: 6741
diff changeset
   456
	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
   457
	WC_BUILD_STATION, WC_BUILD_TOOLBAR,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   458
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   459
	_build_airport_picker_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   460
	BuildAirportPickerWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   461
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   462
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   463
static const WindowDesc _newports_build_airport_desc = {
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
   464
	WDP_AUTO, WDP_AUTO, 148, 410, 148, 410,
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   465
	WC_BUILD_STATION, WC_BUILD_TOOLBAR,
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   466
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   467
	_newports_build_airport_picker_widgets,
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   468
	BuildAirportPickerWndProc
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   469
};
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   470
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6443
diff changeset
   471
static void ShowBuildAirportPicker()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   472
{
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   473
	Window *w;
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   474
	if (GetNumFSMportsClasses() == 0) {
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   475
		w = AllocateWindowDesc(&_build_airport_desc);
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
   476
		_airport.station_type = 0;
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
   477
		_airport.newstations = false;
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   478
	} else
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   479
	{
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   480
		w = AllocateWindowDesc(&_newports_build_airport_desc);
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
   481
		_airport.station_type = 0;
6762
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   482
		_airport.layout_set = 0;
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   483
		_airport.direction = 1;
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
   484
		_airport.newstation_selected = true;
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
   485
		_airport.newstations = true;
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
   486
		_airport.station_count = GetNumCustomFSMports(_airport.fsmports_class);
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
   487
		//if (HASBIT(fsmportspec->callbackmask, CBM_STATION_AVAIL) && GetFSMportsCallback(CBID_STATION_AVAILABILITY, 0, 0, fsmportspec, NULL, INVALID_TILE) == 0) {
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
   488
		//	_airport.station_type = 0;
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
   489
		//}
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   490
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
   491
		w->vscroll.count = _airport.station_count;
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   492
		w->vscroll.cap   = 5;
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
   493
		w->vscroll.pos   = clamp(_airport.station_type - 2, 0, w->vscroll.count - w->vscroll.cap);
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   494
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   495
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   496
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6443
diff changeset
   497
void InitializeAirportGui()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   498
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   499
	_selected_airport_type = AT_SMALL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   500
}