src/airport_gui.cpp
author richk
Tue, 15 Apr 2008 00:47:19 +0000
branchNewGRF_ports
changeset 10184 fcf5fb2548eb
parent 6882 f508b3bab2c5
child 10192 195d7f6dcf71
permissions -rw-r--r--
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
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"
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6882
diff changeset
     7
#include "gui.h"
6872
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
     8
#include "window_gui.h"
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6882
diff changeset
     9
#include "player_func.h"
6872
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    10
#include "terraform_gui.h"
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    11
#include "command_func.h"
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6882
diff changeset
    12
#include "station_gui.h"
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6882
diff changeset
    13
#include "station_func.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    14
#include "airport.h"
1313
bba6afb8a995 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents: 1116
diff changeset
    15
#include "depot.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
    16
#include "newgrf_callbacks.h"
6872
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    17
#include "sound_func.h"
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6882
diff changeset
    18
#include "settings_type.h"
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6882
diff changeset
    19
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6882
diff changeset
    20
#include "strings_func.h"
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6882
diff changeset
    21
#include "core/alloc_func.hpp"
6872
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    22
#include "window_func.h"
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    23
#include "viewport_func.h"
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    24
#include "gfx_func.h"
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    25
#include "widgets/dropdown_func.h"
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6882
diff changeset
    26
#include "order_func.h"
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
    27
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
    28
//TODO: remove station.h once converted to newgrf airports. stations just used as temporary loader
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6882
diff changeset
    29
//#include "station.h"
6768
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
    30
6872
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    31
#include "table/sprites.h"
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    32
#include "table/strings.h"
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    33
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
    34
static struct {
6762
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
    35
	byte layout_set;
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
    36
	byte numtracks;
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
    37
	byte platlength;
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
    38
	bool dragdrop;
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
    39
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
    40
	FSMportsClassIDByte fsmports_class;
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
    41
	byte station_type;
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
    42
	byte station_count;
6768
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
    43
	DirectionByte direction;
6745
f45a41940079 (svn r10783) [NewGRF_ports] -Feature: Added placing FSMport in any of up to 4 different orientations. GUI now has a preview image for each orientation - not interactive, just a screenshot stored.
richk
parents: 6743
diff changeset
    44
} _airport;
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
    45
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6443
diff changeset
    46
