src/road_gui.cpp
author maedhros
Thu, 24 May 2007 09:24:46 +0000
changeset 6678 4d901bc54b74
parent 6677 8120427efe01
child 6691 f9adbb0be102
permissions -rw-r--r--
(svn r9909) -Fix (r9897): Highlight road tunnels properly when building them.
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"
2163
b17b313113a0 (svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents: 2159
diff changeset
     9
#include "functions.h"
679
04ca2cd69420 (svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents: 661
diff changeset
    10
#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
    11
#include "tile.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
#include "window.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    13
#include "gui.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    14
#include "viewport.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
#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
    16
#include "sound.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    17
#include "command.h"
2159
f6284cf5fab0 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2049
diff changeset
    18
#include "variables.h"
6666
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
    19
#include "road.h"
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
    20
#include "road_cmd.h"
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
    21
#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
    22
#include "station_map.h"
568
b0d0df062880 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 543
diff changeset
    23
//needed for catchments
b0d0df062880 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 543
diff changeset
    24
#include "station.h"
b0d0df062880 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 543
diff changeset
    25
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    26
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6102
diff changeset
    27
static void ShowBusStationPicker();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6102
diff changeset
    28
static void ShowTruckStationPicker();
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    33
static byte _place_road_flag;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
6666
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
    35
static RoadType _cur_roadtype;
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
    36
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
    37
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
    38
static DiagDirection _road_station_picker_orientation;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    39
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    40
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
    41
{
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 514
diff changeset
    42
	if (success) SndPlayTileFx(SND_1F_SPLAT, tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    43
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    44
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    45
static void PlaceRoad_NE(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    46
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    47
	_place_road_flag = (_tile_fract_coords.y >= 8) + 4;
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
    48
	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
    49
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    50
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    51
static void PlaceRoad_NW(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    52
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    53
	_place_road_flag = (_tile_fract_coords.x >= 8) + 0;
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
    54
	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
    55
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    57
static void PlaceRoad_Bridge(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    58
{
6670
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
    59
	VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_BUILD_BRIDGE);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    60
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    61
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    62
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    63
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
    64
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    65
	if (success) {
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 514
diff changeset
    66
		SndPlayTileFx(SND_20_SPLAT_2, tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    67
		ResetObjectToPlace();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    68
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    69
		SetRedErrorSquare(_build_tunnel_endtile);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    71
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    72
6676
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
    73
/** 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
    74
struct RoadTypeInfo {
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
    75
	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
    76
	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
    77
	StringID err_depot;             ///< Building a depot
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
    78
	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
    79
	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
    80
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
    81
	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
    82
	SpriteID cursor_nwse;           ///< Cursor for building NW and SE bits
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
    83
};
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
    84
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
    85
/** 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
    86
static const RoadTypeInfo _road_type_infos[] = {
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
    87
	{
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
    88
		STR_1804_CAN_T_BUILD_ROAD_HERE,
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
    89
		STR_1805_CAN_T_REMOVE_ROAD_FROM,
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
    90
		STR_1807_CAN_T_BUILD_ROAD_VEHICLE,
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
    91
		{ STR_1808_CAN_T_BUILD_BUS_STATION, STR_1809_CAN_T_BUILD_TRUCK_STATION },
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
    92
		{ STR_CAN_T_REMOVE_BUS_STATION,     STR_CAN_T_REMOVE_TRUCK_STATION     },
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
    93
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
    94
		SPR_CURSOR_ROAD_NESW,
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
    95
		SPR_CURSOR_ROAD_NWSE,
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
    96
	},
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
    97
};
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
    98
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    99
static void PlaceRoad_Tunnel(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   100
{
6666
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
   101
	DoCommandP(tile, 0x200 | RoadTypeToRoadTypes(_cur_roadtype), 0, CcBuildRoadTunnel, CMD_BUILD_TUNNEL | CMD_AUTO | 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
   102
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   103
3151
711ef4ea85e9 (svn r3774) Remove some more magic numbers and types
tron
parents: 3150
diff changeset
   104
static void BuildRoadOutsideStation(TileIndex tile, DiagDirection direction)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   105
{
4559
aa0c13e39840 (svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents: 4435
diff changeset
   106
	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
   107
	// if there is a roadpiece just outside of the station entrance, build a connecting route
3793
7fe24e10ea63 (svn r4789) - Codechange: rename RoadType to RoadTileType and ROAD_{NORMAL,CROSSING,DEPOT} to ROAD_TILE_* for consistency
rubidium
parents: 3491
diff changeset
   108
	if (IsTileType(tile, MP_STREET) && GetRoadTileType(tile) == ROAD_TILE_NORMAL) {
6666
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
   109
		if (GetRoadBits(tile, _cur_roadtype) != ROAD_NONE) {
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
   110
			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
   111
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   112
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   113
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   114
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   115
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
   116
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   117
	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
   118
		DiagDirection dir = (DiagDirection)GB(p1, 0, 2);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 514
diff changeset
   119
		SndPlayTileFx(SND_1F_SPLAT, tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   120
		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
   121
		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
   122
		/* 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
   123
		if (HASBIT(p2, 1)) BuildRoadOutsideStation(tile, ReverseDiagDir(dir));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   124
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   125
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   126
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   127
static void PlaceRoad_Depot(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   128
{
6676
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   129
	DoCommandP(tile, _cur_roadtype << 2 | _road_depot_orientation, 0, CcRoadDepot, CMD_BUILD_ROAD_DEPOT | CMD_AUTO | 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
   130
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   131
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   132
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
   133
{
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   134
	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
   135
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   136
	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
   137
		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
   138
		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
   139
	}
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   140
	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
   141
}
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   142
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   143
static void PlaceRoad_BusStation(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   144
{
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   145
	if (_remove_button_clicked) {
6676
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   146
		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
   147
	} else {
6676
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   148
		PlaceRoadStop(tile, (_ctrl_pressed << 5) | RoadTypeToRoadTypes(_cur_roadtype) << 2 | RoadStop::BUS, CMD_BUILD_ROAD_STOP | CMD_AUTO | 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
   149
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   150
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   151
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   152
static void PlaceRoad_TruckStation(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   153
{
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   154
	if (_remove_button_clicked) {
6676
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   155
		DoCommandP(tile, 0, RoadStop::TRUCK, CcPlaySound1D, CMD_REMOVE_ROAD_STOP | 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
   156
	} else {
6676
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   157
		PlaceRoadStop(tile, (_ctrl_pressed << 5) | RoadTypeToRoadTypes(_cur_roadtype) << 2 | RoadStop::TRUCK, CMD_BUILD_ROAD_STOP | CMD_AUTO | 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
   158
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   159
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   160
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   161
static void PlaceRoad_DemolishArea(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   162
{
6670
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
   163
	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
   164
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   165
5147
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   166
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   167
enum {
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   168
	RTW_ROAD_X        =  3,
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   169
	RTW_ROAD_Y        =  4,
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   170
	RTW_DEMOLISH      =  5,
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   171
	RTW_DEPOT         =  6,
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   172
	RTW_BUS_STATION   =  7,
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   173
	RTW_TRUCK_STATION =  8,
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   174
	RTW_BUILD_BRIDGE  =  9,
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   175
	RTW_BUILD_TUNNEL  = 10,
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   176
	RTW_REMOVE        = 11
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   177
};
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   178
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   179
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   180
typedef void OnButtonClick(Window *w);
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
static void BuildRoadClick_NE(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   183
{
6676
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   184
	HandlePlacePushButton(w, RTW_ROAD_X, _road_type_infos[_cur_roadtype].cursor_nesw, 1, PlaceRoad_NE);
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   187
static void BuildRoadClick_NW(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   188
{
6676
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   189
	HandlePlacePushButton(w, RTW_ROAD_Y, _road_type_infos[_cur_roadtype].cursor_nwse, 1, PlaceRoad_NW);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   190
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   191
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   192
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   193
static void BuildRoadClick_Demolish(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   194
{
5147
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   195
	HandlePlacePushButton(w, RTW_DEMOLISH, ANIMCURSOR_DEMOLISH, 1, PlaceRoad_DemolishArea);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   196
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   197
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   198
static void BuildRoadClick_Depot(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   199
{
661
0d0a151aa4cd (svn r1095) -Fix: scenario editor road-build-gui works again altough shortcuts are screwed.
darkvater
parents: 651
diff changeset
   200
	if (_game_mode == GM_EDITOR) return;
5147
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   201
	if (HandlePlacePushButton(w, RTW_DEPOT, SPR_CURSOR_ROAD_DEPOT, 1, PlaceRoad_Depot)) ShowRoadDepotPicker();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   202
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   203
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   204
static void BuildRoadClick_BusStation(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   205
{
661
0d0a151aa4cd (svn r1095) -Fix: scenario editor road-build-gui works again altough shortcuts are screwed.
darkvater
parents: 651
diff changeset
   206
	if (_game_mode == GM_EDITOR) return;
5147
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   207
	if (HandlePlacePushButton(w, RTW_BUS_STATION, SPR_CURSOR_BUS_STATION, 1, PlaceRoad_BusStation)) ShowBusStationPicker();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   208
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   209
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   210
static void BuildRoadClick_TruckStation(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   211
{
661
0d0a151aa4cd (svn r1095) -Fix: scenario editor road-build-gui works again altough shortcuts are screwed.
darkvater
parents: 651
diff changeset
   212
	if (_game_mode == GM_EDITOR) return;
5147
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   213
	if (HandlePlacePushButton(w, RTW_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, 1, PlaceRoad_TruckStation)) ShowTruckStationPicker();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   214
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   215
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   216
static void BuildRoadClick_Bridge(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   217
{
5147
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   218
	HandlePlacePushButton(w, RTW_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, 1, PlaceRoad_Bridge);
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   221
static void BuildRoadClick_Tunnel(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   222
{
5147
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   223
	HandlePlacePushButton(w, RTW_BUILD_TUNNEL, SPR_CURSOR_ROAD_TUNNEL, 3, PlaceRoad_Tunnel);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   224
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   225
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   226
static void BuildRoadClick_Remove(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   227
{
5147
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   228
	if (IsWindowWidgetDisabled(w, RTW_REMOVE)) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   229
	SetWindowDirty(w);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 514
diff changeset
   230
	SndPlayFx(SND_15_BEEP);
5147
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   231
	ToggleWidgetLoweredState(w, RTW_REMOVE);
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   232
	SetSelectionRed(IsWindowWidgetLowered(w, RTW_REMOVE));
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   235
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   236
static OnButtonClick* const _build_road_button_proc[] = {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   237
	BuildRoadClick_NE,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   238
	BuildRoadClick_NW,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   239
	BuildRoadClick_Demolish,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   240
	BuildRoadClick_Depot,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   241
	BuildRoadClick_BusStation,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   242
	BuildRoadClick_TruckStation,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   243
	BuildRoadClick_Bridge,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   244
	BuildRoadClick_Tunnel,
5682
f109e2e62af8 (svn r8143) Remove the landscaping button from the build toolbars.
tron
parents: 5587
diff changeset
   245
	BuildRoadClick_Remove
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   246
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   247
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   248
static void BuildRoadToolbWndProc(Window *w, WindowEvent *e)
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   249
{
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   250
	switch (e->event) {
5147
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   251
	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
   252
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   253
	case WE_PAINT:
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   254
		if (IsWindowWidgetLowered(w, RTW_ROAD_X) || IsWindowWidgetLowered(w, RTW_ROAD_Y) || IsWindowWidgetLowered(w, RTW_BUS_STATION) || IsWindowWidgetLowered(w, RTW_TRUCK_STATION)) {
5147
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   255
			EnableWindowWidget(w, RTW_REMOVE);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   256
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   257
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   258
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   259
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   260
	case WE_CLICK: {
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4559
diff changeset
   261
		if (e->we.click.widget >= 3) _build_road_button_proc[e->we.click.widget - 3](w);
6492
286a52449b54 (svn r9673) -Cleanup: remove spaces before tabs and replace non-indenting tabs with spaces.
rubidium
parents: 6491
diff changeset
   262
	} break;
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
	case WE_KEYPRESS:
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4559
diff changeset
   265
		switch (e->we.keypress.keycode) {
2631
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2619
diff changeset
   266
			case '1': BuildRoadClick_NE(w);           break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2619
diff changeset
   267
			case '2': BuildRoadClick_NW(w);           break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2619
diff changeset
   268
			case '3': BuildRoadClick_Demolish(w);     break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2619
diff changeset
   269
			case '4': BuildRoadClick_Depot(w);        break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2619
diff changeset
   270
			case '5': BuildRoadClick_BusStation(w);   break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2619
diff changeset
   271
			case '6': BuildRoadClick_TruckStation(w); break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2619
diff changeset
   272
			case 'B': BuildRoadClick_Bridge(w);       break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2619
diff changeset
   273
			case 'T': BuildRoadClick_Tunnel(w);       break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2619
diff changeset
   274
			case 'R': BuildRoadClick_Remove(w);       break;
2ed0eb408229 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2619
diff changeset
   275
			default: return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   276
		}
756
b76998029c12 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents: 679
diff changeset
   277
		MarkTileDirty(_thd.pos.x, _thd.pos.y); // redraw tile selection
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4559
diff changeset
   278
		e->we.keypress.cont = false;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   279
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   280
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   281
	case WE_PLACE_OBJ:
5147
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   282
		_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
   283
		_place_proc(e->we.place.tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   284
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   285
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   286
	case WE_ABORT_PLACE_OBJ:
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   287
		RaiseWindowButtons(w);
5147
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   288
		DisableWindowWidget(w, RTW_REMOVE);
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   289
		InvalidateWidget(w, RTW_REMOVE);
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
		w = FindWindowById(WC_BUS_STATION, 0);
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6393
diff changeset
   292
		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
   293
		w = FindWindowById(WC_TRUCK_STATION, 0);
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6393
diff changeset
   294
		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
   295
		w = FindWindowById(WC_BUILD_DEPOT, 0);
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6393
diff changeset
   296
		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
   297
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   298
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
   299
	case WE_PLACE_DRAG:
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
   300
		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
   301
			case DDSP_PLACE_ROAD_NE:
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4559
diff changeset
   302
				_place_road_flag = (_place_road_flag & ~2) | ((e->we.place.pt.y & 8) >> 2);
4435
40eff4363774 (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4434
diff changeset
   303
				break;
40eff4363774 (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4434
diff changeset
   304
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
   305
			case DDSP_PLACE_ROAD_NW:
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4559
diff changeset
   306
				_place_road_flag = (_place_road_flag & ~2) | ((e->we.place.pt.x & 8) >> 2);
4435
40eff4363774 (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4434
diff changeset
   307
				break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   308
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   309
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
   310
		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
   311
		return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   312
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   313
	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
   314
		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
   315
			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
   316
			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
   317
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
   318
			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
   319
				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
   320
					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
   321
					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
   322
					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
   323
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
   324
				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
   325
					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
   326
					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
   327
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
   328
				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
   329
				case DDSP_PLACE_ROAD_NW:
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
   330
					DoCommandP(end_tile, start_tile, _place_road_flag | (_cur_roadtype << 3), CcPlaySound1D,
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
   331
						_remove_button_clicked ?
6676
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   332
						CMD_REMOVE_LONG_ROAD | CMD_AUTO | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_road) :
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   333
						CMD_BUILD_LONG_ROAD | CMD_AUTO | 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
   334
					break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   335
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   336
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   337
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   338
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   339
	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
   340
		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
   341
6678
4d901bc54b74 (svn r9909) -Fix (r9897): Highlight road tunnels properly when building them.
maedhros
parents: 6677
diff changeset
   342
		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
   343
		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
   344
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   345
	}
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
   346
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
   347
	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
   348
		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
   349
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   350
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   351
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   352
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   353
static const Widget _build_road_widgets[] = {
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4212
diff changeset
   354
{   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                   STR_018B_CLOSE_WINDOW},
5682
f109e2e62af8 (svn r8143) Remove the landscaping button from the build toolbars.
tron
parents: 5587
diff changeset
   355
{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   205,     0,    13, STR_1802_ROAD_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
f109e2e62af8 (svn r8143) Remove the landscaping button from the build toolbars.
tron
parents: 5587
diff changeset
   356
{  WWT_STICKYBOX,   RESIZE_NONE,     7,   206,   217,     0,    13, 0x0,                        STR_STICKY_BUTTON},
606
da90c837064c (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
   357
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   358
{     WWT_IMGBTN,   RESIZE_NONE,     7,     0,    21,    14,    35, SPR_IMG_ROAD_NW,            STR_180B_BUILD_ROAD_SECTION},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   359
{     WWT_IMGBTN,   RESIZE_NONE,     7,    22,    43,    14,    35, SPR_IMG_ROAD_NE,            STR_180B_BUILD_ROAD_SECTION},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   360
{     WWT_IMGBTN,   RESIZE_NONE,     7,    44,    65,    14,    35, SPR_IMG_DYNAMITE,           STR_018D_DEMOLISH_BUILDINGS_ETC},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   361
{     WWT_IMGBTN,   RESIZE_NONE,     7,    66,    87,    14,    35, SPR_IMG_ROAD_DEPOT,         STR_180C_BUILD_ROAD_VEHICLE_DEPOT},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   362
{     WWT_IMGBTN,   RESIZE_NONE,     7,    88,   109,    14,    35, SPR_IMG_BUS_STATION,        STR_180D_BUILD_BUS_STATION},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   363
{     WWT_IMGBTN,   RESIZE_NONE,     7,   110,   131,    14,    35, SPR_IMG_TRUCK_BAY,          STR_180E_BUILD_TRUCK_LOADING_BAY},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   364
{     WWT_IMGBTN,   RESIZE_NONE,     7,   132,   173,    14,    35, SPR_IMG_BRIDGE,             STR_180F_BUILD_ROAD_BRIDGE},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   365
{     WWT_IMGBTN,   RESIZE_NONE,     7,   174,   195,    14,    35, SPR_IMG_ROAD_TUNNEL,        STR_1810_BUILD_ROAD_TUNNEL},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   366
{     WWT_IMGBTN,   RESIZE_NONE,     7,   196,   217,    14,    35, SPR_IMG_REMOVE,             STR_1811_TOGGLE_BUILD_REMOVE_FOR},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 5
diff changeset
   367
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   368
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   369
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   370
static const WindowDesc _build_road_desc = {
5682
f109e2e62af8 (svn r8143) Remove the landscaping button from the build toolbars.
tron
parents: 5587
diff changeset
   371
	WDP_ALIGN_TBR, 22, 218, 36,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5860
diff changeset
   372
	WC_BUILD_TOOLBAR, WC_NONE,
756
b76998029c12 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents: 679
diff changeset
   373
	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
   374
	_build_road_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   375
	BuildRoadToolbWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   376
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   377
6666
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
   378
void ShowBuildRoadToolbar(RoadType roadtype)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   379
{
5005
f5086bd3945a (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4938
diff changeset
   380
	if (!IsValidPlayer(_current_player)) return;
6666
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
   381
	_cur_roadtype = roadtype;
5005
f5086bd3945a (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4938
diff changeset
   382
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   383
	DeleteWindowById(WC_BUILD_TOOLBAR, 0);
5860
3b26be021371 (svn r8436) -Fix
tron
parents: 5836
diff changeset
   384
	Window *w = AllocateWindowDesc(&_build_road_desc);
3b26be021371 (svn r8436) -Fix
tron
parents: 5836
diff changeset
   385
	if (_patches.link_terraform_toolbar) ShowTerraformToolbar(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   386
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   387
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   388
static const Widget _build_road_scen_widgets[] = {
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4212
diff changeset
   389
{   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                   STR_018B_CLOSE_WINDOW},
5689
2a00c1acabc5 (svn r8152) Fix a off-by-one error in the placement of the sticky box of the road build toolbar in the scenario editor
tron
parents: 5682
diff changeset
   390
{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   139,     0,    13, STR_1802_ROAD_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
2a00c1acabc5 (svn r8152) Fix a off-by-one error in the placement of the sticky box of the road build toolbar in the scenario editor
tron
parents: 5682
diff changeset
   391
{  WWT_STICKYBOX,   RESIZE_NONE,     7,   140,   151,     0,    13, 0x0,                        STR_STICKY_BUTTON},
661
0d0a151aa4cd (svn r1095) -Fix: scenario editor road-build-gui works again altough shortcuts are screwed.
darkvater
parents: 651
diff changeset
   392
4937
8cfdd86fd709 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   393
{     WWT_IMGBTN,   RESIZE_NONE,     7,     0,    21,    14,    35, SPR_IMG_ROAD_NW,            STR_180B_BUILD_ROAD_SECTION},
8cfdd86fd709 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   394
{     WWT_IMGBTN,   RESIZE_NONE,     7,    22,    43,    14,    35, SPR_IMG_ROAD_NE,            STR_180B_BUILD_ROAD_SECTION},
8cfdd86fd709 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   395
{     WWT_IMGBTN,   RESIZE_NONE,     7,    44,    65,    14,    35, SPR_IMG_DYNAMITE,           STR_018D_DEMOLISH_BUILDINGS_ETC},
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4212
diff changeset
   396
{      WWT_EMPTY,   RESIZE_NONE,     0,     0,     0,     0,     0, 0x0,                        STR_NULL},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4212
diff changeset
   397
{      WWT_EMPTY,   RESIZE_NONE,     0,     0,     0,     0,     0, 0x0,                        STR_NULL},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4212
diff changeset
   398
{      WWT_EMPTY,   RESIZE_NONE,     0,     0,     0,     0,     0, 0x0,                        STR_NULL},
4937
8cfdd86fd709 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   399
{     WWT_IMGBTN,   RESIZE_NONE,     7,    66,   107,    14,    35, SPR_IMG_BRIDGE,             STR_180F_BUILD_ROAD_BRIDGE},
8cfdd86fd709 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   400
{     WWT_IMGBTN,   RESIZE_NONE,     7,   108,   129,    14,    35, SPR_IMG_ROAD_TUNNEL,        STR_1810_BUILD_ROAD_TUNNEL},
8cfdd86fd709 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4848
diff changeset
   401
{     WWT_IMGBTN,   RESIZE_NONE,     7,   130,   151,    14,    35, SPR_IMG_REMOVE,             STR_1811_TOGGLE_BUILD_REMOVE_FOR},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 5
diff changeset
   402
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   403
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   404
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   405
static const WindowDesc _build_road_scen_desc = {
5396
e64e67396937 (svn r7586) -Fix (FS#473): remove the Landscaping toolbar option from the Road Construction toolbar in the scenario editor, as there is another Lanscaping GUI in the scenario editor and launching that one could confuse users.
rubidium
parents: 5147
diff changeset
   406
	WDP_AUTO, WDP_AUTO, 152, 36,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5860
diff changeset
   407
	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
   408
	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
   409
	_build_road_scen_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   410
	BuildRoadToolbWndProc
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
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6102
diff changeset
   413
void ShowBuildRoadScenToolbar()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   414
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   415
	AllocateWindowDescFront(&_build_road_scen_desc, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   416
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   417
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   418
static void BuildRoadDepotWndProc(Window *w, WindowEvent *e)
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   419
{
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   420
	switch (e->event) {
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   421
	case WE_CREATE: LowerWindowWidget(w, _road_depot_orientation + 3); break;
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   422
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   423
	case WE_PAINT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   424
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   425
6666
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
   426
		DrawRoadDepotSprite(70, 17, DIAGDIR_NE, _cur_roadtype);
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
   427
		DrawRoadDepotSprite(70, 69, DIAGDIR_SE, _cur_roadtype);
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
   428
		DrawRoadDepotSprite( 2, 69, DIAGDIR_SW, _cur_roadtype);
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
   429
		DrawRoadDepotSprite( 2, 17, DIAGDIR_NW, _cur_roadtype);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   430
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   431
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   432
	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
   433
		switch (e->we.click.widget) {
1116
242ddc1401b5 (svn r1617) -Fix: Ugly hack to only call ResetObjectToPlaceon childwindows of build-toolbar if the window is closed manually (with 'X'); if not checked ResetObjectToPlace is called twice resulting in undesired actions (eg. clicked button is unclicked immediately).
darkvater
parents: 1109
diff changeset
   434
		case 3: case 4: case 5: case 6:
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   435
			RaiseWindowWidget(w, _road_depot_orientation + 3);
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   436
			_road_depot_orientation = (DiagDirection)(e->we.click.widget - 3);
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   437
			LowerWindowWidget(w, _road_depot_orientation + 3);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 514
diff changeset
   438
			SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   439
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   440
			break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   441
		}
6492
286a52449b54 (svn r9673) -Cleanup: remove spaces before tabs and replace non-indenting tabs with spaces.
rubidium
parents: 6491
diff changeset
   442
	} break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   443
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   444
	case WE_MOUSELOOP:
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6393
diff changeset
   445
		if (WP(w, def_d).close) DeleteWindow(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   446
		break;
1072
74cd9150d473 (svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents: 1035
diff changeset
   447
74cd9150d473 (svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents: 1035
diff changeset
   448
	case WE_DESTROY:
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6393
diff changeset
   449
		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
   450
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   451
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   452
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   453
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   454
static const Widget _build_road_depot_widgets[] = {
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4212
diff changeset
   455
{   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 787
diff changeset
   456
{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   139,     0,    13, STR_1806_ROAD_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4212
diff changeset
   457
{      WWT_PANEL,   RESIZE_NONE,     7,     0,   139,    14,   121, 0x0,                             STR_NULL},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4212
diff changeset
   458
{      WWT_PANEL,   RESIZE_NONE,    14,    71,   136,    17,    66, 0x0,                             STR_1813_SELECT_ROAD_VEHICLE_DEPOT},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4212
diff changeset
   459
{      WWT_PANEL,   RESIZE_NONE,    14,    71,   136,    69,   118, 0x0,                             STR_1813_SELECT_ROAD_VEHICLE_DEPOT},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4212
diff changeset
   460
{      WWT_PANEL,   RESIZE_NONE,    14,     3,    68,    69,   118, 0x0,                             STR_1813_SELECT_ROAD_VEHICLE_DEPOT},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4212
diff changeset
   461
{      WWT_PANEL,   RESIZE_NONE,    14,     3,    68,    17,    66, 0x0,                             STR_1813_SELECT_ROAD_VEHICLE_DEPOT},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 5
diff changeset
   462
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   463
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   464
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   465
static const WindowDesc _build_road_depot_desc = {
5070
7f5b13b7e728 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 5005
diff changeset
   466
	WDP_AUTO, WDP_AUTO, 140, 122,
7f5b13b7e728 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 5005
diff changeset
   467
	WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   468
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   469
	_build_road_depot_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   470
	BuildRoadDepotWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   471
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   472
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6102
diff changeset
   473
static void ShowRoadDepotPicker()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   474
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   475
	AllocateWindowDesc(&_build_road_depot_desc);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   476
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   477
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
   478
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
   479
{
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2753
diff changeset
   480
	switch (e->event) {
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   481
	case WE_CREATE:
6677
8120427efe01 (svn r9908) -Codechange: prepare the station picker for more road types.
rubidium
parents: 6676
diff changeset
   482
		/* Trams don't have non-drivethrough stations */
8120427efe01 (svn r9908) -Codechange: prepare the station picker for more road types.
rubidium
parents: 6676
diff changeset
   483
		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
   484
			_road_station_picker_orientation = DIAGDIR_END;
8120427efe01 (svn r9908) -Codechange: prepare the station picker for more road types.
rubidium
parents: 6676
diff changeset
   485
		}
8120427efe01 (svn r9908) -Codechange: prepare the station picker for more road types.
rubidium
parents: 6676
diff changeset
   486
		SetWindowWidgetsDisabledState(w, _cur_roadtype == ROADTYPE_TRAM, 3, 4, 5, 6, WIDGET_LIST_END);
8120427efe01 (svn r9908) -Codechange: prepare the station picker for more road types.
rubidium
parents: 6676
diff changeset
   487
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   488
		LowerWindowWidget(w, _road_station_picker_orientation + 3);
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   489
		LowerWindowWidget(w, _station_show_coverage + 9);
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   490
		break;
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   491
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   492
	case WE_PAINT: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   493
		int image;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   494
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6393
diff changeset
   495
		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
   496
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   497
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   498
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
   499
		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
   500
			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
   501
			SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4008
diff changeset
   502
		} 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
   503
			SetTileSelectSize(1, 1);
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4008
diff changeset
   504
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   505
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   506
		image = (w->window_class == WC_BUS_STATION) ? GFX_BUS_BASE : GFX_TRUCK_BASE;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   507
6677
8120427efe01 (svn r9908) -Codechange: prepare the station picker for more road types.
rubidium
parents: 6676
diff changeset
   508
		StationPickerDrawSprite(103, 35, RAILTYPE_BEGIN, ROADTYPE_ROAD, image);
8120427efe01 (svn r9908) -Codechange: prepare the station picker for more road types.
rubidium
parents: 6676
diff changeset
   509
		StationPickerDrawSprite(103, 85, RAILTYPE_BEGIN, ROADTYPE_ROAD, image + 1);
8120427efe01 (svn r9908) -Codechange: prepare the station picker for more road types.
rubidium
parents: 6676
diff changeset
   510
		StationPickerDrawSprite(35, 85, RAILTYPE_BEGIN, ROADTYPE_ROAD, image + 2);
8120427efe01 (svn r9908) -Codechange: prepare the station picker for more road types.
rubidium
parents: 6676
diff changeset
   511
		StationPickerDrawSprite(35, 35, RAILTYPE_BEGIN, ROADTYPE_ROAD, image + 3);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   512
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   513
		image = (w->window_class == WC_BUS_STATION) ? GFX_BUS_BASE_EXT : GFX_TRUCK_BASE_EXT;
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   514
6677
8120427efe01 (svn r9908) -Codechange: prepare the station picker for more road types.
rubidium
parents: 6676
diff changeset
   515
		StationPickerDrawSprite(171, 35, RAILTYPE_BEGIN, _cur_roadtype, image);
8120427efe01 (svn r9908) -Codechange: prepare the station picker for more road types.
rubidium
parents: 6676
diff changeset
   516
		StationPickerDrawSprite(171, 85, RAILTYPE_BEGIN, _cur_roadtype, image + 1);
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   517
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   518
		DrawStationCoverageAreaText(2, 146,
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6393
diff changeset
   519
			((w->window_class == WC_BUS_STATION) ? (1 << CT_PASSENGERS) : ~(1 << CT_PASSENGERS)),
568
b0d0df062880 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 543
diff changeset
   520
			3);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   521
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   522
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   523
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   524
	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
   525
		switch (e->we.click.widget) {
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   526
		case 3: case 4: case 5: case 6: case 7: case 8:
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   527
			RaiseWindowWidget(w, _road_station_picker_orientation + 3);
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   528
			_road_station_picker_orientation = (DiagDirection)(e->we.click.widget - 3);
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   529
			LowerWindowWidget(w, _road_station_picker_orientation + 3);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 514
diff changeset
   530
			SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   531
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   532
			break;
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   533
		case 9: case 10:
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   534
			RaiseWindowWidget(w, _station_show_coverage + 9);
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   535
			_station_show_coverage = (e->we.click.widget != 9);
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   536
			LowerWindowWidget(w, _station_show_coverage + 9);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 514
diff changeset
   537
			SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   538
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   539
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   540
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   541
	} break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   542
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   543
	case WE_MOUSELOOP: {
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6393
diff changeset
   544
		if (WP(w, def_d).close) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   545
			DeleteWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   546
			return;
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
		CheckRedrawStationCoverage(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   550
	} break;
1109
ecb98f43ba2c (svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents: 1093
diff changeset
   551
1072
74cd9150d473 (svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents: 1035
diff changeset
   552
	case WE_DESTROY:
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6393
diff changeset
   553
		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
   554
		break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   555
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   556
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   557
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   558
static const Widget _bus_station_picker_widgets[] = {
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4212
diff changeset
   559
{   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                         STR_018B_CLOSE_WINDOW},
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   560
{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   206,     0,    13, STR_3042_BUS_STATION_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   561
{      WWT_PANEL,   RESIZE_NONE,     7,     0,   206,    14,   176, 0x0,                              STR_NULL},
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4212
diff changeset
   562
{      WWT_PANEL,   RESIZE_NONE,    14,    71,   136,    17,    66, 0x0,                              STR_3051_SELECT_BUS_STATION_ORIENTATION},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4212
diff changeset
   563
{      WWT_PANEL,   RESIZE_NONE,    14,    71,   136,    69,   118, 0x0,                              STR_3051_SELECT_BUS_STATION_ORIENTATION},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4212
diff changeset
   564
{      WWT_PANEL,   RESIZE_NONE,    14,     3,    68,    69,   118, 0x0,                              STR_3051_SELECT_BUS_STATION_ORIENTATION},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4212
diff changeset
   565
{      WWT_PANEL,   RESIZE_NONE,    14,     3,    68,    17,    66, 0x0,                              STR_3051_SELECT_BUS_STATION_ORIENTATION},
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   566
{      WWT_PANEL,   RESIZE_NONE,    14,   139,   204,    17,    66, 0x0,                              STR_3051_SELECT_BUS_STATION_ORIENTATION},
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   567
{      WWT_PANEL,   RESIZE_NONE,    14,   139,   204,    69,   118, 0x0,                              STR_3051_SELECT_BUS_STATION_ORIENTATION},
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4212
diff changeset
   568
{    WWT_TEXTBTN,   RESIZE_NONE,    14,    10,    69,   133,   144, STR_02DB_OFF,                     STR_3065_DON_T_HIGHLIGHT_COVERAGE},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4212
diff changeset
   569
{    WWT_TEXTBTN,   RESIZE_NONE,    14,    70,   129,   133,   144, STR_02DA_ON,                      STR_3064_HIGHLIGHT_COVERAGE_AREA},
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   570
{      WWT_LABEL,   RESIZE_NONE,     7,     0,   139,   120,   133, STR_3066_COVERAGE_AREA_HIGHLIGHT, STR_NULL},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 5
diff changeset
   571
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   572
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   573
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   574
static const WindowDesc _bus_station_picker_desc = {
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   575
	WDP_AUTO, WDP_AUTO, 207, 177,
5070
7f5b13b7e728 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 5005
diff changeset
   576
	WC_BUS_STATION, WC_BUILD_TOOLBAR,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   577
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   578
	_bus_station_picker_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   579
	RoadStationPickerWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   580
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   581
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6102
diff changeset
   582
static void ShowBusStationPicker()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   583
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   584
	AllocateWindowDesc(&_bus_station_picker_desc);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   585
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   586
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   587
static const Widget _truck_station_picker_widgets[] = {
4345
1da147230c79 (svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents: 4344
diff changeset
   588
{   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                         STR_018B_CLOSE_WINDOW},
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   589
{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   206,     0,    13, STR_3043_TRUCK_STATION_ORIENT,    STR_018C_WINDOW_TITLE_DRAG_THIS},
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   590
{      WWT_PANEL,   RESIZE_NONE,     7,     0,   206,    14,   176, 0x0,                              STR_NULL},
4345
1da147230c79 (svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents: 4344
diff changeset
   591
{      WWT_PANEL,   RESIZE_NONE,    14,    71,   136,    17,    66, 0x0,                              STR_3052_SELECT_TRUCK_LOADING_BAY},
1da147230c79 (svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents: 4344
diff changeset
   592
{      WWT_PANEL,   RESIZE_NONE,    14,    71,   136,    69,   118, 0x0,                              STR_3052_SELECT_TRUCK_LOADING_BAY},
1da147230c79 (svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents: 4344
diff changeset
   593
{      WWT_PANEL,   RESIZE_NONE,    14,     3,    68,    69,   118, 0x0,                              STR_3052_SELECT_TRUCK_LOADING_BAY},
1da147230c79 (svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents: 4344
diff changeset
   594
{      WWT_PANEL,   RESIZE_NONE,    14,     3,    68,    17,    66, 0x0,                              STR_3052_SELECT_TRUCK_LOADING_BAY},
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   595
{      WWT_PANEL,   RESIZE_NONE,    14,   139,   204,    17,    66, 0x0,                              STR_3052_SELECT_TRUCK_LOADING_BAY},
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   596
{      WWT_PANEL,   RESIZE_NONE,    14,   139,   204,    69,   118, 0x0,                              STR_3052_SELECT_TRUCK_LOADING_BAY},
4345
1da147230c79 (svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents: 4344
diff changeset
   597
{    WWT_TEXTBTN,   RESIZE_NONE,    14,    10,    69,   133,   144, STR_02DB_OFF,                     STR_3065_DON_T_HIGHLIGHT_COVERAGE},
1da147230c79 (svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents: 4344
diff changeset
   598
{    WWT_TEXTBTN,   RESIZE_NONE,    14,    70,   129,   133,   144, STR_02DA_ON,                      STR_3064_HIGHLIGHT_COVERAGE_AREA},
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   599
{      WWT_LABEL,   RESIZE_NONE,     7,     0,   139,   120,   133, STR_3066_COVERAGE_AREA_HIGHLIGHT, STR_NULL},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 5
diff changeset
   600
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   601
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   602
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   603
static const WindowDesc _truck_station_picker_desc = {
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   604
	WDP_AUTO, WDP_AUTO, 207, 177,
5070
7f5b13b7e728 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 5005
diff changeset
   605
	WC_TRUCK_STATION, WC_BUILD_TOOLBAR,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   606
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   607
	_truck_station_picker_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   608
	RoadStationPickerWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   609
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   610
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6102
diff changeset
   611
static void ShowTruckStationPicker()
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
	AllocateWindowDesc(&_truck_station_picker_desc);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   614
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   615
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6102
diff changeset
   616
void InitializeRoadGui()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   617
{
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   618
	_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
   619
	_road_station_picker_orientation = DIAGDIR_NW;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   620
}