src/road_gui.cpp
author rubidium
Sun, 01 Jun 2008 16:45:32 +0000
branch0.6
changeset 10801 3ad9dfb5430d
parent 9188 2c86cddd8bb8
child 9281 d8cd9ac52a68
permissions -rw-r--r--
(svn r13352) [0.6] -Backport from trunk (r13348, r13222, r13221, r13217):
- Fix: Industry tiles would sometimes tell they need a 'level' slope when they do not want the slope (r13348)
- Fix: Attempts to make the old AI perform better (r13217, r13221, r13222)
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
6889
f7f6d9cb07a0 (svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas
parents: 6573
diff changeset
     3
/** @file road_gui.cpp */
f7f6d9cb07a0 (svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas
parents: 6573
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
92a3b0aa0946 (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"
8603
88c5ce6a5215 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8602
diff changeset
     8
#include "window_gui.h"
88c5ce6a5215 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8602
diff changeset
     9
#include "station_gui.h"
8701
051036216675 (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: 8662
diff changeset
    10
#include "terraform_gui.h"
8720
4e60c30e2006 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8719
diff changeset
    11
#include "viewport_func.h"
4e60c30e2006 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8719
diff changeset
    12
#include "gfx_func.h"
8612
6414fc21c2f3 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8610
diff changeset
    13
#include "command_func.h"
2159
3b634157c3b2 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2049
diff changeset
    14
#include "variables.h"
8719
c13af43ef987 (svn r11786) -Codechange: shuffle more includes
peter1138
parents: 8701
diff changeset
    15
#include "road_type.h"
7162
b769c2b45103 (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 7158
diff changeset
    16
#include "road_cmd.h"
b769c2b45103 (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 7158
diff changeset
    17
#include "road_map.h"
6338
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6144
diff changeset
    18
#include "station_map.h"
568
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 543
diff changeset
    19
#include "station.h"
8627
448ebf3a8291 (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: 8617
diff changeset
    20
#include "functions.h"
448ebf3a8291 (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: 8617
diff changeset
    21
#include "window_func.h"
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8635
diff changeset
    22
#include "vehicle_func.h"
8653
a83f7a536919 (svn r11719) -Codechange: split sound.h in a header with types and one with functions.
rubidium
parents: 8640
diff changeset
    23
#include "sound_func.h"
8750
fdd6054e7bae (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8733
diff changeset
    24
#include "player_func.h"
8766
c86cfa3a7580 (svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents: 8760
diff changeset
    25
#include "settings_type.h"
568
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 543
diff changeset
    26
8760
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8750
diff changeset
    27
#include "table/sprites.h"
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8750
diff changeset
    28
#include "table/strings.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    29
7189
38df4f4e68ef (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 7187
diff changeset
    30
static void ShowRVStationPicker(RoadStop::Type rs);
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6428
diff changeset
    31
static void ShowRoadDepotPicker();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    32
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    33
static bool _remove_button_clicked;
8402
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
    34
static bool _one_way_button_clicked;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    35
8285
1f026f023f27 (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: 8225
diff changeset
    36
/**
1f026f023f27 (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: 8225
diff changeset
    37
 * Define the values of the RoadFlags
1f026f023f27 (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: 8225
diff changeset
    38
 * @see CmdBuildLongRoad
1f026f023f27 (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: 8225
diff changeset
    39
 */
1f026f023f27 (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: 8225
diff changeset
    40
enum RoadFlags {
1f026f023f27 (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: 8225
diff changeset
    41
	RF_NONE             = 0x00,
8290
2d3d2f515439 (svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
belugas
parents: 8285
diff changeset
    42
	RF_START_HALFROAD_Y = 0x01,    // The start tile in Y-dir should have only a half road
2d3d2f515439 (svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
belugas
parents: 8285
diff changeset
    43
	RF_END_HALFROAD_Y   = 0x02,    // The end tile in Y-dir should have only a half road
8285
1f026f023f27 (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: 8225
diff changeset
    44
	RF_DIR_Y            = 0x04,    // The direction is Y-dir
1f026f023f27 (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: 8225
diff changeset
    45
	RF_DIR_X            = RF_NONE, // Dummy; Dir X is set when RF_DIR_Y is not set
8290
2d3d2f515439 (svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
belugas
parents: 8285
diff changeset
    46
	RF_START_HALFROAD_X = 0x08,    // The start tile in X-dir should have only a half road
2d3d2f515439 (svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
belugas
parents: 8285
diff changeset
    47
	RF_END_HALFROAD_X   = 0x10,    // The end tile in X-dir should have only a half road
8285
1f026f023f27 (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: 8225
diff changeset
    48
};
1f026f023f27 (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: 8225
diff changeset
    49
DECLARE_ENUM_AS_BIT_SET(RoadFlags);
1f026f023f27 (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: 8225
diff changeset
    50
1f026f023f27 (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: 8225
diff changeset
    51
static RoadFlags _place_road_flag;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    52
7162
b769c2b45103 (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 7158
diff changeset
    53
static RoadType _cur_roadtype;
b769c2b45103 (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 7158
diff changeset
    54
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
    55
static DiagDirection _road_depot_orientation;
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
    56
static DiagDirection _road_station_picker_orientation;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    58
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
    59
{
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 514
diff changeset
    60
	if (success) SndPlayTileFx(SND_1F_SPLAT, tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    61
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    62
8285
1f026f023f27 (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: 8225
diff changeset
    63
/**
1f026f023f27 (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: 8225
diff changeset
    64
 * Set the initial flags for the road constuction.
1f026f023f27 (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: 8225
diff changeset
    65
 * The flags are:
8391
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
    66
 * @li The direction is the X-dir
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
    67
 * @li The first tile has a partitial RoadBit (true or false)
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
    68
 *
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
    69
 * @param tile The start tile
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
    70
 */
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
    71
static void PlaceRoad_X_Dir(TileIndex tile)
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
    72
{
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
    73
	_place_road_flag = RF_DIR_X;
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
    74
	if (_tile_fract_coords.x >= 8) _place_road_flag |= RF_START_HALFROAD_X;
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
    75
	VpStartPlaceSizing(tile, VPM_FIX_Y, DDSP_PLACE_ROAD_X_DIR);
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
    76
}
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
    77
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
    78
/**
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
    79
 * Set the initial flags for the road constuction.
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
    80
 * The flags are:
8285
1f026f023f27 (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: 8225
diff changeset
    81
 * @li The direction is the Y-dir
1f026f023f27 (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: 8225
diff changeset
    82
 * @li The first tile has a partitial RoadBit (true or false)
1f026f023f27 (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: 8225
diff changeset
    83
 *
1f026f023f27 (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: 8225
diff changeset
    84
 * @param tile The start tile
1f026f023f27 (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: 8225
diff changeset
    85
 */
8391
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
    86
static void PlaceRoad_Y_Dir(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    87
{
8285
1f026f023f27 (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: 8225
diff changeset
    88
	_place_road_flag = RF_DIR_Y;
1f026f023f27 (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: 8225
diff changeset
    89
	if (_tile_fract_coords.y >= 8) _place_road_flag |= RF_START_HALFROAD_Y;
8391
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
    90
	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
    91
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
8285
1f026f023f27 (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: 8225
diff changeset
    93
/**
1f026f023f27 (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: 8225
diff changeset
    94
 * Set the initial flags for the road constuction.
1f026f023f27 (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: 8225
diff changeset
    95
 * The flags are:
1f026f023f27 (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: 8225
diff changeset
    96
 * @li The direction is not set.
1f026f023f27 (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: 8225
diff changeset
    97
 * @li The first tile has a partitial RoadBit (true or false)
1f026f023f27 (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: 8225
diff changeset
    98
 *
1f026f023f27 (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: 8225
diff changeset
    99
 * @param tile The start tile
1f026f023f27 (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: 8225
diff changeset
   100
 */
1f026f023f27 (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: 8225
diff changeset
   101
static void PlaceRoad_AutoRoad(TileIndex tile)
1f026f023f27 (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: 8225
diff changeset
   102
{
1f026f023f27 (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: 8225
diff changeset
   103
	_place_road_flag = RF_NONE;
1f026f023f27 (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: 8225
diff changeset
   104
	if (_tile_fract_coords.x >= 8) _place_road_flag |= RF_START_HALFROAD_X;
1f026f023f27 (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: 8225
diff changeset
   105
	if (_tile_fract_coords.y >= 8) _place_road_flag |= RF_START_HALFROAD_Y;
1f026f023f27 (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: 8225
diff changeset
   106
	VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_PLACE_AUTOROAD);
1f026f023f27 (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: 8225
diff changeset
   107
}
1f026f023f27 (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: 8225
diff changeset
   108
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   109
static void PlaceRoad_Bridge(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   110
{
7166
3937d5ea59df (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 7165
diff changeset
   111
	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
   112
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   113
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   114
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   115
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
   116
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   117
	if (success) {
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 514
diff changeset
   118
		SndPlayTileFx(SND_20_SPLAT_2, tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
		ResetObjectToPlace();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   120
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
		SetRedErrorSquare(_build_tunnel_endtile);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   122
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   123
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   124
7172
40781792e25f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 7170
diff changeset
   125
/** Structure holding information per roadtype for several functions */
40781792e25f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 7170
diff changeset
   126
struct RoadTypeInfo {
40781792e25f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 7170
diff changeset
   127
	StringID err_build_road;        ///< Building a normal piece of road
40781792e25f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 7170
diff changeset
   128
	StringID err_remove_road;       ///< Removing a normal piece of road
40781792e25f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 7170
diff changeset
   129
	StringID err_depot;             ///< Building a depot
40781792e25f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 7170
diff changeset
   130
	StringID err_build_station[2];  ///< Building a bus or truck station
40781792e25f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 7170
diff changeset
   131
	StringID err_remove_station[2]; ///< Removing of a bus or truck station
40781792e25f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 7170
diff changeset
   132
7189
38df4f4e68ef (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 7187
diff changeset
   133
	StringID picker_title[2];       ///< Title for the station picker for bus or truck stations
38df4f4e68ef (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 7187
diff changeset
   134
	StringID picker_tooltip[2];     ///< Tooltip for the station picker for bus or truck stations
38df4f4e68ef (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 7187
diff changeset
   135
7172
40781792e25f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 7170
diff changeset
   136
	SpriteID cursor_nesw;           ///< Cursor for building NE and SW bits
40781792e25f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 7170
diff changeset
   137
	SpriteID cursor_nwse;           ///< Cursor for building NW and SE bits
8285
1f026f023f27 (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: 8225
diff changeset
   138
	SpriteID cursor_autoroad;       ///< Cursor for building autoroad
7172
40781792e25f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 7170
diff changeset
   139
};
40781792e25f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 7170
diff changeset
   140
40781792e25f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 7170
diff changeset
   141
/** What errors/cursors must be shown for several types of roads */
40781792e25f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 7170
diff changeset
   142
static const RoadTypeInfo _road_type_infos[] = {
40781792e25f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 7170
diff changeset
   143
	{
40781792e25f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 7170
diff changeset
   144
		STR_1804_CAN_T_BUILD_ROAD_HERE,
40781792e25f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 7170
diff changeset
   145
		STR_1805_CAN_T_REMOVE_ROAD_FROM,
40781792e25f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 7170
diff changeset
   146
		STR_1807_CAN_T_BUILD_ROAD_VEHICLE,
7189
38df4f4e68ef (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 7187
diff changeset
   147
		{ STR_1808_CAN_T_BUILD_BUS_STATION,        STR_1809_CAN_T_BUILD_TRUCK_STATION },
38df4f4e68ef (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 7187
diff changeset
   148
		{ STR_CAN_T_REMOVE_BUS_STATION,            STR_CAN_T_REMOVE_TRUCK_STATION     },
38df4f4e68ef (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 7187
diff changeset
   149
		{ STR_3042_BUS_STATION_ORIENTATION,        STR_3043_TRUCK_STATION_ORIENT      },
38df4f4e68ef (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 7187
diff changeset
   150
		{ STR_3051_SELECT_BUS_STATION_ORIENTATION, STR_3052_SELECT_TRUCK_LOADING_BAY  },
7172
40781792e25f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 7170
diff changeset
   151
40781792e25f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 7170
diff changeset
   152
		SPR_CURSOR_ROAD_NESW,
40781792e25f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 7170
diff changeset
   153
		SPR_CURSOR_ROAD_NWSE,
8285
1f026f023f27 (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: 8225
diff changeset
   154
		SPR_CURSOR_AUTOROAD,
7172
40781792e25f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 7170
diff changeset
   155
	},
7187
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7174
diff changeset
   156
	{
8920
04df97185061 (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: 8919
diff changeset
   157
		STR_CAN_T_BUILD_TRAMWAY_HERE,
04df97185061 (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: 8919
diff changeset
   158
		STR_CAN_T_REMOVE_TRAMWAY_FROM,
04df97185061 (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: 8919
diff changeset
   159
		STR_CAN_T_BUILD_TRAM_VEHICLE,
04df97185061 (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: 8919
diff changeset
   160
		{ STR_CAN_T_BUILD_PASSENGER_TRAM_STATION,        STR_CAN_T_BUILD_CARGO_TRAM_STATION        },
04df97185061 (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: 8919
diff changeset
   161
		{ STR_CAN_T_REMOVE_PASSENGER_TRAM_STATION,       STR_CAN_T_REMOVE_CARGO_TRAM_STATION       },
04df97185061 (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: 8919
diff changeset
   162
		{ STR_PASSENGER_TRAM_STATION_ORIENTATION,        STR_CARGO_TRAM_STATION_ORIENT             },
04df97185061 (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: 8919
diff changeset
   163
		{ STR_SELECT_PASSENGER_TRAM_STATION_ORIENTATION, STR_SELECT_CARGO_TRAM_STATION_ORIENTATION },
7187
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7174
diff changeset
   164
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7174
diff changeset
   165
		SPR_CURSOR_TRAMWAY_NESW,
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7174
diff changeset
   166
		SPR_CURSOR_TRAMWAY_NWSE,
8285
1f026f023f27 (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: 8225
diff changeset
   167
		SPR_CURSOR_AUTOTRAM,
7187
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7174
diff changeset
   168
	},
7172
40781792e25f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 7170
diff changeset
   169
};
40781792e25f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 7170
diff changeset
   170
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   171
static void PlaceRoad_Tunnel(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   172
{
8017
8c46e61c510f (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7866
diff changeset
   173
	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
   174
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   175
3151
78f09b2c72c5 (svn r3774) Remove some more magic numbers and types
tron
parents: 3150
diff changeset
   176
static void BuildRoadOutsideStation(TileIndex tile, DiagDirection direction)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   177
{
4559
c853d2440065 (svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents: 4435
diff changeset
   178
	tile += TileOffsByDiagDir(direction);
5
539c9743d999 (svn r6) -Fix [1006530] BuildRoadOutsideStation fix. Fix bug [994720] road depot - bus/lorry station (Truelight+Darkvater :P )
darkvater
parents: 0
diff changeset
   179
	// if there is a roadpiece just outside of the station entrance, build a connecting route
9059
04edde3eb0c6 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch
parents: 9053
diff changeset
   180
	if (IsNormalRoadTile(tile)) {
7162
b769c2b45103 (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 7158
diff changeset
   181
		if (GetRoadBits(tile, _cur_roadtype) != ROAD_NONE) {
b769c2b45103 (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 7158
diff changeset
   182
			DoCommandP(tile, _cur_roadtype << 4 | DiagDirToRoadBits(ReverseDiagDir(direction)), 0, NULL, CMD_BUILD_ROAD);
b769c2b45103 (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 7158
diff changeset
   183
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   184
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   185
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   186
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   187
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
   188
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   189
	if (success) {
7158
ffb31324aa5e (svn r9893) -Fix (r9892): various small bugs that only act up when using something different than plain roads.
rubidium
parents: 7157
diff changeset
   190
		DiagDirection dir = (DiagDirection)GB(p1, 0, 2);
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 514
diff changeset
   191
		SndPlayTileFx(SND_1F_SPLAT, tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   192
		ResetObjectToPlace();
7158
ffb31324aa5e (svn r9893) -Fix (r9892): various small bugs that only act up when using something different than plain roads.
rubidium
parents: 7157
diff changeset
   193
		BuildRoadOutsideStation(tile, dir);
6428
f018110cdd9a (svn r8837) -Fix [FS#626]: drive through stations did not connect to neighbouring roads (mart3p).
rubidium
parents: 6365
diff changeset
   194
		/* For a drive-through road stop build connecting road for other entrance */
8424
4a488a90ccab (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 8409
diff changeset
   195
		if (HasBit(p2, 1)) BuildRoadOutsideStation(tile, ReverseDiagDir(dir));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   196
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   197
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   198
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   199
static void PlaceRoad_Depot(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   200
{
8017
8c46e61c510f (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7866
diff changeset
   201
	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
   202
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   203
6338
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6144
diff changeset
   204
static void PlaceRoadStop(TileIndex tile, uint32 p2, uint32 cmd)
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6144
diff changeset
   205
{
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6144
diff changeset
   206
	uint32 p1 = _road_station_picker_orientation;
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6144
diff changeset
   207
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6144
diff changeset
   208
	if (p1 >= DIAGDIR_END) {
8427
143b0be22af1 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 8424
diff changeset
   209
		SetBit(p2, 1); // It's a drive-through stop
6338
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6144
diff changeset
   210
		p1 -= DIAGDIR_END; // Adjust picker result to actual direction
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6144
diff changeset
   211
	}
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6144
diff changeset
   212
	DoCommandP(tile, p1, p2, CcRoadDepot, cmd);
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6144
diff changeset
   213
}
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6144
diff changeset
   214
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   215
static void PlaceRoad_BusStation(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   216
{
8452
93186e0f15cb (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: 8445
diff changeset
   217
	if (_remove_button_clicked) {
7172
40781792e25f (svn r9907) -Codechange: prepare the road gui for more road types.
rubidium
parents: 7170
diff changeset
   218
		DoCommandP(tile, 0, RoadStop::BUS, CcPlaySound1D, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[RoadStop::BUS]));
6338
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6144
diff changeset
   219
	} else {
8017
8c46e61c510f (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7866
diff changeset
   220
		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]));
6338
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6144
diff changeset
   221
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   222
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   223
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   224
static void PlaceRoad_TruckStation(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   225
{
8452
93186e0f15cb (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: 8445
diff changeset
   226
	if (_remove_button_clicked) {
7835
1178f1162f77 (svn r10702) -Fix: "Can't build ..." instead of "Can't remove ..." message shown for road stops for trucks/cargo trams.
rubidium
parents: 7768
diff changeset
   227
		DoCommandP(tile, 0, RoadStop::TRUCK, CcPlaySound1D, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[RoadStop::TRUCK]));
6338
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6144
diff changeset
   228
	} else {
8017
8c46e61c510f (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7866
diff changeset
   229
		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]));
6338
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6144
diff changeset
   230
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   231
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   232
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   233
static void PlaceRoad_DemolishArea(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   234
{
7166
3937d5ea59df (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 7165
diff changeset
   235
	VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_DEMOLISH_AREA);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   236
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   237
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   238
/** Enum referring to the widgets of the build road toolbar */
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   239
enum RoadToolbarWidgets {
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   240
	RTW_CLOSEBOX = 0,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   241
	RTW_CAPTION,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   242
	RTW_STICKY,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   243
	RTW_ROAD_X,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   244
	RTW_ROAD_Y,
8285
1f026f023f27 (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: 8225
diff changeset
   245
	RTW_AUTOROAD,
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   246
	RTW_DEMOLISH,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   247
	RTW_DEPOT,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   248
	RTW_BUS_STATION,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   249
	RTW_TRUCK_STATION,
8402
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   250
	RTW_ONE_WAY,
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   251
	RTW_BUILD_BRIDGE,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   252
	RTW_BUILD_TUNNEL,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   253
	RTW_REMOVE,
5147
db717cde801d (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   254
};
db717cde801d (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5105
diff changeset
   255
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   256
typedef void OnButtonClick(Window *w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   257
9082
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   258
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   259
/** Toogles state of the Remove button of Build road toolbar
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   260
 * @param w window the button belongs to
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   261
 */
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   262
static void ToggleRoadButton_Remove(Window *w)
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   263
{
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   264
	w->ToggleWidgetLoweredState(RTW_REMOVE);
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   265
	w->InvalidateWidget(RTW_REMOVE);
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   266
	_remove_button_clicked = w->IsWidgetLowered(RTW_REMOVE);
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   267
	SetSelectionRed(_remove_button_clicked);
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   268
}
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   269
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   270
/** Updates the Remove button because of Ctrl state change
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   271
 * @param w window the button belongs to
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   272
 * @return true iff the remove buton was changed
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   273
 */
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   274
static bool RoadToolbar_CtrlChanged(Window *w)
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   275
{
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   276
	if (w->IsWidgetDisabled(RTW_REMOVE)) return false;
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   277
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   278
	/* allow ctrl to switch remove mode only for these widgets */
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   279
	for (uint i = RTW_ROAD_X; i <= RTW_AUTOROAD; i++) {
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   280
		if (w->IsWidgetLowered(i)) {
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   281
			ToggleRoadButton_Remove(w);
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   282
			return true;
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   283
		}
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   284
	}
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   285
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   286
	return false;
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   287
}
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   288
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   289
8285
1f026f023f27 (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: 8225
diff changeset
   290
/**
1f026f023f27 (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: 8225
diff changeset
   291
 * Function that handles the click on the
1f026f023f27 (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: 8225
diff changeset
   292
 *  X road placement button.
1f026f023f27 (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: 8225
diff changeset
   293
 *
1f026f023f27 (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: 8225
diff changeset
   294
 * @param w The current window
1f026f023f27 (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: 8225
diff changeset
   295
 */
8391
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
   296
static void BuildRoadClick_X_Dir(Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   297
{
8391
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
   298
	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
   299
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   300
8285
1f026f023f27 (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: 8225
diff changeset
   301
/**
1f026f023f27 (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: 8225
diff changeset
   302
 * Function that handles the click on the
1f026f023f27 (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: 8225
diff changeset
   303
 *  Y road placement button.
1f026f023f27 (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: 8225
diff changeset
   304
 *
1f026f023f27 (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: 8225
diff changeset
   305
 * @param w The current window
1f026f023f27 (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: 8225
diff changeset
   306
 */
8391
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
   307
static void BuildRoadClick_Y_Dir(Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   308
{
8391
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
   309
	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
   310
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   311
8285
1f026f023f27 (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: 8225
diff changeset
   312
/**
1f026f023f27 (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: 8225
diff changeset
   313
 * Function that handles the click on the
1f026f023f27 (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: 8225
diff changeset
   314
 *  autoroad placement button.
1f026f023f27 (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: 8225
diff changeset
   315
 *
1f026f023f27 (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: 8225
diff changeset
   316
 * @param w The current window
1f026f023f27 (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: 8225
diff changeset
   317
 */
1f026f023f27 (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: 8225
diff changeset
   318
static void BuildRoadClick_AutoRoad(Window *w)
1f026f023f27 (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: 8225
diff changeset
   319
{
8290
2d3d2f515439 (svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
belugas
parents: 8285
diff changeset
   320
	HandlePlacePushButton(w, RTW_AUTOROAD, _road_type_infos[_cur_roadtype].cursor_autoroad, VHM_RECT, PlaceRoad_AutoRoad);
8285
1f026f023f27 (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: 8225
diff changeset
   321
}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   322
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   323
static void BuildRoadClick_Demolish(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   324
{
8290
2d3d2f515439 (svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
belugas
parents: 8285
diff changeset
   325
	HandlePlacePushButton(w, RTW_DEMOLISH, ANIMCURSOR_DEMOLISH, VHM_RECT, PlaceRoad_DemolishArea);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   326
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   327
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   328
static void BuildRoadClick_Depot(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   329
{
7582
9f23c01ae23d (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: 7275
diff changeset
   330
	if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return;
8290
2d3d2f515439 (svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
belugas
parents: 8285
diff changeset
   331
	if (HandlePlacePushButton(w, RTW_DEPOT, SPR_CURSOR_ROAD_DEPOT, VHM_RECT, PlaceRoad_Depot)) ShowRoadDepotPicker();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   332
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   333
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   334
static void BuildRoadClick_BusStation(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   335
{
7582
9f23c01ae23d (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: 7275
diff changeset
   336
	if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return;
8290
2d3d2f515439 (svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
belugas
parents: 8285
diff changeset
   337
	if (HandlePlacePushButton(w, RTW_BUS_STATION, SPR_CURSOR_BUS_STATION, VHM_RECT, PlaceRoad_BusStation)) ShowRVStationPicker(RoadStop::BUS);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   338
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   339
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   340
static void BuildRoadClick_TruckStation(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   341
{
7582
9f23c01ae23d (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: 7275
diff changeset
   342
	if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return;
8290
2d3d2f515439 (svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
belugas
parents: 8285
diff changeset
   343
	if (HandlePlacePushButton(w, RTW_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, VHM_RECT, PlaceRoad_TruckStation)) ShowRVStationPicker(RoadStop::TRUCK);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   344
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   345
8402
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   346
/**
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   347
 * Function that handles the click on the
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   348
 *  one way road button.
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   349
 *
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   350
 * @param w The current window
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   351
 */
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   352
static void BuildRoadClick_OneWay(Window *w)
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   353
{
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8452
diff changeset
   354
	if (w->IsWidgetDisabled(RTW_ONE_WAY)) return;
8402
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   355
	SetWindowDirty(w);
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8452
diff changeset
   356
	w->ToggleWidgetLoweredState(RTW_ONE_WAY);
8403
6686d3705b2c (svn r11459) -Fix: (r11457) The selection highlight color hasn't been reset
skidd13
parents: 8402
diff changeset
   357
	SetSelectionRed(false);
8402
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   358
}
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   359
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   360
static void BuildRoadClick_Bridge(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   361
{
8290
2d3d2f515439 (svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
belugas
parents: 8285
diff changeset
   362
	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
   363
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   364
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   365
static void BuildRoadClick_Tunnel(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   366
{
8290
2d3d2f515439 (svn r11344) -Codechange: Removes some magic numbers referring the highlighting mode in road_gui.cpp
belugas
parents: 8285
diff changeset
   367
	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
   368
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   369
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   370
static void BuildRoadClick_Remove(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   371
{
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8452
diff changeset
   372
	if (w->IsWidgetDisabled(RTW_REMOVE)) return;
9082
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   373
	ToggleRoadButton_Remove(w);
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 514
diff changeset
   374
	SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   375
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   376
8285
1f026f023f27 (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: 8225
diff changeset
   377
/** Array with the handlers of the button-clicks for the road-toolbar */
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   378
static OnButtonClick* const _build_road_button_proc[] = {
8391
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
   379
	BuildRoadClick_X_Dir,
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
   380
	BuildRoadClick_Y_Dir,
8285
1f026f023f27 (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: 8225
diff changeset
   381
	BuildRoadClick_AutoRoad,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   382
	BuildRoadClick_Demolish,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   383
	BuildRoadClick_Depot,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   384
	BuildRoadClick_BusStation,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   385
	BuildRoadClick_TruckStation,
8402
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   386
	BuildRoadClick_OneWay,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   387
	BuildRoadClick_Bridge,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   388
	BuildRoadClick_Tunnel,
5933
0835f3342b79 (svn r8143) Remove the landscaping button from the build toolbars.
tron
parents: 5838
diff changeset
   389
	BuildRoadClick_Remove
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   390
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   391
8285
1f026f023f27 (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: 8225
diff changeset
   392
/** Array with the keycode of the button-clicks for the road-toolbar */
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   393
static const uint16 _road_keycodes[] = {
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   394
	'1',
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   395
	'2',
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   396
	'3',
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   397
	'4',
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   398
	'5',
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   399
	'6',
8285
1f026f023f27 (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: 8225
diff changeset
   400
	'7',
8402
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   401
	'8',
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   402
	'B',
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   403
	'T',
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   404
	'R',
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   405
};
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   406
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   407
/**
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   408
 * Update the remove button lowered state of the road toolbar
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   409
 *
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   410
 * @param w The toolbar window
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   411
 * @param clicked_widget The widget which the player clicked just now
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   412
 */
8402
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   413
static void UpdateOptionWidgetStatus(Window *w, int clicked_widget)
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   414
{
8402
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   415
	/* The remove and the one way button state is driven
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   416
	 * by the other buttons so they don't act on themselfs.
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   417
	 * Both are only valid if they are able to apply as options. */
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   418
	switch (clicked_widget) {
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   419
		case RTW_REMOVE:
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8452
diff changeset
   420
			w->RaiseWidget(RTW_ONE_WAY);
9188
2c86cddd8bb8 (svn r12365) -Fix: missing redraw call in the road gui
skidd13
parents: 9082
diff changeset
   421
			w->InvalidateWidget(RTW_ONE_WAY);
8402
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   422
			break;
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   423
		case RTW_ONE_WAY:
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8452
diff changeset
   424
			w->RaiseWidget(RTW_REMOVE);
9188
2c86cddd8bb8 (svn r12365) -Fix: missing redraw call in the road gui
skidd13
parents: 9082
diff changeset
   425
			w->InvalidateWidget(RTW_REMOVE);
8402
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   426
			break;
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   427
		case RTW_BUS_STATION:
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   428
		case RTW_TRUCK_STATION:
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8452
diff changeset
   429
			w->DisableWidget(RTW_ONE_WAY);
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8452
diff changeset
   430
			w->SetWidgetDisabledState(RTW_REMOVE, !w->IsWidgetLowered(clicked_widget));
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   431
			break;
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   432
		case RTW_ROAD_X:
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   433
		case RTW_ROAD_Y:
8285
1f026f023f27 (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: 8225
diff changeset
   434
		case RTW_AUTOROAD:
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8452
diff changeset
   435
			w->SetWidgetsDisabledState(!w->IsWidgetLowered(clicked_widget),
8402
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   436
				RTW_REMOVE,
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   437
				RTW_ONE_WAY,
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   438
				WIDGET_LIST_END);
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   439
			break;
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   440
		default:
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   441
			/* When any other buttons than road/station, raise and
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   442
			 * disable the removal button */
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8452
diff changeset
   443
			w->SetWidgetsDisabledState(true,
8402
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   444
				RTW_REMOVE,
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   445
				RTW_ONE_WAY,
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   446
				WIDGET_LIST_END);
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8452
diff changeset
   447
			w->SetWidgetsLoweredState (false,
8402
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   448
				RTW_REMOVE,
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   449
				RTW_ONE_WAY,
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   450
				WIDGET_LIST_END);
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   451
			break;
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   452
	}
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   453
}
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   454
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   455
static void BuildRoadToolbWndProc(Window *w, WindowEvent *e)
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   456
{
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   457
	switch (e->event) {
8402
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   458
	case WE_CREATE:
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8452
diff changeset
   459
		w->SetWidgetsDisabledState(true,
8402
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   460
			RTW_REMOVE,
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   461
			RTW_ONE_WAY,
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   462
			WIDGET_LIST_END);
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   463
		break;
5105
4332193c0aec (svn r7176) -Fix: remove button was not always disabled when it should have been (rail/road build toolbar)
glx
parents: 5072
diff changeset
   464
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   465
	case WE_PAINT:
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8452
diff changeset
   466
		w->SetWidgetsDisabledState(!CanBuildVehicleInfrastructure(VEH_ROAD),
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   467
			RTW_DEPOT,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   468
			RTW_BUS_STATION,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   469
			RTW_TRUCK_STATION,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   470
			WIDGET_LIST_END);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   471
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   472
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   473
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   474
	case WE_CLICK:
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   475
		if (e->we.click.widget >= RTW_ROAD_X) {
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   476
			_remove_button_clicked = false;
8402
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   477
			_one_way_button_clicked = false;
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   478
			_build_road_button_proc[e->we.click.widget - RTW_ROAD_X](w);
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   479
		}
8402
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   480
		UpdateOptionWidgetStatus(w, e->we.click.widget);
9082
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   481
		if (_ctrl_pressed) RoadToolbar_CtrlChanged(w);
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   482
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   483
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   484
	case WE_KEYPRESS:
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   485
		for (uint8 i = 0; i != lengthof(_road_keycodes); i++) {
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   486
			if (e->we.keypress.keycode == _road_keycodes[i]) {
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   487
				e->we.keypress.cont = false;
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   488
				_remove_button_clicked = false;
8402
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   489
				_one_way_button_clicked = false;
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   490
				_build_road_button_proc[i](w);
8402
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   491
				UpdateOptionWidgetStatus(w, i + RTW_ROAD_X);
9082
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   492
				if (_ctrl_pressed) RoadToolbar_CtrlChanged(w);
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   493
				break;
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   494
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   495
		}
756
d1f1dc31b6f4 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents: 679
diff changeset
   496
		MarkTileDirty(_thd.pos.x, _thd.pos.y); // redraw tile selection
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   497
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   498
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   499
	case WE_PLACE_OBJ:
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8452
diff changeset
   500
		_remove_button_clicked = w->IsWidgetLowered(RTW_REMOVE);
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8452
diff changeset
   501
		_one_way_button_clicked = w->IsWidgetLowered(RTW_ONE_WAY);
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4559
diff changeset
   502
		_place_proc(e->we.place.tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   503
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   504
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   505
	case WE_ABORT_PLACE_OBJ:
8523
b20d30c6ae9f (svn r11587) -Fix (r11457): The one way road button wasn't reset on abort
skidd13
parents: 8493
diff changeset
   506
		w->RaiseButtons();
b20d30c6ae9f (svn r11587) -Fix (r11457): The one way road button wasn't reset on abort
skidd13
parents: 8493
diff changeset
   507
		w->SetWidgetsDisabledState(true,
b20d30c6ae9f (svn r11587) -Fix (r11457): The one way road button wasn't reset on abort
skidd13
parents: 8493
diff changeset
   508
			RTW_REMOVE,
b20d30c6ae9f (svn r11587) -Fix (r11457): The one way road button wasn't reset on abort
skidd13
parents: 8493
diff changeset
   509
			RTW_ONE_WAY,
b20d30c6ae9f (svn r11587) -Fix (r11457): The one way road button wasn't reset on abort
skidd13
parents: 8493
diff changeset
   510
			WIDGET_LIST_END);
b20d30c6ae9f (svn r11587) -Fix (r11457): The one way road button wasn't reset on abort
skidd13
parents: 8493
diff changeset
   511
		w->InvalidateWidget(RTW_REMOVE);
b20d30c6ae9f (svn r11587) -Fix (r11457): The one way road button wasn't reset on abort
skidd13
parents: 8493
diff changeset
   512
		w->InvalidateWidget(RTW_ONE_WAY);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   513
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   514
		w = FindWindowById(WC_BUS_STATION, 0);
6987
b0f13039bda2 (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6889
diff changeset
   515
		if (w != NULL) WP(w, def_d).close = true;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   516
		w = FindWindowById(WC_TRUCK_STATION, 0);
6987
b0f13039bda2 (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6889
diff changeset
   517
		if (w != NULL) WP(w, def_d).close = true;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   518
		w = FindWindowById(WC_BUILD_DEPOT, 0);
6987
b0f13039bda2 (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6889
diff changeset
   519
		if (w != NULL) WP(w, def_d).close = true;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   520
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   521
7165
37eb253f3c06 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 7162
diff changeset
   522
	case WE_PLACE_DRAG:
8285
1f026f023f27 (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: 8225
diff changeset
   523
		/* Here we update the end tile flags
1f026f023f27 (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: 8225
diff changeset
   524
		 * of the road placement actions.
1f026f023f27 (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: 8225
diff changeset
   525
		 * At first we reset the end halfroad
1f026f023f27 (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: 8225
diff changeset
   526
		 * bits and if needed we set them again. */
7166
3937d5ea59df (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 7165
diff changeset
   527
		switch (e->we.place.select_proc) {
8391
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
   528
			case DDSP_PLACE_ROAD_X_DIR:
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
   529
				_place_road_flag &= ~RF_END_HALFROAD_X;
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
   530
				if (e->we.place.pt.x & 8) _place_road_flag |= RF_END_HALFROAD_X;
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
   531
				break;
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
   532
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
   533
			case DDSP_PLACE_ROAD_Y_DIR:
8285
1f026f023f27 (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: 8225
diff changeset
   534
				_place_road_flag &= ~RF_END_HALFROAD_Y;
1f026f023f27 (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: 8225
diff changeset
   535
				if (e->we.place.pt.y & 8) _place_road_flag |= RF_END_HALFROAD_Y;
4435
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4434
diff changeset
   536
				break;
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4434
diff changeset
   537
8285
1f026f023f27 (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: 8225
diff changeset
   538
			case DDSP_PLACE_AUTOROAD:
1f026f023f27 (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: 8225
diff changeset
   539
				_place_road_flag &= ~(RF_END_HALFROAD_Y | RF_END_HALFROAD_X);
1f026f023f27 (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: 8225
diff changeset
   540
				if (e->we.place.pt.y & 8) _place_road_flag |= RF_END_HALFROAD_Y;
1f026f023f27 (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: 8225
diff changeset
   541
				if (e->we.place.pt.x & 8) _place_road_flag |= RF_END_HALFROAD_X;
1f026f023f27 (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: 8225
diff changeset
   542
1f026f023f27 (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: 8225
diff changeset
   543
				/* For autoroad we need to update the
1f026f023f27 (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: 8225
diff changeset
   544
				 * direction of the road */
1f026f023f27 (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: 8225
diff changeset
   545
				if (_thd.size.x > _thd.size.y || (_thd.size.x == _thd.size.y &&
8409
5c92516290c9 (svn r11466) -Fix (r11339): operator priority problem resulting in problematic autoroad placement in some cases
smatz
parents: 8403
diff changeset
   546
						( (_tile_fract_coords.x < _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) < 16) ||
5c92516290c9 (svn r11466) -Fix (r11339): operator priority problem resulting in problematic autoroad placement in some cases
smatz
parents: 8403
diff changeset
   547
						  (_tile_fract_coords.x > _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) > 16) ))) {
8285
1f026f023f27 (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: 8225
diff changeset
   548
					/* Set dir = X */
1f026f023f27 (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: 8225
diff changeset
   549
					_place_road_flag &= ~RF_DIR_Y;
1f026f023f27 (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: 8225
diff changeset
   550
				} else {
1f026f023f27 (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: 8225
diff changeset
   551
					/* Set dir = Y */
1f026f023f27 (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: 8225
diff changeset
   552
					_place_road_flag |= RF_DIR_Y;
1f026f023f27 (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: 8225
diff changeset
   553
				}
1f026f023f27 (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: 8225
diff changeset
   554
4435
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4434
diff changeset
   555
				break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   556
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   557
7165
37eb253f3c06 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 7162
diff changeset
   558
		VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   559
		return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   560
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   561
	case WE_PLACE_MOUSEUP:
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4559
diff changeset
   562
		if (e->we.place.pt.x != -1) {
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4559
diff changeset
   563
			TileIndex start_tile = e->we.place.starttile;
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4559
diff changeset
   564
			TileIndex end_tile = e->we.place.tile;
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   565
7166
3937d5ea59df (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 7165
diff changeset
   566
			switch (e->we.place.select_proc) {
3937d5ea59df (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 7165
diff changeset
   567
				case DDSP_BUILD_BRIDGE:
7165
37eb253f3c06 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 7162
diff changeset
   568
					ResetObjectToPlace();
9053
13c47e8836eb (svn r12135) -Codechange: Road and rail bridge selection windows were identical apart the caption. So remove one window definition and set manually the caption accordingly.
belugas
parents: 8936
diff changeset
   569
					ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_ROAD, RoadTypeToRoadTypes(_cur_roadtype));
7165
37eb253f3c06 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 7162
diff changeset
   570
					break;
37eb253f3c06 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 7162
diff changeset
   571
7166
3937d5ea59df (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 7165
diff changeset
   572
				case DDSP_DEMOLISH_AREA:
7165
37eb253f3c06 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 7162
diff changeset
   573
					DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
37eb253f3c06 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 7162
diff changeset
   574
					break;
37eb253f3c06 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 7162
diff changeset
   575
8391
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
   576
				case DDSP_PLACE_ROAD_X_DIR:
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
   577
				case DDSP_PLACE_ROAD_Y_DIR:
8285
1f026f023f27 (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: 8225
diff changeset
   578
				case DDSP_PLACE_AUTOROAD:
1f026f023f27 (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: 8225
diff changeset
   579
					/* Flag description:
1f026f023f27 (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: 8225
diff changeset
   580
					 * Use the first three bits (0x07) if dir == Y
1f026f023f27 (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: 8225
diff changeset
   581
					 * else use the last 2 bits (X dir has
1f026f023f27 (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: 8225
diff changeset
   582
					 * not the 3rd bit set) */
1f026f023f27 (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: 8225
diff changeset
   583
					_place_road_flag = (RoadFlags)((_place_road_flag & RF_DIR_Y) ? (_place_road_flag & 0x07) : (_place_road_flag >> 3));
1f026f023f27 (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: 8225
diff changeset
   584
8402
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   585
					DoCommandP(end_tile, start_tile, _place_road_flag | (_cur_roadtype << 3) | (_one_way_button_clicked << 5), CcPlaySound1D,
8400
89e1ee0c796c (svn r11455) -Codechange: make autoroad, 'normal' road building and 'normal' rail building all react the same on CTRL as autorail.
rubidium
parents: 8391
diff changeset
   586
						(_ctrl_pressed || _remove_button_clicked) ?
8017
8c46e61c510f (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7866
diff changeset
   587
						CMD_REMOVE_LONG_ROAD | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_road) :
8c46e61c510f (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7866
diff changeset
   588
						CMD_BUILD_LONG_ROAD | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_road));
7165
37eb253f3c06 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 7162
diff changeset
   589
					break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   590
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   591
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   592
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   593
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   594
	case WE_PLACE_PRESIZE: {
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4559
diff changeset
   595
		TileIndex tile = e->we.place.tile;
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   596
7174
96c2db032ade (svn r9909) -Fix (r9897): Highlight road tunnels properly when building them.
maedhros
parents: 7173
diff changeset
   597
		DoCommand(tile, 0x200 | RoadTypeToRoadTypes(_cur_roadtype), 0, DC_AUTO, CMD_BUILD_TUNNEL);
4000
bab1ebc37da0 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3793
diff changeset
   598
		VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   599
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   600
	}
2619
c2f488e400b1 (svn r3157) - Feature: Added patch option to link the terraform toolbar to the rail, road, water and airport toolbars. If enabled, the terraform toolbar will open and close with those toolbars.
peter1138
parents: 2186
diff changeset
   601
c2f488e400b1 (svn r3157) - Feature: Added patch option to link the terraform toolbar to the rail, road, water and airport toolbars. If enabled, the terraform toolbar will open and close with those toolbars.
peter1138
parents: 2186
diff changeset
   602
	case WE_DESTROY:
c2f488e400b1 (svn r3157) - Feature: Added patch option to link the terraform toolbar to the rail, road, water and airport toolbars. If enabled, the terraform toolbar will open and close with those toolbars.
peter1138
parents: 2186
diff changeset
   603
		if (_patches.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
c2f488e400b1 (svn r3157) - Feature: Added patch option to link the terraform toolbar to the rail, road, water and airport toolbars. If enabled, the terraform toolbar will open and close with those toolbars.
peter1138
parents: 2186
diff changeset
   604
		break;
9082
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   605
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   606
	case WE_CTRL_CHANGED:
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   607
		if (RoadToolbar_CtrlChanged(w)) e->we.ctrl.cont = false;
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 9069
diff changeset
   608
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   609
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   610
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   611
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   612
/** Widget definition of the build road toolbar */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   613
static const Widget _build_road_widgets[] = {
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   614
{   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                   STR_018B_CLOSE_WINDOW},             // RTW_CLOSEBOX
8402
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   615
{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   250,     0,    13, STR_1802_ROAD_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},   // RTW_CAPTION
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   616
{  WWT_STICKYBOX,   RESIZE_NONE,     7,   251,   262,     0,    13, 0x0,                        STR_STICKY_BUTTON},                 // RTW_STICKY
606
0e507bb0f63a (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
   617
8391
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
   618
{     WWT_IMGBTN,   RESIZE_NONE,     7,     0,    21,    14,    35, SPR_IMG_ROAD_X_DIR,         STR_180B_BUILD_ROAD_SECTION},       // RTW_ROAD_X
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
   619
{     WWT_IMGBTN,   RESIZE_NONE,     7,    22,    43,    14,    35, SPR_IMG_ROAD_Y_DIR,         STR_180B_BUILD_ROAD_SECTION},       // RTW_ROAD_Y
8285
1f026f023f27 (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: 8225
diff changeset
   620
{     WWT_IMGBTN,   RESIZE_NONE,     7,    44,    65,    14,    35, SPR_IMG_AUTOROAD,           STR_BUILD_AUTOROAD_TIP},            // RTW_AUTOROAD
1f026f023f27 (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: 8225
diff changeset
   621
{     WWT_IMGBTN,   RESIZE_NONE,     7,    66,    87,    14,    35, SPR_IMG_DYNAMITE,           STR_018D_DEMOLISH_BUILDINGS_ETC},   // RTW_DEMOLISH
1f026f023f27 (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: 8225
diff changeset
   622
{     WWT_IMGBTN,   RESIZE_NONE,     7,    88,   109,    14,    35, SPR_IMG_ROAD_DEPOT,         STR_180C_BUILD_ROAD_VEHICLE_DEPOT}, // RTW_DEPOT
1f026f023f27 (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: 8225
diff changeset
   623
{     WWT_IMGBTN,   RESIZE_NONE,     7,   110,   131,    14,    35, SPR_IMG_BUS_STATION,        STR_180D_BUILD_BUS_STATION},        // RTW_BUS_STATION
1f026f023f27 (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: 8225
diff changeset
   624
{     WWT_IMGBTN,   RESIZE_NONE,     7,   132,   153,    14,    35, SPR_IMG_TRUCK_BAY,          STR_180E_BUILD_TRUCK_LOADING_BAY},  // RTW_TRUCK_STATION
8402
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   625
{     WWT_IMGBTN,   RESIZE_NONE,     7,   154,   175,    14,    35, SPR_IMG_ROAD_ONE_WAY,       STR_TOGGLE_ONE_WAY_ROAD},           // RTW_ONE_WAY
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   626
{     WWT_IMGBTN,   RESIZE_NONE,     7,   176,   218,    14,    35, SPR_IMG_BRIDGE,             STR_180F_BUILD_ROAD_BRIDGE},        // RTW_BUILD_BRIDGE
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   627
{     WWT_IMGBTN,   RESIZE_NONE,     7,   219,   240,    14,    35, SPR_IMG_ROAD_TUNNEL,        STR_1810_BUILD_ROAD_TUNNEL},        // RTW_BUILD_TUNNEL
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   628
{     WWT_IMGBTN,   RESIZE_NONE,     7,   241,   262,    14,    35, SPR_IMG_REMOVE,             STR_1811_TOGGLE_BUILD_REMOVE_FOR},  // RTW_REMOVE
8285
1f026f023f27 (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: 8225
diff changeset
   629
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 5
diff changeset
   630
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   631
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   632
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   633
static const WindowDesc _build_road_desc = {
8402
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   634
	WDP_ALIGN_TBR, 22, 263, 36, 263, 36,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6111
diff changeset
   635
	WC_BUILD_TOOLBAR, WC_NONE,
756
d1f1dc31b6f4 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents: 679
diff changeset
   636
	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
   637
	_build_road_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   638
	BuildRoadToolbWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   639
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   640
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   641
/** Widget definition of the build tram toolbar */
7187
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7174
diff changeset
   642
static const Widget _build_tramway_widgets[] = {
8936
8aa1c9403495 (svn r12010) -Fix (r11994): build tramway window should use STR_WHITE_TRAMWAY_CONSTRUCTION
smatz
parents: 8920
diff changeset
   643
{   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},                // RTW_CLOSEBOX
8aa1c9403495 (svn r12010) -Fix (r11994): build tramway window should use STR_WHITE_TRAMWAY_CONSTRUCTION
smatz
parents: 8920
diff changeset
   644
{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   228,     0,    13, STR_WHITE_TRAMWAY_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},      // RTW_CAPTION
8aa1c9403495 (svn r12010) -Fix (r11994): build tramway window should use STR_WHITE_TRAMWAY_CONSTRUCTION
smatz
parents: 8920
diff changeset
   645
{  WWT_STICKYBOX,   RESIZE_NONE,     7,   229,   240,     0,    13, 0x0,                            STR_STICKY_BUTTON},                    // RTW_STICKY
7187
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7174
diff changeset
   646
8936
8aa1c9403495 (svn r12010) -Fix (r11994): build tramway window should use STR_WHITE_TRAMWAY_CONSTRUCTION
smatz
parents: 8920
diff changeset
   647
{     WWT_IMGBTN,   RESIZE_NONE,     7,     0,    21,    14,    35, SPR_IMG_TRAMWAY_X_DIR,          STR_BUILD_TRAMWAY_SECTION},            // RTW_ROAD_X
8aa1c9403495 (svn r12010) -Fix (r11994): build tramway window should use STR_WHITE_TRAMWAY_CONSTRUCTION
smatz
parents: 8920
diff changeset
   648
{     WWT_IMGBTN,   RESIZE_NONE,     7,    22,    43,    14,    35, SPR_IMG_TRAMWAY_Y_DIR,          STR_BUILD_TRAMWAY_SECTION},            // RTW_ROAD_Y
8aa1c9403495 (svn r12010) -Fix (r11994): build tramway window should use STR_WHITE_TRAMWAY_CONSTRUCTION
smatz
parents: 8920
diff changeset
   649
{     WWT_IMGBTN,   RESIZE_NONE,     7,    44,    65,    14,    35, SPR_IMG_AUTOTRAM,               STR_BUILD_AUTOTRAM_TIP},               // RTW_AUTOROAD
8aa1c9403495 (svn r12010) -Fix (r11994): build tramway window should use STR_WHITE_TRAMWAY_CONSTRUCTION
smatz
parents: 8920
diff changeset
   650
{     WWT_IMGBTN,   RESIZE_NONE,     7,    66,    87,    14,    35, SPR_IMG_DYNAMITE,               STR_018D_DEMOLISH_BUILDINGS_ETC},      // RTW_DEMOLISH
8aa1c9403495 (svn r12010) -Fix (r11994): build tramway window should use STR_WHITE_TRAMWAY_CONSTRUCTION
smatz
parents: 8920
diff changeset
   651
{     WWT_IMGBTN,   RESIZE_NONE,     7,    88,   109,    14,    35, SPR_IMG_ROAD_DEPOT,             STR_BUILD_TRAM_VEHICLE_DEPOT},         // RTW_DEPOT
8aa1c9403495 (svn r12010) -Fix (r11994): build tramway window should use STR_WHITE_TRAMWAY_CONSTRUCTION
smatz
parents: 8920
diff changeset
   652
{     WWT_IMGBTN,   RESIZE_NONE,     7,   110,   131,    14,    35, SPR_IMG_BUS_STATION,            STR_BUILD_PASSENGER_TRAM_STATION},     // RTW_BUS_STATION
8aa1c9403495 (svn r12010) -Fix (r11994): build tramway window should use STR_WHITE_TRAMWAY_CONSTRUCTION
smatz
parents: 8920
diff changeset
   653
{     WWT_IMGBTN,   RESIZE_NONE,     7,   132,   153,    14,    35, SPR_IMG_TRUCK_BAY,              STR_BUILD_CARGO_TRAM_STATION},         // RTW_TRUCK_STATION
8aa1c9403495 (svn r12010) -Fix (r11994): build tramway window should use STR_WHITE_TRAMWAY_CONSTRUCTION
smatz
parents: 8920
diff changeset
   654
{      WWT_EMPTY,   RESIZE_NONE,     0,     0,     0,     0,     0, 0x0,                            STR_NULL},                             // RTW_ONE_WAY
8aa1c9403495 (svn r12010) -Fix (r11994): build tramway window should use STR_WHITE_TRAMWAY_CONSTRUCTION
smatz
parents: 8920
diff changeset
   655
{     WWT_IMGBTN,   RESIZE_NONE,     7,   154,   196,    14,    35, SPR_IMG_BRIDGE,                 STR_BUILD_TRAMWAY_BRIDGE},             // RTW_BUILD_BRIDGE
8aa1c9403495 (svn r12010) -Fix (r11994): build tramway window should use STR_WHITE_TRAMWAY_CONSTRUCTION
smatz
parents: 8920
diff changeset
   656
{     WWT_IMGBTN,   RESIZE_NONE,     7,   197,   218,    14,    35, SPR_IMG_ROAD_TUNNEL,            STR_BUILD_TRAMWAY_TUNNEL},             // RTW_BUILD_TUNNEL
8aa1c9403495 (svn r12010) -Fix (r11994): build tramway window should use STR_WHITE_TRAMWAY_CONSTRUCTION
smatz
parents: 8920
diff changeset
   657
{     WWT_IMGBTN,   RESIZE_NONE,     7,   219,   240,    14,    35, SPR_IMG_REMOVE,                 STR_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS}, // RTW_REMOVE
8285
1f026f023f27 (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: 8225
diff changeset
   658
7187
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7174
diff changeset
   659
{   WIDGETS_END},
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7174
diff changeset
   660
};
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7174
diff changeset
   661
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7174
diff changeset
   662
static const WindowDesc _build_tramway_desc = {
8402
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   663
	WDP_ALIGN_TBR, 22, 241, 36, 241, 36,
7187
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7174
diff changeset
   664
	WC_BUILD_TOOLBAR, WC_NONE,
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7174
diff changeset
   665
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7174
diff changeset
   666
	_build_tramway_widgets,
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7174
diff changeset
   667
	BuildRoadToolbWndProc
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7174
diff changeset
   668
};
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7174
diff changeset
   669
7162
b769c2b45103 (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 7158
diff changeset
   670
void ShowBuildRoadToolbar(RoadType roadtype)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   671
{
5005
21e84e53c732 (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4938
diff changeset
   672
	if (!IsValidPlayer(_current_player)) return;
7162
b769c2b45103 (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 7158
diff changeset
   673
	_cur_roadtype = roadtype;
5005
21e84e53c732 (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4938
diff changeset
   674
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   675
	DeleteWindowById(WC_BUILD_TOOLBAR, 0);
7187
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7174
diff changeset
   676
	Window *w = AllocateWindowDesc(roadtype == ROADTYPE_ROAD ? &_build_road_desc : &_build_tramway_desc);
6111
32f6149dc192 (svn r8436) -Fix
tron
parents: 6087
diff changeset
   677
	if (_patches.link_terraform_toolbar) ShowTerraformToolbar(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   678
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   679
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   680
/** 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
   681
static const Widget _build_road_scen_widgets[] = {
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   682
{   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                   STR_018B_CLOSE_WINDOW},            // RTW_CLOSEBOX
8402
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   683
{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   184,     0,    13, STR_1802_ROAD_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},  // RTW_CAPTION
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   684
{  WWT_STICKYBOX,   RESIZE_NONE,     7,   185,   196,     0,    13, 0x0,                        STR_STICKY_BUTTON},                // RTW_STICKY
661
a0bdbdffb06a (svn r1095) -Fix: scenario editor road-build-gui works again altough shortcuts are screwed.
darkvater
parents: 651
diff changeset
   685
8391
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
   686
{     WWT_IMGBTN,   RESIZE_NONE,     7,     0,    21,    14,    35, SPR_IMG_ROAD_X_DIR,         STR_180B_BUILD_ROAD_SECTION},      // RTW_ROAD_X
533d149e52a9 (svn r11446) -Codechange: change the naming of road related code parts to something more descriptive
skidd13
parents: 8290
diff changeset
   687
{     WWT_IMGBTN,   RESIZE_NONE,     7,    22,    43,    14,    35, SPR_IMG_ROAD_Y_DIR,         STR_180B_BUILD_ROAD_SECTION},      // RTW_ROAD_Y
8285
1f026f023f27 (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: 8225
diff changeset
   688
{     WWT_IMGBTN,   RESIZE_NONE,     7,    44,    65,    14,    35, SPR_IMG_AUTOROAD,           STR_BUILD_AUTOROAD_TIP},           // RTW_AUTOROAD
1f026f023f27 (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: 8225
diff changeset
   689
{     WWT_IMGBTN,   RESIZE_NONE,     7,    66,    87,    14,    35, SPR_IMG_DYNAMITE,           STR_018D_DEMOLISH_BUILDINGS_ETC},  // RTW_DEMOLISH
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   690
{      WWT_EMPTY,   RESIZE_NONE,     0,     0,     0,     0,     0, 0x0,                        STR_NULL},                         // RTW_DEPOT
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   691
{      WWT_EMPTY,   RESIZE_NONE,     0,     0,     0,     0,     0, 0x0,                        STR_NULL},                         // RTW_BUS_STATION
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   692
{      WWT_EMPTY,   RESIZE_NONE,     0,     0,     0,     0,     0, 0x0,                        STR_NULL},                         // RTW_TRUCK_STATION
8402
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   693
{     WWT_IMGBTN,   RESIZE_NONE,     7,    88,   109,    14,    35, SPR_IMG_ROAD_ONE_WAY,       STR_TOGGLE_ONE_WAY_ROAD},          // RTW_ONE_WAY
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   694
{     WWT_IMGBTN,   RESIZE_NONE,     7,   110,   152,    14,    35, SPR_IMG_BRIDGE,             STR_180F_BUILD_ROAD_BRIDGE},       // RTW_BUILD_BRIDGE
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   695
{     WWT_IMGBTN,   RESIZE_NONE,     7,   153,   174,    14,    35, SPR_IMG_ROAD_TUNNEL,        STR_1810_BUILD_ROAD_TUNNEL},       // RTW_BUILD_TUNNEL
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   696
{     WWT_IMGBTN,   RESIZE_NONE,     7,   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
   697
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   698
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   699
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   700
static const WindowDesc _build_road_scen_desc = {
8402
d2f50a0bac7f (svn r11457) -Fix: (r11455) Reenable the accidentaly removed one way roads option
skidd13
parents: 8400
diff changeset
   701
	WDP_AUTO, WDP_AUTO, 197, 36, 197, 36,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6111
diff changeset
   702
	WC_SCEN_BUILD_ROAD, WC_NONE,
777
3d7798da0f10 (svn r1243) -Fix: Scenario road-building toolbar also stickified. Thx for the notice teeone
darkvater
parents: 756
diff changeset
   703
	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
   704
	_build_road_scen_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   705
	BuildRoadToolbWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   706
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   707
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6428
diff changeset
   708
void ShowBuildRoadScenToolbar()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   709
{
7275
301967cc2351 (svn r10015) -Fix: one could build (only) tram tracks when that was the last built roadtype (in a normal game).
rubidium
parents: 7260
diff changeset
   710
	_cur_roadtype = ROADTYPE_ROAD;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   711
	AllocateWindowDescFront(&_build_road_scen_desc, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   712
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   713
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   714
/** Enum referring to the widgets of the build road depot window */
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   715
enum BuildRoadDepotWidgets {
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   716
	BRDW_CLOSEBOX = 0,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   717
	BRDW_CAPTION,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   718
	BRDW_BACKGROUND,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   719
	BRDW_DEPOT_NE,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   720
	BRDW_DEPOT_SE,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   721
	BRDW_DEPOT_SW,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   722
	BRDW_DEPOT_NW,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   723
};
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   724
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   725
static void BuildRoadDepotWndProc(Window *w, WindowEvent *e)
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   726
{
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   727
	switch (e->event) {
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8452
diff changeset
   728
	case WE_CREATE: w->LowerWidget(_road_depot_orientation + BRDW_DEPOT_NE); break;
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   729
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   730
	case WE_PAINT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   731
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   732
7162
b769c2b45103 (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 7158
diff changeset
   733
		DrawRoadDepotSprite(70, 17, DIAGDIR_NE, _cur_roadtype);
b769c2b45103 (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 7158
diff changeset
   734
		DrawRoadDepotSprite(70, 69, DIAGDIR_SE, _cur_roadtype);
b769c2b45103 (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 7158
diff changeset
   735
		DrawRoadDepotSprite( 2, 69, DIAGDIR_SW, _cur_roadtype);
b769c2b45103 (svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents: 7158
diff changeset
   736
		DrawRoadDepotSprite( 2, 17, DIAGDIR_NW, _cur_roadtype);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   737
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   738
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   739
	case WE_CLICK:
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4559
diff changeset
   740
		switch (e->we.click.widget) {
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   741
			case BRDW_DEPOT_NW:
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   742
			case BRDW_DEPOT_NE:
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   743
			case BRDW_DEPOT_SW:
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   744
			case BRDW_DEPOT_SE:
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8452
diff changeset
   745
				w->RaiseWidget(_road_depot_orientation + BRDW_DEPOT_NE);
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   746
				_road_depot_orientation = (DiagDirection)(e->we.click.widget - BRDW_DEPOT_NE);
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8452
diff changeset
   747
				w->LowerWidget(_road_depot_orientation + BRDW_DEPOT_NE);
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   748
				SndPlayFx(SND_15_BEEP);
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   749
				SetWindowDirty(w);
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   750
				break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   751
		}
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   752
		break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   753
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   754
	case WE_MOUSELOOP:
6987
b0f13039bda2 (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6889
diff changeset
   755
		if (WP(w, def_d).close) DeleteWindow(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   756
		break;
1072
01bf9fc64236 (svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents: 1035
diff changeset
   757
01bf9fc64236 (svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents: 1035
diff changeset
   758
	case WE_DESTROY:
6987
b0f13039bda2 (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6889
diff changeset
   759
		if (!WP(w, def_d).close) ResetObjectToPlace();
1072
01bf9fc64236 (svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents: 1035
diff changeset
   760
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   761
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   762
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   763
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   764
/** Widget definition of the build road depot window */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   765
static const Widget _build_road_depot_widgets[] = {
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   766
{   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},              // BRDW_CLOSEBOX
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   767
{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   139,     0,    13, STR_1806_ROAD_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS},    // BRDW_CAPTION
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   768
{      WWT_PANEL,   RESIZE_NONE,     7,     0,   139,    14,   121, 0x0,                             STR_NULL},                           // BRDW_BACKGROUND
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   769
{      WWT_PANEL,   RESIZE_NONE,    14,    71,   136,    17,    66, 0x0,                             STR_1813_SELECT_ROAD_VEHICLE_DEPOT}, // BRDW_DEPOT_NE
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   770
{      WWT_PANEL,   RESIZE_NONE,    14,    71,   136,    69,   118, 0x0,                             STR_1813_SELECT_ROAD_VEHICLE_DEPOT}, // BRDW_DEPOT_SE
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   771
{      WWT_PANEL,   RESIZE_NONE,    14,     3,    68,    69,   118, 0x0,                             STR_1813_SELECT_ROAD_VEHICLE_DEPOT}, // BRDW_DEPOT_SW
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   772
{      WWT_PANEL,   RESIZE_NONE,    14,     3,    68,    17,    66, 0x0,                             STR_1813_SELECT_ROAD_VEHICLE_DEPOT}, // BRDW_DEPOT_NW
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 5
diff changeset
   773
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   774
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   775
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   776
/** Widget definition of the build tram depot window */
7187
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7174
diff changeset
   777
static const Widget _build_tram_depot_widgets[] = {
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   778
{   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},              // BRDW_CLOSEBOX
8920
04df97185061 (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: 8919
diff changeset
   779
{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   139,     0,    13, STR_TRAM_DEPOT_ORIENTATION,      STR_018C_WINDOW_TITLE_DRAG_THIS},    // BRDW_CAPTION
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   780
{      WWT_PANEL,   RESIZE_NONE,     7,     0,   139,    14,   121, 0x0,                             STR_NULL},                           // BRDW_BACKGROUND
8920
04df97185061 (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: 8919
diff changeset
   781
{      WWT_PANEL,   RESIZE_NONE,    14,    71,   136,    17,    66, 0x0,                             STR_SELECT_TRAM_VEHICLE_DEPOT},      // BRDW_DEPOT_NE
04df97185061 (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: 8919
diff changeset
   782
{      WWT_PANEL,   RESIZE_NONE,    14,    71,   136,    69,   118, 0x0,                             STR_SELECT_TRAM_VEHICLE_DEPOT},      // BRDW_DEPOT_SE
04df97185061 (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: 8919
diff changeset
   783
{      WWT_PANEL,   RESIZE_NONE,    14,     3,    68,    69,   118, 0x0,                             STR_SELECT_TRAM_VEHICLE_DEPOT},      // BRDW_DEPOT_SW
04df97185061 (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: 8919
diff changeset
   784
{      WWT_PANEL,   RESIZE_NONE,    14,     3,    68,    17,    66, 0x0,                             STR_SELECT_TRAM_VEHICLE_DEPOT},      // BRDW_DEPOT_NW
7187
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7174
diff changeset
   785
{   WIDGETS_END},
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7174
diff changeset
   786
};
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7174
diff changeset
   787
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   788
static const WindowDesc _build_road_depot_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7835
diff changeset
   789
	WDP_AUTO, WDP_AUTO, 140, 122, 140, 122,
5070
0bbf5264bfb7 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 5005
diff changeset
   790
	WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   791
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   792
	_build_road_depot_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   793
	BuildRoadDepotWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   794
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   795
7187
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7174
diff changeset
   796
static const WindowDesc _build_tram_depot_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7835
diff changeset
   797
	WDP_AUTO, WDP_AUTO, 140, 122, 140, 122,
7187
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7174
diff changeset
   798
	WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7174
diff changeset
   799
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7174
diff changeset
   800
	_build_tram_depot_widgets,
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7174
diff changeset
   801
	BuildRoadDepotWndProc
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7174
diff changeset
   802
};
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7174
diff changeset
   803
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6428
diff changeset
   804
static void ShowRoadDepotPicker()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   805
{
7187
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7174
diff changeset
   806
	AllocateWindowDesc(_cur_roadtype == ROADTYPE_ROAD ? &_build_road_depot_desc : &_build_tram_depot_desc);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   807
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   808
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   809
/** Enum referring to the widgets of the build road station window */
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   810
enum BuildRoadStationWidgets {
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   811
	BRSW_CLOSEBOX = 0,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   812
	BRSW_CAPTION,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   813
	BRSW_BACKGROUND,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   814
	BRSW_STATION_NE,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   815
	BRSW_STATION_SE,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   816
	BRSW_STATION_SW,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   817
	BRSW_STATION_NW,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   818
	BRSW_STATION_X,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   819
	BRSW_STATION_Y,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   820
	BRSW_LT_OFF,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   821
	BRSW_LT_ON,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   822
	BRSW_INFO,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   823
};
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   824
987
ea47ad079de8 (svn r1485) -Fix: [1031451] Catchment area shows when buying sign. Catchment area wasn't reset when road station window was unselected
darkvater
parents: 946
diff changeset
   825
static void RoadStationPickerWndProc(Window *w, WindowEvent *e)
ea47ad079de8 (svn r1485) -Fix: [1031451] Catchment area shows when buying sign. Catchment area wasn't reset when road station window was unselected
darkvater
parents: 946
diff changeset
   826
{
2952
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2753
diff changeset
   827
	switch (e->event) {
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   828
	case WE_CREATE:
7173
0a9b13debedf (svn r9908) -Codechange: prepare the station picker for more road types.
rubidium
parents: 7172
diff changeset
   829
		/* Trams don't have non-drivethrough stations */
0a9b13debedf (svn r9908) -Codechange: prepare the station picker for more road types.
rubidium
parents: 7172
diff changeset
   830
		if (_cur_roadtype == ROADTYPE_TRAM && _road_station_picker_orientation < DIAGDIR_END) {
0a9b13debedf (svn r9908) -Codechange: prepare the station picker for more road types.
rubidium
parents: 7172
diff changeset
   831
			_road_station_picker_orientation = DIAGDIR_END;
0a9b13debedf (svn r9908) -Codechange: prepare the station picker for more road types.
rubidium
parents: 7172
diff changeset
   832
		}
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8452
diff changeset
   833
		w->SetWidgetsDisabledState(_cur_roadtype == ROADTYPE_TRAM,
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   834
			BRSW_STATION_NE,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   835
			BRSW_STATION_SE,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   836
			BRSW_STATION_SW,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   837
			BRSW_STATION_NW,
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   838
			WIDGET_LIST_END);
7173
0a9b13debedf (svn r9908) -Codechange: prepare the station picker for more road types.
rubidium
parents: 7172
diff changeset
   839
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8452
diff changeset
   840
		w->LowerWidget(_road_station_picker_orientation + BRSW_STATION_NE);
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8452
diff changeset
   841
		w->LowerWidget(_station_show_coverage + BRSW_LT_OFF);
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   842
		break;
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   843
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   844
	case WE_PAINT: {
6987
b0f13039bda2 (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6889
diff changeset
   845
		if (WP(w, def_d).close) return;
987
ea47ad079de8 (svn r1485) -Fix: [1031451] Catchment area shows when buying sign. Catchment area wasn't reset when road station window was unselected
darkvater
parents: 946
diff changeset
   846
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   847
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   848
987
ea47ad079de8 (svn r1485) -Fix: [1031451] Catchment area shows when buying sign. Catchment area wasn't reset when road station window was unselected
darkvater
parents: 946
diff changeset
   849
		if (_station_show_coverage) {
9069
7b9573ccc411 (svn r12154) -Codechange: removed a magic number
glx
parents: 9059
diff changeset
   850
			int rad = _patches.modified_catchment ? CA_TRUCK /* = CA_BUS */ : CA_UNMODIFIED;
987
ea47ad079de8 (svn r1485) -Fix: [1031451] Catchment area shows when buying sign. Catchment area wasn't reset when road station window was unselected
darkvater
parents: 946
diff changeset
   851
			SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4008
diff changeset
   852
		} else {
987
ea47ad079de8 (svn r1485) -Fix: [1031451] Catchment area shows when buying sign. Catchment area wasn't reset when road station window was unselected
darkvater
parents: 946
diff changeset
   853
			SetTileSelectSize(1, 1);
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4008
diff changeset
   854
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   855
7768
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7762
diff changeset
   856
		StationType st = (w->window_class == WC_BUS_STATION) ? STATION_BUS : STATION_TRUCK;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   857
8662
ea3cdf414e87 (svn r11729) -Codechange: Don't rely on the first railtype's sprite offset being zero when drawing road stations.
peter1138
parents: 8653
diff changeset
   858
		StationPickerDrawSprite(103, 35, st, INVALID_RAILTYPE, ROADTYPE_ROAD, 0);
ea3cdf414e87 (svn r11729) -Codechange: Don't rely on the first railtype's sprite offset being zero when drawing road stations.
peter1138
parents: 8653
diff changeset
   859
		StationPickerDrawSprite(103, 85, st, INVALID_RAILTYPE, ROADTYPE_ROAD, 1);
ea3cdf414e87 (svn r11729) -Codechange: Don't rely on the first railtype's sprite offset being zero when drawing road stations.
peter1138
parents: 8653
diff changeset
   860
		StationPickerDrawSprite( 35, 85, st, INVALID_RAILTYPE, ROADTYPE_ROAD, 2);
ea3cdf414e87 (svn r11729) -Codechange: Don't rely on the first railtype's sprite offset being zero when drawing road stations.
peter1138
parents: 8653
diff changeset
   861
		StationPickerDrawSprite( 35, 35, st, INVALID_RAILTYPE, ROADTYPE_ROAD, 3);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   862
8662
ea3cdf414e87 (svn r11729) -Codechange: Don't rely on the first railtype's sprite offset being zero when drawing road stations.
peter1138
parents: 8653
diff changeset
   863
		StationPickerDrawSprite(171, 35, st, INVALID_RAILTYPE, _cur_roadtype, 4);
ea3cdf414e87 (svn r11729) -Codechange: Don't rely on the first railtype's sprite offset being zero when drawing road stations.
peter1138
parents: 8653
diff changeset
   864
		StationPickerDrawSprite(171, 85, st, INVALID_RAILTYPE, _cur_roadtype, 5);
6338
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6144
diff changeset
   865
8919
b627c71f9cc3 (svn r11993) -Fix: Resize station/roadstop/dock/airport construction windows if cargo acceptance list is too long.
peter1138
parents: 8766
diff changeset
   866
		int text_end = DrawStationCoverageAreaText(2, 146,
7737
7ab95e599292 (svn r10522) -Fix: the "build truck station" GUI showed that it would accept tourists when it does not, whereas the "build bus station" GUI did not show them when it did accept them.
rubidium
parents: 7582
diff changeset
   867
			(w->window_class == WC_BUS_STATION) ? SCT_PASSENGERS_ONLY : SCT_NON_PASSENGERS_ONLY,
8919
b627c71f9cc3 (svn r11993) -Fix: Resize station/roadstop/dock/airport construction windows if cargo acceptance list is too long.
peter1138
parents: 8766
diff changeset
   868
			3) + 4;
b627c71f9cc3 (svn r11993) -Fix: Resize station/roadstop/dock/airport construction windows if cargo acceptance list is too long.
peter1138
parents: 8766
diff changeset
   869
		if (text_end > w->widget[BRSW_BACKGROUND].bottom) {
b627c71f9cc3 (svn r11993) -Fix: Resize station/roadstop/dock/airport construction windows if cargo acceptance list is too long.
peter1138
parents: 8766
diff changeset
   870
			SetWindowDirty(w);
b627c71f9cc3 (svn r11993) -Fix: Resize station/roadstop/dock/airport construction windows if cargo acceptance list is too long.
peter1138
parents: 8766
diff changeset
   871
			ResizeWindowForWidget(w, BRSW_BACKGROUND, 0, text_end - w->widget[BRSW_BACKGROUND].bottom);
b627c71f9cc3 (svn r11993) -Fix: Resize station/roadstop/dock/airport construction windows if cargo acceptance list is too long.
peter1138
parents: 8766
diff changeset
   872
			SetWindowDirty(w);
b627c71f9cc3 (svn r11993) -Fix: Resize station/roadstop/dock/airport construction windows if cargo acceptance list is too long.
peter1138
parents: 8766
diff changeset
   873
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   874
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   875
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   876
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   877
	case WE_CLICK: {
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4559
diff changeset
   878
		switch (e->we.click.widget) {
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   879
			case BRSW_STATION_NE:
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   880
			case BRSW_STATION_SE:
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   881
			case BRSW_STATION_SW:
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   882
			case BRSW_STATION_NW:
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   883
			case BRSW_STATION_X:
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   884
			case BRSW_STATION_Y:
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8452
diff changeset
   885
				w->RaiseWidget(_road_station_picker_orientation + BRSW_STATION_NE);
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   886
				_road_station_picker_orientation = (DiagDirection)(e->we.click.widget - BRSW_STATION_NE);
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8452
diff changeset
   887
				w->LowerWidget(_road_station_picker_orientation + BRSW_STATION_NE);
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   888
				SndPlayFx(SND_15_BEEP);
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   889
				SetWindowDirty(w);
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   890
				break;
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   891
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   892
			case BRSW_LT_OFF:
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   893
			case BRSW_LT_ON:
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8452
diff changeset
   894
				w->RaiseWidget(_station_show_coverage + BRSW_LT_OFF);
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   895
				_station_show_coverage = (e->we.click.widget != BRSW_LT_OFF);
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8452
diff changeset
   896
				w->LowerWidget(_station_show_coverage + BRSW_LT_OFF);
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   897
				SndPlayFx(SND_15_BEEP);
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   898
				SetWindowDirty(w);
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   899
				break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   900
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   901
	} break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   902
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   903
	case WE_MOUSELOOP: {
6987
b0f13039bda2 (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6889
diff changeset
   904
		if (WP(w, def_d).close) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   905
			DeleteWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   906
			return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   907
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   908
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   909
		CheckRedrawStationCoverage(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   910
	} break;
1109
1bab892228cd (svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents: 1093
diff changeset
   911
1072
01bf9fc64236 (svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents: 1035
diff changeset
   912
	case WE_DESTROY:
6987
b0f13039bda2 (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6889
diff changeset
   913
		if (!WP(w, def_d).close) ResetObjectToPlace();
1072
01bf9fc64236 (svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents: 1035
diff changeset
   914
		break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   915
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   916
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   917
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   918
/** Widget definition of the build raod station window */
7189
38df4f4e68ef (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 7187
diff changeset
   919
static const Widget _rv_station_picker_widgets[] = {
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   920
{   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                         STR_018B_CLOSE_WINDOW},             // BRSW_CLOSEBOX
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   921
{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   206,     0,    13, STR_NULL,                         STR_018C_WINDOW_TITLE_DRAG_THIS},   // BRSW_CAPTION
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   922
{      WWT_PANEL,   RESIZE_NONE,     7,     0,   206,    14,   176, 0x0,                              STR_NULL},                          // BRSW_BACKGROUND
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   923
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   924
{      WWT_PANEL,   RESIZE_NONE,    14,    71,   136,    17,    66, 0x0,                              STR_NULL},                          // BRSW_STATION_NE
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   925
{      WWT_PANEL,   RESIZE_NONE,    14,    71,   136,    69,   118, 0x0,                              STR_NULL},                          // BRSW_STATION_SE
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   926
{      WWT_PANEL,   RESIZE_NONE,    14,     3,    68,    69,   118, 0x0,                              STR_NULL},                          // BRSW_STATION_SW
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   927
{      WWT_PANEL,   RESIZE_NONE,    14,     3,    68,    17,    66, 0x0,                              STR_NULL},                          // BRSW_STATION_NW
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   928
{      WWT_PANEL,   RESIZE_NONE,    14,   139,   204,    17,    66, 0x0,                              STR_NULL},                          // BRSW_STATION_X
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   929
{      WWT_PANEL,   RESIZE_NONE,    14,   139,   204,    69,   118, 0x0,                              STR_NULL},                          // BRSW_STATION_Y
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   930
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   931
{    WWT_TEXTBTN,   RESIZE_NONE,    14,    10,    69,   133,   144, STR_02DB_OFF,                     STR_3065_DON_T_HIGHLIGHT_COVERAGE}, // BRSW_LT_OFF
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   932
{    WWT_TEXTBTN,   RESIZE_NONE,    14,    70,   129,   133,   144, STR_02DA_ON,                      STR_3064_HIGHLIGHT_COVERAGE_AREA},  // BRSW_LT_ON
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   933
{      WWT_LABEL,   RESIZE_NONE,     7,     0,   139,   120,   133, STR_3066_COVERAGE_AREA_HIGHLIGHT, STR_NULL},                          // BRSW_INFO
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 5
diff changeset
   934
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   935
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   936
7189
38df4f4e68ef (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 7187
diff changeset
   937
static const WindowDesc _rv_station_picker_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7835
diff changeset
   938
	WDP_AUTO, WDP_AUTO, 207, 177, 207, 177,
5070
0bbf5264bfb7 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 5005
diff changeset
   939
	WC_BUS_STATION, WC_BUILD_TOOLBAR,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   940
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
7189
38df4f4e68ef (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 7187
diff changeset
   941
	_rv_station_picker_widgets,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   942
	RoadStationPickerWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   943
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   944
7189
38df4f4e68ef (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 7187
diff changeset
   945
static void ShowRVStationPicker(RoadStop::Type rs)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   946
{
7189
38df4f4e68ef (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 7187
diff changeset
   947
	Window *w = AllocateWindowDesc(&_rv_station_picker_desc);
38df4f4e68ef (svn r9925) -Fix: wrong tooltips in station picker.
rubidium
parents: 7187
diff changeset
   948
	if (w == NULL) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   949
7197
292134da6f79 (svn r9933) -Fix (9925): unified a little too much.
rubidium
parents: 7189
diff changeset
   950
	w->window_class = (rs == RoadStop::BUS) ? WC_BUS_STATION : WC_TRUCK_STATION;
8225
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   951
	w->widget[BRSW_CAPTION].data = _road_type_infos[_cur_roadtype].picker_title[rs];
7cf635a89c7d (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 8017
diff changeset
   952
	for (uint i = BRSW_STATION_NE; i < BRSW_LT_OFF; i++) w->widget[i].tooltips = _road_type_infos[_cur_roadtype].picker_tooltip[rs];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   953
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   954
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6428
diff changeset
   955
void InitializeRoadGui()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   956
{
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   957
	_road_depot_orientation = DIAGDIR_NW;
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   958
	_road_station_picker_orientation = DIAGDIR_NW;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   959
}