src/dock_gui.cpp
author rubidium
Wed, 19 Dec 2007 23:26:02 +0000
changeset 8108 b42a0e5c67ef
parent 8107 bb7deea89175
child 8116 8da76dcb3287
permissions -rw-r--r--
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
6125
a6fff965707c (svn r8862) -Cleanup: doxygen changes, again. Mostly @files missing tags and a few comments style.
belugas
parents: 5893
diff changeset
     3
/** @file dock_gui.cpp */
a6fff965707c (svn r8862) -Cleanup: doxygen changes, again. Mostly @files missing tags and a few comments style.
belugas
parents: 5893
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
862800791170 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1632
diff changeset
     6
#include "openttd.h"
1363
775a7ee52369 (svn r1867) Include tables/sprites.h only in files which need it
tron
parents: 1116
diff changeset
     7
#include "table/sprites.h"
507
04b5403aaf6b (svn r815) Include strings.h only in the files which need it.
tron
parents: 337
diff changeset
     8
#include "table/strings.h"
2163
b17b313113a0 (svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents: 2159
diff changeset
     9
#include "functions.h"
679
04ca2cd69420 (svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents: 606
diff changeset
    10
#include "map.h"
8108
b42a0e5c67ef (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8107
diff changeset
    11
#include "tile_map.h"
568
b0d0df062880 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 543
diff changeset
    12
#include "station.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    13
#include "gui.h"
8107
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
    14
#include "window_gui.h"
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
    15
#include "station_gui.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    16
#include "viewport.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    17
#include "gfx.h"
337
cbe0c766c947 (svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents: 193
diff changeset
    18
#include "sound.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    19
#include "command.h"
2159
f6284cf5fab0 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 1981
diff changeset
    20
#include "variables.h"
7948
e408508f5727 (svn r11504) -Fix [FS#1467]: removing docks/ship depots could result in non-canal water where canals should have been build.
rubidium
parents: 7889
diff changeset
    21
#include "water.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    22
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6125
diff changeset
    23
static void ShowBuildDockStationPicker();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6125
diff changeset
    24
static void ShowBuildDocksDepotPicker();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    25
3157
3f35e2d9c8e3 (svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents: 2952
diff changeset
    26
static Axis _ship_depot_direction;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    27
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    28
void CcBuildDocks(bool success, TileIndex tile, uint32 p1, uint32 p2)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    29
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    30
	if (success) {
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 507
diff changeset
    31
		SndPlayTileFx(SND_02_SPLAT, tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    32
		ResetObjectToPlace();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    33
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    35
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    36
void CcBuildCanal(bool success, TileIndex tile, uint32 p1, uint32 p2)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    37
{
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 507
diff changeset
    38
	if (success) SndPlayTileFx(SND_02_SPLAT, tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    39
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    40
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    41
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    42
static void PlaceDocks_Dock(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    43
{
7521
0da1e91510e4 (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7341
diff changeset
    44
	DoCommandP(tile, _ctrl_pressed, 0, CcBuildDocks, CMD_BUILD_DOCK | CMD_MSG(STR_9802_CAN_T_BUILD_DOCK_HERE));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    45
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    46
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    47
static void PlaceDocks_Depot(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    48
{
7521
0da1e91510e4 (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7341
diff changeset
    49
	DoCommandP(tile, _ship_depot_direction, 0, CcBuildDocks, CMD_BUILD_SHIP_DEPOT | CMD_MSG(STR_3802_CAN_T_BUILD_SHIP_DEPOT));
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
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    52
static void PlaceDocks_Buoy(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    53
{
7521
0da1e91510e4 (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7341
diff changeset
    54
	DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_BUOY | CMD_MSG(STR_9835_CAN_T_POSITION_BUOY_HERE));
0
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
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    57
static void PlaceDocks_DemolishArea(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    58
{
6670
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
    59
	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
    60
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    61
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    62
static void PlaceDocks_BuildCanal(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    63
{
6670
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
    64
	VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_CREATE_WATER);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    65
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    66
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    67
static void PlaceDocks_BuildLock(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    68
{
7521
0da1e91510e4 (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7341
diff changeset
    69
	DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_LOCK | CMD_MSG(STR_CANT_BUILD_LOCKS));
0
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    72
5147
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5072
diff changeset
    73
enum {
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5072
diff changeset
    74
	DTW_CANAL    = 3,
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5072
diff changeset
    75
	DTW_LOCK     = 4,
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5072
diff changeset
    76
	DTW_DEMOLISH = 6,
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5072
diff changeset
    77
	DTW_DEPOT    = 7,
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5072
diff changeset
    78
	DTW_STATION  = 8,
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5072
diff changeset
    79
	DTW_BUOY     = 9
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5072
diff changeset
    80
};
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5072
diff changeset
    81
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5072
diff changeset
    82
606
da90c837064c (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
    83
static void BuildDocksClick_Canal(Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    84
{
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7521
diff changeset
    85
	HandlePlacePushButton(w, DTW_CANAL, SPR_CURSOR_CANAL, VHM_RECT, PlaceDocks_BuildCanal);
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
606
da90c837064c (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
    88
static void BuildDocksClick_Lock(Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
{
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7521
diff changeset
    90
	HandlePlacePushButton(w, DTW_LOCK, SPR_CURSOR_LOCK, VHM_RECT, PlaceDocks_BuildLock);
0
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
static void BuildDocksClick_Demolish(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
{
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7521
diff changeset
    95
	HandlePlacePushButton(w, DTW_DEMOLISH, ANIMCURSOR_DEMOLISH, VHM_RECT, PlaceDocks_DemolishArea);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
606
da90c837064c (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
    98
static void BuildDocksClick_Depot(Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
{
7086
de7e83fb1602 (svn r10353) -Fix/Feature [FS#669]: disallow (in the GUI) the building of infrastructure you do not have available vehicles for. This means that the airport building button is disabled till you can actually build aircraft. The game itself will not disallow you to build the infrastructure and this "new" behaviour can be overriden with a patch setting.
rubidium
parents: 6829
diff changeset
   100
	if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return;
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7521
diff changeset
   101
	if (HandlePlacePushButton(w, DTW_DEPOT, SPR_CURSOR_SHIP_DEPOT, VHM_RECT, PlaceDocks_Depot)) ShowBuildDocksDepotPicker();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   102
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   103
606
da90c837064c (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
   104
static void BuildDocksClick_Dock(Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   105
{
7086
de7e83fb1602 (svn r10353) -Fix/Feature [FS#669]: disallow (in the GUI) the building of infrastructure you do not have available vehicles for. This means that the airport building button is disabled till you can actually build aircraft. The game itself will not disallow you to build the infrastructure and this "new" behaviour can be overriden with a patch setting.
rubidium
parents: 6829
diff changeset
   106
	if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return;
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7521
diff changeset
   107
	if (HandlePlacePushButton(w, DTW_STATION, SPR_CURSOR_DOCK, VHM_SPECIAL, PlaceDocks_Dock)) ShowBuildDockStationPicker();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   108
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   109
606
da90c837064c (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
   110
static void BuildDocksClick_Buoy(Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   111
{
7086
de7e83fb1602 (svn r10353) -Fix/Feature [FS#669]: disallow (in the GUI) the building of infrastructure you do not have available vehicles for. This means that the airport building button is disabled till you can actually build aircraft. The game itself will not disallow you to build the infrastructure and this "new" behaviour can be overriden with a patch setting.
rubidium
parents: 6829
diff changeset
   112
	if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return;
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7521
diff changeset
   113
	HandlePlacePushButton(w, DTW_BUOY, SPR_CURSOR_BOUY, VHM_RECT, PlaceDocks_Buoy);
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   116
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   117
typedef void OnButtonClick(Window *w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   118
static OnButtonClick * const _build_docks_button_proc[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
	BuildDocksClick_Canal,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   120
	BuildDocksClick_Lock,
2548
49c8a096033f (svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents: 2186
diff changeset
   121
	NULL,
606
da90c837064c (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
   122
	BuildDocksClick_Demolish,
da90c837064c (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
   123
	BuildDocksClick_Depot,
da90c837064c (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
   124
	BuildDocksClick_Dock,
5682
f109e2e62af8 (svn r8143) Remove the landscaping button from the build toolbars.
tron
parents: 5587
diff changeset
   125
	BuildDocksClick_Buoy
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   128
static void BuildDocksToolbWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   129
{
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2725
diff changeset
   130
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   131
	case WE_PAINT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   132
		DrawWindowWidgets(w);
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7948
diff changeset
   133
		w->SetWidgetsDisabledState(!CanBuildVehicleInfrastructure(VEH_SHIP), 7, 8, 9, WIDGET_LIST_END);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   134
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   135
2548
49c8a096033f (svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents: 2186
diff changeset
   136
	case WE_CLICK:
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4539
diff changeset
   137
		if (e->we.click.widget - 3 >= 0 && e->we.click.widget != 5) _build_docks_button_proc[e->we.click.widget - 3](w);
2548
49c8a096033f (svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents: 2186
diff changeset
   138
		break;
1019
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 946
diff changeset
   139
2549
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
   140
	case WE_KEYPRESS:
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4539
diff changeset
   141
		switch (e->we.keypress.keycode) {
937
883afa491049 (svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents: 867
diff changeset
   142
			case '1': BuildDocksClick_Canal(w); break;
883afa491049 (svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents: 867
diff changeset
   143
			case '2': BuildDocksClick_Lock(w); break;
883afa491049 (svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents: 867
diff changeset
   144
			case '3': BuildDocksClick_Demolish(w); break;
883afa491049 (svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents: 867
diff changeset
   145
			case '4': BuildDocksClick_Depot(w); break;
883afa491049 (svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents: 867
diff changeset
   146
			case '5': BuildDocksClick_Dock(w); break;
883afa491049 (svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents: 867
diff changeset
   147
			case '6': BuildDocksClick_Buoy(w); break;
2549
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
   148
			default:  return;
937
883afa491049 (svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents: 867
diff changeset
   149
		}
2549
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
   150
		break;
0
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
	case WE_PLACE_OBJ:
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4539
diff changeset
   153
		_place_proc(e->we.place.tile);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   154
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   155
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   156
	case WE_PLACE_DRAG: {
6669
bb48a810a509 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 6491
diff changeset
   157
		VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   158
		return;
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   161
	case WE_PLACE_MOUSEUP:
4994
aec94128f5d5 (svn r7000) -Fix: Incorrect use of e->we.click when the event is a 'place'. This didn't cause any
Darkvater
parents: 4938
diff changeset
   162
		if (e->we.place.pt.x != -1) {
6670
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
   163
			switch (e->we.place.select_proc) {
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
   164
				case DDSP_DEMOLISH_AREA:
6669
bb48a810a509 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 6491
diff changeset
   165
					GUIPlaceProcDragXY(e);
bb48a810a509 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 6491
diff changeset
   166
					break;
6670
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
   167
				case DDSP_CREATE_WATER:
7521
0da1e91510e4 (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7341
diff changeset
   168
					DoCommandP(e->we.place.tile, e->we.place.starttile, 0, CcBuildCanal, CMD_BUILD_CANAL | CMD_MSG(STR_CANT_BUILD_CANALS));
6669
bb48a810a509 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 6491
diff changeset
   169
					break;
bb48a810a509 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 6491
diff changeset
   170
				default: break;
2549
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
   171
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   172
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   173
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   174
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   175
	case WE_ABORT_PLACE_OBJ:
8032
f35fba9bacb0 (svn r11592) -Codechange: Use the Window member RaiseButtons and remove the now useless RaiseWindowButtons function
belugas
parents: 7997
diff changeset
   176
		w->RaiseButtons();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   177
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   178
		w = FindWindowById(WC_BUILD_STATION, 0);
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6286
diff changeset
   179
		if (w != NULL) WP(w, def_d).close = true;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   180
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   181
		w = FindWindowById(WC_BUILD_DEPOT, 0);
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6286
diff changeset
   182
		if (w != NULL) WP(w, def_d).close = true;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   183
		break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   184
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   185
	case WE_PLACE_PRESIZE: {
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   186
		TileIndex tile_from;
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   187
		TileIndex tile_to;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   188
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4539
diff changeset
   189
		tile_from = tile_to = e->we.place.tile;
1981
3c9c682f1212 (svn r2487) Replace TILE_XY by TileXY/TileDiffXY
tron
parents: 1977
diff changeset
   190
		switch (GetTileSlope(tile_from, NULL)) {
3636
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3157
diff changeset
   191
			case SLOPE_SW: tile_to += TileDiffXY(-1,  0); break;
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3157
diff changeset
   192
			case SLOPE_SE: tile_to += TileDiffXY( 0, -1); break;
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3157
diff changeset
   193
			case SLOPE_NW: tile_to += TileDiffXY( 0,  1); break;
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3157
diff changeset
   194
			case SLOPE_NE: tile_to += TileDiffXY( 1,  0); break;
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3157
diff changeset
   195
			default: break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   196
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   197
		VpSetPresizeRange(tile_from, tile_to);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   198
	} break;
2619
1b20d578a660 (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: 2549
diff changeset
   199
1b20d578a660 (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: 2549
diff changeset
   200
	case WE_DESTROY:
1b20d578a660 (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: 2549
diff changeset
   201
		if (_patches.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
1b20d578a660 (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: 2549
diff changeset
   202
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   203
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   204
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   205
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   206
static const Widget _build_docks_toolb_widgets[] = {
4344
7e123fec5b0b (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: 4087
diff changeset
   207
{   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                   STR_018B_CLOSE_WINDOW},
5682
f109e2e62af8 (svn r8143) Remove the landscaping button from the build toolbars.
tron
parents: 5587
diff changeset
   208
{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   123,     0,    13, STR_9801_DOCK_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
f109e2e62af8 (svn r8143) Remove the landscaping button from the build toolbars.
tron
parents: 5587
diff changeset
   209
{  WWT_STICKYBOX,   RESIZE_NONE,     7,   124,   135,     0,    13, 0x0,                        STR_STICKY_BUTTON},
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   210
{     WWT_IMGBTN,   RESIZE_NONE,     7,     0,    21,    14,    35, SPR_IMG_BUILD_CANAL,        STR_BUILD_CANALS_TIP},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   211
{     WWT_IMGBTN,   RESIZE_NONE,     7,    22,    43,    14,    35, SPR_IMG_BUILD_LOCK,         STR_BUILD_LOCKS_TIP},
606
da90c837064c (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
   212
4344
7e123fec5b0b (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: 4087
diff changeset
   213
{      WWT_PANEL,   RESIZE_NONE,     7,    44,    47,    14,    35, 0x0,                        STR_NULL},
606
da90c837064c (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
   214
4937
8cfdd86fd709 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   215
{     WWT_IMGBTN,   RESIZE_NONE,     7,    48,    69,    14,    35, SPR_IMG_DYNAMITE,           STR_018D_DEMOLISH_BUILDINGS_ETC},
8cfdd86fd709 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   216
{     WWT_IMGBTN,   RESIZE_NONE,     7,    70,    91,    14,    35, SPR_IMG_SHIP_DEPOT,         STR_981E_BUILD_SHIP_DEPOT_FOR_BUILDING},
8cfdd86fd709 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   217
{     WWT_IMGBTN,   RESIZE_NONE,     7,    92,   113,    14,    35, SPR_IMG_SHIP_DOCK,          STR_981D_BUILD_SHIP_DOCK},
8cfdd86fd709 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   218
{     WWT_IMGBTN,   RESIZE_NONE,     7,   114,   135,    14,    35, SPR_IMG_BOUY,               STR_9834_POSITION_BUOY_WHICH_CAN},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 0
diff changeset
   219
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   220
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   221
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   222
static const WindowDesc _build_docks_toolbar_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7241
diff changeset
   223
	WDP_ALIGN_TBR, 22, 136, 36, 136, 36,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5860
diff changeset
   224
	WC_BUILD_TOOLBAR, WC_NONE,
756
b76998029c12 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents: 750
diff changeset
   225
	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
   226
	_build_docks_toolb_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   227
	BuildDocksToolbWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   228
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   229
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6125
diff changeset
   230
void ShowBuildDocksToolbar()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   231
{
5005
f5086bd3945a (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4994
diff changeset
   232
	if (!IsValidPlayer(_current_player)) return;
f5086bd3945a (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4994
diff changeset
   233
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   234
	DeleteWindowById(WC_BUILD_TOOLBAR, 0);
5860
3b26be021371 (svn r8436) -Fix
tron
parents: 5682
diff changeset
   235
	Window *w = AllocateWindowDesc(&_build_docks_toolbar_desc);
3b26be021371 (svn r8436) -Fix
tron
parents: 5682
diff changeset
   236
	if (_patches.link_terraform_toolbar) ShowTerraformToolbar(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   237
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   238
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   239
static void BuildDockStationWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   240
{
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   241
	switch (e->event) {
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7948
diff changeset
   242
	case WE_CREATE: w->LowerWidget(_station_show_coverage + 3); break;
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4634
diff changeset
   243
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   244
	case WE_PAINT: {
6829
baf24dad91c9 (svn r10068) -Fix [FS#835]: coverage area highlight was still show when it was turned off for docks.
rubidium
parents: 6674
diff changeset
   245
		int rad = (_patches.modified_catchment) ? CA_DOCK : 4;
713
aeeebdfdaae0 (svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents: 679
diff changeset
   246
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6286
diff changeset
   247
		if (WP(w, def_d).close) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   248
		DrawWindowWidgets(w);
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2619
diff changeset
   249
6829
baf24dad91c9 (svn r10068) -Fix [FS#835]: coverage area highlight was still show when it was turned off for docks.
rubidium
parents: 6674
diff changeset
   250
		if (_station_show_coverage) {
baf24dad91c9 (svn r10068) -Fix [FS#835]: coverage area highlight was still show when it was turned off for docks.
rubidium
parents: 6674
diff changeset
   251
			SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
baf24dad91c9 (svn r10068) -Fix [FS#835]: coverage area highlight was still show when it was turned off for docks.
rubidium
parents: 6674
diff changeset
   252
		} else {
baf24dad91c9 (svn r10068) -Fix [FS#835]: coverage area highlight was still show when it was turned off for docks.
rubidium
parents: 6674
diff changeset
   253
			SetTileSelectSize(1, 1);
baf24dad91c9 (svn r10068) -Fix [FS#835]: coverage area highlight was still show when it was turned off for docks.
rubidium
parents: 6674
diff changeset
   254
		}
713
aeeebdfdaae0 (svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents: 679
diff changeset
   255
7241
7fd23b6f6713 (svn r10522) -Fix: the "build truck station" GUI showed that it would accept tourists when it does not, whereas the "build bus station" GUI did not show them when it did accept them.
rubidium
parents: 7086
diff changeset
   256
		DrawStationCoverageAreaText(4, 50, SCT_ALL, rad);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   257
		break;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   258
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   259
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   260
	case WE_CLICK:
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4539
diff changeset
   261
		switch (e->we.click.widget) {
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   262
			case 3:
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   263
			case 4:
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7948
diff changeset
   264
				w->RaiseWidget(_station_show_coverage + 3);
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   265
				_station_show_coverage = (e->we.click.widget != 3);
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7948
diff changeset
   266
				w->LowerWidget(_station_show_coverage + 3);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   267
				SndPlayFx(SND_15_BEEP);
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   268
				SetWindowDirty(w);
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   269
				break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   270
		}
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   271
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   272
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   273
	case WE_MOUSELOOP:
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6286
diff changeset
   274
		if (WP(w, def_d).close) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   275
			DeleteWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   276
			return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   277
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   278
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   279
		CheckRedrawStationCoverage(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   280
		break;
1072
74cd9150d473 (svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents: 1019
diff changeset
   281
74cd9150d473 (svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents: 1019
diff changeset
   282
	case WE_DESTROY:
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6286
diff changeset
   283
		if (!WP(w, def_d).close) ResetObjectToPlace();
1072
74cd9150d473 (svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents: 1019
diff changeset
   284
		break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   285
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   286
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   287
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   288
static const Widget _build_dock_station_widgets[] = {
4345
1da147230c79 (svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents: 4344
diff changeset
   289
{   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                         STR_018B_CLOSE_WINDOW},
1da147230c79 (svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents: 4344
diff changeset
   290
{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   147,     0,    13, STR_3068_DOCK,                    STR_018C_WINDOW_TITLE_DRAG_THIS},
1da147230c79 (svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents: 4344
diff changeset
   291
{      WWT_PANEL,   RESIZE_NONE,     7,     0,   147,    14,    74, 0x0,                              STR_NULL},
1da147230c79 (svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents: 4344
diff changeset
   292
{    WWT_TEXTBTN,   RESIZE_NONE,    14,    14,    73,    30,    40, STR_02DB_OFF,                     STR_3065_DON_T_HIGHLIGHT_COVERAGE},
1da147230c79 (svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents: 4344
diff changeset
   293
{    WWT_TEXTBTN,   RESIZE_NONE,    14,    74,   133,    30,    40, STR_02DA_ON,                      STR_3064_HIGHLIGHT_COVERAGE_AREA},
1da147230c79 (svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents: 4344
diff changeset
   294
{      WWT_LABEL,   RESIZE_NONE,     7,     0,   147,    17,    30, 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
   295
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   296
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   297
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   298
static const WindowDesc _build_dock_station_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7241
diff changeset
   299
	WDP_AUTO, WDP_AUTO, 148, 75, 148, 75,
5070
7f5b13b7e728 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 5005
diff changeset
   300
	WC_BUILD_STATION, WC_BUILD_TOOLBAR,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   301
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   302
	_build_dock_station_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   303
	BuildDockStationWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   304
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   305
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6125
diff changeset
   306
static void ShowBuildDockStationPicker()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   307
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   308
	AllocateWindowDesc(&_build_dock_station_desc);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   309
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   310
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6125
diff changeset
   311
static void UpdateDocksDirection()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   312
{
3157
3f35e2d9c8e3 (svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents: 2952
diff changeset
   313
	if (_ship_depot_direction != AXIS_X) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   314
		SetTileSelectSize(1, 2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   315
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   316
		SetTileSelectSize(2, 1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   317
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   318
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   319
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   320
static void BuildDocksDepotWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   321
{
2549
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
   322
	switch (e->event) {
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7948
diff changeset
   323
	case WE_CREATE: w->LowerWidget(_ship_depot_direction + 3); break;
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4634
diff changeset
   324
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   325
	case WE_PAINT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   326
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   327
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   328
		DrawShipDepotSprite(67, 35, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   329
		DrawShipDepotSprite(35, 51, 1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   330
		DrawShipDepotSprite(135, 35, 2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   331
		DrawShipDepotSprite(167, 51, 3);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   332
		return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   333
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   334
	case WE_CLICK: {
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4539
diff changeset
   335
		switch (e->we.click.widget) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   336
		case 3:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   337
		case 4:
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7948
diff changeset
   338
			w->RaiseWidget(_ship_depot_direction + 3);
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   339
			_ship_depot_direction = (e->we.click.widget == 3 ? AXIS_X : AXIS_Y);
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7948
diff changeset
   340
			w->LowerWidget(_ship_depot_direction + 3);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 507
diff changeset
   341
			SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   342
			UpdateDocksDirection();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   343
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   344
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   345
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   346
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   347
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   348
	case WE_MOUSELOOP:
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6286
diff changeset
   349
		if (WP(w, def_d).close) DeleteWindow(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   350
		break;
1072
74cd9150d473 (svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents: 1019
diff changeset
   351
74cd9150d473 (svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents: 1019
diff changeset
   352
	case WE_DESTROY:
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6286
diff changeset
   353
		if (!WP(w, def_d).close) ResetObjectToPlace();
1072
74cd9150d473 (svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents: 1019
diff changeset
   354
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   355
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   356
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   357
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   358
static const Widget _build_docks_depot_widgets[] = {
4344
7e123fec5b0b (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: 4087
diff changeset
   359
{   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},
7e123fec5b0b (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: 4087
diff changeset
   360
{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   203,     0,    13, STR_3800_SHIP_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
7e123fec5b0b (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: 4087
diff changeset
   361
{      WWT_PANEL,   RESIZE_NONE,     7,     0,   203,    14,    85, 0x0,                             STR_NULL},
7e123fec5b0b (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: 4087
diff changeset
   362
{      WWT_PANEL,   RESIZE_NONE,    14,     3,   100,    17,    82, 0x0,                             STR_3803_SELECT_SHIP_DEPOT_ORIENTATION},
7e123fec5b0b (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: 4087
diff changeset
   363
{      WWT_PANEL,   RESIZE_NONE,    14,   103,   200,    17,    82, 0x0,                             STR_3803_SELECT_SHIP_DEPOT_ORIENTATION},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 0
diff changeset
   364
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   365
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   366
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   367
static const WindowDesc _build_docks_depot_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7241
diff changeset
   368
	WDP_AUTO, WDP_AUTO, 204, 86, 204, 86,
5070
7f5b13b7e728 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 5005
diff changeset
   369
	WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   370
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   371
	_build_docks_depot_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   372
	BuildDocksDepotWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   373
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   374
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   375
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6125
diff changeset
   376
static void ShowBuildDocksDepotPicker()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   377
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   378
	AllocateWindowDesc(&_build_docks_depot_desc);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   379
	UpdateDocksDirection();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   380
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   381
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   382
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6125
diff changeset
   383
void InitializeDockGui()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   384
{
3157
3f35e2d9c8e3 (svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents: 2952
diff changeset
   385
	_ship_depot_direction = AXIS_X;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   386
}