dock_gui.c
author tron
Fri, 22 Jul 2005 07:02:20 +0000
changeset 2163 637ec3c361f5
parent 2159 3b634157c3b2
child 2186 461a2aff3486
permissions -rw-r--r--
(svn r2673) Include functions.h directly, not globally via openttd.h
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     1
#include "stdafx.h"
1891
92a3b0aa0946 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1632
diff changeset
     2
#include "openttd.h"
1363
01d3de5d8039 (svn r1867) Include tables/sprites.h only in files which need it
tron
parents: 1116
diff changeset
     3
#include "table/sprites.h"
507
8aa8100b0b22 (svn r815) Include strings.h only in the files which need it.
tron
parents: 337
diff changeset
     4
#include "table/strings.h"
2163
637ec3c361f5 (svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents: 2159
diff changeset
     5
#include "functions.h"
679
e959706a3e4d (svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents: 606
diff changeset
     6
#include "map.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
#include "window.h"
568
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 543
diff changeset
     8
#include "station.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     9
#include "gui.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    10
#include "viewport.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    11
#include "gfx.h"
337
66647f97e7c0 (svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents: 193
diff changeset
    12
#include "sound.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    13
#include "command.h"
2159
3b634157c3b2 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 1981
diff changeset
    14
#include "variables.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1072
diff changeset
    16
static void ShowBuildDockStationPicker(void);
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1072
diff changeset
    17
static void ShowBuildDocksDepotPicker(void);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    18
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    19
static byte _ship_depot_direction;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    20
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    21
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
    22
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    23
	if (success) {
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 507
diff changeset
    24
		SndPlayTileFx(SND_02_SPLAT, tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    25
		ResetObjectToPlace();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    26
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    27
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    28
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    29
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
    30
{
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 507
diff changeset
    31
	if (success) SndPlayTileFx(SND_02_SPLAT, tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    32
}
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
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    35
static void PlaceDocks_Dock(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    36
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    37
	DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_DOCK | CMD_AUTO | CMD_MSG(STR_9802_CAN_T_BUILD_DOCK_HERE));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    38
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    39
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    40
static void PlaceDocks_Depot(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    41
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    42
	DoCommandP(tile, _ship_depot_direction, 0, CcBuildDocks, CMD_BUILD_SHIP_DEPOT | CMD_AUTO | CMD_MSG(STR_3802_CAN_T_BUILD_SHIP_DEPOT));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    43
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    44
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    45
static void PlaceDocks_Buoy(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    46
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    47
	DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_BUOY | CMD_AUTO | CMD_MSG(STR_9835_CAN_T_POSITION_BUOY_HERE));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    48
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    49
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    50
static void PlaceDocks_DemolishArea(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    51
{
1632
c4ae19bfebf7 (svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents: 1363
diff changeset
    52
	VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_DemolishArea);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    53
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    54
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    55
static void PlaceDocks_BuildCanal(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
	VpStartPlaceSizing(tile, VPM_X_OR_Y);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    58
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    59
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    60
static void PlaceDocks_BuildLock(TileIndex tile)
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
	DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_LOCK | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_LOCKS));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    63
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    64
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    65
606
0e507bb0f63a (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
    66
static void BuildDocksClick_Canal(Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    67
{
1914
5ede46fd496f (svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents: 1891
diff changeset
    68
	HandlePlacePushButton(w, 3, SPR_CURSOR_CANAL, 1, PlaceDocks_BuildCanal);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    69
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
606
0e507bb0f63a (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
    71
static void BuildDocksClick_Lock(Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    72
{
1914
5ede46fd496f (svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents: 1891
diff changeset
    73
	HandlePlacePushButton(w, 4, SPR_CURSOR_LOCK, 1, PlaceDocks_BuildLock);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    74
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    75
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    76
static void BuildDocksClick_Demolish(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    77
{
756
d1f1dc31b6f4 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents: 750
diff changeset
    78
	HandlePlacePushButton(w, 6, ANIMCURSOR_DEMOLISH, 1, PlaceDocks_DemolishArea);
0
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
606
0e507bb0f63a (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
    81
static void BuildDocksClick_Depot(Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    82
{
1914
5ede46fd496f (svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents: 1891
diff changeset
    83
	if (HandlePlacePushButton(w, 7, SPR_CURSOR_SHIP_DEPOT, 1, PlaceDocks_Depot)) ShowBuildDocksDepotPicker();
0
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
606
0e507bb0f63a (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
    86
static void BuildDocksClick_Dock(Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    87
{
606
0e507bb0f63a (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
    88
1914
5ede46fd496f (svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents: 1891
diff changeset
    89
	if (HandlePlacePushButton(w, 8, SPR_CURSOR_DOCK, 3, PlaceDocks_Dock)) ShowBuildDockStationPicker();
0
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
606
0e507bb0f63a (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
    92
static void BuildDocksClick_Buoy(Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
{
1914
5ede46fd496f (svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents: 1891
diff changeset
    94
	HandlePlacePushButton(w, 9, SPR_CURSOR_BOUY, 1, PlaceDocks_Buoy);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
606
0e507bb0f63a (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
    97
static void BuildDocksClick_Landscaping(Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    98
{
606
0e507bb0f63a (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
    99
	ShowTerraformToolbar();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   100
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   101
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   102
typedef void OnButtonClick(Window *w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   103
static OnButtonClick * const _build_docks_button_proc[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   104
	BuildDocksClick_Canal,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   105
	BuildDocksClick_Lock,
606
0e507bb0f63a (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
   106
	0,
0e507bb0f63a (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
   107
	BuildDocksClick_Demolish,
0e507bb0f63a (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
   108
	BuildDocksClick_Depot,
0e507bb0f63a (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
   109
	BuildDocksClick_Dock,
0e507bb0f63a (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
   110
	BuildDocksClick_Buoy,
0e507bb0f63a (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
   111
	BuildDocksClick_Landscaping,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   112
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   113
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   114
static void BuildDocksToolbWndProc(Window *w, WindowEvent *e)
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
	switch(e->event) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   117
	case WE_PAINT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   118
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   120
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
	case WE_CLICK: {
756
d1f1dc31b6f4 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents: 750
diff changeset
   122
		if (e->click.widget - 3 >= 0 && e->click.widget != 5) _build_docks_button_proc[e->click.widget - 3](w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   123
	} break;
1019
6363b8a4273e (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 946
diff changeset
   124
937
a8dfd3eb406f (svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents: 867
diff changeset
   125
	case WE_KEYPRESS: {
a8dfd3eb406f (svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents: 867
diff changeset
   126
		switch(e->keypress.keycode) {
a8dfd3eb406f (svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents: 867
diff changeset
   127
			case '1': BuildDocksClick_Canal(w); break;
a8dfd3eb406f (svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents: 867
diff changeset
   128
			case '2': BuildDocksClick_Lock(w); break;
a8dfd3eb406f (svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents: 867
diff changeset
   129
			case '3': BuildDocksClick_Demolish(w); break;
a8dfd3eb406f (svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents: 867
diff changeset
   130
			case '4': BuildDocksClick_Depot(w); break;
a8dfd3eb406f (svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents: 867
diff changeset
   131
			case '5': BuildDocksClick_Dock(w); break;
a8dfd3eb406f (svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents: 867
diff changeset
   132
			case '6': BuildDocksClick_Buoy(w); break;
a8dfd3eb406f (svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents: 867
diff changeset
   133
			case 'l': BuildDocksClick_Landscaping(w); break;
1019
6363b8a4273e (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 946
diff changeset
   134
			default:
937
a8dfd3eb406f (svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents: 867
diff changeset
   135
				return;
a8dfd3eb406f (svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents: 867
diff changeset
   136
		}
a8dfd3eb406f (svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents: 867
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
	case WE_PLACE_OBJ:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   140
		_place_proc(e->place.tile);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   141
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   142
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   143
	case WE_PLACE_DRAG: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   144
		VpSelectTilesWithMethod(e->place.pt.x, e->place.pt.y, e->place.userdata);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   145
		return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   146
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   147
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   148
	case WE_PLACE_MOUSEUP:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   149
		if (e->click.pt.x != -1) {
1632
c4ae19bfebf7 (svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents: 1363
diff changeset
   150
			if ((e->place.userdata & 0xF) == VPM_X_AND_Y) { // dragged actions
c4ae19bfebf7 (svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents: 1363
diff changeset
   151
				GUIPlaceProcDragXY(e);
c4ae19bfebf7 (svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents: 1363
diff changeset
   152
			} else if(e->place.userdata == VPM_X_OR_Y)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   153
				DoCommandP(e->place.tile, e->place.starttile, 0, CcBuildCanal, CMD_BUILD_CANAL | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_CANALS));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   154
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   155
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   156
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   157
	case WE_ABORT_PLACE_OBJ:
756
d1f1dc31b6f4 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents: 750
diff changeset
   158
		UnclickWindowButtons(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   159
		SetWindowDirty(w);
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
		w = FindWindowById(WC_BUILD_STATION, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   162
		if (w != NULL) WP(w,def_d).close=true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   163
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   164
		w = FindWindowById(WC_BUILD_DEPOT, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   165
		if (w != NULL) WP(w,def_d).close=true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   166
		break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   167
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   168
	case WE_PLACE_PRESIZE: {
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   169
		TileIndex tile_from;
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   170
		TileIndex tile_to;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   171
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   172
		tile_from = tile_to = e->place.tile;
1981
de031d2aed47 (svn r2487) Replace TILE_XY by TileXY/TileDiffXY
tron
parents: 1977
diff changeset
   173
		switch (GetTileSlope(tile_from, NULL)) {
de031d2aed47 (svn r2487) Replace TILE_XY by TileXY/TileDiffXY
tron
parents: 1977
diff changeset
   174
			case  3: tile_to += TileDiffXY(-1,  0); break;
de031d2aed47 (svn r2487) Replace TILE_XY by TileXY/TileDiffXY
tron
parents: 1977
diff changeset
   175
			case  6: tile_to += TileDiffXY( 0, -1); break;
de031d2aed47 (svn r2487) Replace TILE_XY by TileXY/TileDiffXY
tron
parents: 1977
diff changeset
   176
			case  9: tile_to += TileDiffXY( 0,  1); break;
de031d2aed47 (svn r2487) Replace TILE_XY by TileXY/TileDiffXY
tron
parents: 1977
diff changeset
   177
			case 12: tile_to += TileDiffXY( 1,  0); break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   178
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   179
		VpSetPresizeRange(tile_from, tile_to);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   180
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   181
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   182
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   183
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   184
static const Widget _build_docks_toolb_widgets[] = {
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 787
diff changeset
   185
{   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,										STR_018B_CLOSE_WINDOW},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 787
diff changeset
   186
{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   145,     0,    13, STR_9801_DOCK_CONSTRUCTION,	STR_018C_WINDOW_TITLE_DRAG_THIS},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 787
diff changeset
   187
{  WWT_STICKYBOX,   RESIZE_NONE,     7,   146,   157,     0,    13, 0x0,                         STR_STICKY_BUTTON},
1632
c4ae19bfebf7 (svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents: 1363
diff changeset
   188
{      WWT_PANEL,   RESIZE_NONE,     7,     0,    21,    14,    35, SPR_IMG_BUILD_CANAL,					STR_BUILD_CANALS_TIP},
c4ae19bfebf7 (svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents: 1363
diff changeset
   189
{      WWT_PANEL,   RESIZE_NONE,     7,    22,    43,    14,    35, SPR_IMG_BUILD_LOCK,					STR_BUILD_LOCKS_TIP},
606
0e507bb0f63a (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
   190
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 787
diff changeset
   191
{      WWT_PANEL,   RESIZE_NONE,     7,    44,    47,    14,    35, 0x0,													STR_NULL},
606
0e507bb0f63a (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
   192
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 787
diff changeset
   193
{      WWT_PANEL,   RESIZE_NONE,     7,    48,    69,    14,    35, 703,													STR_018D_DEMOLISH_BUILDINGS_ETC},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 787
diff changeset
   194
{      WWT_PANEL,   RESIZE_NONE,     7,    70,    91,    14,    35, 748,													STR_981E_BUILD_SHIP_DEPOT_FOR_BUILDING},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 787
diff changeset
   195
{      WWT_PANEL,   RESIZE_NONE,     7,    92,   113,    14,    35, 746,													STR_981D_BUILD_SHIP_DOCK},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 787
diff changeset
   196
{      WWT_PANEL,   RESIZE_NONE,     7,   114,   135,    14,    35, 693,													STR_9834_POSITION_BUOY_WHICH_CAN},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 787
diff changeset
   197
{      WWT_PANEL,   RESIZE_NONE,     7,   136,   157,    14,    35, SPR_IMG_LANDSCAPING,				STR_LANDSCAPING_TOOLBAR_TIP},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 0
diff changeset
   198
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   199
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   200
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   201
static const WindowDesc _build_docks_toolbar_desc = {
606
0e507bb0f63a (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
   202
	640-158, 22, 158, 36,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   203
	WC_BUILD_TOOLBAR,0,
756
d1f1dc31b6f4 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents: 750
diff changeset
   204
	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
   205
	_build_docks_toolb_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   206
	BuildDocksToolbWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   207
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   208
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1072
diff changeset
   209
void ShowBuildDocksToolbar(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   210
{
946
81cf624bbdc5 (svn r1435) Fix: [ 1094092 ] Toolbars accessible via keyboard in spectator mode
dominik
parents: 937
diff changeset
   211
	if (_current_player == OWNER_SPECTATOR) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   212
	DeleteWindowById(WC_BUILD_TOOLBAR, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   213
	AllocateWindowDesc(&_build_docks_toolbar_desc);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   214
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   215
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   216
static void BuildDockStationWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   217
{
568
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 543
diff changeset
   218
	int rad;
713
5b0be616ee1e (svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents: 679
diff changeset
   219
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   220
	switch(e->event) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   221
	case WE_PAINT: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   222
		if (WP(w,def_d).close)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   223
			return;
713
5b0be616ee1e (svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents: 679
diff changeset
   224
		w->click_state = (1<<3) << _station_show_coverage;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   225
		DrawWindowWidgets(w);
568
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 543
diff changeset
   226
		if (_patches.modified_catchment) {
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 543
diff changeset
   227
			rad = CA_DOCK;
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 543
diff changeset
   228
		} else {
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 543
diff changeset
   229
			rad = 4;
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 543
diff changeset
   230
		}
713
5b0be616ee1e (svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents: 679
diff changeset
   231
5b0be616ee1e (svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents: 679
diff changeset
   232
		if (_station_show_coverage)	SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
5b0be616ee1e (svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents: 679
diff changeset
   233
		else SetTileSelectBigSize(0, 0, 0, 0);
5b0be616ee1e (svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents: 679
diff changeset
   234
750
f68f0af1dc53 (svn r1206) Fix: Polished build docks window a bit.
dominik
parents: 713
diff changeset
   235
		DrawStringCentered(74, 17, STR_3066_COVERAGE_AREA_HIGHLIGHT, 0);
f68f0af1dc53 (svn r1206) Fix: Polished build docks window a bit.
dominik
parents: 713
diff changeset
   236
		DrawStationCoverageAreaText(4, 50, (uint)-1, rad);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   237
	} break;
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
	case WE_CLICK: {
713
5b0be616ee1e (svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents: 679
diff changeset
   240
		switch(e->click.widget) {
5b0be616ee1e (svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents: 679
diff changeset
   241
		case 3: case 4:
5b0be616ee1e (svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents: 679
diff changeset
   242
			_station_show_coverage = e->click.widget - 3;
5b0be616ee1e (svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents: 679
diff changeset
   243
			SndPlayFx(SND_15_BEEP);
5b0be616ee1e (svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents: 679
diff changeset
   244
			SetWindowDirty(w);
5b0be616ee1e (svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents: 679
diff changeset
   245
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   246
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   247
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   248
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   249
	case WE_MOUSELOOP: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   250
		if (WP(w,def_d).close) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   251
			DeleteWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   252
			return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   253
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   254
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   255
		CheckRedrawStationCoverage(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   256
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   257
	}
1072
01bf9fc64236 (svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents: 1019
diff changeset
   258
01bf9fc64236 (svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents: 1019
diff changeset
   259
	case WE_DESTROY:
1116
a38aed715c95 (svn r1617) -Fix: Ugly hack to only call ResetObjectToPlaceon childwindows of build-toolbar if the window is closed manually (with 'X'); if not checked ResetObjectToPlace is called twice resulting in undesired actions (eg. clicked button is unclicked immediately).
darkvater
parents: 1093
diff changeset
   260
		if (!WP(w,def_d).close)
a38aed715c95 (svn r1617) -Fix: Ugly hack to only call ResetObjectToPlaceon childwindows of build-toolbar if the window is closed manually (with 'X'); if not checked ResetObjectToPlace is called twice resulting in undesired actions (eg. clicked button is unclicked immediately).
darkvater
parents: 1093
diff changeset
   261
			ResetObjectToPlace();
1072
01bf9fc64236 (svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents: 1019
diff changeset
   262
		break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   263
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   264
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   265
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   266
static const Widget _build_dock_station_widgets[] = {
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 787
diff changeset
   267
{   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,			STR_018B_CLOSE_WINDOW},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 787
diff changeset
   268
{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   147,     0,    13, STR_3068_DOCK,	STR_018C_WINDOW_TITLE_DRAG_THIS},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 787
diff changeset
   269
{      WWT_PANEL,   RESIZE_NONE,     7,     0,   147,    14,    74, 0x0,						STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 787
diff changeset
   270
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,    14,    73,    30,    40, STR_02DB_OFF,	STR_3065_DON_T_HIGHLIGHT_COVERAGE},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 787
diff changeset
   271
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,    74,   133,    30,    40, STR_02DA_ON,		STR_3064_HIGHLIGHT_COVERAGE_AREA},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 0
diff changeset
   272
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   273
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   274
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   275
static const WindowDesc _build_dock_station_desc = {
750
f68f0af1dc53 (svn r1206) Fix: Polished build docks window a bit.
dominik
parents: 713
diff changeset
   276
	-1, -1, 148, 75,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   277
	WC_BUILD_STATION,WC_BUILD_TOOLBAR,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   278
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   279
	_build_dock_station_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   280
	BuildDockStationWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   281
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   282
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1072
diff changeset
   283
static void ShowBuildDockStationPicker(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   284
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   285
	AllocateWindowDesc(&_build_dock_station_desc);
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
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1072
diff changeset
   288
static void UpdateDocksDirection(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   289
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   290
	if (_ship_depot_direction != 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   291
		SetTileSelectSize(1, 2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   292
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   293
		SetTileSelectSize(2, 1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   294
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   295
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   296
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   297
static void BuildDocksDepotWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   298
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   299
	switch(e->event) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   300
	case WE_PAINT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   301
		w->click_state = (1<<3) << _ship_depot_direction;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   302
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   303
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   304
		DrawShipDepotSprite(67, 35, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   305
		DrawShipDepotSprite(35, 51, 1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   306
		DrawShipDepotSprite(135, 35, 2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   307
		DrawShipDepotSprite(167, 51, 3);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   308
		return;
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
	case WE_CLICK: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   311
		switch(e->click.widget) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   312
		case 3:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   313
		case 4:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   314
			_ship_depot_direction = e->click.widget - 3;
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 507
diff changeset
   315
			SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   316
			UpdateDocksDirection();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   317
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   318
			break;
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
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   321
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   322
	case WE_MOUSELOOP:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   323
		if (WP(w,def_d).close)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   324
			DeleteWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   325
		break;
1072
01bf9fc64236 (svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents: 1019
diff changeset
   326
01bf9fc64236 (svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents: 1019
diff changeset
   327
	case WE_DESTROY:
1116
a38aed715c95 (svn r1617) -Fix: Ugly hack to only call ResetObjectToPlaceon childwindows of build-toolbar if the window is closed manually (with 'X'); if not checked ResetObjectToPlace is called twice resulting in undesired actions (eg. clicked button is unclicked immediately).
darkvater
parents: 1093
diff changeset
   328
		if (!WP(w,def_d).close)
a38aed715c95 (svn r1617) -Fix: Ugly hack to only call ResetObjectToPlaceon childwindows of build-toolbar if the window is closed manually (with 'X'); if not checked ResetObjectToPlace is called twice resulting in undesired actions (eg. clicked button is unclicked immediately).
darkvater
parents: 1093
diff changeset
   329
			ResetObjectToPlace();
1072
01bf9fc64236 (svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents: 1019
diff changeset
   330
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   331
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   332
}
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
static const Widget _build_docks_depot_widgets[] = {
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 787
diff changeset
   335
{   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,												STR_018B_CLOSE_WINDOW},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 787
diff changeset
   336
{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   203,     0,    13, STR_3800_SHIP_DEPOT_ORIENTATION,	STR_018C_WINDOW_TITLE_DRAG_THIS},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 787
diff changeset
   337
{      WWT_PANEL,   RESIZE_NONE,     7,     0,   203,    14,    85, 0x0,															STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 787
diff changeset
   338
{      WWT_PANEL,   RESIZE_NONE,    14,     3,   100,    17,    82, 0x0,															STR_3803_SELECT_SHIP_DEPOT_ORIENTATION},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 787
diff changeset
   339
{      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
   340
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   341
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   342
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   343
static const WindowDesc _build_docks_depot_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   344
	-1, -1, 204, 86,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   345
	WC_BUILD_DEPOT,WC_BUILD_TOOLBAR,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   346
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   347
	_build_docks_depot_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   348
	BuildDocksDepotWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   349
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   350
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   351
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1072
diff changeset
   352
static void ShowBuildDocksDepotPicker(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   353
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   354
	AllocateWindowDesc(&_build_docks_depot_desc);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   355
	UpdateDocksDirection();
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
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1072
diff changeset
   359
void InitializeDockGui(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   360
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   361
	_ship_depot_direction = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   362
}