src/road_gui.cpp
author translators
Thu, 18 Dec 2008 18:47:39 +0000
changeset 10437 6d64230b9fb9
parent 10208 72c00af5c95d
permissions -rw-r--r--
(svn r14691) -Update: WebTranslator2 update to 2008-12-18 18:47:25
arabic_egypt - 132 fixed, 1 changed by khaloofah (133)
czech - 10 fixed, 25 changed by Hadez (35)
esperanto - 15 fixed by Athaba (15)
greek - 7 fixed by ouranogrammi (7)
indonesian - 88 changed by fanioz (88)
latvian - 117 fixed, 16 changed by peerer (83), marismols (50)
lithuanian - 15 fixed by Zogg (15)
malay - 38 fixed by tombakemas (5), Syed (33)
serbian - 39 fixed, 1 changed by Jenraux (40)
thai - 105 fixed by vetbook (105)
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
9111
48ce04029fe4 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 9080
diff changeset
     3
/** @file road_gui.cpp GUI for building roads. */
6393
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"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
#include "gui.h"
8107
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
     8
#include "window_gui.h"
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
     9
#include "station_gui.h"
8205
2bde724f1b5d (svn r11768) -Codechange: move some terraform related gui stuff from main_gui.cpp to terraform_gui.cpp (and introduce terraform_gui.h). Based on a patch by Roujin.
rubidium
parents: 8166
diff changeset
    10
#include "terraform_gui.h"
8224
c5a64d87cc54 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8223
diff changeset
    11
#include "viewport_func.h"
c5a64d87cc54 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8223
diff changeset
    12
#include "gfx_func.h"
8116
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8114
diff changeset
    13
#include "command_func.h"
2159
f6284cf5fab0 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2049
diff changeset
    14
#include "variables.h"
8223
2f64b8462e66 (svn r11786) -Codechange: shuffle more includes
peter1138
parents: 8205
diff changeset
    15
#include "road_type.h"
6666
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
    16
#include "road_cmd.h"
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
    17
#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
    18
