src/road_gui.cpp
author belugas
Fri, 26 Oct 2007 16:38:32 +0000
changeset 7794 ce96912e77fb
parent 7789 ffac1a901f54
child 7895 2ac7de1f03e6
permissions -rw-r--r--
(svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
Some typos fixed too.(FS#1371-skidd13)
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
6393
e1e4939d19b5 (svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas
parents: 6247
diff changeset
     3
/** @file road_gui.cpp */
e1e4939d19b5 (svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas
parents: 6247
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: 1363
diff changeset
     6
#include "openttd.h"
1363
775a7ee52369 (svn r1867) Include tables/sprites.h only in files which need it
tron
parents: 1217
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"
7266
b16e67e992b4 (svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents: 7241
diff changeset
     9
#include "strings.h"
2163
b17b313113a0 (svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents: 2159
diff changeset
    10
#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: 661
diff changeset
    11
#include "map.h"
1209
2e00193652b2 (svn r1713) Split off several functions which query/set information about a single tile from map.h and put them into a seperate file tile.h
tron
parents: 1116
diff changeset
    12
#include "tile.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    13
#include "window.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    14
#include "gui.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
#include "viewport.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    16
#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
    17
#include "sound.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    18
#include "command.h"
2159
f6284cf5fab0 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2049
diff changeset
    19
#include "variables.h"
6666
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
    20
#include "road.h"
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
    21
#include "road_cmd.h"
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
    22
#include "road_map.h"
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
    23
#include "station_map.h"
568
b0d0df062880 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 543
diff changeset
    24
//needed for catchments
b0d0df062880 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 543
diff changeset
    25
#include "station.h"
b0d0df062880 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 543
diff changeset
    26
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    27
6693
00bef74e4d3a (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 6691
diff changeset
    28
static void ShowRVStationPicker(RoadStop::Type rs);
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6102
diff changeset
    29
static void ShowRoadDepotPicker();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    30
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    31
static bool _remove_button_clicked;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    32
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    33
/**
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    34
 * Define the values of the RoadFlags
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    35
 * @see CmdBuildLongRoad
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    36
 */
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    37
enum RoadFlags {
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    38
	RF_NONE             = 0x00,
7794
ce96912e77fb (svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
belugas
parents: 7789
diff changeset
    39
	RF_START_HALFROAD_Y = 0x01,    // The start tile in Y-dir should have only a half road
ce96912e77fb (svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
belugas
parents: 7789
diff changeset
    40
	RF_END_HALFROAD_Y   = 0x02,    // The end tile in Y-dir should have only a half road
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    41
	RF_DIR_Y            = 0x04,    // The direction is Y-dir
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    42
	RF_DIR_X            = RF_NONE, // Dummy; Dir X is set when RF_DIR_Y is not set
7794
ce96912e77fb (svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
belugas
parents: 7789
diff changeset
    43
	RF_START_HALFROAD_X = 0x08,    // The start tile in X-dir should have only a half road
ce96912e77fb (svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
belugas
parents: 7789
diff changeset
    44
	RF_END_HALFROAD_X   = 0x10,    // The end tile in X-dir should have only a half road
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    45
};
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    46
DECLARE_ENUM_AS_BIT_SET(RoadFlags);
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    47
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    48
static RoadFlags _place_road_flag;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    49
6666
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
    50
static RoadType _cur_roadtype;
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
    51
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
    52
static DiagDirection _road_depot_orientation;
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
    53
static DiagDirection _road_station_picker_orientation;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    54
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    55
void CcPlaySound1D(bool success, TileIndex tile, uint32 p1, uint32 p2)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
{
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 514
diff changeset
    57
	if (success) SndPlayTileFx(SND_1F_SPLAT, tile);
0
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
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    60
/**
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    61
 * Set the initial flags for the road constuction.
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    62
 * The flags are:
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    63
 * @li The direction is the Y-dir
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    64
 * @li The first tile has a partitial RoadBit (true or false)
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    65
 *
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    66
 * @param tile The start tile
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    67
 */
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    68
static void PlaceRoad_NE(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    69
{
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    70
	_place_road_flag = RF_DIR_Y;
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    71
	if (_tile_fract_coords.y >= 8) _place_road_flag |= RF_START_HALFROAD_Y;
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
    72
	VpStartPlaceSizing(tile, VPM_FIX_X, DDSP_PLACE_ROAD_NE);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    73
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    74
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    75
/**
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    76
 * Set the initial flags for the road constuction.
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    77
 * The flags are:
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    78
 * @li The direction is the X-dir
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    79
 * @li The first tile has a partitial RoadBit (true or false)
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    80
 *
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    81
 * @param tile The start tile
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    82
 */
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    83
static void PlaceRoad_NW(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    84
{
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    85
	_place_road_flag = RF_DIR_X;
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    86
	if (_tile_fract_coords.x >= 8) _place_road_flag |= RF_START_HALFROAD_X;
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
    87
	VpStartPlaceSizing(tile, VPM_FIX_Y, DDSP_PLACE_ROAD_NW);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    88
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    90
/**
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    91
 * Set the initial flags for the road constuction.
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    92
 * The flags are:
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    93
 * @li The direction is not set.
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    94
 * @li The first tile has a partitial RoadBit (true or false)
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    95
 *
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    96
 * @param tile The start tile
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    97
 */
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    98
static void PlaceRoad_AutoRoad(TileIndex tile)
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    99
{
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   100
	_place_road_flag = RF_NONE;
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   101
	if (_tile_fract_coords.x >= 8) _place_road_flag |= RF_START_HALFROAD_X;
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   102
	if (_tile_fract_coords.y >= 8) _place_road_flag |= RF_START_HALFROAD_Y;
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   103
	VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_PLACE_AUTOROAD);
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   104
}
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   105
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   106
static void PlaceRoad_Bridge(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   107
{
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
   108
	VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_BUILD_BRIDGE);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   109
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   110
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   111
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   112
void CcBuildRoadTunnel(bool success, TileIndex tile, uint32 p1, uint32 p2)
0
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
	if (success) {
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 514
diff changeset
   115
		SndPlayTileFx(SND_20_SPLAT_2, tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   116
		ResetObjectToPlace();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   117
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   118
		SetRedErrorSquare(_build_tunnel_endtile);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
	}
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
6676
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   122
/** Structure holding information per roadtype for several functions */
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   123
struct RoadTypeInfo {
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   124
	StringID err_build_road;        ///< Building a normal piece of road
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   125
	StringID err_remove_road;       ///< Removing a normal piece of road
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   126
	StringID err_depot;             ///< Building a depot
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   127
	StringID err_build_station[2];  ///< Building a bus or truck station
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   128
	StringID err_remove_station[2]; ///< Removing of a bus or truck station
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   129
6693
00bef74e4d3a (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 6691
diff changeset
   130
	StringID picker_title[2];       ///< Title for the station picker for bus or truck stations
00bef74e4d3a (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 6691
diff changeset
   131
	StringID picker_tooltip[2];     ///< Tooltip for the station picker for bus or truck stations
00bef74e4d3a (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 6691
diff changeset
   132
6676
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   133
	SpriteID cursor_nesw;           ///< Cursor for building NE and SW bits
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   134
	SpriteID cursor_nwse;           ///< Cursor for building NW and SE bits
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   135
	SpriteID cursor_autoroad;       ///< Cursor for building autoroad
6676
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   136
};
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   137
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   138
/** What errors/cursors must be shown for several types of roads */
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   139
static const RoadTypeInfo _road_type_infos[] = {
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   140
	{
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   141
		STR_1804_CAN_T_BUILD_ROAD_HERE,
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   142
		STR_1805_CAN_T_REMOVE_ROAD_FROM,
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   143
		STR_1807_CAN_T_BUILD_ROAD_VEHICLE,
6693
00bef74e4d3a (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 6691
diff changeset
   144
		{ STR_1808_CAN_T_BUILD_BUS_STATION,        STR_1809_CAN_T_BUILD_TRUCK_STATION },
00bef74e4d3a (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 6691
diff changeset
   145
		{ STR_CAN_T_REMOVE_BUS_STATION,            STR_CAN_T_REMOVE_TRUCK_STATION     },
00bef74e4d3a (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 6691
diff changeset
   146
		{ STR_3042_BUS_STATION_ORIENTATION,        STR_3043_TRUCK_STATION_ORIENT      },
00bef74e4d3a (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 6691
diff changeset
   147
		{ STR_3051_SELECT_BUS_STATION_ORIENTATION, STR_3052_SELECT_TRUCK_LOADING_BAY  },
6676
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   148
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   149
		SPR_CURSOR_ROAD_NESW,
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   150
		SPR_CURSOR_ROAD_NWSE,
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   151
		SPR_CURSOR_AUTOROAD,
6676
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   152
	},
6691
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   153
	{
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   154
		STR_1804_CAN_T_BUILD_TRAMWAY_HERE,
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   155
		STR_1805_CAN_T_REMOVE_TRAMWAY_FROM,
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   156
		STR_1807_CAN_T_BUILD_TRAM_VEHICLE,
6693
00bef74e4d3a (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 6691
diff changeset
   157
		{ STR_1808_CAN_T_BUILD_PASSENGER_TRAM_STATION,        STR_1809_CAN_T_BUILD_CARGO_TRAM_STATION        },
00bef74e4d3a (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 6691
diff changeset
   158
		{ STR_CAN_T_REMOVE_PASSENGER_TRAM_STATION,            STR_CAN_T_REMOVE_CARGO_TRAM_STATION            },
00bef74e4d3a (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 6691
diff changeset
   159
		{ STR_3042_PASSENGER_TRAM_STATION_ORIENTATION,        STR_3043_CARGO_TRAM_STATION_ORIENT             },
00bef74e4d3a (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 6691
diff changeset
   160
		{ STR_3051_SELECT_PASSENGER_TRAM_STATION_ORIENTATION, STR_3052_SELECT_CARGO_TRAM_STATION_ORIENTATION },
6691
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   161
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   162
		SPR_CURSOR_TRAMWAY_NESW,
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   163
		SPR_CURSOR_TRAMWAY_NWSE,
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   164
		SPR_CURSOR_AUTOTRAM,
6691
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   165
	},
6676
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   166
};
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   167
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   168
static void PlaceRoad_Tunnel(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   169
{
7521
0da1e91510e4 (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7370
diff changeset
   170
	DoCommandP(tile, 0x200 | RoadTypeToRoadTypes(_cur_roadtype), 0, CcBuildRoadTunnel, CMD_BUILD_TUNNEL | CMD_MSG(STR_5016_CAN_T_BUILD_TUNNEL_HERE));
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
3151
711ef4ea85e9 (svn r3774) Remove some more magic numbers and types
tron
parents: 3150
diff changeset
   173
static void BuildRoadOutsideStation(TileIndex tile, DiagDirection direction)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   174
{
4559
aa0c13e39840 (svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents: 4435
diff changeset
   175
	tile += TileOffsByDiagDir(direction);
5
539c9743d999 (svn r6) -Fix [1006530] BuildRoadOutsideStation fix. Fix bug [994720] road depot - bus/lorry station (Truelight+Darkvater :P )
darkvater
parents: 0
diff changeset
   176
	// if there is a roadpiece just outside of the station entrance, build a connecting route
7370
41adc721b1fa (svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium
parents: 7341
diff changeset
   177
	if (IsTileType(tile, MP_ROAD) && GetRoadTileType(tile) == ROAD_TILE_NORMAL) {
6666
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
   178
		if (GetRoadBits(tile, _cur_roadtype) != ROAD_NONE) {
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
   179
			DoCommandP(tile, _cur_roadtype << 4 | DiagDirToRoadBits(ReverseDiagDir(direction)), 0, NULL, CMD_BUILD_ROAD);
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
   180
		}
0
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
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   184
void CcRoadDepot(bool success, TileIndex tile, uint32 p1, uint32 p2)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   185
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   186
	if (success) {
6662
ea30b3497d9a (svn r9893) -Fix (r9892): various small bugs that only act up when using something different than plain roads.
rubidium
parents: 6661
diff changeset
   187
		DiagDirection dir = (DiagDirection)GB(p1, 0, 2);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 514
diff changeset
   188
		SndPlayTileFx(SND_1F_SPLAT, tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   189
		ResetObjectToPlace();
6662
ea30b3497d9a (svn r9893) -Fix (r9892): various small bugs that only act up when using something different than plain roads.
rubidium
parents: 6661
diff changeset
   190
		BuildRoadOutsideStation(tile, dir);
6102
307c3273b22b (svn r8837) -Fix [FS#626]: drive through stations did not connect to neighbouring roads (mart3p).
rubidium
parents: 6039
diff changeset
   191
		/* For a drive-through road stop build connecting road for other entrance */
6662
ea30b3497d9a (svn r9893) -Fix (r9892): various small bugs that only act up when using something different than plain roads.
rubidium
parents: 6661
diff changeset
   192
		if (HASBIT(p2, 1)) BuildRoadOutsideStation(tile, ReverseDiagDir(dir));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   193
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   194
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   195
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   196
static void PlaceRoad_Depot(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   197
{
7521
0da1e91510e4 (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7370
diff changeset
   198
	DoCommandP(tile, _cur_roadtype << 2 | _road_depot_orientation, 0, CcRoadDepot, CMD_BUILD_ROAD_DEPOT | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_depot));
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
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   201
static void PlaceRoadStop(TileIndex tile, uint32 p2, uint32 cmd)
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   202
{
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   203
	uint32 p1 = _road_station_picker_orientation;
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   204
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   205
	if (p1 >= DIAGDIR_END) {
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   206
		SETBIT(p2, 1); // It's a drive-through stop
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   207
		p1 -= DIAGDIR_END; // Adjust picker result to actual direction
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   208
	}
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   209
	DoCommandP(tile, p1, p2, CcRoadDepot, cmd);
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   210
}
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   211
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   212
static void PlaceRoad_BusStation(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   213
{
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   214
	if (_remove_button_clicked) {
6676
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   215
		DoCommandP(tile, 0, RoadStop::BUS, CcPlaySound1D, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[RoadStop::BUS]));
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   216
	} else {
7521
0da1e91510e4 (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7370
diff changeset
   217
		PlaceRoadStop(tile, (_ctrl_pressed << 5) | RoadTypeToRoadTypes(_cur_roadtype) << 2 | RoadStop::BUS, CMD_BUILD_ROAD_STOP | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_station[RoadStop::BUS]));
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   218
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   219
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   220
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   221
static void PlaceRoad_TruckStation(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   222
{
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   223
	if (_remove_button_clicked) {
7339
b1951b442a68 (svn r10702) -Fix: "Can't build ..." instead of "Can't remove ..." message shown for road stops for trucks/cargo trams.
rubidium
parents: 7272
diff changeset
   224
		DoCommandP(tile, 0, RoadStop::TRUCK, CcPlaySound1D, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[RoadStop::TRUCK]));
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   225
	} else {
7521
0da1e91510e4 (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7370
diff changeset
   226
		PlaceRoadStop(tile, (_ctrl_pressed << 5) | RoadTypeToRoadTypes(_cur_roadtype) << 2 | RoadStop::TRUCK, CMD_BUILD_ROAD_STOP | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_station[RoadStop::TRUCK]));
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   227
	}
0
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
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   230
static void PlaceRoad_DemolishArea(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   231
{
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
   232
	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
   233
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   234
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   235
/** Enum referring to the widgets of the build road toolbar */
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   236
enum RoadToolbarWidgets {
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   237
	RTW_CLOSEBOX = 0,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   238
	RTW_CAPTION,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   239
	RTW_STICKY,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   240
	RTW_ROAD_X,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   241
	RTW_ROAD_Y,
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   242
	RTW_AUTOROAD,
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   243
	RTW_DEMOLISH,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   244
	RTW_DEPOT,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   245
	RTW_BUS_STATION,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   246
	RTW_TRUCK_STATION,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   247
	RTW_BUILD_BRIDGE,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   248
	RTW_BUILD_TUNNEL,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   249
	RTW_REMOVE,
5147
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   250
};
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   251
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   252
typedef void OnButtonClick(Window *w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   253
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   254
/**
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   255
 * Function that handles the click on the
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   256
 *  X road placement button.
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   257
 *
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   258
 * @param w The current window
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   259
 */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   260
static void BuildRoadClick_NE(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   261
{
7794
ce96912e77fb (svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
belugas
parents: 7789
diff changeset
   262
	HandlePlacePushButton(w, RTW_ROAD_X, _road_type_infos[_cur_roadtype].cursor_nesw, VHM_RECT, PlaceRoad_NE);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   263
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   264
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   265
/**
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   266
 * Function that handles the click on the
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   267
 *  Y road placement button.
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   268
 *
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   269
 * @param w The current window
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   270
 */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   271
static void BuildRoadClick_NW(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   272
{
7794
ce96912e77fb (svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
belugas
parents: 7789
diff changeset
   273
	HandlePlacePushButton(w, RTW_ROAD_Y, _road_type_infos[_cur_roadtype].cursor_nwse, VHM_RECT, PlaceRoad_NW);
0
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
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   276
/**
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   277
 * Function that handles the click on the
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   278
 *  autoroad placement button.
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   279
 *
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   280
 * @param w The current window
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   281
 */
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   282
static void BuildRoadClick_AutoRoad(Window *w)
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   283
{
7794
ce96912e77fb (svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
belugas
parents: 7789
diff changeset
   284
	HandlePlacePushButton(w, RTW_AUTOROAD, _road_type_infos[_cur_roadtype].cursor_autoroad, VHM_RECT, PlaceRoad_AutoRoad);
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
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
static void BuildRoadClick_Demolish(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   288
{
7794
ce96912e77fb (svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
belugas
parents: 7789
diff changeset
   289
	HandlePlacePushButton(w, RTW_DEMOLISH, ANIMCURSOR_DEMOLISH, VHM_RECT, PlaceRoad_DemolishArea);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   290
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   291
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   292
static void BuildRoadClick_Depot(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   293
{
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: 6779
diff changeset
   294
	if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return;
7794
ce96912e77fb (svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
belugas
parents: 7789
diff changeset
   295
	if (HandlePlacePushButton(w, RTW_DEPOT, SPR_CURSOR_ROAD_DEPOT, VHM_RECT, PlaceRoad_Depot)) ShowRoadDepotPicker();
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 void BuildRoadClick_BusStation(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   299
{
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: 6779
diff changeset
   300
	if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return;
7794
ce96912e77fb (svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
belugas
parents: 7789
diff changeset
   301
	if (HandlePlacePushButton(w, RTW_BUS_STATION, SPR_CURSOR_BUS_STATION, VHM_RECT, PlaceRoad_BusStation)) ShowRVStationPicker(RoadStop::BUS);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   302
}
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
static void BuildRoadClick_TruckStation(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   305
{
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: 6779
diff changeset
   306
	if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return;
7794
ce96912e77fb (svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
belugas
parents: 7789
diff changeset
   307
	if (HandlePlacePushButton(w, RTW_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, VHM_RECT, PlaceRoad_TruckStation)) ShowRVStationPicker(RoadStop::TRUCK);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   308
}
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
static void BuildRoadClick_Bridge(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   311
{
7794
ce96912e77fb (svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
belugas
parents: 7789
diff changeset
   312
	HandlePlacePushButton(w, RTW_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, VHM_RECT, PlaceRoad_Bridge);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   313
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   314
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   315
static void BuildRoadClick_Tunnel(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   316
{
7794
ce96912e77fb (svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
belugas
parents: 7789
diff changeset
   317
	HandlePlacePushButton(w, RTW_BUILD_TUNNEL, SPR_CURSOR_ROAD_TUNNEL, VHM_SPECIAL, PlaceRoad_Tunnel);
0
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 BuildRoadClick_Remove(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   321
{
5147
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   322
	if (IsWindowWidgetDisabled(w, RTW_REMOVE)) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   323
	SetWindowDirty(w);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 514
diff changeset
   324
	SndPlayFx(SND_15_BEEP);
5147
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   325
	ToggleWidgetLoweredState(w, RTW_REMOVE);
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   326
	SetSelectionRed(IsWindowWidgetLowered(w, RTW_REMOVE));
0
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
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   329
/** Array with the handlers of the button-clicks for the road-toolbar */
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   330
static OnButtonClick* const _build_road_button_proc[] = {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   331
	BuildRoadClick_NE,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   332
	BuildRoadClick_NW,
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   333
	BuildRoadClick_AutoRoad,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   334
	BuildRoadClick_Demolish,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   335
	BuildRoadClick_Depot,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   336
	BuildRoadClick_BusStation,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   337
	BuildRoadClick_TruckStation,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   338
	BuildRoadClick_Bridge,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   339
	BuildRoadClick_Tunnel,
5682
f109e2e62af8 (svn r8143) Remove the landscaping button from the build toolbars.
tron
parents: 5587
diff changeset
   340
	BuildRoadClick_Remove
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
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   343
/** Array with the keycode of the button-clicks for the road-toolbar */
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   344
static const uint16 _road_keycodes[] = {
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   345
	'1',
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   346
	'2',
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   347
	'3',
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   348
	'4',
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   349
	'5',
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   350
	'6',
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   351
	'7',
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   352
	'B',
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   353
	'T',
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   354
	'R',
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   355
};
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   356
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   357
/**
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   358
 * Update the remove button lowered state of the road toolbar
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   359
 *
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   360
 * @param w The toolbar window
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   361
 * @param clicked_widget The widget which the player clicked just now
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   362
 */
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   363
static void UpdateRemoveWidgetStatus(Window *w, int clicked_widget)
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   364
{
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   365
	switch (clicked_widget) {
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   366
		case RTW_REMOVE:
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   367
			/* If it is the removal button that has been clicked, do nothing,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   368
			 * as it is up to the other buttons to drive removal status */
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   369
			return;
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   370
			break;
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   371
		case RTW_ROAD_X:
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   372
		case RTW_ROAD_Y:
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   373
		case RTW_AUTOROAD:
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   374
		case RTW_BUS_STATION:
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   375
		case RTW_TRUCK_STATION:
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   376
			/* Removal button is enabled only if the road/station
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   377
			 * button is still lowered.  Once raised, it has to be disabled */
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   378
			SetWindowWidgetDisabledState(w, RTW_REMOVE, !IsWindowWidgetLowered(w, clicked_widget));
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   379
			break;
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   380
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   381
		default:
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   382
			/* When any other buttons than road/station, raise and
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   383
			 * disable the removal button */
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   384
			DisableWindowWidget(w, RTW_REMOVE);
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   385
			RaiseWindowWidget(w, RTW_REMOVE);
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   386
			break;
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   387
	}
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   388
}
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   389
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   390
static void BuildRoadToolbWndProc(Window *w, WindowEvent *e)
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   391
{
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   392
	switch (e->event) {
5147
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   393
	case WE_CREATE: DisableWindowWidget(w, RTW_REMOVE); break;
5105
62ab4f2c1677 (svn r7176) -Fix: remove button was not always disabled when it should have been (rail/road build toolbar)
glx
parents: 5072
diff changeset
   394
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   395
	case WE_PAINT:
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   396
		SetWindowWidgetsDisabledState(w, !CanBuildVehicleInfrastructure(VEH_ROAD),
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   397
			RTW_DEPOT,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   398
			RTW_BUS_STATION,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   399
			RTW_TRUCK_STATION,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   400
			WIDGET_LIST_END);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   401
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   402
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   403
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   404
	case WE_CLICK:
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   405
		if (e->we.click.widget >= RTW_ROAD_X) {
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   406
			_remove_button_clicked = false;
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   407
			_build_road_button_proc[e->we.click.widget - RTW_ROAD_X](w);
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   408
		}
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   409
		UpdateRemoveWidgetStatus(w, e->we.click.widget);
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   410
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   411
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   412
	case WE_KEYPRESS:
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   413
		for (uint8 i = 0; i != lengthof(_road_keycodes); i++) {
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   414
			if (e->we.keypress.keycode == _road_keycodes[i]) {
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   415
				e->we.keypress.cont = false;
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   416
				_remove_button_clicked = false;
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   417
				_build_road_button_proc[i](w);
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   418
				UpdateRemoveWidgetStatus(w, i + RTW_ROAD_X);
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   419
				break;
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   420
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   421
		}
756
b76998029c12 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents: 679
diff changeset
   422
		MarkTileDirty(_thd.pos.x, _thd.pos.y); // redraw tile selection
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   423
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   424
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   425
	case WE_PLACE_OBJ:
5147
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   426
		_remove_button_clicked = IsWindowWidgetLowered(w, RTW_REMOVE);
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4559
diff changeset
   427
		_place_proc(e->we.place.tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   428
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   429
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   430
	case WE_ABORT_PLACE_OBJ:
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   431
		RaiseWindowButtons(w);
5147
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   432
		DisableWindowWidget(w, RTW_REMOVE);
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   433
		InvalidateWidget(w, RTW_REMOVE);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   434
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   435
		w = FindWindowById(WC_BUS_STATION, 0);
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6393
diff changeset
   436
		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
   437
		w = FindWindowById(WC_TRUCK_STATION, 0);
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6393
diff changeset
   438
		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
   439
		w = FindWindowById(WC_BUILD_DEPOT, 0);
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6393
diff changeset
   440
		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
   441
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   442
6669
bb48a810a509 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 6666
diff changeset
   443
	case WE_PLACE_DRAG:
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   444
		/* Here we update the end tile flags
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   445
		 * of the road placement actions.
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   446
		 * At first we reset the end halfroad
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   447
		 * bits and if needed we set them again. */
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
   448
		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
   449
			case DDSP_PLACE_ROAD_NE:
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   450
				_place_road_flag &= ~RF_END_HALFROAD_Y;
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   451
				if (e->we.place.pt.y & 8) _place_road_flag |= RF_END_HALFROAD_Y;
4435
40eff4363774 (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4434
diff changeset
   452
				break;
40eff4363774 (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4434
diff changeset
   453
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
   454
			case DDSP_PLACE_ROAD_NW:
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   455
				_place_road_flag &= ~RF_END_HALFROAD_X;
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   456
				if (e->we.place.pt.x & 8) _place_road_flag |= RF_END_HALFROAD_X;
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   457
				break;
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   458
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   459
			case DDSP_PLACE_AUTOROAD:
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   460
				_place_road_flag &= ~(RF_END_HALFROAD_Y | RF_END_HALFROAD_X);
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   461
				if (e->we.place.pt.y & 8) _place_road_flag |= RF_END_HALFROAD_Y;
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   462
				if (e->we.place.pt.x & 8) _place_road_flag |= RF_END_HALFROAD_X;
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   463
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   464
				/* For autoroad we need to update the
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   465
				 * direction of the road */
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   466
				if (_thd.size.x > _thd.size.y || (_thd.size.x == _thd.size.y &&
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   467
						(_tile_fract_coords.x < _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) < 16) ||
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   468
						(_tile_fract_coords.x > _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) > 16) )) {
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   469
					/* Set dir = X */
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   470
					_place_road_flag &= ~RF_DIR_Y;
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   471
				} else {
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   472
					/* Set dir = Y */
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   473
					_place_road_flag |= RF_DIR_Y;
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   474
				}
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   475
4435
40eff4363774 (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4434
diff changeset
   476
				break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   477
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   478
6669
bb48a810a509 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 6666
diff changeset
   479
		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
   480
		return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   481
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   482
	case WE_PLACE_MOUSEUP:
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4559
diff changeset
   483
		if (e->we.place.pt.x != -1) {
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4559
diff changeset
   484
			TileIndex start_tile = e->we.place.starttile;
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4559
diff changeset
   485
			TileIndex end_tile = e->we.place.tile;
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   486
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
   487
			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
   488
				case DDSP_BUILD_BRIDGE:
6669
bb48a810a509 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 6666
diff changeset
   489
					ResetObjectToPlace();
bb48a810a509 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 6666
diff changeset
   490
					ShowBuildBridgeWindow(start_tile, end_tile, 0x80 | RoadTypeToRoadTypes(_cur_roadtype));
bb48a810a509 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 6666
diff changeset
   491
					break;
bb48a810a509 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 6666
diff changeset
   492
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
   493
				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: 6666
diff changeset
   494
					DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
bb48a810a509 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 6666
diff changeset
   495
					break;
bb48a810a509 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 6666
diff changeset
   496
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
   497
				case DDSP_PLACE_ROAD_NE:
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
   498
				case DDSP_PLACE_ROAD_NW:
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   499
				case DDSP_PLACE_AUTOROAD:
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   500
					/* Flag description:
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   501
					 * Use the first three bits (0x07) if dir == Y
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   502
					 * else use the last 2 bits (X dir has
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   503
					 * not the 3rd bit set) */
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   504
					_place_road_flag = (RoadFlags)((_place_road_flag & RF_DIR_Y) ? (_place_road_flag & 0x07) : (_place_road_flag >> 3));
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   505
6764
d09d8d618a07 (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium
parents: 6701
diff changeset
   506
					DoCommandP(end_tile, start_tile, _place_road_flag | (_cur_roadtype << 3) | _ctrl_pressed << 5, CcPlaySound1D,
6669
bb48a810a509 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 6666
diff changeset
   507
						_remove_button_clicked ?
7521
0da1e91510e4 (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7370
diff changeset
   508
						CMD_REMOVE_LONG_ROAD | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_road) :
0da1e91510e4 (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7370
diff changeset
   509
						CMD_BUILD_LONG_ROAD | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_road));
6669
bb48a810a509 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 6666
diff changeset
   510
					break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   511
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   512
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   513
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   514
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   515
	case WE_PLACE_PRESIZE: {
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4559
diff changeset
   516
		TileIndex tile = e->we.place.tile;
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   517
6678
4d901bc54b74 (svn r9909) -Fix (r9897): Highlight road tunnels properly when building them.
maedhros
parents: 6677
diff changeset
   518
		DoCommand(tile, 0x200 | RoadTypeToRoadTypes(_cur_roadtype), 0, DC_AUTO, CMD_BUILD_TUNNEL);
4000
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3793
diff changeset
   519
		VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   520
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   521
	}
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: 2186
diff changeset
   522
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: 2186
diff changeset
   523
	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: 2186
diff changeset
   524
		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: 2186
diff changeset
   525
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   526
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   527
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   528
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   529
/** Widget definition of the build road toolbar */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   530
static const Widget _build_road_widgets[] = {
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   531
{   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                   STR_018B_CLOSE_WINDOW},             // RTW_CLOSEBOX
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   532
{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   227,     0,    13, STR_1802_ROAD_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},   // RTW_CAPTION
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   533
{  WWT_STICKYBOX,   RESIZE_NONE,     7,   228,   239,     0,    13, 0x0,                        STR_STICKY_BUTTON},                 // RTW_STICKY
606
da90c837064c (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
   534
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   535
{     WWT_IMGBTN,   RESIZE_NONE,     7,     0,    21,    14,    35, SPR_IMG_ROAD_NW,            STR_180B_BUILD_ROAD_SECTION},       // RTW_ROAD_X
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   536
{     WWT_IMGBTN,   RESIZE_NONE,     7,    22,    43,    14,    35, SPR_IMG_ROAD_NE,            STR_180B_BUILD_ROAD_SECTION},       // RTW_ROAD_Y
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   537
{     WWT_IMGBTN,   RESIZE_NONE,     7,    44,    65,    14,    35, SPR_IMG_AUTOROAD,           STR_BUILD_AUTOROAD_TIP},            // RTW_AUTOROAD
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   538
{     WWT_IMGBTN,   RESIZE_NONE,     7,    66,    87,    14,    35, SPR_IMG_DYNAMITE,           STR_018D_DEMOLISH_BUILDINGS_ETC},   // RTW_DEMOLISH
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   539
{     WWT_IMGBTN,   RESIZE_NONE,     7,    88,   109,    14,    35, SPR_IMG_ROAD_DEPOT,         STR_180C_BUILD_ROAD_VEHICLE_DEPOT}, // RTW_DEPOT
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   540
{     WWT_IMGBTN,   RESIZE_NONE,     7,   110,   131,    14,    35, SPR_IMG_BUS_STATION,        STR_180D_BUILD_BUS_STATION},        // RTW_BUS_STATION
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   541
{     WWT_IMGBTN,   RESIZE_NONE,     7,   132,   153,    14,    35, SPR_IMG_TRUCK_BAY,          STR_180E_BUILD_TRUCK_LOADING_BAY},  // RTW_TRUCK_STATION
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   542
{     WWT_IMGBTN,   RESIZE_NONE,     7,   153,   195,    14,    35, SPR_IMG_BRIDGE,             STR_180F_BUILD_ROAD_BRIDGE},        // RTW_BUILD_BRIDGE
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   543
{     WWT_IMGBTN,   RESIZE_NONE,     7,   196,   217,    14,    35, SPR_IMG_ROAD_TUNNEL,        STR_1810_BUILD_ROAD_TUNNEL},        // RTW_BUILD_TUNNEL
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   544
{     WWT_IMGBTN,   RESIZE_NONE,     7,   218,   239,    14,    35, SPR_IMG_REMOVE,             STR_1811_TOGGLE_BUILD_REMOVE_FOR},  // RTW_REMOVE
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   545
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 5
diff changeset
   546
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   547
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   548
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   549
static const WindowDesc _build_road_desc = {
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   550
	WDP_ALIGN_TBR, 22, 240, 36, 240, 36,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5860
diff changeset
   551
	WC_BUILD_TOOLBAR, WC_NONE,
756
b76998029c12 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents: 679
diff changeset
   552
	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
   553
	_build_road_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   554
	BuildRoadToolbWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   555
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   556
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   557
/** Widget definition of the build tram toolbar */
6691
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   558
static const Widget _build_tramway_widgets[] = {
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   559
{   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                   STR_018B_CLOSE_WINDOW},                     // RTW_CLOSEBOX
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   560
{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   227,     0,    13, STR_1802_TRAMWAY_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},        // RTW_CAPTION
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   561
{  WWT_STICKYBOX,   RESIZE_NONE,     7,   228,   239,     0,    13, 0x0,                        STR_STICKY_BUTTON},                         // RTW_STICKY
6691
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   562
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   563
{     WWT_IMGBTN,   RESIZE_NONE,     7,     0,    21,    14,    35, SPR_IMG_TRAMWAY_NW,         STR_180B_BUILD_TRAMWAY_SECTION},            // RTW_ROAD_X
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   564
{     WWT_IMGBTN,   RESIZE_NONE,     7,    22,    43,    14,    35, SPR_IMG_TRAMWAY_NE,         STR_180B_BUILD_TRAMWAY_SECTION},            // RTW_ROAD_Y
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   565
{     WWT_IMGBTN,   RESIZE_NONE,     7,    44,    65,    14,    35, SPR_IMG_AUTOTRAM,           STR_BUILD_AUTOTRAM_TIP},                    // RTW_AUTOROAD
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   566
{     WWT_IMGBTN,   RESIZE_NONE,     7,    66,    87,    14,    35, SPR_IMG_DYNAMITE,           STR_018D_DEMOLISH_BUILDINGS_ETC},           // RTW_DEMOLISH
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   567
{     WWT_IMGBTN,   RESIZE_NONE,     7,    88,   109,    14,    35, SPR_IMG_ROAD_DEPOT,         STR_180C_BUILD_TRAM_VEHICLE_DEPOT},         // RTW_DEPOT
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   568
{     WWT_IMGBTN,   RESIZE_NONE,     7,   110,   131,    14,    35, SPR_IMG_BUS_STATION,        STR_180D_BUILD_PASSENGER_TRAM_STATION},     // RTW_BUS_STATION
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   569
{     WWT_IMGBTN,   RESIZE_NONE,     7,   132,   153,    14,    35, SPR_IMG_TRUCK_BAY,          STR_180E_BUILD_CARGO_TRAM_STATION},         // RTW_TRUCK_STATION
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   570
{     WWT_IMGBTN,   RESIZE_NONE,     7,   153,   195,    14,    35, SPR_IMG_BRIDGE,             STR_180F_BUILD_TRAMWAY_BRIDGE},             // RTW_BUILD_BRIDGE
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   571
{     WWT_IMGBTN,   RESIZE_NONE,     7,   196,   217,    14,    35, SPR_IMG_ROAD_TUNNEL,        STR_1810_BUILD_TRAMWAY_TUNNEL},             // RTW_BUILD_TUNNEL
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   572
{     WWT_IMGBTN,   RESIZE_NONE,     7,   218,   239,    14,    35, SPR_IMG_REMOVE,             STR_1811_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS}, // RTW_REMOVE
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   573
6691
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   574
{   WIDGETS_END},
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   575
};
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   576
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   577
static const WindowDesc _build_tramway_desc = {
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   578
	WDP_ALIGN_TBR, 22, 240, 36, 240, 36,
6691
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   579
	WC_BUILD_TOOLBAR, WC_NONE,
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   580
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   581
	_build_tramway_widgets,
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   582
	BuildRoadToolbWndProc
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   583
};
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   584
6666
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
   585
void ShowBuildRoadToolbar(RoadType roadtype)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   586
{
5005
f5086bd3945a (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4938
diff changeset
   587
	if (!IsValidPlayer(_current_player)) return;
6666
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
   588
	_cur_roadtype = roadtype;
5005
f5086bd3945a (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4938
diff changeset
   589
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   590
	DeleteWindowById(WC_BUILD_TOOLBAR, 0);
6691
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   591
	Window *w = AllocateWindowDesc(roadtype == ROADTYPE_ROAD ? &_build_road_desc : &_build_tramway_desc);
5860
3b26be021371 (svn r8436) -Fix
tron
parents: 5836
diff changeset
   592
	if (_patches.link_terraform_toolbar) ShowTerraformToolbar(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   593
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   594
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   595
/** Widget definition of the build road toolbar in the scenario editor */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   596
static const Widget _build_road_scen_widgets[] = {
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   597
{   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                   STR_018B_CLOSE_WINDOW},            // RTW_CLOSEBOX
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   598
{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   161,     0,    13, STR_1802_ROAD_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},  // RTW_CAPTION
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   599
{  WWT_STICKYBOX,   RESIZE_NONE,     7,   162,   173,     0,    13, 0x0,                        STR_STICKY_BUTTON},                // RTW_STICKY
661
0d0a151aa4cd (svn r1095) -Fix: scenario editor road-build-gui works again altough shortcuts are screwed.
darkvater
parents: 651
diff changeset
   600
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   601
{     WWT_IMGBTN,   RESIZE_NONE,     7,     0,    21,    14,    35, SPR_IMG_ROAD_NW,            STR_180B_BUILD_ROAD_SECTION},      // RTW_ROAD_X
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   602
{     WWT_IMGBTN,   RESIZE_NONE,     7,    22,    43,    14,    35, SPR_IMG_ROAD_NE,            STR_180B_BUILD_ROAD_SECTION},      // RTW_ROAD_Y
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   603
{     WWT_IMGBTN,   RESIZE_NONE,     7,    44,    65,    14,    35, SPR_IMG_AUTOROAD,           STR_BUILD_AUTOROAD_TIP},           // RTW_AUTOROAD
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   604
{     WWT_IMGBTN,   RESIZE_NONE,     7,    66,    87,    14,    35, SPR_IMG_DYNAMITE,           STR_018D_DEMOLISH_BUILDINGS_ETC},  // RTW_DEMOLISH
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   605
{      WWT_EMPTY,   RESIZE_NONE,     0,     0,     0,     0,     0, 0x0,                        STR_NULL},                         // RTW_DEPOT
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   606
{      WWT_EMPTY,   RESIZE_NONE,     0,     0,     0,     0,     0, 0x0,                        STR_NULL},                         // RTW_BUS_STATION
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   607
{      WWT_EMPTY,   RESIZE_NONE,     0,     0,     0,     0,     0, 0x0,                        STR_NULL},                         // RTW_TRUCK_STATION
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   608
{     WWT_IMGBTN,   RESIZE_NONE,     7,    88,   130,    14,    35, SPR_IMG_BRIDGE,             STR_180F_BUILD_ROAD_BRIDGE},       // RTW_BUILD_BRIDGE
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   609
{     WWT_IMGBTN,   RESIZE_NONE,     7,   131,   151,    14,    35, SPR_IMG_ROAD_TUNNEL,        STR_1810_BUILD_ROAD_TUNNEL},       // RTW_BUILD_TUNNEL
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   610
{     WWT_IMGBTN,   RESIZE_NONE,     7,   152,   173,    14,    35, SPR_IMG_REMOVE,             STR_1811_TOGGLE_BUILD_REMOVE_FOR}, // RTW_REMOVE
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 5
diff changeset
   611
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   612
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   613
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   614
static const WindowDesc _build_road_scen_desc = {
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   615
	WDP_AUTO, WDP_AUTO, 174, 36, 174, 36,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5860
diff changeset
   616
	WC_SCEN_BUILD_ROAD, WC_NONE,
777
95dc447f24e3 (svn r1243) -Fix: Scenario road-building toolbar also stickified. Thx for the notice teeone
darkvater
parents: 756
diff changeset
   617
	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
   618
	_build_road_scen_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   619
	BuildRoadToolbWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   620
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   621
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6102
diff changeset
   622
void ShowBuildRoadScenToolbar()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   623
{
6779
2efcd25812d9 (svn r10015) -Fix: one could build (only) tram tracks when that was the last built roadtype (in a normal game).
rubidium
parents: 6764
diff changeset
   624
	_cur_roadtype = ROADTYPE_ROAD;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   625
	AllocateWindowDescFront(&_build_road_scen_desc, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   626
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   627
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   628
/** Enum referring to the widgets of the build road depot window */
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   629
enum BuildRoadDepotWidgets {
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   630
	BRDW_CLOSEBOX = 0,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   631
	BRDW_CAPTION,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   632
	BRDW_BACKGROUND,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   633
	BRDW_DEPOT_NE,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   634
	BRDW_DEPOT_SE,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   635
	BRDW_DEPOT_SW,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   636
	BRDW_DEPOT_NW,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   637
};
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   638
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   639
static void BuildRoadDepotWndProc(Window *w, WindowEvent *e)
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   640
{
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   641
	switch (e->event) {
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   642
	case WE_CREATE: LowerWindowWidget(w, _road_depot_orientation + BRDW_DEPOT_NE); break;
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   643
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   644
	case WE_PAINT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   645
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   646
6666
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
   647
		DrawRoadDepotSprite(70, 17, DIAGDIR_NE, _cur_roadtype);
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
   648
		DrawRoadDepotSprite(70, 69, DIAGDIR_SE, _cur_roadtype);
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
   649
		DrawRoadDepotSprite( 2, 69, DIAGDIR_SW, _cur_roadtype);
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
   650
		DrawRoadDepotSprite( 2, 17, DIAGDIR_NW, _cur_roadtype);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   651
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   652
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   653
	case WE_CLICK:
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4559
diff changeset
   654
		switch (e->we.click.widget) {
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   655
			case BRDW_DEPOT_NW:
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   656
			case BRDW_DEPOT_NE:
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   657
			case BRDW_DEPOT_SW:
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   658
			case BRDW_DEPOT_SE:
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   659
				RaiseWindowWidget(w, _road_depot_orientation + BRDW_DEPOT_NE);
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   660
				_road_depot_orientation = (DiagDirection)(e->we.click.widget - BRDW_DEPOT_NE);
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   661
				LowerWindowWidget(w, _road_depot_orientation + BRDW_DEPOT_NE);
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   662
				SndPlayFx(SND_15_BEEP);
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   663
				SetWindowDirty(w);
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   664
				break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   665
		}
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   666
		break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   667
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   668
	case WE_MOUSELOOP:
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6393
diff changeset
   669
		if (WP(w, def_d).close) DeleteWindow(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   670
		break;
1072
74cd9150d473 (svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents: 1035
diff changeset
   671
74cd9150d473 (svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents: 1035
diff changeset
   672
	case WE_DESTROY:
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6393
diff changeset
   673
		if (!WP(w, def_d).close) ResetObjectToPlace();
1072
74cd9150d473 (svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents: 1035
diff changeset
   674
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   675
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   676
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   677
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   678
/** Widget definition of the build road depot window */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   679
static const Widget _build_road_depot_widgets[] = {
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   680
{   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},              // BRDW_CLOSEBOX
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   681
{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   139,     0,    13, STR_1806_ROAD_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS},    // BRDW_CAPTION
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   682
{      WWT_PANEL,   RESIZE_NONE,     7,     0,   139,    14,   121, 0x0,                             STR_NULL},                           // BRDW_BACKGROUND
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   683
{      WWT_PANEL,   RESIZE_NONE,    14,    71,   136,    17,    66, 0x0,                             STR_1813_SELECT_ROAD_VEHICLE_DEPOT}, // BRDW_DEPOT_NE
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   684
{      WWT_PANEL,   RESIZE_NONE,    14,    71,   136,    69,   118, 0x0,                             STR_1813_SELECT_ROAD_VEHICLE_DEPOT}, // BRDW_DEPOT_SE
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   685
{      WWT_PANEL,   RESIZE_NONE,    14,     3,    68,    69,   118, 0x0,                             STR_1813_SELECT_ROAD_VEHICLE_DEPOT}, // BRDW_DEPOT_SW
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   686
{      WWT_PANEL,   RESIZE_NONE,    14,     3,    68,    17,    66, 0x0,                             STR_1813_SELECT_ROAD_VEHICLE_DEPOT}, // BRDW_DEPOT_NW
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 5
diff changeset
   687
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   688
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   689
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   690
/** Widget definition of the build tram depot window */
6691
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   691
static const Widget _build_tram_depot_widgets[] = {
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   692
{   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},              // BRDW_CLOSEBOX
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   693
{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   139,     0,    13, STR_1806_TRAM_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS},    // BRDW_CAPTION
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   694
{      WWT_PANEL,   RESIZE_NONE,     7,     0,   139,    14,   121, 0x0,                             STR_NULL},                           // BRDW_BACKGROUND
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   695
{      WWT_PANEL,   RESIZE_NONE,    14,    71,   136,    17,    66, 0x0,                             STR_1813_SELECT_TRAM_VEHICLE_DEPOT}, // BRDW_DEPOT_NE
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   696
{      WWT_PANEL,   RESIZE_NONE,    14,    71,   136,    69,   118, 0x0,                             STR_1813_SELECT_TRAM_VEHICLE_DEPOT}, // BRDW_DEPOT_SE
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   697
{      WWT_PANEL,   RESIZE_NONE,    14,     3,    68,    69,   118, 0x0,                             STR_1813_SELECT_TRAM_VEHICLE_DEPOT}, // BRDW_DEPOT_SW
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   698
{      WWT_PANEL,   RESIZE_NONE,    14,     3,    68,    17,    66, 0x0,                             STR_1813_SELECT_TRAM_VEHICLE_DEPOT}, // BRDW_DEPOT_NW
6691
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   699
{   WIDGETS_END},
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   700
};
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   701
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   702
static const WindowDesc _build_road_depot_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7339
diff changeset
   703
	WDP_AUTO, WDP_AUTO, 140, 122, 140, 122,
5070
7f5b13b7e728 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 5005
diff changeset
   704
	WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   705
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   706
	_build_road_depot_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   707
	BuildRoadDepotWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   708
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   709
6691
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   710
static const WindowDesc _build_tram_depot_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7339
diff changeset
   711
	WDP_AUTO, WDP_AUTO, 140, 122, 140, 122,
6691
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   712
	WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   713
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   714
	_build_tram_depot_widgets,
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   715
	BuildRoadDepotWndProc
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   716
};
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   717
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6102
diff changeset
   718
static void ShowRoadDepotPicker()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   719
{
6691
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   720
	AllocateWindowDesc(_cur_roadtype == ROADTYPE_ROAD ? &_build_road_depot_desc : &_build_tram_depot_desc);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   721
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   722
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   723
/** Enum referring to the widgets of the build road station window */
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   724
enum BuildRoadStationWidgets {
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   725
	BRSW_CLOSEBOX = 0,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   726
	BRSW_CAPTION,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   727
	BRSW_BACKGROUND,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   728
	BRSW_STATION_NE,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   729
	BRSW_STATION_SE,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   730
	BRSW_STATION_SW,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   731
	BRSW_STATION_NW,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   732
	BRSW_STATION_X,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   733
	BRSW_STATION_Y,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   734
	BRSW_LT_OFF,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   735
	BRSW_LT_ON,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   736
	BRSW_INFO,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   737
};
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   738
987
551193c150d9 (svn r1485) -Fix: [1031451] Catchment area shows when buying sign. Catchment area wasn't reset when road station window was unselected
darkvater
parents: 946
diff changeset
   739
static void RoadStationPickerWndProc(Window *w, WindowEvent *e)
551193c150d9 (svn r1485) -Fix: [1031451] Catchment area shows when buying sign. Catchment area wasn't reset when road station window was unselected
darkvater
parents: 946
diff changeset
   740
{
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2753
diff changeset
   741
	switch (e->event) {
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   742
	case WE_CREATE:
6677
8120427efe01 (svn r9908) -Codechange: prepare the station picker for more road types.
rubidium
parents: 6676
diff changeset
   743
		/* Trams don't have non-drivethrough stations */
8120427efe01 (svn r9908) -Codechange: prepare the station picker for more road types.
rubidium
parents: 6676
diff changeset
   744
		if (_cur_roadtype == ROADTYPE_TRAM && _road_station_picker_orientation < DIAGDIR_END) {
8120427efe01 (svn r9908) -Codechange: prepare the station picker for more road types.
rubidium
parents: 6676
diff changeset
   745
			_road_station_picker_orientation = DIAGDIR_END;
8120427efe01 (svn r9908) -Codechange: prepare the station picker for more road types.
rubidium
parents: 6676
diff changeset
   746
		}
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   747
		SetWindowWidgetsDisabledState(w, _cur_roadtype == ROADTYPE_TRAM,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   748
			BRSW_STATION_NE,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   749
			BRSW_STATION_SE,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   750
			BRSW_STATION_SW,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   751
			BRSW_STATION_NW,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   752
			WIDGET_LIST_END);
6677
8120427efe01 (svn r9908) -Codechange: prepare the station picker for more road types.
rubidium
parents: 6676
diff changeset
   753
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   754
		LowerWindowWidget(w, _road_station_picker_orientation + BRSW_STATION_NE);
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   755
		LowerWindowWidget(w, _station_show_coverage + BRSW_LT_OFF);
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   756
		break;
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   757
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   758
	case WE_PAINT: {
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6393
diff changeset
   759
		if (WP(w, def_d).close) return;
987
551193c150d9 (svn r1485) -Fix: [1031451] Catchment area shows when buying sign. Catchment area wasn't reset when road station window was unselected
darkvater
parents: 946
diff changeset
   760
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   761
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   762
987
551193c150d9 (svn r1485) -Fix: [1031451] Catchment area shows when buying sign. Catchment area wasn't reset when road station window was unselected
darkvater
parents: 946
diff changeset
   763
		if (_station_show_coverage) {
551193c150d9 (svn r1485) -Fix: [1031451] Catchment area shows when buying sign. Catchment area wasn't reset when road station window was unselected
darkvater
parents: 946
diff changeset
   764
			int rad = _patches.modified_catchment ? CA_TRUCK /* = CA_BUS */ : 4;
551193c150d9 (svn r1485) -Fix: [1031451] Catchment area shows when buying sign. Catchment area wasn't reset when road station window was unselected
darkvater
parents: 946
diff changeset
   765
			SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4008
diff changeset
   766
		} else {
987
551193c150d9 (svn r1485) -Fix: [1031451] Catchment area shows when buying sign. Catchment area wasn't reset when road station window was unselected
darkvater
parents: 946
diff changeset
   767
			SetTileSelectSize(1, 1);
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4008
diff changeset
   768
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   769
7272
d47fc9e22d1c (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7266
diff changeset
   770
		StationType st = (w->window_class == WC_BUS_STATION) ? STATION_BUS : STATION_TRUCK;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   771
7272
d47fc9e22d1c (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7266
diff changeset
   772
		StationPickerDrawSprite(103, 35, st, RAILTYPE_BEGIN, ROADTYPE_ROAD, 0);
d47fc9e22d1c (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7266
diff changeset
   773
		StationPickerDrawSprite(103, 85, st, RAILTYPE_BEGIN, ROADTYPE_ROAD, 1);
d47fc9e22d1c (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7266
diff changeset
   774
		StationPickerDrawSprite( 35, 85, st, RAILTYPE_BEGIN, ROADTYPE_ROAD, 2);
d47fc9e22d1c (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7266
diff changeset
   775
		StationPickerDrawSprite( 35, 35, st, RAILTYPE_BEGIN, ROADTYPE_ROAD, 3);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   776
7272
d47fc9e22d1c (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7266
diff changeset
   777
		StationPickerDrawSprite(171, 35, st, RAILTYPE_BEGIN, _cur_roadtype, 4);
d47fc9e22d1c (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7266
diff changeset
   778
		StationPickerDrawSprite(171, 85, st, RAILTYPE_BEGIN, _cur_roadtype, 5);
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   779
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   780
		DrawStationCoverageAreaText(2, 146,
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
   781
			(w->window_class == WC_BUS_STATION) ? SCT_PASSENGERS_ONLY : SCT_NON_PASSENGERS_ONLY,
568
b0d0df062880 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 543
diff changeset
   782
			3);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   783
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   784
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   785
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   786
	case WE_CLICK: {
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4559
diff changeset
   787
		switch (e->we.click.widget) {
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   788
			case BRSW_STATION_NE:
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   789
			case BRSW_STATION_SE:
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   790
			case BRSW_STATION_SW:
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   791
			case BRSW_STATION_NW:
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   792
			case BRSW_STATION_X:
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   793
			case BRSW_STATION_Y:
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   794
				RaiseWindowWidget(w, _road_station_picker_orientation + BRSW_STATION_NE);
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   795
				_road_station_picker_orientation = (DiagDirection)(e->we.click.widget - BRSW_STATION_NE);
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   796
				LowerWindowWidget(w, _road_station_picker_orientation + BRSW_STATION_NE);
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   797
				SndPlayFx(SND_15_BEEP);
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   798
				SetWindowDirty(w);
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   799
				break;
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   800
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   801
			case BRSW_LT_OFF:
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   802
			case BRSW_LT_ON:
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   803
				RaiseWindowWidget(w, _station_show_coverage + BRSW_LT_OFF);
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   804
				_station_show_coverage = (e->we.click.widget != BRSW_LT_OFF);
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   805
				LowerWindowWidget(w, _station_show_coverage + BRSW_LT_OFF);
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   806
				SndPlayFx(SND_15_BEEP);
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   807
				SetWindowDirty(w);
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   808
				break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   809
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   810
	} break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   811
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   812
	case WE_MOUSELOOP: {
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6393
diff changeset
   813
		if (WP(w, def_d).close) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   814
			DeleteWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   815
			return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   816
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   817
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   818
		CheckRedrawStationCoverage(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   819
	} break;
1109
ecb98f43ba2c (svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents: 1093
diff changeset
   820
1072
74cd9150d473 (svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents: 1035
diff changeset
   821
	case WE_DESTROY:
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6393
diff changeset
   822
		if (!WP(w, def_d).close) ResetObjectToPlace();
1072
74cd9150d473 (svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents: 1035
diff changeset
   823
		break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   824
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   825
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   826
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   827
/** Widget definition of the build raod station window */
6693
00bef74e4d3a (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 6691
diff changeset
   828
static const Widget _rv_station_picker_widgets[] = {
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   829
{   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                         STR_018B_CLOSE_WINDOW},             // BRSW_CLOSEBOX
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   830
{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   206,     0,    13, STR_NULL,                         STR_018C_WINDOW_TITLE_DRAG_THIS},   // BRSW_CAPTION
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   831
{      WWT_PANEL,   RESIZE_NONE,     7,     0,   206,    14,   176, 0x0,                              STR_NULL},                          // BRSW_BACKGROUND
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   832
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   833
{      WWT_PANEL,   RESIZE_NONE,    14,    71,   136,    17,    66, 0x0,                              STR_NULL},                          // BRSW_STATION_NE
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   834
{      WWT_PANEL,   RESIZE_NONE,    14,    71,   136,    69,   118, 0x0,                              STR_NULL},                          // BRSW_STATION_SE
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   835
{      WWT_PANEL,   RESIZE_NONE,    14,     3,    68,    69,   118, 0x0,                              STR_NULL},                          // BRSW_STATION_SW
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   836
{      WWT_PANEL,   RESIZE_NONE,    14,     3,    68,    17,    66, 0x0,                              STR_NULL},                          // BRSW_STATION_NW
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   837
{      WWT_PANEL,   RESIZE_NONE,    14,   139,   204,    17,    66, 0x0,                              STR_NULL},                          // BRSW_STATION_X
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   838
{      WWT_PANEL,   RESIZE_NONE,    14,   139,   204,    69,   118, 0x0,                              STR_NULL},                          // BRSW_STATION_Y
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   839
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   840
{    WWT_TEXTBTN,   RESIZE_NONE,    14,    10,    69,   133,   144, STR_02DB_OFF,                     STR_3065_DON_T_HIGHLIGHT_COVERAGE}, // BRSW_LT_OFF
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   841
{    WWT_TEXTBTN,   RESIZE_NONE,    14,    70,   129,   133,   144, STR_02DA_ON,                      STR_3064_HIGHLIGHT_COVERAGE_AREA},  // BRSW_LT_ON
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   842
{      WWT_LABEL,   RESIZE_NONE,     7,     0,   139,   120,   133, STR_3066_COVERAGE_AREA_HIGHLIGHT, STR_NULL},                          // BRSW_INFO
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 5
diff changeset
   843
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   844
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   845
6693
00bef74e4d3a (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 6691
diff changeset
   846
static const WindowDesc _rv_station_picker_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7339
diff changeset
   847
	WDP_AUTO, WDP_AUTO, 207, 177, 207, 177,
5070
7f5b13b7e728 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 5005
diff changeset
   848
	WC_BUS_STATION, WC_BUILD_TOOLBAR,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   849
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
6693
00bef74e4d3a (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 6691
diff changeset
   850
	_rv_station_picker_widgets,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   851
	RoadStationPickerWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   852
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   853
6693
00bef74e4d3a (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 6691
diff changeset
   854
static void ShowRVStationPicker(RoadStop::Type rs)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   855
{
6693
00bef74e4d3a (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 6691
diff changeset
   856
	Window *w = AllocateWindowDesc(&_rv_station_picker_desc);
00bef74e4d3a (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 6691
diff changeset
   857
	if (w == NULL) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   858
6701
f9df2ced0908 (svn r9933) -Fix (9925): unified a little too much.
rubidium
parents: 6693
diff changeset
   859
	w->window_class = (rs == RoadStop::BUS) ? WC_BUS_STATION : WC_TRUCK_STATION;
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   860
	w->widget[BRSW_CAPTION].data = _road_type_infos[_cur_roadtype].picker_title[rs];
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   861
	for (uint i = BRSW_STATION_NE; i < BRSW_LT_OFF; i++) w->widget[i].tooltips = _road_type_infos[_cur_roadtype].picker_tooltip[rs];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   862
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   863
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6102
diff changeset
   864
void InitializeRoadGui()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   865
{
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   866
	_road_depot_orientation = DIAGDIR_NW;
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   867
	_road_station_picker_orientation = DIAGDIR_NW;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   868
}