src/airport_gui.cpp
author richk
Fri, 18 Apr 2008 19:55:13 +0000
branchNewGRF_ports
changeset 10242 52b4a9006029
parent 10192 195d7f6dcf71
child 10724 68a692eacf22
permissions -rw-r--r--
(svn r12774) [NewGRF_ports] -Sync: with trunk r12742:12772.
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"
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
    15
#include "newgrf_callbacks.h"
6872
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    16
#include "sound_func.h"
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6882
diff changeset
    17
#include "settings_type.h"
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6882
diff changeset
    18
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6882
diff changeset
    19
#include "strings_func.h"
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6882
diff changeset
    20
#include "core/alloc_func.hpp"
6872
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    21
#include "window_func.h"
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    22
#include "viewport_func.h"
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    23
#include "gfx_func.h"
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    24
#include "widgets/dropdown_func.h"
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6882
diff changeset
    25
#include "order_func.h"
10242
52b4a9006029 (svn r12774) [NewGRF_ports] -Sync: with trunk r12742:12772.
richk
parents: 10192
diff changeset
    26
#include "station_type.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
6872
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    28
#include "table/sprites.h"
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    29
#include "table/strings.h"
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    30
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
    31
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
    32
	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
    33
	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
    34
	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
    35
	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
    36
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
    37
	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
    38
	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
    39
	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
    40
	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
    41
} _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
    42
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6443
diff changeset
    43