static void ShowBuildAirportPicker();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    47
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    48
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    49
void CcBuildAirport(bool success, TileIndex tile, uint32 p1, uint32 p2)
0
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
	if (success) {
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 507
diff changeset
    52
		SndPlayTileFx(SND_1F_SPLAT, tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    53
		ResetObjectToPlace();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    54
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    57
static void PlaceAirport(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    58
{
6760
d7a806a9aa44 (svn r10802) [NewGRF_ports] -Feature: Added availability dates for airports, using callbacks. Gui modified to disable unavailable airports. If no airports available at all, airport placement disabled.
richk
parents: 6757
diff changeset
    59
	if (_airport.station_type != 0xFF) /*0xFF represents No Airports Available to build */
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
    60
		DoCommandP(tile,
6762
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
    61
				_airport.layout_set | (_airport.numtracks << 8) | (_airport.platlength << 16) | (_ctrl_pressed << 24),
6768
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
    62
				0x80 | (_airport.fsmports_class << 8) | (_airport.station_type << 16), CcBuildAirport,
6870
ca3fd1fbe311 (svn r11219) [NewGRF_ports] -Sync: with trunk r11035:11218.
rubidium
parents: 6814
diff changeset
    63
				CMD_BUILD_AIRPORT | CMD_MSG(STR_A001_CAN_T_BUILD_AIRPORT_HERE));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    64
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    65
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    66
static void PlaceAir_DemolishArea(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    67
{
6719
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6718
diff changeset
    68
	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
    69
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    71
5147
db717cde801d (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5072
diff changeset
    72
enum {
db717cde801d (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5072
diff changeset
    73
	ATW_AIRPORT  = 3,
db717cde801d (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5072
diff changeset
    74
	ATW_DEMOLISH = 4
db717cde801d (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5072
diff changeset
    75
};
db717cde801d (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5072
diff changeset
    76
db717cde801d (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5072
diff changeset
    77
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    78
static void BuildAirClick_Airport(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    79
{
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6870
diff changeset
    80
	if (HandlePlacePushButton(w, ATW_AIRPORT, SPR_CURSOR_AIRPORT, VHM_RECT, PlaceAirport)) ShowBuildAirportPicker();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    81
}
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
static void BuildAirClick_Demolish(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    84
{
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6870
diff changeset
    85
	HandlePlacePushButton(w, ATW_DEMOLISH, ANIMCURSOR_DEMOLISH, VHM_RECT, PlaceAir_DemolishArea);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    86
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    87
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    88
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
typedef void OnButtonClick(Window *w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
static OnButtonClick * const _build_air_button_proc[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
	BuildAirClick_Airport,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
	BuildAirClick_Demolish,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
static void BuildAirToolbWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
{
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
    97
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    98
	case WE_PAINT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   100
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   101
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   102
	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
   103
		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
   104
			_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
   105
		break;
1019
6363b8a4273e (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 946
diff changeset
   106
937
a8dfd3eb406f (svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents: 867
diff changeset
   107
	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
   108
		switch (e->we.keypress.keycode) {
937
a8dfd3eb406f (svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents: 867
diff changeset
   109
			case '1': BuildAirClick_Airport(w); break;
a8dfd3eb406f (svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents: 867
diff changeset
   110
			case '2': BuildAirClick_Demolish(w); break;
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2619
diff changeset
   111
			default: return;
937
a8dfd3eb406f (svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents: 867
diff changeset
   112
		}
a8dfd3eb406f (svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents: 867
diff changeset
   113
	} break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   114
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   115
	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
   116
		_place_proc(e->we.place.tile);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   117
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   118
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4059
diff changeset
   119
	case WE_PLACE_DRAG:
6719
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6718
diff changeset
   120
		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
   121
		break;
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
	case WE_PLACE_MOUSEUP:
6719
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6718
diff changeset
   124
		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
   125
			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
   126
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   127
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   128
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   129
	case WE_ABORT_PLACE_OBJ:
6872
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
   130
		w->RaiseButtons();
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   131
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   132
		w = FindWindowById(WC_BUILD_STATION, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   133
		if (w != 0)
6719
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6718
diff changeset
   134
			WP(w, def_d).close = true;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   135
		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
   136
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
   137
	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
   138
		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
   139
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   140
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   141
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   142
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   143
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
   144
{   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
   145
{    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
   146
{  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
   147
{     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
   148
{     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
   149
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   150
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   151
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   152
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   153
static const WindowDesc _air_toolbar_desc = {
6743
cabfaa4a0295 (svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents: 6741
diff changeset
   154
	WDP_ALIGN_TBR, 22, 64, 36, 64, 36,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6111
diff changeset
   155
	WC_BUILD_TOOLBAR, WC_NONE,
756
d1f1dc31b6f4 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents: 751
diff changeset
   156
	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
   157
	_air_toolbar_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   158
	BuildAirToolbWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   159
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   160
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6443
diff changeset
   161
void ShowBuildAirToolbar()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   162
{
5005
21e84e53c732 (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4968
diff changeset
   163
	if (!IsValidPlayer(_current_player)) return;
21e84e53c732 (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4968
diff changeset
   164
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   165
	DeleteWindowById(WC_BUILD_TOOLBAR, 0);
6111
32f6149dc192 (svn r8436) -Fix
tron
parents: 5933
diff changeset
   166
	Window *w = AllocateWindowDescFront(&_air_toolbar_desc, 0);
32f6149dc192 (svn r8436) -Fix
tron
parents: 5933
diff changeset
   167
	if (_patches.link_terraform_toolbar) ShowTerraformToolbar(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   168
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   169
6874
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   170
/** Enum referring to the widgets of the airport build window */
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   171
enum BuildAirportWidgets {
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   172
	BAPW_CLOSEBOX = 0,
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   173
	BAPW_CAPTION,
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   174
	BAPW_BACKGROUND,
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   175
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   176
	BAPW_NEWAP_DROPDOWN,
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   177
	BAPW_NEWAP_LIST,
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   178
	BAPW_NEWAP_SCROLL,
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   179
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   180
	BAPW_MINIPIC_PANEL,
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   181
	BAPW_ORIENT_NE,
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   182
	BAPW_ORIENT_SE,
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   183
	BAPW_ORIENT_SW,
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   184
	BAPW_ORIENT_NW,
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   185
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   186
	BAPW_HIGHLIGHT_OFF,
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   187
	BAPW_HIGHLIGHT_ON,
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   188
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   189
};
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   190
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   191
static void BuildAirportPickerWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   192
{
1784
6eb3ab1bc33c (svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents: 1363
diff changeset
   193
	switch (e->event) {
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   194
	case WE_CREATE:
6874
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   195
		w->SetWidgetLoweredState(BAPW_HIGHLIGHT_OFF, !_station_show_coverage);
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   196
		w->SetWidgetLoweredState(BAPW_HIGHLIGHT_ON, _station_show_coverage);
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   197
		break;
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   198
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   199
	case WE_PAINT: {
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
   200
		byte preview_sprite = 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
   201
6768
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   202
		FSMportsSpec *fsmportspec = GetCustomFSMportsSpec(_airport.fsmports_class, _airport.station_type);
6760
d7a806a9aa44 (svn r10802) [NewGRF_ports] -Feature: Added availability dates for airports, using callbacks. Gui modified to disable unavailable airports. If no airports available at all, airport placement disabled.
richk
parents: 6757
diff changeset
   203
		/* if the port is no longer available, find one that is */
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6870
diff changeset
   204
		if ((fsmportspec == NULL) || (HasBit(fsmportspec->callbackmask, CBM_STATION_AVAIL) && GetFSMportsCallback(CBID_STATION_AVAILABILITY, 0, 0, fsmportspec, NULL, INVALID_TILE) == 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
   205
			/* 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
   206
			_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
   207
			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
   208
				fsmportspec = GetCustomFSMportsSpec(_airport.fsmports_class, i);
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6870
diff changeset
   209
				if (!HasBit(fsmportspec->callbackmask, CBM_STATION_AVAIL) || GetFSMportsCallback(CBID_STATION_AVAILABILITY, 0, 0, fsmportspec, NULL, INVALID_TILE) != 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
   210
					_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
   211
					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
   212
				}
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
			}
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
		}
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   215
6719
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6718
diff changeset
   216
		if (WP(w, def_d).close) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   217
6768
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   218
		for (byte j = 0; j < 4; j++) {
6874
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   219
			w->SetWidgetDisabledState(BAPW_ORIENT_NE + j, true);
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   220
			w->RaiseWidget(BAPW_ORIENT_NE + j);
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   221
			w->widget[BAPW_ORIENT_NE + 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
   222
		}
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   223
6768
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   224
		if (_airport.station_type != 0xFF) {
6762
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   225
			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
   226
			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
   227
			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
   228
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
   229
			/* an airport is available, so read it and update screen accordingly */
6768
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   230
			for (byte j = 0; j < fsmportspec->numlayouts; j++) {
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
				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
   232
				/* 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
   233
				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
   234
				memcpy(layout_ptr, fsmportspec->layouts[j], (x * y) + 2);
6874
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   235
				w->SetWidgetDisabledState(BAPW_ORIENT_NE + 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
   236
				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
   237
					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
   238
					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
   239
				}
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
   240
			}
6874
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   241
			w->LowerWidget(BAPW_ORIENT_NE + DirToDiagDir(_airport.direction));
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   242
			w->widget[BAPW_ORIENT_NE + DirToDiagDir(_airport.direction)].data = SPR_IMG_ARROW_NE_YELLOW + DirToDiagDir(_airport.direction);  //show in yellow
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
   243
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   244
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
   245
		SetDParam(0, GetFSMportsClassName(_airport.fsmports_class));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   246
		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
   247
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4059
diff changeset
   248
		// 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
   249
		// 'Coverage Area'
6768
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   250
		if (_airport.station_type != 0xFF) {
6776
710f906532ff (svn r10832) [NewGRF_ports] -Change: If no airports are selectable, then the image of the first in the list is shown, but greyed out.
richk
parents: 6774
diff changeset
   251
			/* draw the preview image if the station is available */
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6870
diff changeset
   252
			if (!HasBit(fsmportspec->callbackmask, CBM_STATION_AVAIL) || GetFSMportsCallback(CBID_STATION_AVAILABILITY, 0, 0, fsmportspec, NULL, INVALID_TILE) != 0) {
6774
058a44ffc7c2 (svn r10830) [NewGRF_ports] -Fix: Only test and draw a preview picture if the fsmportspec can be accessed.
richk
parents: 6770
diff changeset
   253
				DrawFSMportsTile(9, 106, preview_sprite, _airport.fsmports_class, _airport.station_type);
058a44ffc7c2 (svn r10830) [NewGRF_ports] -Fix: Only test and draw a preview picture if the fsmportspec can be accessed.
richk
parents: 6770
diff changeset
   254
			}
6807
436fc766fc34 (svn r10881) [NewGRF_ports] -Feature: Adds irregular highlight to airport placement based on the FSMportLayout data. You can now see where the holes should be!
richk
parents: 6776
diff changeset
   255
			_thd.FSMportLayout = &fsmportspec->layouts[_airport.layout_set];  // irregular airport support
6812
35bd847c2aba (svn r10889) [NewGRF_ports] -Feature: Colour of highlight for FSMs with placement masks shows Green for land tiles, and Blue for water tiles.
richk
parents: 6807
diff changeset
   256
			_thd.FSMportMask = NULL;
35bd847c2aba (svn r10889) [NewGRF_ports] -Feature: Colour of highlight for FSMs with placement masks shows Green for land tiles, and Blue for water tiles.
richk
parents: 6807
diff changeset
   257
			if (fsmportspec->layout_mask != NULL) _thd.FSMportMask = &fsmportspec->layout_mask[_airport.layout_set];  // irregular airport support
6768
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   258
			int rad = _patches.modified_catchment ? fsmportspec->portFSM->catchment : 4;
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
   259
			if (_station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6882
diff changeset
   260
			int text_end = DrawStationCoverageAreaText(2, 206, SCT_ALL, rad, false);
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6882
diff changeset
   261
			text_end = DrawStationCoverageAreaText(2, text_end + 4, SCT_ALL, rad, true) + 4;
6882
f508b3bab2c5 (svn r12356) [NewGRF_ports] -Codechange: Use enummed widgets since its got them.
richk
parents: 6881
diff changeset
   262
			if (text_end > w->widget[BAPW_BACKGROUND].bottom) {
6877
889301acc299 (svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents: 6874
diff changeset
   263
				SetWindowDirty(w);
6882
f508b3bab2c5 (svn r12356) [NewGRF_ports] -Codechange: Use enummed widgets since its got them.
richk
parents: 6881
diff changeset
   264
				ResizeWindowForWidget(w, BAPW_BACKGROUND, 0, text_end - w->widget[BAPW_BACKGROUND].bottom);
6877
889301acc299 (svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents: 6874
diff changeset
   265
				SetWindowDirty(w);
889301acc299 (svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents: 6874
diff changeset
   266
			}
6776
710f906532ff (svn r10832) [NewGRF_ports] -Change: If no airports are selectable, then the image of the first in the list is shown, but greyed out.
richk
parents: 6774
diff changeset
   267
		} else {
710f906532ff (svn r10832) [NewGRF_ports] -Change: If no airports are selectable, then the image of the first in the list is shown, but greyed out.
richk
parents: 6774
diff changeset
   268
			/* if nothing is selectable, draw the image of the first in the non-selectable list, but grey out the preview */
6814
69417b3657f1 (svn r10893) [NewGRF_ports] -Fix: Ensure coloured & masked selections disabled on exit of airport_gui.
richk
parents: 6812
diff changeset
   269
			fsmportspec = GetCustomFSMportsSpec(_airport.fsmports_class, 0);
69417b3657f1 (svn r10893) [NewGRF_ports] -Fix: Ensure coloured & masked selections disabled on exit of airport_gui.
richk
parents: 6812
diff changeset
   270
			byte *layout_ptr = (byte*)alloca(fsmportspec->size_x[0] * fsmportspec->size_y[0] + 2);
69417b3657f1 (svn r10893) [NewGRF_ports] -Fix: Ensure coloured & masked selections disabled on exit of airport_gui.
richk
parents: 6812
diff changeset
   271
			memcpy(layout_ptr, fsmportspec->layouts[0], (fsmportspec->size_x[0] * fsmportspec->size_y[0]) + 2);
69417b3657f1 (svn r10893) [NewGRF_ports] -Fix: Ensure coloured & masked selections disabled on exit of airport_gui.
richk
parents: 6812
diff changeset
   272
			layout_ptr++;
69417b3657f1 (svn r10893) [NewGRF_ports] -Fix: Ensure coloured & masked selections disabled on exit of airport_gui.
richk
parents: 6812
diff changeset
   273
			preview_sprite = *layout_ptr;
69417b3657f1 (svn r10893) [NewGRF_ports] -Fix: Ensure coloured & masked selections disabled on exit of airport_gui.
richk
parents: 6812
diff changeset
   274
			DrawFSMportsTile(9, 106, preview_sprite, _airport.fsmports_class, 0);
69417b3657f1 (svn r10893) [NewGRF_ports] -Fix: Ensure coloured & masked selections disabled on exit of airport_gui.
richk
parents: 6812
diff changeset
   275
			GfxFillRect(8, 106, 105, 172, (1 << PALETTE_MODIFIER_GREYOUT));
69417b3657f1 (svn r10893) [NewGRF_ports] -Fix: Ensure coloured & masked selections disabled on exit of airport_gui.
richk
parents: 6812
diff changeset
   276
			_thd.FSMportLayout = NULL;  // ensure irregular airport support disabled
69417b3657f1 (svn r10893) [NewGRF_ports] -Fix: Ensure coloured & masked selections disabled on exit of airport_gui.
richk
parents: 6812
diff changeset
   277
			_thd.FSMportMask = NULL;
69417b3657f1 (svn r10893) [NewGRF_ports] -Fix: Ensure coloured & masked selections disabled on exit of airport_gui.
richk
parents: 6812
diff changeset
   278
			SetTileSelectSize(1,1);
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
   279
		}
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   280
6768
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   281
		for (uint16 i = w->vscroll.pos, y = 35; i < _airport.station_count && i < (uint)(w->vscroll.pos + w->vscroll.cap); i++, y += 14) {
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   282
			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
   283
6768
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   284
			if (fsmportspec != NULL && fsmportspec->name != 0) {
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6870
diff changeset
   285
				if (HasBit(fsmportspec->callbackmask, CBM_STATION_AVAIL) && GetFSMportsCallback(CBID_STATION_AVAILABILITY, 0, 0, fsmportspec, NULL, INVALID_TILE) == 0) {
6768
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   286
					GfxFillRect(8, y - 2, 127, y + 10, (1 << PALETTE_MODIFIER_GREYOUT));
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   287
				}
6768
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   288
				DrawStringTruncated(9, y, fsmportspec->name, i == _airport.station_type ? 12 : 16, 118);
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   289
			} else {
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   290
				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
   291
			}
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   292
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   293
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   294
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   295
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   296
	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
   297
		switch (e->we.click.widget) {
6874
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   298
		case BAPW_HIGHLIGHT_OFF: case BAPW_HIGHLIGHT_ON:
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   299
			_station_show_coverage = (e->we.click.widget != BAPW_HIGHLIGHT_OFF);
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   300
			w->SetWidgetLoweredState(BAPW_HIGHLIGHT_OFF, !_station_show_coverage);
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   301
			w->SetWidgetLoweredState(BAPW_HIGHLIGHT_ON, _station_show_coverage);
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 507
diff changeset
   302
			SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   303
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   304
			break;
6874
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   305
		case BAPW_NEWAP_DROPDOWN:
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   306
			ShowDropDownList(w, BuildFSMportsClassDropdown(), _airport.fsmports_class, BAPW_NEWAP_DROPDOWN);
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   307
			break;
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   308
6874
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   309
		case BAPW_NEWAP_LIST: {
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   310
			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
   311
			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
   312
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   313
			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
   314
			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
   315
			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
   316
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   317
			/* 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
   318
			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
   319
			if (fsmportspec != NULL &&
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6870
diff changeset
   320
				HasBit(fsmportspec->callbackmask, CBM_STATION_AVAIL) &&
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   321
				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
   322
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
   323
			_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
   324
			_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
   325
			_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
   326
			_airport.numtracks = fsmportspec->size_x[_airport.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
   327
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   328
			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
   329
			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
   330
			break;
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   331
			}
6874
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   332
		case BAPW_ORIENT_NE:
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   333
		case BAPW_ORIENT_SE:
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   334
		case BAPW_ORIENT_SW:
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   335
		case BAPW_ORIENT_NW:
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   336
			w->widget[BAPW_ORIENT_NE + DirToDiagDir(_airport.direction)].data = SPR_IMG_ARROW_NE_WHITE + DirToDiagDir(_airport.direction);  //reset arrow to white
6762
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   337
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   338
			/* 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
   339
			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
   340
			_airport.layout_set = 0;
6874
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   341
			_airport.direction = DiagDirToDir((DiagDirection)(e->we.click.widget - BAPW_ORIENT_NE));
6768
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   342
			for (byte j = 0; j < fsmportspec->numlayouts; j++) {
6762
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   343
				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
   344
				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
   345
				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
   346
				/* enable the permitted orientations */
6768
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   347
				byte *layout_ptr = (byte*)alloca(x * y + 2);
6762
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   348
				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
   349
				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
   350
					_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
   351
					break;
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   352
				}
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   353
			}
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   354
6874
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   355
			w->SetWidgetLoweredState( BAPW_ORIENT_NE, (_airport.direction == DIR_NE));
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   356
			w->SetWidgetLoweredState( BAPW_ORIENT_SE, (_airport.direction == DIR_SE));
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   357
			w->SetWidgetLoweredState( BAPW_ORIENT_SW, (_airport.direction == DIR_SW));
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   358
			w->SetWidgetLoweredState( BAPW_ORIENT_NW, (_airport.direction == DIR_NW));
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
   359
			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
   360
			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
   361
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   362
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   363
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   364
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   365
	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
   366
		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
   367
			_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
   368
			_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
   369
			_airport.layout_set = 0;
6768
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   370
			_airport.direction = DIR_NE;
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
   371
			_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
   372
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
   373
			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
   374
			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
   375
		}
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   376
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   377
		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
   378
		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
   379
	} break;
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   380
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   381
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   382
	case WE_MOUSELOOP: {
6719
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6718
diff changeset
   383
		if (WP(w, def_d).close) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   384
			DeleteWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   385
			return;
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
		CheckRedrawStationCoverage(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   389
	} break;
1109
1bab892228cd (svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents: 1093
diff changeset
   390
1072
01bf9fc64236 (svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents: 1019
diff changeset
   391
	case WE_DESTROY:
6719
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6718
diff changeset
   392
		if (!WP(w, def_d).close) ResetObjectToPlace();
6814
69417b3657f1 (svn r10893) [NewGRF_ports] -Fix: Ensure coloured & masked selections disabled on exit of airport_gui.
richk
parents: 6812
diff changeset
   393
		_thd.FSMportLayout = NULL;  // ensure irregular airport support disabled
69417b3657f1 (svn r10893) [NewGRF_ports] -Fix: Ensure coloured & masked selections disabled on exit of airport_gui.
richk
parents: 6812
diff changeset
   394
		_thd.FSMportMask = NULL;
1072
01bf9fc64236 (svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents: 1019
diff changeset
   395
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   396
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   397
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   398
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   399
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
   400
{   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
   401
{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   147,     0,    13, STR_3001_AIRPORT_SELECTION,       STR_018C_WINDOW_TITLE_DRAG_THIS},
6768
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   402
{      WWT_PANEL,   RESIZE_NONE,     7,     0,   147,    14,   239, 0x0,                              STR_NULL},
6874
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   403
{ WWT_DROPDOWNIN,   RESIZE_NONE,    14,     7,   140,    17,    28, STR_02BD,                         STR_SELECT_STATION_CLASS_TIP},        // BAPW_NEWAP_DROPDOWN
6768
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   404
{     WWT_MATRIX,   RESIZE_NONE,    14,     7,   128,    32,   102, 0x501,                            STR_SELECT_STATION_TYPE_TIP},
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   405
{  WWT_SCROLLBAR,   RESIZE_NONE,    14,   129,   140,    32,   102, 0x0,                              STR_0190_SCROLL_BAR_SCROLLS_LIST},
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   406
{      WWT_INSET,   RESIZE_NONE,     7,     7,   107,   104,   173, 0x0,                              STR_NULL},
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   407
{     WWT_IMGBTN,   RESIZE_NONE,    14,   109,   140,   104,   119, SPR_IMG_ARROW_NE_WHITE,           STR_NULL},
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   408
{     WWT_IMGBTN,   RESIZE_NONE,    14,   109,   140,   122,   137, SPR_IMG_ARROW_SE_WHITE,           STR_NULL},
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   409
{     WWT_IMGBTN,   RESIZE_NONE,    14,   109,   140,   140,   155, SPR_IMG_ARROW_SW_WHITE,           STR_NULL},
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   410
{     WWT_IMGBTN,   RESIZE_NONE,    14,   109,   140,   158,   173, SPR_IMG_ARROW_NW_WHITE,           STR_NULL},
4345
dd12549ad473 (svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents: 4344
diff changeset
   411
{    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
   412
{    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
   413
{      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
   414
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   415
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   416
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   417
static const WindowDesc _build_airport_desc = {
6743
cabfaa4a0295 (svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents: 6741
diff changeset
   418
	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
   419
	WC_BUILD_STATION, WC_BUILD_TOOLBAR,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   420
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   421
	_build_airport_picker_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   422
	BuildAirportPickerWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   423
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   424
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6443
diff changeset
   425
static void ShowBuildAirportPicker()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   426
{
6768
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   427
	Window *w = AllocateWindowDesc(&_build_airport_desc);
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   428
	if (w == NULL) 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
   429
6768
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   430
	_airport.station_type = 0;
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   431
	_airport.layout_set = 0;
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   432
	_airport.direction = DIR_NE;
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   433
	_airport.station_count = GetNumCustomFSMports(_airport.fsmports_class);
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6870
diff changeset
   434
	//if (HasBit(fsmportspec->callbackmask, CBM_STATION_AVAIL) && GetFSMportsCallback(CBID_STATION_AVAILABILITY, 0, 0, fsmportspec, NULL, INVALID_TILE) == 0) {
6768
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   435
	//	_airport.station_type = 0;
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   436
	//}
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   437
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   438
	w->vscroll.count = _airport.station_count;
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   439
	w->vscroll.cap   = 5;
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6870
diff changeset
   440
	w->vscroll.pos   = Clamp(_airport.station_type - 2, 0, w->vscroll.count - w->vscroll.cap);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   441
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   442
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6443
diff changeset
   443
void InitializeAirportGui()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   444
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   445
}