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