static void ShowBuildAirportPicker();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    44
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    45
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    46
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
    47
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    48
	if (success) {
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 507
diff changeset
    49
		SndPlayTileFx(SND_1F_SPLAT, tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    50
		ResetObjectToPlace();
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
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    53
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    54
static void PlaceAirport(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
{
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
    56
	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
    57
		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
    58
				_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
    59
				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
    60
				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
    61
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    62
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    63
static void PlaceAir_DemolishArea(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    64
{
6719
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6718
diff changeset
    65
	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
    66
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    67
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    68
5147
db717cde801d (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5072
diff changeset
    69
enum {
db717cde801d (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5072
diff changeset
    70
	ATW_AIRPORT  = 3,
db717cde801d (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5072
diff changeset
    71
	ATW_DEMOLISH = 4
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
db717cde801d (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5072
diff changeset
    74
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    75
static void BuildAirClick_Airport(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    76
{
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6870
diff changeset
    77
	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
    78
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    79
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    80
static void BuildAirClick_Demolish(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    81
{
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6870
diff changeset
    82
	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
    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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    86
typedef void OnButtonClick(Window *w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    87
static OnButtonClick * const _build_air_button_proc[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    88
	BuildAirClick_Airport,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
	BuildAirClick_Demolish,
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
static void BuildAirToolbWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
{
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
    94
	switch (e->event) {
10192
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
    95
		case WE_PAINT:
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
    96
			DrawWindowWidgets(w);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
    97
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    98
10192
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
    99
		case WE_CLICK:
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   100
			if (e->we.click.widget - 3 >= 0)
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   101
				_build_air_button_proc[e->we.click.widget - 3](w);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   102
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   103
10192
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   104
		case WE_KEYPRESS: {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   105
			switch (e->we.keypress.keycode) {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   106
				case '1': BuildAirClick_Airport(w); break;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   107
				case '2': BuildAirClick_Demolish(w); break;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   108
				default: return;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   109
			}
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   110
			break;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   111
		}
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   112
10192
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   113
		case WE_PLACE_OBJ:
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   114
			_place_proc(e->we.place.tile);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   115
			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
   116
10192
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   117
		case WE_PLACE_DRAG:
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   118
			VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   119
			break;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   120
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   121
		case WE_PLACE_MOUSEUP:
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   122
			if (e->we.place.pt.x != -1 && e->we.place.select_proc == DDSP_DEMOLISH_AREA) {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   123
				DoCommandP(e->we.place.tile, e->we.place.starttile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   124
			}
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   125
			break;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   126
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   127
		case WE_ABORT_PLACE_OBJ:
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   128
			w->RaiseButtons();
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   129
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   130
			w = FindWindowById(WC_BUILD_STATION, 0);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   131
			if (w != 0)
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   132
				WP(w, def_d).close = true;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   133
			break;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   134
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   135
		case WE_DESTROY:
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   136
			if (_patches.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   137
			break;
0
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
}
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
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
   142
{   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
   143
{    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
   144
{  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
   145
{     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
   146
{     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
   147
{   WIDGETS_END},
0
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
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
static const WindowDesc _air_toolbar_desc = {
6743
cabfaa4a0295 (svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents: 6741
diff changeset
   152
	WDP_ALIGN_TBR, 22, 64, 36, 64, 36,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6111
diff changeset
   153
	WC_BUILD_TOOLBAR, WC_NONE,
756
d1f1dc31b6f4 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents: 751
diff changeset
   154
	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
   155
	_air_toolbar_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   156
	BuildAirToolbWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   157
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   158
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6443
diff changeset
   159
void ShowBuildAirToolbar()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   160
{
5005
21e84e53c732 (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4968
diff changeset
   161
	if (!IsValidPlayer(_current_player)) return;
21e84e53c732 (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4968
diff changeset
   162
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   163
	DeleteWindowById(WC_BUILD_TOOLBAR, 0);
6111
32f6149dc192 (svn r8436) -Fix
tron
parents: 5933
diff changeset
   164
	Window *w = AllocateWindowDescFront(&_air_toolbar_desc, 0);
32f6149dc192 (svn r8436) -Fix
tron
parents: 5933
diff changeset
   165
	if (_patches.link_terraform_toolbar) ShowTerraformToolbar(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   166
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   167
6874
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   168
/** 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
   169
enum BuildAirportWidgets {
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   170
	BAPW_CLOSEBOX = 0,
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   171
	BAPW_CAPTION,
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   172
	BAPW_BACKGROUND,
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   173
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   174
	BAPW_NEWAP_DROPDOWN,
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   175
	BAPW_NEWAP_LIST,
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   176
	BAPW_NEWAP_SCROLL,
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   177
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   178
	BAPW_MINIPIC_PANEL,
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   179
	BAPW_ORIENT_NE,
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   180
	BAPW_ORIENT_SE,
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   181
	BAPW_ORIENT_SW,
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   182
	BAPW_ORIENT_NW,
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   183
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   184
	BAPW_HIGHLIGHT_OFF,
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   185
	BAPW_HIGHLIGHT_ON,
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   186
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   187
};
5d69ad7a3c98 (svn r12039) [NewGRF_ports] -Fix: Corrected GUI to revised format.
richk
parents: 6872
diff changeset
   188
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   189
static void BuildAirportPickerWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   190
{
1784
6eb3ab1bc33c (svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents: 1363
diff changeset
   191
	switch (e->event) {
10192
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   192
		case WE_CREATE:
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   193
			w->SetWidgetLoweredState(BAPW_HIGHLIGHT_OFF, !_station_show_coverage);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   194
			w->SetWidgetLoweredState(BAPW_HIGHLIGHT_ON, _station_show_coverage);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   195
			break;
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
   196
10192
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   197
		case WE_PAINT: {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   198
			byte preview_sprite = 0xFF;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   199
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   200
			FSMportsSpec *fsmportspec = GetCustomFSMportsSpec(_airport.fsmports_class, _airport.station_type);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   201
			/* if the port is no longer available, find one that is */
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   202
			if ((fsmportspec == NULL) || (HasBit(fsmportspec->callbackmask, CBM_STATION_AVAIL) && GetFSMportsCallback(CBID_STATION_AVAILABILITY, 0, 0, fsmportspec, NULL, INVALID_TILE) == 0)) {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   203
				/* port not available, find new one*/
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   204
				_airport.station_type = 0xFF;  //set to the invalid condition to prevent any selection if nothing is available
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   205
				for (uint i = 0; i < _airport.station_count; i++) {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   206
					fsmportspec = GetCustomFSMportsSpec(_airport.fsmports_class, i);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   207
					if (!HasBit(fsmportspec->callbackmask, CBM_STATION_AVAIL) || GetFSMportsCallback(CBID_STATION_AVAILABILITY, 0, 0, fsmportspec, NULL, INVALID_TILE) != 0) {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   208
						_airport.station_type = i;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   209
						break;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   210
					}
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
   211
				}
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
			}
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   213
10192
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   214
			if (WP(w, def_d).close) return;
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
   215
10192
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   216
			for (byte j = 0; j < 4; j++) {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   217
				w->SetWidgetDisabledState(BAPW_ORIENT_NE + j, true);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   218
				w->RaiseWidget(BAPW_ORIENT_NE + j);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   219
				w->widget[BAPW_ORIENT_NE + j].data = SPR_IMG_ARROW_NE_WHITE + j;  //reset arrows to white
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   220
			}
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   221
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   222
			if (_airport.station_type != 0xFF) {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   223
				int x = fsmportspec->size_x[_airport.layout_set];
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   224
				int y = fsmportspec->size_y[_airport.layout_set];
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   225
				SetTileSelectSize(x, y);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   226
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   227
				/* an airport is available, so read it and update screen accordingly */
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   228
				for (byte j = 0; j < fsmportspec->numlayouts; j++) {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   229
					if (fsmportspec->layouts[j] == NULL) break;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   230
					/* enable the permitted orientations */
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   231
					byte *layout_ptr = (byte*)alloca(x*y + 2);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   232
					memcpy(layout_ptr, fsmportspec->layouts[j], (x * y) + 2);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   233
					w->SetWidgetDisabledState(BAPW_ORIENT_NE + GB((byte)*layout_ptr, 1, 2), false);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   234
					if (j == _airport.layout_set) {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   235
						layout_ptr++;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   236
						preview_sprite = *layout_ptr;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   237
					}
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   238
				}
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   239
				w->LowerWidget(BAPW_ORIENT_NE + DirToDiagDir(_airport.direction));
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   240
				w->widget[BAPW_ORIENT_NE + DirToDiagDir(_airport.direction)].data = SPR_IMG_ARROW_NE_YELLOW + DirToDiagDir(_airport.direction);  //show in yellow
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   241
			}
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   242
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   243
			SetDParam(0, GetFSMportsClassName(_airport.fsmports_class));
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   244
			DrawWindowWidgets(w);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   245
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   246
			/* strings such as 'Size' and 'Coverage Area' */
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   247
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   248
			if (_airport.station_type != 0xFF) {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   249
				/* draw the preview image if the station is available */
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   250
				if (!HasBit(fsmportspec->callbackmask, CBM_STATION_AVAIL) || GetFSMportsCallback(CBID_STATION_AVAILABILITY, 0, 0, fsmportspec, NULL, INVALID_TILE) != 0) {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   251
					DrawFSMportsTile(9, 106, preview_sprite, _airport.fsmports_class, _airport.station_type);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   252
				}
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   253
				_thd.FSMportLayout = &fsmportspec->layouts[_airport.layout_set];  // irregular airport support
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   254
				_thd.FSMportMask = NULL;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   255
				if (fsmportspec->layout_mask != NULL) _thd.FSMportMask = &fsmportspec->layout_mask[_airport.layout_set];  // irregular airport support
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   256
				int rad = _patches.modified_catchment ? fsmportspec->portFSM->catchment : 4;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   257
				if (_station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   258
				int text_end = DrawStationCoverageAreaText(2, 206, SCT_ALL, rad, false);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   259
				text_end = DrawStationCoverageAreaText(2, text_end + 4, SCT_ALL, rad, true) + 4;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   260
				if (text_end > w->widget[BAPW_BACKGROUND].bottom) {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   261
					SetWindowDirty(w);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   262
					ResizeWindowForWidget(w, BAPW_BACKGROUND, 0, text_end - w->widget[BAPW_BACKGROUND].bottom);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   263
					SetWindowDirty(w);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   264
				}
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   265
			} else {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   266
				/* if nothing is selectable, draw the image of the first in the non-selectable list, but grey out the preview */
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   267
				fsmportspec = GetCustomFSMportsSpec(_airport.fsmports_class, 0);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   268
				byte *layout_ptr = (byte*)alloca(fsmportspec->size_x[0] * fsmportspec->size_y[0] + 2);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   269
				memcpy(layout_ptr, fsmportspec->layouts[0], (fsmportspec->size_x[0] * fsmportspec->size_y[0]) + 2);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   270
				layout_ptr++;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   271
				preview_sprite = *layout_ptr;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   272
				DrawFSMportsTile(9, 106, preview_sprite, _airport.fsmports_class, 0);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   273
				GfxFillRect(8, 106, 105, 172, (1 << PALETTE_MODIFIER_GREYOUT));
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   274
				_thd.FSMportLayout = NULL;  // ensure irregular airport support disabled
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   275
				_thd.FSMportMask = NULL;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   276
				SetTileSelectSize(1,1);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   277
			}
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   278
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   279
			for (uint16 i = w->vscroll.pos, y = 35; i < _airport.station_count && i < (uint)(w->vscroll.pos + w->vscroll.cap); i++, y += 14) {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   280
				const FSMportsSpec *fsmportspec = GetCustomFSMportsSpec(_airport.fsmports_class, i);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   281
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   282
				if (fsmportspec != NULL && fsmportspec->name != 0) {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   283
					if (HasBit(fsmportspec->callbackmask, CBM_STATION_AVAIL) && GetFSMportsCallback(CBID_STATION_AVAILABILITY, 0, 0, fsmportspec, NULL, INVALID_TILE) == 0) {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   284
						GfxFillRect(8, y - 2, 127, y + 10, (1 << PALETTE_MODIFIER_GREYOUT));
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   285
					}
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   286
					DrawStringTruncated(9, y, fsmportspec->name, i == _airport.station_type ? 12 : 16, 118);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   287
				} else {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   288
					DrawStringTruncated(9, y, STR_STAT_CLASS_DFLT, i == _airport.station_type ? 12 : 16, 118);
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
   289
				}
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
   290
			}
10192
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   291
			break;
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
   292
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   293
10192
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   294
		case WE_CLICK: {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   295
			switch (e->we.click.widget) {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   296
				case BAPW_HIGHLIGHT_OFF: case BAPW_HIGHLIGHT_ON:
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   297
					_station_show_coverage = (e->we.click.widget != BAPW_HIGHLIGHT_OFF);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   298
					w->SetWidgetLoweredState(BAPW_HIGHLIGHT_OFF, !_station_show_coverage);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   299
					w->SetWidgetLoweredState(BAPW_HIGHLIGHT_ON, _station_show_coverage);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   300
					SndPlayFx(SND_15_BEEP);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   301
					SetWindowDirty(w);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   302
					break;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   303
				case BAPW_NEWAP_DROPDOWN:
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   304
					ShowDropDownList(w, BuildFSMportsClassDropdown(), _airport.fsmports_class, BAPW_NEWAP_DROPDOWN);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   305
					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
   306
10192
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   307
				case BAPW_NEWAP_LIST: {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   308
					const FSMportsSpec *fsmportspec;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   309
					int y = (e->we.click.pt.y - 32) / 14;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   310
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   311
					if (y >= w->vscroll.cap) return;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   312
					y += w->vscroll.pos;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   313
					if (y >= _airport.station_count) return;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   314
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   315
					/* Check station availability callback */
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   316
					fsmportspec = GetCustomFSMportsSpec(_airport.fsmports_class, y);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   317
					if (fsmportspec != NULL &&
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   318
						HasBit(fsmportspec->callbackmask, CBM_STATION_AVAIL) &&
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   319
						GetFSMportsCallback(CBID_STATION_AVAILABILITY, 0, 0, fsmportspec, NULL, INVALID_TILE) == 0) return;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   320
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   321
					_airport.station_type = y;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   322
					_airport.layout_set = 0;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   323
					_airport.platlength= fsmportspec->size_y[_airport.layout_set];
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   324
					_airport.numtracks = fsmportspec->size_x[_airport.layout_set];
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   325
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   326
					SndPlayFx(SND_15_BEEP);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   327
					SetWindowDirty(w);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   328
					break;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   329
				}
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   330
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   331
				case BAPW_ORIENT_NE:
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   332
				case BAPW_ORIENT_SE:
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   333
				case BAPW_ORIENT_SW:
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   334
				case BAPW_ORIENT_NW:
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   335
					w->widget[BAPW_ORIENT_NE + DirToDiagDir(_airport.direction)].data = SPR_IMG_ARROW_NE_WHITE + DirToDiagDir(_airport.direction);  //reset arrow to white
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   336
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   337
					/* find the layout_set that corresponds to the selected orientation */
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   338
					FSMportsSpec *fsmportspec = GetCustomFSMportsSpec(_airport.fsmports_class, _airport.station_type);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   339
					_airport.layout_set = 0;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   340
					_airport.direction = DiagDirToDir((DiagDirection)(e->we.click.widget - BAPW_ORIENT_NE));
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   341
					for (byte j = 0; j < fsmportspec->numlayouts; j++) {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   342
						int x = fsmportspec->size_x[j];
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   343
						int y = fsmportspec->size_y[j];
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   344
						if (fsmportspec->layouts[j] == NULL) break;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   345
						/* enable the permitted orientations */
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   346
						byte *layout_ptr = (byte*)alloca(x * y + 2);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   347
						memcpy(layout_ptr, fsmportspec->layouts[j], (x * y) + 2);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   348
						if (*layout_ptr == _airport.direction) {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   349
							_airport.layout_set = j;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   350
							break;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   351
						}
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   352
					}
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   353
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   354
					w->SetWidgetLoweredState( BAPW_ORIENT_NE, (_airport.direction == DIR_NE));
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   355
					w->SetWidgetLoweredState( BAPW_ORIENT_SE, (_airport.direction == DIR_SE));
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   356
					w->SetWidgetLoweredState( BAPW_ORIENT_SW, (_airport.direction == DIR_SW));
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   357
					w->SetWidgetLoweredState( BAPW_ORIENT_NW, (_airport.direction == DIR_NW));
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   358
					SndPlayFx(SND_15_BEEP);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   359
					SetWindowDirty(w);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   360
					break;
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
   361
			}
10192
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   362
			break;
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
   363
		}
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   364
10192
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   365
		case WE_DROPDOWN_SELECT: {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   366
			if (_airport.fsmports_class != e->we.dropdown.index) {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   367
				_airport.fsmports_class = (FSMportsClassID)e->we.dropdown.index;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   368
				_airport.station_type  = 0;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   369
				_airport.layout_set = 0;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   370
				_airport.direction = DIR_NE;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   371
				_airport.station_count = GetNumCustomFSMports(_airport.fsmports_class);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   372
10192
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   373
				w->vscroll.count = _airport.station_count;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   374
				w->vscroll.pos   = _airport.station_type;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   375
			}
6722
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;
10192
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   380
		}
6762
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   381
10192
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   382
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   383
		case WE_MOUSELOOP: {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   384
			if (WP(w, def_d).close) {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   385
				DeleteWindow(w);
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   386
				return;
6762
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   387
			}
aebd7285dbc2 (svn r10804) [NewGRF_ports] -Fix: Gui failed when layouts were not contiguous. eg. 01 and 07
richk
parents: 6760
diff changeset
   388
10192
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   389
			CheckRedrawStationCoverage(w);
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
   390
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   391
		}
6722
72f280229ee1 (svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents: 6720
diff changeset
   392
10192
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   393
		case WE_DESTROY:
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   394
			if (!WP(w, def_d).close) ResetObjectToPlace();
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   395
			_thd.FSMportLayout = NULL;  // ensure irregular airport support disabled
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   396
			_thd.FSMportMask = NULL;
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   397
			break;
0
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
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   400
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   401
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
   402
{   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
   403
{    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
   404
{      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
   405
{ 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
   406
{     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
   407
{  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
   408
{      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
   409
{     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
   410
{     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
   411
{     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
   412
{     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
   413
{    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
   414
{    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
   415
{      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
   416
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   417
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   418
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   419
static const WindowDesc _build_airport_desc = {
6743
cabfaa4a0295 (svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents: 6741
diff changeset
   420
	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
   421
	WC_BUILD_STATION, WC_BUILD_TOOLBAR,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   422
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   423
	_build_airport_picker_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   424
	BuildAirportPickerWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   425
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   426
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6443
diff changeset
   427
static void ShowBuildAirportPicker()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   428
{
6768
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   429
	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
   430
	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
   431
6768
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   432
	_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
   433
	_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
   434
	_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
   435
	_airport.station_count = GetNumCustomFSMports(_airport.fsmports_class);
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6870
diff changeset
   436
	//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
   437
	//	_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
   438
	//}
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   439
d29ac98e3e0c (svn r10818) [NewGRF_ports] -Codechange: remove the remnants of the old airports from the GUI.
rubidium
parents: 6765
diff changeset
   440
	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
   441
	w->vscroll.cap   = 5;
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6870
diff changeset
   442
	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
   443
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   444
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6443
diff changeset
   445
void InitializeAirportGui()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   446
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   447
}