#include "station_map.h"
8131
160939e24ed3 (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents: 8121
diff changeset
    19
#include "functions.h"
160939e24ed3 (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents: 8121
diff changeset
    20
#include "window_func.h"
8144
65cec0877b78 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8139
diff changeset
    21
#include "vehicle_func.h"
8157
1505def01945 (svn r11719) -Codechange: split sound.h in a header with types and one with functions.
rubidium
parents: 8144
diff changeset
    22
#include "sound_func.h"
10208
72c00af5c95d (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium
parents: 10207
diff changeset
    23
#include "company_func.h"
8270
e7c342f6b14c (svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents: 8264
diff changeset
    24
#include "settings_type.h"
8973
749e572f9378 (svn r12765) -Codechange: move some stuff out of variables.h that required including other headers in variables.h.
rubidium
parents: 8846
diff changeset
    25
#include "tunnelbridge.h"
9127
14f21c5954ee (svn r12987) -Codechange: split viewport and tile selection.
rubidium
parents: 9123
diff changeset
    26
#include "tilehighlight_func.h"
10208
72c00af5c95d (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium
parents: 10207
diff changeset
    27
#include "company_base.h"
568
b0d0df062880 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 543
diff changeset
    28
8264
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    29
#include "table/sprites.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    30
#include "table/strings.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    31
9338
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
    32
static void ShowRVStationPicker(Window *parent, RoadStopType rs);
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
    33
static void ShowRoadDepotPicker(Window *parent);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    35
static bool _remove_button_clicked;
7906
d39b6db978ff (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 7904
diff changeset
    36
static bool _one_way_button_clicked;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    37
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    38
/**
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    39
 * Define the values of the RoadFlags
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    40
 * @see CmdBuildLongRoad
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    41
 */
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    42
enum RoadFlags {
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    43
	RF_NONE             = 0x00,
7794
ce96912e77fb (svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
belugas
parents: 7789
diff changeset
    44
	RF_START_HALFROAD_Y = 0x01,    // The start tile in Y-dir should have only a half road
ce96912e77fb (svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
belugas
parents: 7789
diff changeset
    45
	RF_END_HALFROAD_Y   = 0x02,    // The end tile in Y-dir should have only a half road
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    46
	RF_DIR_Y            = 0x04,    // The direction is Y-dir
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    47
	RF_DIR_X            = RF_NONE, // Dummy; Dir X is set when RF_DIR_Y is not set
7794
ce96912e77fb (svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
belugas
parents: 7789
diff changeset
    48
	RF_START_HALFROAD_X = 0x08,    // The start tile in X-dir should have only a half road
ce96912e77fb (svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
belugas
parents: 7789
diff changeset
    49
	RF_END_HALFROAD_X   = 0x10,    // The end tile in X-dir should have only a half road
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    50
};
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    51
DECLARE_ENUM_AS_BIT_SET(RoadFlags);
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    52
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    53
static RoadFlags _place_road_flag;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    54
6666
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
    55
static RoadType _cur_roadtype;
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
    56
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
    57
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
    58
static DiagDirection _road_station_picker_orientation;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    59
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    60
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
    61
{
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 514
diff changeset
    62
	if (success) SndPlayTileFx(SND_1F_SPLAT, tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    63
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    64
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    65
/**
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    66
 * Set the initial flags for the road constuction.
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    67
 * The flags are:
7895
2ac7de1f03e6 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 7794
diff changeset
    68
 * @li The direction is the X-dir
2ac7de1f03e6 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 7794
diff changeset
    69
 * @li The first tile has a partitial RoadBit (true or false)
2ac7de1f03e6 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 7794
diff changeset
    70
 *
2ac7de1f03e6 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 7794
diff changeset
    71
 * @param tile The start tile
2ac7de1f03e6 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 7794
diff changeset
    72
 */
2ac7de1f03e6 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 7794
diff changeset
    73
static void PlaceRoad_X_Dir(TileIndex tile)
2ac7de1f03e6 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 7794
diff changeset
    74
{
2ac7de1f03e6 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 7794
diff changeset
    75
	_place_road_flag = RF_DIR_X;
2ac7de1f03e6 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 7794
diff changeset
    76
	if (_tile_fract_coords.x >= 8) _place_road_flag |= RF_START_HALFROAD_X;
2ac7de1f03e6 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 7794
diff changeset
    77
	VpStartPlaceSizing(tile, VPM_FIX_Y, DDSP_PLACE_ROAD_X_DIR);
2ac7de1f03e6 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 7794
diff changeset
    78
}
2ac7de1f03e6 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 7794
diff changeset
    79
2ac7de1f03e6 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 7794
diff changeset
    80
/**
2ac7de1f03e6 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 7794
diff changeset
    81
 * Set the initial flags for the road constuction.
2ac7de1f03e6 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 7794
diff changeset
    82
 * The flags are:
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    83
 * @li The direction is the Y-dir
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    84
 * @li The first tile has a partitial RoadBit (true or false)
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    85
 *
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    86
 * @param tile The start tile
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    87
 */
7895
2ac7de1f03e6 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 7794
diff changeset
    88
static void PlaceRoad_Y_Dir(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
{
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    90
	_place_road_flag = RF_DIR_Y;
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    91
	if (_tile_fract_coords.y >= 8) _place_road_flag |= RF_START_HALFROAD_Y;
7895
2ac7de1f03e6 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 7794
diff changeset
    92
	VpStartPlaceSizing(tile, VPM_FIX_X, DDSP_PLACE_ROAD_Y_DIR);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    95
/**
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    96
 * Set the initial flags for the road constuction.
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    97
 * The flags are:
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    98
 * @li The direction is not set.
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
    99
 * @li The first tile has a partitial RoadBit (true or false)
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   100
 *
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   101
 * @param tile The start tile
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   102
 */
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   103
static void PlaceRoad_AutoRoad(TileIndex tile)
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   104
{
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   105
	_place_road_flag = RF_NONE;
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   106
	if (_tile_fract_coords.x >= 8) _place_road_flag |= RF_START_HALFROAD_X;
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   107
	if (_tile_fract_coords.y >= 8) _place_road_flag |= RF_START_HALFROAD_Y;
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   108
	VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_PLACE_AUTOROAD);
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   109
}
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   110
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   111
static void PlaceRoad_Bridge(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   112
{
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
   113
	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
   114
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   115
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   116
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   117
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
   118
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
	if (success) {
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 514
diff changeset
   120
		SndPlayTileFx(SND_20_SPLAT_2, tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
		ResetObjectToPlace();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   122
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   123
		SetRedErrorSquare(_build_tunnel_endtile);
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
6676
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   127
/** 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
   128
struct RoadTypeInfo {
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   129
	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
   130
	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
   131
	StringID err_depot;             ///< Building a depot
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   132
	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
   133
	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
   134
6693
00bef74e4d3a (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 6691
diff changeset
   135
	StringID picker_title[2];       ///< Title for the station picker for bus or truck stations
00bef74e4d3a (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 6691
diff changeset
   136
	StringID picker_tooltip[2];     ///< Tooltip for the station picker for bus or truck stations
00bef74e4d3a (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 6691
diff changeset
   137
6676
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   138
	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
   139
	SpriteID cursor_nwse;           ///< Cursor for building NW and SE bits
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   140
	SpriteID cursor_autoroad;       ///< Cursor for building autoroad
6676
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   141
};
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   142
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   143
/** 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
   144
static const RoadTypeInfo _road_type_infos[] = {
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   145
	{
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   146
		STR_1804_CAN_T_BUILD_ROAD_HERE,
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   147
		STR_1805_CAN_T_REMOVE_ROAD_FROM,
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   148
		STR_1807_CAN_T_BUILD_ROAD_VEHICLE,
6693
00bef74e4d3a (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 6691
diff changeset
   149
		{ STR_1808_CAN_T_BUILD_BUS_STATION,        STR_1809_CAN_T_BUILD_TRUCK_STATION },
00bef74e4d3a (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 6691
diff changeset
   150
		{ STR_CAN_T_REMOVE_BUS_STATION,            STR_CAN_T_REMOVE_TRUCK_STATION     },
00bef74e4d3a (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 6691
diff changeset
   151
		{ STR_3042_BUS_STATION_ORIENTATION,        STR_3043_TRUCK_STATION_ORIENT      },
00bef74e4d3a (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 6691
diff changeset
   152
		{ STR_3051_SELECT_BUS_STATION_ORIENTATION, STR_3052_SELECT_TRUCK_LOADING_BAY  },
6676
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   153
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   154
		SPR_CURSOR_ROAD_NESW,
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   155
		SPR_CURSOR_ROAD_NWSE,
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   156
		SPR_CURSOR_AUTOROAD,
6676
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   157
	},
6691
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   158
	{
8424
c3477565c975 (svn r11994) -Codechange: Remove numbers from string names where the strings aren't present in TTD, since they don't correspond to either TTD's TextIDs or OpenTTD's StringIDs.
maedhros
parents: 8423
diff changeset
   159
		STR_CAN_T_BUILD_TRAMWAY_HERE,
c3477565c975 (svn r11994) -Codechange: Remove numbers from string names where the strings aren't present in TTD, since they don't correspond to either TTD's TextIDs or OpenTTD's StringIDs.
maedhros
parents: 8423
diff changeset
   160
		STR_CAN_T_REMOVE_TRAMWAY_FROM,
c3477565c975 (svn r11994) -Codechange: Remove numbers from string names where the strings aren't present in TTD, since they don't correspond to either TTD's TextIDs or OpenTTD's StringIDs.
maedhros
parents: 8423
diff changeset
   161
		STR_CAN_T_BUILD_TRAM_VEHICLE,
c3477565c975 (svn r11994) -Codechange: Remove numbers from string names where the strings aren't present in TTD, since they don't correspond to either TTD's TextIDs or OpenTTD's StringIDs.
maedhros
parents: 8423
diff changeset
   162
		{ STR_CAN_T_BUILD_PASSENGER_TRAM_STATION,        STR_CAN_T_BUILD_CARGO_TRAM_STATION        },
c3477565c975 (svn r11994) -Codechange: Remove numbers from string names where the strings aren't present in TTD, since they don't correspond to either TTD's TextIDs or OpenTTD's StringIDs.
maedhros
parents: 8423
diff changeset
   163
		{ STR_CAN_T_REMOVE_PASSENGER_TRAM_STATION,       STR_CAN_T_REMOVE_CARGO_TRAM_STATION       },
c3477565c975 (svn r11994) -Codechange: Remove numbers from string names where the strings aren't present in TTD, since they don't correspond to either TTD's TextIDs or OpenTTD's StringIDs.
maedhros
parents: 8423
diff changeset
   164
		{ STR_PASSENGER_TRAM_STATION_ORIENTATION,        STR_CARGO_TRAM_STATION_ORIENT             },
c3477565c975 (svn r11994) -Codechange: Remove numbers from string names where the strings aren't present in TTD, since they don't correspond to either TTD's TextIDs or OpenTTD's StringIDs.
maedhros
parents: 8423
diff changeset
   165
		{ STR_SELECT_PASSENGER_TRAM_STATION_ORIENTATION, STR_SELECT_CARGO_TRAM_STATION_ORIENTATION },
6691
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   166
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   167
		SPR_CURSOR_TRAMWAY_NESW,
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   168
		SPR_CURSOR_TRAMWAY_NWSE,
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   169
		SPR_CURSOR_AUTOTRAM,
6691
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   170
	},
6676
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   171
};
9e305978401f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 6674
diff changeset
   172
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   173
static void PlaceRoad_Tunnel(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   174
{
7521
0da1e91510e4 (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7370
diff changeset
   175
	DoCommandP(tile, 0x200 | RoadTypeToRoadTypes(_cur_roadtype), 0, CcBuildRoadTunnel, CMD_BUILD_TUNNEL | CMD_MSG(STR_5016_CAN_T_BUILD_TUNNEL_HERE));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   176
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   177
3151
711ef4ea85e9 (svn r3774) Remove some more magic numbers and types
tron
parents: 3150
diff changeset
   178
static void BuildRoadOutsideStation(TileIndex tile, DiagDirection direction)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   179
{
4559
aa0c13e39840 (svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents: 4435
diff changeset
   180
	tile += TileOffsByDiagDir(direction);
8821
1411d08e26b3 (svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz
parents: 8785
diff changeset
   181
	/* if there is a roadpiece just outside of the station entrance, build a connecting route */
8563
13b1a41e46f1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch
parents: 8557
diff changeset
   182
	if (IsNormalRoadTile(tile)) {
6666
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
   183
		if (GetRoadBits(tile, _cur_roadtype) != ROAD_NONE) {
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
   184
			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
   185
		}
0
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
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   188
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   189
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
   190
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   191
	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
   192
		DiagDirection dir = (DiagDirection)GB(p1, 0, 2);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 514
diff changeset
   193
		SndPlayTileFx(SND_1F_SPLAT, tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   194
		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
   195
		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
   196
		/* For a drive-through road stop build connecting road for other entrance */
7928
63e18de69e50 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 7913
diff changeset
   197
		if (HasBit(p2, 1)) BuildRoadOutsideStation(tile, ReverseDiagDir(dir));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   198
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   199
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   200
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   201
static void PlaceRoad_Depot(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   202
{
7521
0da1e91510e4 (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7370
diff changeset
   203
	DoCommandP(tile, _cur_roadtype << 2 | _road_depot_orientation, 0, CcRoadDepot, CMD_BUILD_ROAD_DEPOT | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_depot));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   204
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   205
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   206
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
   207
{
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   208
	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
   209
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   210
	if (p1 >= DIAGDIR_END) {
7931
b0a46cd92225 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 7928
diff changeset
   211
		SetBit(p2, 1); // It's a drive-through stop
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   212
		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
   213
	}
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   214
	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
   215
}
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   216
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   217
static void PlaceRoad_BusStation(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   218
{
7956
b6b1b5d53252 (svn r11512) -Change: make the subsidy window able to resize to something smaller than 640x127 (especially the 640 part) when the screen is really too small.
rubidium
parents: 7949
diff changeset
   219
	if (_remove_button_clicked) {
8785
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents: 8692
diff changeset
   220
		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
   221
	} else {
8785
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents: 8692
diff changeset
   222
		PlaceRoadStop(tile, (_ctrl_pressed << 5) | RoadTypeToRoadTypes(_cur_roadtype) << 2 | ROADSTOP_BUS, CMD_BUILD_ROAD_STOP | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_station[ROADSTOP_BUS]));
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   223
	}
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
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   226
static void PlaceRoad_TruckStation(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   227
{
7956
b6b1b5d53252 (svn r11512) -Change: make the subsidy window able to resize to something smaller than 640x127 (especially the 640 part) when the screen is really too small.
rubidium
parents: 7949
diff changeset
   228
	if (_remove_button_clicked) {
8785
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents: 8692
diff changeset
   229
		DoCommandP(tile, 0, ROADSTOP_TRUCK, CcPlaySound1D, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[ROADSTOP_TRUCK]));
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   230
	} else {
8785
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents: 8692
diff changeset
   231
		PlaceRoadStop(tile, (_ctrl_pressed << 5) | RoadTypeToRoadTypes(_cur_roadtype) << 2 | ROADSTOP_TRUCK, CMD_BUILD_ROAD_STOP | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_station[ROADSTOP_TRUCK]));
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   232
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   233
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   234
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   235
/** Enum referring to the widgets of the build road toolbar */
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   236
enum RoadToolbarWidgets {
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   237
	RTW_CLOSEBOX = 0,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   238
	RTW_CAPTION,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   239
	RTW_STICKY,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   240
	RTW_ROAD_X,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   241
	RTW_ROAD_Y,
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   242
	RTW_AUTOROAD,
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   243
	RTW_DEMOLISH,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   244
	RTW_DEPOT,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   245
	RTW_BUS_STATION,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   246
	RTW_TRUCK_STATION,
7906
d39b6db978ff (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 7904
diff changeset
   247
	RTW_ONE_WAY,
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   248
	RTW_BUILD_BRIDGE,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   249
	RTW_BUILD_TUNNEL,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   250
	RTW_REMOVE,
5147
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   251
};
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   252
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   253
typedef void OnButtonClick(Window *w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   254
8586
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   255
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   256
/** Toogles state of the Remove button of Build road toolbar
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   257
 * @param w window the button belongs to
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   258
 */
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   259
static void ToggleRoadButton_Remove(Window *w)
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   260
{
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   261
	w->ToggleWidgetLoweredState(RTW_REMOVE);
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   262
	w->InvalidateWidget(RTW_REMOVE);
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   263
	_remove_button_clicked = w->IsWidgetLowered(RTW_REMOVE);
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   264
	SetSelectionRed(_remove_button_clicked);
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   265
}
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   266
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   267
/** Updates the Remove button because of Ctrl state change
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   268
 * @param w window the button belongs to
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   269
 * @return true iff the remove buton was changed
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   270
 */
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   271
static bool RoadToolbar_CtrlChanged(Window *w)
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   272
{
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   273
	if (w->IsWidgetDisabled(RTW_REMOVE)) return false;
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   274
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   275
	/* allow ctrl to switch remove mode only for these widgets */
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   276
	for (uint i = RTW_ROAD_X; i <= RTW_AUTOROAD; i++) {
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   277
		if (w->IsWidgetLowered(i)) {
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   278
			ToggleRoadButton_Remove(w);
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   279
			return true;
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   280
		}
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   281
	}
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   282
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   283
	return false;
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   284
}
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   285
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   286
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   287
/**
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   288
 * Function that handles the click on the
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   289
 *  X road placement button.
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   290
 *
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   291
 * @param w The current window
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   292
 */
7895
2ac7de1f03e6 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 7794
diff changeset
   293
static void BuildRoadClick_X_Dir(Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   294
{
7895
2ac7de1f03e6 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 7794
diff changeset
   295
	HandlePlacePushButton(w, RTW_ROAD_X, _road_type_infos[_cur_roadtype].cursor_nwse, VHM_RECT, PlaceRoad_X_Dir);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   296
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   297
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   298
/**
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   299
 * Function that handles the click on the
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   300
 *  Y road placement button.
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   301
 *
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   302
 * @param w The current window
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   303
 */
7895
2ac7de1f03e6 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 7794
diff changeset
   304
static void BuildRoadClick_Y_Dir(Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   305
{
7895
2ac7de1f03e6 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 7794
diff changeset
   306
	HandlePlacePushButton(w, RTW_ROAD_Y, _road_type_infos[_cur_roadtype].cursor_nesw, VHM_RECT, PlaceRoad_Y_Dir);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   307
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   308
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   309
/**
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   310
 * Function that handles the click on the
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   311
 *  autoroad placement button.
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   312
 *
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   313
 * @param w The current window
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   314
 */
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   315
static void BuildRoadClick_AutoRoad(Window *w)
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   316
{
7794
ce96912e77fb (svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
belugas
parents: 7789
diff changeset
   317
	HandlePlacePushButton(w, RTW_AUTOROAD, _road_type_infos[_cur_roadtype].cursor_autoroad, VHM_RECT, PlaceRoad_AutoRoad);
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   318
}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   319
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   320
static void BuildRoadClick_Demolish(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   321
{
9123
d2a939cbdf1d (svn r12983) -Codechange [FS#1987] : Unification of all dynamite tools calls to only one. Thanks to Roujin
belugas
parents: 9116
diff changeset
   322
	HandlePlacePushButton(w, RTW_DEMOLISH, ANIMCURSOR_DEMOLISH, VHM_RECT, PlaceProc_DemolishArea);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   323
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   324
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   325
static void BuildRoadClick_Depot(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   326
{
7086
de7e83fb1602 (svn r10353) -Fix/Feature [FS#669]: disallow (in the GUI) the building of infrastructure you do not have available vehicles for. This means that the airport building button is disabled till you can actually build aircraft. The game itself will not disallow you to build the infrastructure and this "new" behaviour can be overriden with a patch setting.
rubidium
parents: 6779
diff changeset
   327
	if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return;
9338
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
   328
	if (HandlePlacePushButton(w, RTW_DEPOT, SPR_CURSOR_ROAD_DEPOT, VHM_RECT, PlaceRoad_Depot)) ShowRoadDepotPicker(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   329
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   330
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   331
static void BuildRoadClick_BusStation(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   332
{
7086
de7e83fb1602 (svn r10353) -Fix/Feature [FS#669]: disallow (in the GUI) the building of infrastructure you do not have available vehicles for. This means that the airport building button is disabled till you can actually build aircraft. The game itself will not disallow you to build the infrastructure and this "new" behaviour can be overriden with a patch setting.
rubidium
parents: 6779
diff changeset
   333
	if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return;
9338
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
   334
	if (HandlePlacePushButton(w, RTW_BUS_STATION, SPR_CURSOR_BUS_STATION, VHM_RECT, PlaceRoad_BusStation)) ShowRVStationPicker(w, ROADSTOP_BUS);
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
static void BuildRoadClick_TruckStation(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   338
{
7086
de7e83fb1602 (svn r10353) -Fix/Feature [FS#669]: disallow (in the GUI) the building of infrastructure you do not have available vehicles for. This means that the airport building button is disabled till you can actually build aircraft. The game itself will not disallow you to build the infrastructure and this "new" behaviour can be overriden with a patch setting.
rubidium
parents: 6779
diff changeset
   339
	if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return;
9338
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
   340
	if (HandlePlacePushButton(w, RTW_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, VHM_RECT, PlaceRoad_TruckStation)) ShowRVStationPicker(w, ROADSTOP_TRUCK);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   341
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   342
7906
d39b6db978ff (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 7904
diff changeset
   343
/**
d39b6db978ff (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 7904
diff changeset
   344
 * Function that handles the click on the
d39b6db978ff (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 7904
diff changeset
   345
 *  one way road button.
d39b6db978ff (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 7904
diff changeset
   346
 *
d39b6db978ff (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 7904
diff changeset
   347
 * @param w The current window
d39b6db978ff (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 7904
diff changeset
   348
 */
d39b6db978ff (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 7904
diff changeset
   349
static void BuildRoadClick_OneWay(Window *w)
d39b6db978ff (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 7904
diff changeset
   350
{
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7956
diff changeset
   351
	if (w->IsWidgetDisabled(RTW_ONE_WAY)) return;
9116
f2491d3c321b (svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents: 9115
diff changeset
   352
	w->SetDirty();
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7956
diff changeset
   353
	w->ToggleWidgetLoweredState(RTW_ONE_WAY);
7907
3c2d241eb8f4 (svn r11459) -Fix: (r11457) The selection highlight color hasn't been reset
skidd13
parents: 7906
diff changeset
   354
	SetSelectionRed(false);
7906
d39b6db978ff (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 7904
diff changeset
   355
}
d39b6db978ff (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 7904
diff changeset
   356
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   357
static void BuildRoadClick_Bridge(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   358
{
7794
ce96912e77fb (svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
belugas
parents: 7789
diff changeset
   359
	HandlePlacePushButton(w, RTW_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, VHM_RECT, PlaceRoad_Bridge);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   360
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   361
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   362
static void BuildRoadClick_Tunnel(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   363
{
7794
ce96912e77fb (svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
belugas
parents: 7789
diff changeset
   364
	HandlePlacePushButton(w, RTW_BUILD_TUNNEL, SPR_CURSOR_ROAD_TUNNEL, VHM_SPECIAL, PlaceRoad_Tunnel);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   365
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   366
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   367
static void BuildRoadClick_Remove(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   368
{
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7956
diff changeset
   369
	if (w->IsWidgetDisabled(RTW_REMOVE)) return;
8586
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   370
	ToggleRoadButton_Remove(w);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 514
diff changeset
   371
	SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   372
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   373
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   374
/** Array with the handlers of the button-clicks for the road-toolbar */
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   375
static OnButtonClick* const _build_road_button_proc[] = {
7895
2ac7de1f03e6 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 7794
diff changeset
   376
	BuildRoadClick_X_Dir,
2ac7de1f03e6 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 7794
diff changeset
   377
	BuildRoadClick_Y_Dir,
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   378
	BuildRoadClick_AutoRoad,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   379
	BuildRoadClick_Demolish,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   380
	BuildRoadClick_Depot,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   381
	BuildRoadClick_BusStation,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   382
	BuildRoadClick_TruckStation,
7906
d39b6db978ff (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 7904
diff changeset
   383
	BuildRoadClick_OneWay,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   384
	BuildRoadClick_Bridge,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   385
	BuildRoadClick_Tunnel,
5682
f109e2e62af8 (svn r8143) Remove the landscaping button from the build toolbars.
tron
parents: 5587
diff changeset
   386
	BuildRoadClick_Remove
0
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
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   389
/** Array with the keycode of the button-clicks for the road-toolbar */
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   390
static const uint16 _road_keycodes[] = {
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   391
	'1',
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   392
	'2',
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   393
	'3',
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   394
	'4',
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   395
	'5',
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   396
	'6',
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   397
	'7',
7906
d39b6db978ff (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 7904
diff changeset
   398
	'8',
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   399
	'B',
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   400
	'T',
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   401
	'R',
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   402
};
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   403
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   404
struct BuildRoadToolbarWindow : Window {
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   405
	BuildRoadToolbarWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   406
	{
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   407
		this->SetWidgetsDisabledState(true,
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   408
			RTW_REMOVE,
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   409
			RTW_ONE_WAY,
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   410
			WIDGET_LIST_END);
8821
1411d08e26b3 (svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz
parents: 8785
diff changeset
   411
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   412
		this->FindWindowPlacementAndResize(desc);
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9354
diff changeset
   413
		if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   414
	}
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   415
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   416
	~BuildRoadToolbarWindow()
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   417
	{
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9354
diff changeset
   418
		if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   419
	}
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
   420
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   421
	/**
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   422
	 * Update the remove button lowered state of the road toolbar
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   423
	 *
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 9763
diff changeset
   424
	 * @param clicked_widget The widget which the client clicked just now
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   425
	 */
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   426
	void UpdateOptionWidgetStatus(RoadToolbarWidgets clicked_widget)
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   427
	{
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   428
		/* The remove and the one way button state is driven
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   429
		 * by the other buttons so they don't act on themselfs.
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   430
		 * Both are only valid if they are able to apply as options. */
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   431
		switch (clicked_widget) {
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   432
			case RTW_REMOVE:
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   433
				this->RaiseWidget(RTW_ONE_WAY);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   434
				this->InvalidateWidget(RTW_ONE_WAY);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   435
				break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   436
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   437
			case RTW_ONE_WAY:
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   438
				this->RaiseWidget(RTW_REMOVE);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   439
				this->InvalidateWidget(RTW_REMOVE);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   440
				break;
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   441
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   442
			case RTW_BUS_STATION:
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   443
			case RTW_TRUCK_STATION:
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   444
				this->DisableWidget(RTW_ONE_WAY);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   445
				this->SetWidgetDisabledState(RTW_REMOVE, !this->IsWidgetLowered(clicked_widget));
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   446
				break;
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   447
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   448
			case RTW_ROAD_X:
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   449
			case RTW_ROAD_Y:
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   450
			case RTW_AUTOROAD:
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   451
				this->SetWidgetsDisabledState(!this->IsWidgetLowered(clicked_widget),
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   452
					RTW_REMOVE,
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   453
					RTW_ONE_WAY,
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   454
					WIDGET_LIST_END);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   455
				break;
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   456
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   457
			default:
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   458
				/* When any other buttons than road/station, raise and
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   459
				 * disable the removal button */
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   460
				this->SetWidgetsDisabledState(true,
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   461
					RTW_REMOVE,
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   462
					RTW_ONE_WAY,
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   463
					WIDGET_LIST_END);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   464
				this->SetWidgetsLoweredState (false,
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   465
					RTW_REMOVE,
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   466
					RTW_ONE_WAY,
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   467
					WIDGET_LIST_END);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   468
				break;
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   469
		}
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   470
	}
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   471
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   472
	virtual void OnPaint()
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   473
	{
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   474
		this->SetWidgetsDisabledState(!CanBuildVehicleInfrastructure(VEH_ROAD),
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   475
			RTW_DEPOT,
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   476
			RTW_BUS_STATION,
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   477
			RTW_TRUCK_STATION,
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   478
			WIDGET_LIST_END);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   479
		this->DrawWidgets();
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   480
	}
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   481
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   482
	virtual void OnClick(Point pt, int widget)
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   483
	{
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   484
		if (widget >= RTW_ROAD_X) {
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   485
			_remove_button_clicked = false;
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   486
			_one_way_button_clicked = false;
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   487
			_build_road_button_proc[widget - RTW_ROAD_X](this);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   488
		}
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   489
		this->UpdateOptionWidgetStatus((RoadToolbarWidgets)widget);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   490
		if (_ctrl_pressed) RoadToolbar_CtrlChanged(this);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   491
	}
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   492
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   493
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   494
	{
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   495
		EventState state = ES_NOT_HANDLED;
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   496
		for (uint i = 0; i != lengthof(_road_keycodes); i++) {
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   497
			if (keycode == _road_keycodes[i]) {
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   498
				_remove_button_clicked = false;
7906
d39b6db978ff (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 7904
diff changeset
   499
				_one_way_button_clicked = false;
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   500
				_build_road_button_proc[i](this);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   501
				this->UpdateOptionWidgetStatus((RoadToolbarWidgets)(i + RTW_ROAD_X));
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   502
				if (_ctrl_pressed) RoadToolbar_CtrlChanged(this);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   503
				state = ES_HANDLED;
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   504
				break;
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   505
			}
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   506
		}
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   507
		MarkTileDirty(_thd.pos.x, _thd.pos.y); // redraw tile selection
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   508
		return state;
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   509
	}
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   510
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   511
	virtual void OnPlaceObject(Point pt, TileIndex tile)
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   512
	{
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   513
		_remove_button_clicked = this->IsWidgetLowered(RTW_REMOVE);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   514
		_one_way_button_clicked = this->IsWidgetLowered(RTW_ONE_WAY);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   515
		_place_proc(tile);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   516
	}
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   517
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   518
	virtual void OnPlaceObjectAbort()
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   519
	{
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   520
		this->RaiseButtons();
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   521
		this->SetWidgetsDisabledState(true,
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   522
			RTW_REMOVE,
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   523
			RTW_ONE_WAY,
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   524
			WIDGET_LIST_END);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   525
		this->InvalidateWidget(RTW_REMOVE);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   526
		this->InvalidateWidget(RTW_ONE_WAY);
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
   527
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   528
		delete FindWindowById(WC_BUS_STATION, 0);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   529
		delete FindWindowById(WC_TRUCK_STATION, 0);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   530
		delete FindWindowById(WC_BUILD_DEPOT, 0);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   531
	}
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   532
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   533
	virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   534
	{
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   535
		/* Here we update the end tile flags
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   536
		 * of the road placement actions.
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   537
		 * At first we reset the end halfroad
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   538
		 * bits and if needed we set them again. */
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   539
		switch (select_proc) {
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   540
			case DDSP_PLACE_ROAD_X_DIR:
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   541
				_place_road_flag &= ~RF_END_HALFROAD_X;
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   542
				if (pt.x & 8) _place_road_flag |= RF_END_HALFROAD_X;
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   543
				break;
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   544
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   545
			case DDSP_PLACE_ROAD_Y_DIR:
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   546
				_place_road_flag &= ~RF_END_HALFROAD_Y;
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   547
				if (pt.y & 8) _place_road_flag |= RF_END_HALFROAD_Y;
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   548
				break;
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   549
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   550
			case DDSP_PLACE_AUTOROAD:
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   551
				_place_road_flag &= ~(RF_END_HALFROAD_Y | RF_END_HALFROAD_X);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   552
				if (pt.y & 8) _place_road_flag |= RF_END_HALFROAD_Y;
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   553
				if (pt.x & 8) _place_road_flag |= RF_END_HALFROAD_X;
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   554
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   555
				/* For autoroad we need to update the
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   556
				 * direction of the road */
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   557
				if (_thd.size.x > _thd.size.y || (_thd.size.x == _thd.size.y &&
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   558
						( (_tile_fract_coords.x < _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) < 16) ||
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   559
						(_tile_fract_coords.x > _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) > 16) ))) {
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   560
					/* Set dir = X */
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   561
					_place_road_flag &= ~RF_DIR_Y;
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   562
				} else {
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   563
					/* Set dir = Y */
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   564
					_place_road_flag |= RF_DIR_Y;
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   565
				}
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   566
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   567
				break;
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   568
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   569
			default:
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   570
				break;
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   571
		}
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   572
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   573
		VpSelectTilesWithMethod(pt.x, pt.y, select_method);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   574
	}
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   575
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   576
	virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   577
	{
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   578
		if (pt.x != -1) {
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   579
			switch (select_proc) {
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   580
				default: NOT_REACHED();
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   581
				case DDSP_BUILD_BRIDGE:
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   582
					ResetObjectToPlace();
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   583
					ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_ROAD, RoadTypeToRoadTypes(_cur_roadtype));
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
   584
					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
   585
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   586
				case DDSP_DEMOLISH_AREA:
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   587
					GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
8821
1411d08e26b3 (svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz
parents: 8785
diff changeset
   588
					break;
1411d08e26b3 (svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz
parents: 8785
diff changeset
   589
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   590
				case DDSP_PLACE_ROAD_X_DIR:
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   591
				case DDSP_PLACE_ROAD_Y_DIR:
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   592
				case DDSP_PLACE_AUTOROAD:
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   593
					/* Flag description:
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   594
					* Use the first three bits (0x07) if dir == Y
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   595
					* else use the last 2 bits (X dir has
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   596
					* not the 3rd bit set) */
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   597
					_place_road_flag = (RoadFlags)((_place_road_flag & RF_DIR_Y) ? (_place_road_flag & 0x07) : (_place_road_flag >> 3));
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   598
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   599
					DoCommandP(end_tile, start_tile, _place_road_flag | (_cur_roadtype << 3) | (_one_way_button_clicked << 5), CcPlaySound1D,
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   600
						(_ctrl_pressed || _remove_button_clicked) ?
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   601
						CMD_REMOVE_LONG_ROAD | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_road) :
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   602
						CMD_BUILD_LONG_ROAD | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_road));
6669
bb48a810a509 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 6666
diff changeset
   603
					break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   604
			}
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   605
		}
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   606
	}
8821
1411d08e26b3 (svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz
parents: 8785
diff changeset
   607
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   608
	virtual void OnPlacePresize(Point pt, TileIndex tile)
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   609
	{
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   610
		DoCommand(tile, 0x200 | RoadTypeToRoadTypes(_cur_roadtype), 0, DC_AUTO, CMD_BUILD_TUNNEL);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   611
		VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   612
	}
8821
1411d08e26b3 (svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz
parents: 8785
diff changeset
   613
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   614
	virtual EventState OnCTRLStateChange()
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   615
	{
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   616
		if (RoadToolbar_CtrlChanged(this)) return ES_HANDLED;
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   617
		return ES_NOT_HANDLED;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   618
	}
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   619
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   620
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   621
/** Widget definition of the build road toolbar */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   622
static const Widget _build_road_widgets[] = {
9763
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   623
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_DARK_GREEN,     0,    10,     0,    13, STR_00C5,                   STR_018B_CLOSE_WINDOW},             // RTW_CLOSEBOX
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   624
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_DARK_GREEN,    11,   250,     0,    13, STR_1802_ROAD_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},   // RTW_CAPTION
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   625
{  WWT_STICKYBOX,   RESIZE_NONE,  COLOUR_DARK_GREEN,   251,   262,     0,    13, 0x0,                        STR_STICKY_BUTTON},                 // RTW_STICKY
606
da90c837064c (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
   626
9763
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   627
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,     0,    21,    14,    35, SPR_IMG_ROAD_X_DIR,         STR_180B_BUILD_ROAD_SECTION},       // RTW_ROAD_X
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   628
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,    22,    43,    14,    35, SPR_IMG_ROAD_Y_DIR,         STR_180B_BUILD_ROAD_SECTION},       // RTW_ROAD_Y
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   629
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,    44,    65,    14,    35, SPR_IMG_AUTOROAD,           STR_BUILD_AUTOROAD_TIP},            // RTW_AUTOROAD
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   630
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,    66,    87,    14,    35, SPR_IMG_DYNAMITE,           STR_018D_DEMOLISH_BUILDINGS_ETC},   // RTW_DEMOLISH
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   631
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,    88,   109,    14,    35, SPR_IMG_ROAD_DEPOT,         STR_180C_BUILD_ROAD_VEHICLE_DEPOT}, // RTW_DEPOT
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   632
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,   110,   131,    14,    35, SPR_IMG_BUS_STATION,        STR_180D_BUILD_BUS_STATION},        // RTW_BUS_STATION
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   633
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,   132,   153,    14,    35, SPR_IMG_TRUCK_BAY,          STR_180E_BUILD_TRUCK_LOADING_BAY},  // RTW_TRUCK_STATION
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   634
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,   154,   175,    14,    35, SPR_IMG_ROAD_ONE_WAY,       STR_TOGGLE_ONE_WAY_ROAD},           // RTW_ONE_WAY
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   635
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,   176,   218,    14,    35, SPR_IMG_BRIDGE,             STR_180F_BUILD_ROAD_BRIDGE},        // RTW_BUILD_BRIDGE
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   636
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,   219,   240,    14,    35, SPR_IMG_ROAD_TUNNEL,        STR_1810_BUILD_ROAD_TUNNEL},        // RTW_BUILD_TUNNEL
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   637
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,   241,   262,    14,    35, SPR_IMG_REMOVE,             STR_1811_TOGGLE_BUILD_REMOVE_FOR},  // RTW_REMOVE
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   638
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 5
diff changeset
   639
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   640
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   641
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   642
static const WindowDesc _build_road_desc = {
7906
d39b6db978ff (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 7904
diff changeset
   643
	WDP_ALIGN_TBR, 22, 263, 36, 263, 36,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5860
diff changeset
   644
	WC_BUILD_TOOLBAR, WC_NONE,
756
b76998029c12 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents: 679
diff changeset
   645
	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
   646
	_build_road_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   647
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   648
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   649
/** Widget definition of the build tram toolbar */
6691
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   650
static const Widget _build_tramway_widgets[] = {
9763
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   651
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_DARK_GREEN,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},                // RTW_CLOSEBOX
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   652
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_DARK_GREEN,    11,   228,     0,    13, STR_WHITE_TRAMWAY_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},      // RTW_CAPTION
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   653
{  WWT_STICKYBOX,   RESIZE_NONE,  COLOUR_DARK_GREEN,   229,   240,     0,    13, 0x0,                            STR_STICKY_BUTTON},                    // RTW_STICKY
6691
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   654
9763
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   655
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,     0,    21,    14,    35, SPR_IMG_TRAMWAY_X_DIR,          STR_BUILD_TRAMWAY_SECTION},            // RTW_ROAD_X
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   656
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,    22,    43,    14,    35, SPR_IMG_TRAMWAY_Y_DIR,          STR_BUILD_TRAMWAY_SECTION},            // RTW_ROAD_Y
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   657
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,    44,    65,    14,    35, SPR_IMG_AUTOTRAM,               STR_BUILD_AUTOTRAM_TIP},               // RTW_AUTOROAD
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   658
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,    66,    87,    14,    35, SPR_IMG_DYNAMITE,               STR_018D_DEMOLISH_BUILDINGS_ETC},      // RTW_DEMOLISH
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   659
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,    88,   109,    14,    35, SPR_IMG_ROAD_DEPOT,             STR_BUILD_TRAM_VEHICLE_DEPOT},         // RTW_DEPOT
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   660
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,   110,   131,    14,    35, SPR_IMG_BUS_STATION,            STR_BUILD_PASSENGER_TRAM_STATION},     // RTW_BUS_STATION
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   661
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,   132,   153,    14,    35, SPR_IMG_TRUCK_BAY,              STR_BUILD_CARGO_TRAM_STATION},         // RTW_TRUCK_STATION
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   662
{      WWT_EMPTY,   RESIZE_NONE,  COLOUR_DARK_GREEN,     0,     0,     0,     0, 0x0,                            STR_NULL},                             // RTW_ONE_WAY
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   663
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,   154,   196,    14,    35, SPR_IMG_BRIDGE,                 STR_BUILD_TRAMWAY_BRIDGE},             // RTW_BUILD_BRIDGE
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   664
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,   197,   218,    14,    35, SPR_IMG_ROAD_TUNNEL,            STR_BUILD_TRAMWAY_TUNNEL},             // RTW_BUILD_TUNNEL
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   665
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,   219,   240,    14,    35, SPR_IMG_REMOVE,                 STR_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS}, // RTW_REMOVE
7789
ffac1a901f54 (svn r11339) -Add: autoroad; same as autorail, but for road and trams and only on X and Y direction. Patch by Octopussy and skidd13.
rubidium
parents: 7729
diff changeset
   666
6691
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   667
{   WIDGETS_END},
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   668
};
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   669
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   670
static const WindowDesc _build_tramway_desc = {
7906
d39b6db978ff (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 7904
diff changeset
   671
	WDP_ALIGN_TBR, 22, 241, 36, 241, 36,
6691
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   672
	WC_BUILD_TOOLBAR, WC_NONE,
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   673
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   674
	_build_tramway_widgets,
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   675
};
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   676
6666
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
   677
void ShowBuildRoadToolbar(RoadType roadtype)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   678
{
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 9763
diff changeset
   679
	if (!IsValidCompanyID(_current_company)) return;
6666
41ceafa4c85e (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 6662
diff changeset
   680
	_cur_roadtype = roadtype;
5005
f5086bd3945a (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4938
diff changeset
   681
9080
34bc7cbbb79a (svn r12939) -Codechange: do not use the window proc to determine whether a toolbar is a rail toolbar, but use the window number.
rubidium
parents: 8973
diff changeset
   682
	DeleteWindowByClass(WC_BUILD_TOOLBAR);
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   683
	AllocateWindowDescFront<BuildRoadToolbarWindow>(roadtype == ROADTYPE_ROAD ? &_build_road_desc : &_build_tramway_desc, TRANSPORT_ROAD);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   684
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   685
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   686
/** Widget definition of the build road toolbar in the scenario editor */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   687
static const Widget _build_road_scen_widgets[] = {
9763
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   688
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_DARK_GREEN,     0,    10,     0,    13, STR_00C5,                   STR_018B_CLOSE_WINDOW},            // RTW_CLOSEBOX
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   689
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_DARK_GREEN,    11,   184,     0,    13, STR_1802_ROAD_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},  // RTW_CAPTION
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   690
{  WWT_STICKYBOX,   RESIZE_NONE,  COLOUR_DARK_GREEN,   185,   196,     0,    13, 0x0,                        STR_STICKY_BUTTON},                // RTW_STICKY
661
0d0a151aa4cd (svn r1095) -Fix: scenario editor road-build-gui works again altough shortcuts are screwed.
darkvater
parents: 651
diff changeset
   691
9763
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   692
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,     0,    21,    14,    35, SPR_IMG_ROAD_X_DIR,         STR_180B_BUILD_ROAD_SECTION},      // RTW_ROAD_X
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   693
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,    22,    43,    14,    35, SPR_IMG_ROAD_Y_DIR,         STR_180B_BUILD_ROAD_SECTION},      // RTW_ROAD_Y
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   694
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,    44,    65,    14,    35, SPR_IMG_AUTOROAD,           STR_BUILD_AUTOROAD_TIP},           // RTW_AUTOROAD
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   695
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,    66,    87,    14,    35, SPR_IMG_DYNAMITE,           STR_018D_DEMOLISH_BUILDINGS_ETC},  // RTW_DEMOLISH
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   696
{      WWT_EMPTY,   RESIZE_NONE,  COLOUR_DARK_GREEN,     0,     0,     0,     0, 0x0,                        STR_NULL},                         // RTW_DEPOT
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   697
{      WWT_EMPTY,   RESIZE_NONE,  COLOUR_DARK_GREEN,     0,     0,     0,     0, 0x0,                        STR_NULL},                         // RTW_BUS_STATION
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   698
{      WWT_EMPTY,   RESIZE_NONE,  COLOUR_DARK_GREEN,     0,     0,     0,     0, 0x0,                        STR_NULL},                         // RTW_TRUCK_STATION
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   699
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,    88,   109,    14,    35, SPR_IMG_ROAD_ONE_WAY,       STR_TOGGLE_ONE_WAY_ROAD},          // RTW_ONE_WAY
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   700
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,   110,   152,    14,    35, SPR_IMG_BRIDGE,             STR_180F_BUILD_ROAD_BRIDGE},       // RTW_BUILD_BRIDGE
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   701
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,   153,   174,    14,    35, SPR_IMG_ROAD_TUNNEL,        STR_1810_BUILD_ROAD_TUNNEL},       // RTW_BUILD_TUNNEL
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   702
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,   175,   196,    14,    35, SPR_IMG_REMOVE,             STR_1811_TOGGLE_BUILD_REMOVE_FOR}, // RTW_REMOVE
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 5
diff changeset
   703
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   704
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   705
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   706
static const WindowDesc _build_road_scen_desc = {
7906
d39b6db978ff (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 7904
diff changeset
   707
	WDP_AUTO, WDP_AUTO, 197, 36, 197, 36,
9588
620c97d8cee4 (svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents: 9413
diff changeset
   708
	WC_SCEN_BUILD_TOOLBAR, WC_NONE,
777
95dc447f24e3 (svn r1243) -Fix: Scenario road-building toolbar also stickified. Thx for the notice teeone
darkvater
parents: 756
diff changeset
   709
	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
   710
	_build_road_scen_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   711
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   712
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6102
diff changeset
   713
void ShowBuildRoadScenToolbar()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   714
{
6779
2efcd25812d9 (svn r10015) -Fix: one could build (only) tram tracks when that was the last built roadtype (in a normal game).
rubidium
parents: 6764
diff changeset
   715
	_cur_roadtype = ROADTYPE_ROAD;
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   716
	AllocateWindowDescFront<BuildRoadToolbarWindow>(&_build_road_scen_desc, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   717
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   718
9278
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   719
struct BuildRoadDepotWindow : public PickerWindowBase {
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   720
private:
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   721
	/** Enum referring to the widgets of the build road depot window */
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   722
	enum BuildRoadDepotWidgets {
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   723
		BRDW_CLOSEBOX = 0,
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   724
		BRDW_CAPTION,
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   725
		BRDW_BACKGROUND,
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   726
		BRDW_DEPOT_NE,
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   727
		BRDW_DEPOT_SE,
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   728
		BRDW_DEPOT_SW,
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   729
		BRDW_DEPOT_NW,
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   730
	};
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   731
9278
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   732
public:
9338
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
   733
	BuildRoadDepotWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
9278
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   734
	{
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   735
		this->LowerWidget(_road_depot_orientation + BRDW_DEPOT_NE);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   736
		if ( _cur_roadtype == ROADTYPE_TRAM) {
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   737
			this->widget[BRDW_CAPTION].data = STR_TRAM_DEPOT_ORIENTATION;
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   738
			for (int i = BRDW_DEPOT_NE; i <= BRDW_DEPOT_NW; i++) this->widget[i].tooltips = STR_SELECT_TRAM_VEHICLE_DEPOT;
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   739
		}
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   740
		this->FindWindowPlacementAndResize(desc);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   741
	}
1072
74cd9150d473 (svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents: 1035
diff changeset
   742
9278
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   743
	virtual void OnPaint()
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   744
	{
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   745
		this->DrawWidgets();
8821
1411d08e26b3 (svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz
parents: 8785
diff changeset
   746
9278
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   747
		DrawRoadDepotSprite(70, 17, DIAGDIR_NE, _cur_roadtype);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   748
		DrawRoadDepotSprite(70, 69, DIAGDIR_SE, _cur_roadtype);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   749
		DrawRoadDepotSprite( 2, 69, DIAGDIR_SW, _cur_roadtype);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   750
		DrawRoadDepotSprite( 2, 17, DIAGDIR_NW, _cur_roadtype);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   751
	}
8821
1411d08e26b3 (svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz
parents: 8785
diff changeset
   752
9278
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   753
	virtual void OnClick(Point pt, int widget)
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   754
	{
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   755
		switch (widget) {
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   756
			case BRDW_DEPOT_NW:
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   757
			case BRDW_DEPOT_NE:
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   758
			case BRDW_DEPOT_SW:
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   759
			case BRDW_DEPOT_SE:
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   760
				this->RaiseWidget(_road_depot_orientation + BRDW_DEPOT_NE);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   761
				_road_depot_orientation = (DiagDirection)(widget - BRDW_DEPOT_NE);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   762
				this->LowerWidget(_road_depot_orientation + BRDW_DEPOT_NE);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   763
				SndPlayFx(SND_15_BEEP);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   764
				this->SetDirty();
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   765
				break;
8821
1411d08e26b3 (svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz
parents: 8785
diff changeset
   766
9278
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   767
			default:
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   768
				break;
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   769
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   770
	}
9278
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   771
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   772
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   773
/** Widget definition of the build road depot window */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   774
static const Widget _build_road_depot_widgets[] = {
9763
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   775
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_DARK_GREEN,    0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},              // BRDW_CLOSEBOX
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   776
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_DARK_GREEN,   11,   139,     0,    13, STR_1806_ROAD_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS},    // BRDW_CAPTION
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   777
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_DARK_GREEN,    0,   139,    14,   121, 0x0,                             STR_NULL},                           // BRDW_BACKGROUND
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   778
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,         71,   136,    17,    66, 0x0,                             STR_1813_SELECT_ROAD_VEHICLE_DEPOT}, // BRDW_DEPOT_NE
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   779
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,         71,   136,    69,   118, 0x0,                             STR_1813_SELECT_ROAD_VEHICLE_DEPOT}, // BRDW_DEPOT_SE
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   780
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,          3,    68,    69,   118, 0x0,                             STR_1813_SELECT_ROAD_VEHICLE_DEPOT}, // BRDW_DEPOT_SW
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   781
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,          3,    68,    17,    66, 0x0,                             STR_1813_SELECT_ROAD_VEHICLE_DEPOT}, // BRDW_DEPOT_NW
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 5
diff changeset
   782
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   783
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   784
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   785
static const WindowDesc _build_road_depot_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7339
diff changeset
   786
	WDP_AUTO, WDP_AUTO, 140, 122, 140, 122,
5070
7f5b13b7e728 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 5005
diff changeset
   787
	WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   788
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   789
	_build_road_depot_widgets,
6691
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   790
};
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6678
diff changeset
   791
9338
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
   792
static void ShowRoadDepotPicker(Window *parent)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   793
{
9338
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
   794
	new BuildRoadDepotWindow(&_build_road_depot_desc, parent);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   795
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   796
9278
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   797
struct BuildRoadStationWindow : public PickerWindowBase {
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   798
private:
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   799
	/** Enum referring to the widgets of the build road station window */
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   800
	enum BuildRoadStationWidgets {
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   801
		BRSW_CLOSEBOX = 0,
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   802
		BRSW_CAPTION,
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   803
		BRSW_BACKGROUND,
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   804
		BRSW_STATION_NE,
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   805
		BRSW_STATION_SE,
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   806
		BRSW_STATION_SW,
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   807
		BRSW_STATION_NW,
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   808
		BRSW_STATION_X,
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   809
		BRSW_STATION_Y,
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   810
		BRSW_LT_OFF,
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   811
		BRSW_LT_ON,
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   812
		BRSW_INFO,
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   813
	};
8821
1411d08e26b3 (svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz
parents: 8785
diff changeset
   814
9278
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   815
public:
9338
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
   816
	BuildRoadStationWindow(const WindowDesc *desc, Window *parent, RoadStopType rs) : PickerWindowBase(desc, parent)
9278
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   817
	{
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   818
		/* Trams don't have non-drivethrough stations */
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   819
		if (_cur_roadtype == ROADTYPE_TRAM && _road_station_picker_orientation < DIAGDIR_END) {
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   820
			_road_station_picker_orientation = DIAGDIR_END;
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   821
		}
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   822
		this->SetWidgetsDisabledState(_cur_roadtype == ROADTYPE_TRAM,
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   823
			BRSW_STATION_NE,
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   824
			BRSW_STATION_SE,
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   825
			BRSW_STATION_SW,
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   826
			BRSW_STATION_NW,
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   827
			WIDGET_LIST_END);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   828
9278
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   829
		this->window_class = (rs == ROADSTOP_BUS) ? WC_BUS_STATION : WC_TRUCK_STATION;
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   830
		this->widget[BRSW_CAPTION].data = _road_type_infos[_cur_roadtype].picker_title[rs];
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   831
		for (uint i = BRSW_STATION_NE; i < BRSW_LT_OFF; i++) this->widget[i].tooltips = _road_type_infos[_cur_roadtype].picker_tooltip[rs];
1109
ecb98f43ba2c (svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents: 1093
diff changeset
   832
9278
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   833
		this->LowerWidget(_road_station_picker_orientation + BRSW_STATION_NE);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   834
		this->LowerWidget(_station_show_coverage + BRSW_LT_OFF);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   835
		this->FindWindowPlacementAndResize(desc);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   836
	}
8821
1411d08e26b3 (svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz
parents: 8785
diff changeset
   837
9278
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   838
	virtual void OnPaint()
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   839
	{
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   840
		this->DrawWidgets();
8821
1411d08e26b3 (svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz
parents: 8785
diff changeset
   841
9278
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   842
		if (_station_show_coverage) {
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9354
diff changeset
   843
			int rad = _settings_game.station.modified_catchment ? CA_TRUCK /* = CA_BUS */ : CA_UNMODIFIED;
9278
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   844
			SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   845
		} else {
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   846
			SetTileSelectSize(1, 1);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   847
		}
8821
1411d08e26b3 (svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz
parents: 8785
diff changeset
   848
9278
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   849
		StationType st = (this->window_class == WC_BUS_STATION) ? STATION_BUS : STATION_TRUCK;
8821
1411d08e26b3 (svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz
parents: 8785
diff changeset
   850
9278
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   851
		StationPickerDrawSprite(103, 35, st, INVALID_RAILTYPE, ROADTYPE_ROAD, 0);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   852
		StationPickerDrawSprite(103, 85, st, INVALID_RAILTYPE, ROADTYPE_ROAD, 1);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   853
		StationPickerDrawSprite( 35, 85, st, INVALID_RAILTYPE, ROADTYPE_ROAD, 2);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   854
		StationPickerDrawSprite( 35, 35, st, INVALID_RAILTYPE, ROADTYPE_ROAD, 3);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   855
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   856
		StationPickerDrawSprite(171, 35, st, INVALID_RAILTYPE, _cur_roadtype, 4);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   857
		StationPickerDrawSprite(171, 85, st, INVALID_RAILTYPE, _cur_roadtype, 5);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   858
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   859
		int text_end = DrawStationCoverageAreaText(2, 146,
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   860
			(this->window_class == WC_BUS_STATION) ? SCT_PASSENGERS_ONLY : SCT_NON_PASSENGERS_ONLY,
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   861
			3, false);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   862
		text_end = DrawStationCoverageAreaText(2, text_end + 4,
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   863
			(this->window_class == WC_BUS_STATION) ? SCT_PASSENGERS_ONLY : SCT_NON_PASSENGERS_ONLY,
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   864
			3, true) + 4;
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   865
		if (text_end > this->widget[BRSW_BACKGROUND].bottom) {
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   866
			this->SetDirty();
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   867
			ResizeWindowForWidget(this, BRSW_BACKGROUND, 0, text_end - this->widget[BRSW_BACKGROUND].bottom);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   868
			this->SetDirty();
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   869
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   870
	}
9278
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   871
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   872
	virtual void OnClick(Point pt, int widget)
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   873
	{
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   874
		switch (widget) {
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   875
			case BRSW_STATION_NE:
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   876
			case BRSW_STATION_SE:
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   877
			case BRSW_STATION_SW:
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   878
			case BRSW_STATION_NW:
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   879
			case BRSW_STATION_X:
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   880
			case BRSW_STATION_Y:
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   881
				this->RaiseWidget(_road_station_picker_orientation + BRSW_STATION_NE);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   882
				_road_station_picker_orientation = (DiagDirection)(widget - BRSW_STATION_NE);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   883
				this->LowerWidget(_road_station_picker_orientation + BRSW_STATION_NE);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   884
				SndPlayFx(SND_15_BEEP);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   885
				this->SetDirty();
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   886
				break;
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   887
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   888
			case BRSW_LT_OFF:
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   889
			case BRSW_LT_ON:
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   890
				this->RaiseWidget(_station_show_coverage + BRSW_LT_OFF);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   891
				_station_show_coverage = (widget != BRSW_LT_OFF);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   892
				this->LowerWidget(_station_show_coverage + BRSW_LT_OFF);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   893
				SndPlayFx(SND_15_BEEP);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   894
				this->SetDirty();
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   895
				break;
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   896
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   897
			default:
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   898
				break;
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   899
		}
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   900
	}
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   901
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   902
	virtual void OnTick()
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   903
	{
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   904
		CheckRedrawStationCoverage(this);
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   905
	}
b81f5b869a90 (svn r13144) -Codechange: make classes of the BuildRoad[Depot|Station]Window.
glx
parents: 9273
diff changeset
   906
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   907
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   908
/** Widget definition of the build raod station window */
6693
00bef74e4d3a (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 6691
diff changeset
   909
static const Widget _rv_station_picker_widgets[] = {
9763
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   910
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_DARK_GREEN,   0,    10,     0,    13, STR_00C5,                         STR_018B_CLOSE_WINDOW},             // BRSW_CLOSEBOX
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   911
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_DARK_GREEN,  11,   206,     0,    13, STR_NULL,                         STR_018C_WINDOW_TITLE_DRAG_THIS},   // BRSW_CAPTION
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   912
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_DARK_GREEN,   0,   206,    14,   176, 0x0,                              STR_NULL},                          // BRSW_BACKGROUND
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   913
9763
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   914
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,        71,   136,    17,    66, 0x0,                              STR_NULL},                          // BRSW_STATION_NE
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   915
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,        71,   136,    69,   118, 0x0,                              STR_NULL},                          // BRSW_STATION_SE
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   916
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,         3,    68,    69,   118, 0x0,                              STR_NULL},                          // BRSW_STATION_SW
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   917
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,         3,    68,    17,    66, 0x0,                              STR_NULL},                          // BRSW_STATION_NW
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   918
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,       139,   204,    17,    66, 0x0,                              STR_NULL},                          // BRSW_STATION_X
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   919
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,       139,   204,    69,   118, 0x0,                              STR_NULL},                          // BRSW_STATION_Y
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   920
9763
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   921
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        10,    69,   133,   144, STR_02DB_OFF,                     STR_3065_DON_T_HIGHLIGHT_COVERAGE}, // BRSW_LT_OFF
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   922
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        70,   129,   133,   144, STR_02DA_ON,                      STR_3064_HIGHLIGHT_COVERAGE_AREA},  // BRSW_LT_ON
bd4f733cd758 (svn r13899) -Codechange: Replace numbers with Colours enum on roads gui.
belugas
parents: 9659
diff changeset
   923
{      WWT_LABEL,   RESIZE_NONE,  COLOUR_DARK_GREEN,   0,   139,   120,   133, STR_3066_COVERAGE_AREA_HIGHLIGHT, STR_NULL},                          // BRSW_INFO
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 5
diff changeset
   924
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   925
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   926
6693
00bef74e4d3a (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 6691
diff changeset
   927
static const WindowDesc _rv_station_picker_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7339
diff changeset
   928
	WDP_AUTO, WDP_AUTO, 207, 177, 207, 177,
5070
7f5b13b7e728 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 5005
diff changeset
   929
	WC_BUS_STATION, WC_BUILD_TOOLBAR,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   930
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
6693
00bef74e4d3a (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 6691
diff changeset
   931
	_rv_station_picker_widgets,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   932
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   933
9338
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
   934
static void ShowRVStationPicker(Window *parent, RoadStopType rs)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   935
{
9338
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
   936
	new BuildRoadStationWindow(&_rv_station_picker_desc, parent, rs);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   937
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   938
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6102
diff changeset
   939
void InitializeRoadGui()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   940
{
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   941
	_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
   942
	_road_station_picker_orientation = DIAGDIR_NW;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   943
}