author | maedhros |
Wed, 23 May 2007 17:33:03 +0000 | |
changeset 7170 | bd34b6d0e4f1 |
parent 7166 | 3937d5ea59df |
child 7172 | 40781792e25f |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6889
f7f6d9cb07a0
(svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas
parents:
6573
diff
changeset
|
3 |
/** @file road_gui.cpp */ |
f7f6d9cb07a0
(svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas
parents:
6573
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1363
diff
changeset
|
6 |
#include "openttd.h" |
1363
01d3de5d8039
(svn r1867) Include tables/sprites.h only in files which need it
tron
parents:
1217
diff
changeset
|
7 |
#include "table/sprites.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
337
diff
changeset
|
8 |
#include "table/strings.h" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
9 |
#include "functions.h" |
679
e959706a3e4d
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
661
diff
changeset
|
10 |
#include "map.h" |
1209
a1ac96655b79
(svn r1713) Split off several functions which query/set information about a single tile from map.h and put them into a seperate file tile.h
tron
parents:
1116
diff
changeset
|
11 |
#include "tile.h" |
0 | 12 |
#include "window.h" |
13 |
#include "gui.h" |
|
14 |
#include "viewport.h" |
|
15 |
#include "gfx.h" |
|
337
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
16 |
#include "sound.h" |
0 | 17 |
#include "command.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2049
diff
changeset
|
18 |
#include "variables.h" |
7162
b769c2b45103
(svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents:
7158
diff
changeset
|
19 |
#include "road.h" |
b769c2b45103
(svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents:
7158
diff
changeset
|
20 |
#include "road_cmd.h" |
b769c2b45103
(svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents:
7158
diff
changeset
|
21 |
#include "road_map.h" |
6338
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
22 |
#include "station_map.h" |
568
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
23 |
//needed for catchments |
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
24 |
#include "station.h" |
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
25 |
|
0 | 26 |
|
6573 | 27 |
static void ShowBusStationPicker(); |
28 |
static void ShowTruckStationPicker(); |
|
29 |
static void ShowRoadDepotPicker(); |
|
0 | 30 |
|
31 |
static bool _remove_button_clicked; |
|
32 |
||
33 |
static byte _place_road_flag; |
|
34 |
||
7162
b769c2b45103
(svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents:
7158
diff
changeset
|
35 |
static RoadType _cur_roadtype; |
b769c2b45103
(svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents:
7158
diff
changeset
|
36 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
37 |
static DiagDirection _road_depot_orientation; |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
38 |
static DiagDirection _road_station_picker_orientation; |
0 | 39 |
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
40 |
void CcPlaySound1D(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 41 |
{ |
541 | 42 |
if (success) SndPlayTileFx(SND_1F_SPLAT, tile); |
0 | 43 |
} |
44 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
45 |
static void PlaceRoad_NE(TileIndex tile) |
0 | 46 |
{ |
47 |
_place_road_flag = (_tile_fract_coords.y >= 8) + 4; |
|
7166
3937d5ea59df
(svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents:
7165
diff
changeset
|
48 |
VpStartPlaceSizing(tile, VPM_FIX_X, DDSP_PLACE_ROAD_NE); |
0 | 49 |
} |
50 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
51 |
static void PlaceRoad_NW(TileIndex tile) |
0 | 52 |
{ |
53 |
_place_road_flag = (_tile_fract_coords.x >= 8) + 0; |
|
7166
3937d5ea59df
(svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents:
7165
diff
changeset
|
54 |
VpStartPlaceSizing(tile, VPM_FIX_Y, DDSP_PLACE_ROAD_NW); |
0 | 55 |
} |
56 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
57 |
static void PlaceRoad_Bridge(TileIndex tile) |
0 | 58 |
{ |
7166
3937d5ea59df
(svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents:
7165
diff
changeset
|
59 |
VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_BUILD_BRIDGE); |
0 | 60 |
} |
61 |
||
62 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
63 |
void CcBuildRoadTunnel(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 64 |
{ |
65 |
if (success) { |
|
541 | 66 |
SndPlayTileFx(SND_20_SPLAT_2, tile); |
0 | 67 |
ResetObjectToPlace(); |
68 |
} else { |
|
69 |
SetRedErrorSquare(_build_tunnel_endtile); |
|
70 |
} |
|
71 |
} |
|
72 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
73 |
static void PlaceRoad_Tunnel(TileIndex tile) |
0 | 74 |
{ |
7162
b769c2b45103
(svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents:
7158
diff
changeset
|
75 |
DoCommandP(tile, 0x200 | RoadTypeToRoadTypes(_cur_roadtype), 0, CcBuildRoadTunnel, CMD_BUILD_TUNNEL | CMD_AUTO | CMD_MSG(STR_5016_CAN_T_BUILD_TUNNEL_HERE)); |
0 | 76 |
} |
77 |
||
3151 | 78 |
static void BuildRoadOutsideStation(TileIndex tile, DiagDirection direction) |
0 | 79 |
{ |
4559
c853d2440065
(svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents:
4435
diff
changeset
|
80 |
tile += TileOffsByDiagDir(direction); |
5
539c9743d999
(svn r6) -Fix [1006530] BuildRoadOutsideStation fix. Fix bug [994720] road depot - bus/lorry station (Truelight+Darkvater :P )
darkvater
parents:
0
diff
changeset
|
81 |
// if there is a roadpiece just outside of the station entrance, build a connecting route |
3793
33cdb5bf7b21
(svn r4789) - Codechange: rename RoadType to RoadTileType and ROAD_{NORMAL,CROSSING,DEPOT} to ROAD_TILE_* for consistency
rubidium
parents:
3491
diff
changeset
|
82 |
if (IsTileType(tile, MP_STREET) && GetRoadTileType(tile) == ROAD_TILE_NORMAL) { |
7162
b769c2b45103
(svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents:
7158
diff
changeset
|
83 |
if (GetRoadBits(tile, _cur_roadtype) != ROAD_NONE) { |
b769c2b45103
(svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents:
7158
diff
changeset
|
84 |
DoCommandP(tile, _cur_roadtype << 4 | DiagDirToRoadBits(ReverseDiagDir(direction)), 0, NULL, CMD_BUILD_ROAD); |
b769c2b45103
(svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents:
7158
diff
changeset
|
85 |
} |
0 | 86 |
} |
87 |
} |
|
88 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
89 |
void CcRoadDepot(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 90 |
{ |
91 |
if (success) { |
|
7158
ffb31324aa5e
(svn r9893) -Fix (r9892): various small bugs that only act up when using something different than plain roads.
rubidium
parents:
7157
diff
changeset
|
92 |
DiagDirection dir = (DiagDirection)GB(p1, 0, 2); |
541 | 93 |
SndPlayTileFx(SND_1F_SPLAT, tile); |
0 | 94 |
ResetObjectToPlace(); |
7158
ffb31324aa5e
(svn r9893) -Fix (r9892): various small bugs that only act up when using something different than plain roads.
rubidium
parents:
7157
diff
changeset
|
95 |
BuildRoadOutsideStation(tile, dir); |
6428
f018110cdd9a
(svn r8837) -Fix [FS#626]: drive through stations did not connect to neighbouring roads (mart3p).
rubidium
parents:
6365
diff
changeset
|
96 |
/* For a drive-through road stop build connecting road for other entrance */ |
7158
ffb31324aa5e
(svn r9893) -Fix (r9892): various small bugs that only act up when using something different than plain roads.
rubidium
parents:
7157
diff
changeset
|
97 |
if (HASBIT(p2, 1)) BuildRoadOutsideStation(tile, ReverseDiagDir(dir)); |
0 | 98 |
} |
99 |
} |
|
100 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
101 |
static void PlaceRoad_Depot(TileIndex tile) |
0 | 102 |
{ |
7162
b769c2b45103
(svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents:
7158
diff
changeset
|
103 |
DoCommandP(tile, _cur_roadtype << 2 | _road_depot_orientation, 0, CcRoadDepot, CMD_BUILD_ROAD_DEPOT | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1807_CAN_T_BUILD_ROAD_VEHICLE)); |
0 | 104 |
} |
105 |
||
6338
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
106 |
static void PlaceRoadStop(TileIndex tile, uint32 p2, uint32 cmd) |
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
107 |
{ |
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
108 |
uint32 p1 = _road_station_picker_orientation; |
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
109 |
|
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
110 |
if (p1 >= DIAGDIR_END) { |
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
111 |
SETBIT(p2, 1); // It's a drive-through stop |
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
112 |
p1 -= DIAGDIR_END; // Adjust picker result to actual direction |
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
113 |
} |
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
114 |
DoCommandP(tile, p1, p2, CcRoadDepot, cmd); |
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
115 |
} |
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
116 |
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
117 |
static void PlaceRoad_BusStation(TileIndex tile) |
0 | 118 |
{ |
6338
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
119 |
if (_remove_button_clicked) { |
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
120 |
DoCommandP(tile, 0, RoadStop::BUS, CcPlaySound1D, CMD_REMOVE_ROAD_STOP | CMD_MSG(STR_CAN_T_REMOVE_BUS_STATION)); |
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
121 |
} else { |
7170
bd34b6d0e4f1
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros
parents:
7166
diff
changeset
|
122 |
PlaceRoadStop(tile, (_ctrl_pressed << 5) | ROADTYPES_ROAD << 2 | RoadStop::BUS, CMD_BUILD_ROAD_STOP | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1808_CAN_T_BUILD_BUS_STATION)); |
6338
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
123 |
} |
0 | 124 |
} |
125 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
126 |
static void PlaceRoad_TruckStation(TileIndex tile) |
0 | 127 |
{ |
6338
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
128 |
if (_remove_button_clicked) { |
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
129 |
DoCommandP(tile, 0, RoadStop::TRUCK, CcPlaySound1D, CMD_REMOVE_ROAD_STOP | CMD_MSG(STR_CAN_T_REMOVE_TRUCK_STATION)); |
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
130 |
} else { |
7170
bd34b6d0e4f1
(svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros
parents:
7166
diff
changeset
|
131 |
PlaceRoadStop(tile, (_ctrl_pressed << 5) | ROADTYPES_ROAD << 2 | RoadStop::TRUCK, CMD_BUILD_ROAD_STOP | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1809_CAN_T_BUILD_TRUCK_STATION)); |
6338
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
132 |
} |
0 | 133 |
} |
134 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
135 |
static void PlaceRoad_DemolishArea(TileIndex tile) |
0 | 136 |
{ |
7166
3937d5ea59df
(svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents:
7165
diff
changeset
|
137 |
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_DEMOLISH_AREA); |
0 | 138 |
} |
139 |
||
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5105
diff
changeset
|
140 |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5105
diff
changeset
|
141 |
enum { |
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5105
diff
changeset
|
142 |
RTW_ROAD_X = 3, |
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5105
diff
changeset
|
143 |
RTW_ROAD_Y = 4, |
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5105
diff
changeset
|
144 |
RTW_DEMOLISH = 5, |
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5105
diff
changeset
|
145 |
RTW_DEPOT = 6, |
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5105
diff
changeset
|
146 |
RTW_BUS_STATION = 7, |
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5105
diff
changeset
|
147 |
RTW_TRUCK_STATION = 8, |
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5105
diff
changeset
|
148 |
RTW_BUILD_BRIDGE = 9, |
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5105
diff
changeset
|
149 |
RTW_BUILD_TUNNEL = 10, |
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5105
diff
changeset
|
150 |
RTW_REMOVE = 11 |
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5105
diff
changeset
|
151 |
}; |
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5105
diff
changeset
|
152 |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5105
diff
changeset
|
153 |
|
0 | 154 |
typedef void OnButtonClick(Window *w); |
155 |
||
156 |
static void BuildRoadClick_NE(Window *w) |
|
157 |
{ |
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5105
diff
changeset
|
158 |
HandlePlacePushButton(w, RTW_ROAD_X, SPR_CURSOR_ROAD_NESW, 1, PlaceRoad_NE); |
0 | 159 |
} |
160 |
||
161 |
static void BuildRoadClick_NW(Window *w) |
|
162 |
{ |
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5105
diff
changeset
|
163 |
HandlePlacePushButton(w, RTW_ROAD_Y, SPR_CURSOR_ROAD_NWSE, 1, PlaceRoad_NW); |
0 | 164 |
} |
165 |
||
166 |
||
167 |
static void BuildRoadClick_Demolish(Window *w) |
|
168 |
{ |
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5105
diff
changeset
|
169 |
HandlePlacePushButton(w, RTW_DEMOLISH, ANIMCURSOR_DEMOLISH, 1, PlaceRoad_DemolishArea); |
0 | 170 |
} |
171 |
||
172 |
static void BuildRoadClick_Depot(Window *w) |
|
173 |
{ |
|
661
a0bdbdffb06a
(svn r1095) -Fix: scenario editor road-build-gui works again altough shortcuts are screwed.
darkvater
parents:
651
diff
changeset
|
174 |
if (_game_mode == GM_EDITOR) return; |
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5105
diff
changeset
|
175 |
if (HandlePlacePushButton(w, RTW_DEPOT, SPR_CURSOR_ROAD_DEPOT, 1, PlaceRoad_Depot)) ShowRoadDepotPicker(); |
0 | 176 |
} |
177 |
||
178 |
static void BuildRoadClick_BusStation(Window *w) |
|
179 |
{ |
|
661
a0bdbdffb06a
(svn r1095) -Fix: scenario editor road-build-gui works again altough shortcuts are screwed.
darkvater
parents:
651
diff
changeset
|
180 |
if (_game_mode == GM_EDITOR) return; |
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5105
diff
changeset
|
181 |
if (HandlePlacePushButton(w, RTW_BUS_STATION, SPR_CURSOR_BUS_STATION, 1, PlaceRoad_BusStation)) ShowBusStationPicker(); |
0 | 182 |
} |
183 |
||
184 |
static void BuildRoadClick_TruckStation(Window *w) |
|
185 |
{ |
|
661
a0bdbdffb06a
(svn r1095) -Fix: scenario editor road-build-gui works again altough shortcuts are screwed.
darkvater
parents:
651
diff
changeset
|
186 |
if (_game_mode == GM_EDITOR) return; |
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5105
diff
changeset
|
187 |
if (HandlePlacePushButton(w, RTW_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, 1, PlaceRoad_TruckStation)) ShowTruckStationPicker(); |
0 | 188 |
} |
189 |
||
190 |
static void BuildRoadClick_Bridge(Window *w) |
|
191 |
{ |
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5105
diff
changeset
|
192 |
HandlePlacePushButton(w, RTW_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, 1, PlaceRoad_Bridge); |
0 | 193 |
} |
194 |
||
195 |
static void BuildRoadClick_Tunnel(Window *w) |
|
196 |
{ |
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5105
diff
changeset
|
197 |
HandlePlacePushButton(w, RTW_BUILD_TUNNEL, SPR_CURSOR_ROAD_TUNNEL, 3, PlaceRoad_Tunnel); |
0 | 198 |
} |
199 |
||
200 |
static void BuildRoadClick_Remove(Window *w) |
|
201 |
{ |
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5105
diff
changeset
|
202 |
if (IsWindowWidgetDisabled(w, RTW_REMOVE)) return; |
0 | 203 |
SetWindowDirty(w); |
541 | 204 |
SndPlayFx(SND_15_BEEP); |
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5105
diff
changeset
|
205 |
ToggleWidgetLoweredState(w, RTW_REMOVE); |
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5105
diff
changeset
|
206 |
SetSelectionRed(IsWindowWidgetLowered(w, RTW_REMOVE)); |
0 | 207 |
} |
208 |
||
209 |
||
2639 | 210 |
static OnButtonClick* const _build_road_button_proc[] = { |
0 | 211 |
BuildRoadClick_NE, |
212 |
BuildRoadClick_NW, |
|
213 |
BuildRoadClick_Demolish, |
|
214 |
BuildRoadClick_Depot, |
|
215 |
BuildRoadClick_BusStation, |
|
216 |
BuildRoadClick_TruckStation, |
|
217 |
BuildRoadClick_Bridge, |
|
218 |
BuildRoadClick_Tunnel, |
|
5933
0835f3342b79
(svn r8143) Remove the landscaping button from the build toolbars.
tron
parents:
5838
diff
changeset
|
219 |
BuildRoadClick_Remove |
0 | 220 |
}; |
221 |
||
4171 | 222 |
static void BuildRoadToolbWndProc(Window *w, WindowEvent *e) |
2639 | 223 |
{ |
224 |
switch (e->event) { |
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5105
diff
changeset
|
225 |
case WE_CREATE: DisableWindowWidget(w, RTW_REMOVE); break; |
5105
4332193c0aec
(svn r7176) -Fix: remove button was not always disabled when it should have been (rail/road build toolbar)
glx
parents:
5072
diff
changeset
|
226 |
|
0 | 227 |
case WE_PAINT: |
6338
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
228 |
if (IsWindowWidgetLowered(w, RTW_ROAD_X) || IsWindowWidgetLowered(w, RTW_ROAD_Y) || IsWindowWidgetLowered(w, RTW_BUS_STATION) || IsWindowWidgetLowered(w, RTW_TRUCK_STATION)) { |
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5105
diff
changeset
|
229 |
EnableWindowWidget(w, RTW_REMOVE); |
0 | 230 |
} |
231 |
DrawWindowWidgets(w); |
|
232 |
break; |
|
233 |
||
234 |
case WE_CLICK: { |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4559
diff
changeset
|
235 |
if (e->we.click.widget >= 3) _build_road_button_proc[e->we.click.widget - 3](w); |
6988
76eba6a9cc6f
(svn r9673) -Cleanup: remove spaces before tabs and replace non-indenting tabs with spaces.
rubidium
parents:
6987
diff
changeset
|
236 |
} break; |
0 | 237 |
|
238 |
case WE_KEYPRESS: |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4559
diff
changeset
|
239 |
switch (e->we.keypress.keycode) { |
2631
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2619
diff
changeset
|
240 |
case '1': BuildRoadClick_NE(w); break; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2619
diff
changeset
|
241 |
case '2': BuildRoadClick_NW(w); break; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2619
diff
changeset
|
242 |
case '3': BuildRoadClick_Demolish(w); break; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2619
diff
changeset
|
243 |
case '4': BuildRoadClick_Depot(w); break; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2619
diff
changeset
|
244 |
case '5': BuildRoadClick_BusStation(w); break; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2619
diff
changeset
|
245 |
case '6': BuildRoadClick_TruckStation(w); break; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2619
diff
changeset
|
246 |
case 'B': BuildRoadClick_Bridge(w); break; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2619
diff
changeset
|
247 |
case 'T': BuildRoadClick_Tunnel(w); break; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2619
diff
changeset
|
248 |
case 'R': BuildRoadClick_Remove(w); break; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2619
diff
changeset
|
249 |
default: return; |
0 | 250 |
} |
756
d1f1dc31b6f4
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
679
diff
changeset
|
251 |
MarkTileDirty(_thd.pos.x, _thd.pos.y); // redraw tile selection |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4559
diff
changeset
|
252 |
e->we.keypress.cont = false; |
0 | 253 |
break; |
254 |
||
255 |
case WE_PLACE_OBJ: |
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5105
diff
changeset
|
256 |
_remove_button_clicked = IsWindowWidgetLowered(w, RTW_REMOVE); |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4559
diff
changeset
|
257 |
_place_proc(e->we.place.tile); |
0 | 258 |
break; |
259 |
||
260 |
case WE_ABORT_PLACE_OBJ: |
|
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
261 |
RaiseWindowButtons(w); |
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5105
diff
changeset
|
262 |
DisableWindowWidget(w, RTW_REMOVE); |
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5105
diff
changeset
|
263 |
InvalidateWidget(w, RTW_REMOVE); |
0 | 264 |
|
265 |
w = FindWindowById(WC_BUS_STATION, 0); |
|
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6889
diff
changeset
|
266 |
if (w != NULL) WP(w, def_d).close = true; |
0 | 267 |
w = FindWindowById(WC_TRUCK_STATION, 0); |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6889
diff
changeset
|
268 |
if (w != NULL) WP(w, def_d).close = true; |
0 | 269 |
w = FindWindowById(WC_BUILD_DEPOT, 0); |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6889
diff
changeset
|
270 |
if (w != NULL) WP(w, def_d).close = true; |
0 | 271 |
break; |
272 |
||
7165
37eb253f3c06
(svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents:
7162
diff
changeset
|
273 |
case WE_PLACE_DRAG: |
7166
3937d5ea59df
(svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents:
7165
diff
changeset
|
274 |
switch (e->we.place.select_proc) { |
3937d5ea59df
(svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents:
7165
diff
changeset
|
275 |
case DDSP_PLACE_ROAD_NE: |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4559
diff
changeset
|
276 |
_place_road_flag = (_place_road_flag & ~2) | ((e->we.place.pt.y & 8) >> 2); |
4435
cde1d8fc5c8f
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4434
diff
changeset
|
277 |
break; |
cde1d8fc5c8f
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4434
diff
changeset
|
278 |
|
7166
3937d5ea59df
(svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents:
7165
diff
changeset
|
279 |
case DDSP_PLACE_ROAD_NW: |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4559
diff
changeset
|
280 |
_place_road_flag = (_place_road_flag & ~2) | ((e->we.place.pt.x & 8) >> 2); |
4435
cde1d8fc5c8f
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4434
diff
changeset
|
281 |
break; |
0 | 282 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
283 |
|
7165
37eb253f3c06
(svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents:
7162
diff
changeset
|
284 |
VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method); |
0 | 285 |
return; |
286 |
||
287 |
case WE_PLACE_MOUSEUP: |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4559
diff
changeset
|
288 |
if (e->we.place.pt.x != -1) { |
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4559
diff
changeset
|
289 |
TileIndex start_tile = e->we.place.starttile; |
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4559
diff
changeset
|
290 |
TileIndex end_tile = e->we.place.tile; |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
291 |
|
7166
3937d5ea59df
(svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents:
7165
diff
changeset
|
292 |
switch (e->we.place.select_proc) { |
3937d5ea59df
(svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents:
7165
diff
changeset
|
293 |
case DDSP_BUILD_BRIDGE: |
7165
37eb253f3c06
(svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents:
7162
diff
changeset
|
294 |
ResetObjectToPlace(); |
37eb253f3c06
(svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents:
7162
diff
changeset
|
295 |
ShowBuildBridgeWindow(start_tile, end_tile, 0x80 | RoadTypeToRoadTypes(_cur_roadtype)); |
37eb253f3c06
(svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents:
7162
diff
changeset
|
296 |
break; |
37eb253f3c06
(svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents:
7162
diff
changeset
|
297 |
|
7166
3937d5ea59df
(svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents:
7165
diff
changeset
|
298 |
case DDSP_DEMOLISH_AREA: |
7165
37eb253f3c06
(svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents:
7162
diff
changeset
|
299 |
DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA)); |
37eb253f3c06
(svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents:
7162
diff
changeset
|
300 |
break; |
37eb253f3c06
(svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents:
7162
diff
changeset
|
301 |
|
7166
3937d5ea59df
(svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents:
7165
diff
changeset
|
302 |
case DDSP_PLACE_ROAD_NE: |
3937d5ea59df
(svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents:
7165
diff
changeset
|
303 |
case DDSP_PLACE_ROAD_NW: |
7165
37eb253f3c06
(svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents:
7162
diff
changeset
|
304 |
DoCommandP(end_tile, start_tile, _place_road_flag | (_cur_roadtype << 3), CcPlaySound1D, |
37eb253f3c06
(svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents:
7162
diff
changeset
|
305 |
_remove_button_clicked ? |
37eb253f3c06
(svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents:
7162
diff
changeset
|
306 |
CMD_REMOVE_LONG_ROAD | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1805_CAN_T_REMOVE_ROAD_FROM) : |
37eb253f3c06
(svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents:
7162
diff
changeset
|
307 |
CMD_BUILD_LONG_ROAD | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1804_CAN_T_BUILD_ROAD_HERE)); |
37eb253f3c06
(svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents:
7162
diff
changeset
|
308 |
break; |
0 | 309 |
} |
310 |
} |
|
311 |
break; |
|
312 |
||
313 |
case WE_PLACE_PRESIZE: { |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4559
diff
changeset
|
314 |
TileIndex tile = e->we.place.tile; |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
315 |
|
7162
b769c2b45103
(svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents:
7158
diff
changeset
|
316 |
DoCommand(tile, 0x200 | _cur_roadtype, 0, DC_AUTO, CMD_BUILD_TUNNEL); |
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3793
diff
changeset
|
317 |
VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile); |
0 | 318 |
break; |
319 |
} |
|
2619
c2f488e400b1
(svn r3157) - Feature: Added patch option to link the terraform toolbar to the rail, road, water and airport toolbars. If enabled, the terraform toolbar will open and close with those toolbars.
peter1138
parents:
2186
diff
changeset
|
320 |
|
c2f488e400b1
(svn r3157) - Feature: Added patch option to link the terraform toolbar to the rail, road, water and airport toolbars. If enabled, the terraform toolbar will open and close with those toolbars.
peter1138
parents:
2186
diff
changeset
|
321 |
case WE_DESTROY: |
c2f488e400b1
(svn r3157) - Feature: Added patch option to link the terraform toolbar to the rail, road, water and airport toolbars. If enabled, the terraform toolbar will open and close with those toolbars.
peter1138
parents:
2186
diff
changeset
|
322 |
if (_patches.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0); |
c2f488e400b1
(svn r3157) - Feature: Added patch option to link the terraform toolbar to the rail, road, water and airport toolbars. If enabled, the terraform toolbar will open and close with those toolbars.
peter1138
parents:
2186
diff
changeset
|
323 |
break; |
0 | 324 |
} |
325 |
} |
|
326 |
||
327 |
static const Widget _build_road_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4212
diff
changeset
|
328 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5933
0835f3342b79
(svn r8143) Remove the landscaping button from the build toolbars.
tron
parents:
5838
diff
changeset
|
329 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 205, 0, 13, STR_1802_ROAD_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
0835f3342b79
(svn r8143) Remove the landscaping button from the build toolbars.
tron
parents:
5838
diff
changeset
|
330 |
{ WWT_STICKYBOX, RESIZE_NONE, 7, 206, 217, 0, 13, 0x0, STR_STICKY_BUTTON}, |
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
331 |
|
4938
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4937
diff
changeset
|
332 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_ROAD_NW, STR_180B_BUILD_ROAD_SECTION}, |
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4937
diff
changeset
|
333 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 22, 43, 14, 35, SPR_IMG_ROAD_NE, STR_180B_BUILD_ROAD_SECTION}, |
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4937
diff
changeset
|
334 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 44, 65, 14, 35, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC}, |
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4937
diff
changeset
|
335 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 66, 87, 14, 35, SPR_IMG_ROAD_DEPOT, STR_180C_BUILD_ROAD_VEHICLE_DEPOT}, |
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4937
diff
changeset
|
336 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 88, 109, 14, 35, SPR_IMG_BUS_STATION, STR_180D_BUILD_BUS_STATION}, |
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4937
diff
changeset
|
337 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 110, 131, 14, 35, SPR_IMG_TRUCK_BAY, STR_180E_BUILD_TRUCK_LOADING_BAY}, |
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4937
diff
changeset
|
338 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 132, 173, 14, 35, SPR_IMG_BRIDGE, STR_180F_BUILD_ROAD_BRIDGE}, |
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4937
diff
changeset
|
339 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 174, 195, 14, 35, SPR_IMG_ROAD_TUNNEL, STR_1810_BUILD_ROAD_TUNNEL}, |
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4937
diff
changeset
|
340 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 196, 217, 14, 35, SPR_IMG_REMOVE, STR_1811_TOGGLE_BUILD_REMOVE_FOR}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
5
diff
changeset
|
341 |
{ WIDGETS_END}, |
0 | 342 |
}; |
343 |
||
344 |
static const WindowDesc _build_road_desc = { |
|
5933
0835f3342b79
(svn r8143) Remove the landscaping button from the build toolbars.
tron
parents:
5838
diff
changeset
|
345 |
WDP_ALIGN_TBR, 22, 218, 36, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6111
diff
changeset
|
346 |
WC_BUILD_TOOLBAR, WC_NONE, |
756
d1f1dc31b6f4
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
679
diff
changeset
|
347 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON, |
0 | 348 |
_build_road_widgets, |
349 |
BuildRoadToolbWndProc |
|
350 |
}; |
|
351 |
||
7162
b769c2b45103
(svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents:
7158
diff
changeset
|
352 |
void ShowBuildRoadToolbar(RoadType roadtype) |
0 | 353 |
{ |
5005
21e84e53c732
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4938
diff
changeset
|
354 |
if (!IsValidPlayer(_current_player)) return; |
7162
b769c2b45103
(svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents:
7158
diff
changeset
|
355 |
_cur_roadtype = roadtype; |
5005
21e84e53c732
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4938
diff
changeset
|
356 |
|
0 | 357 |
DeleteWindowById(WC_BUILD_TOOLBAR, 0); |
6111 | 358 |
Window *w = AllocateWindowDesc(&_build_road_desc); |
359 |
if (_patches.link_terraform_toolbar) ShowTerraformToolbar(w); |
|
0 | 360 |
} |
361 |
||
362 |
static const Widget _build_road_scen_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4212
diff
changeset
|
363 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5940
bfa6d1c71afc
(svn r8152) Fix a off-by-one error in the placement of the sticky box of the road build toolbar in the scenario editor
tron
parents:
5933
diff
changeset
|
364 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 139, 0, 13, STR_1802_ROAD_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
bfa6d1c71afc
(svn r8152) Fix a off-by-one error in the placement of the sticky box of the road build toolbar in the scenario editor
tron
parents:
5933
diff
changeset
|
365 |
{ WWT_STICKYBOX, RESIZE_NONE, 7, 140, 151, 0, 13, 0x0, STR_STICKY_BUTTON}, |
661
a0bdbdffb06a
(svn r1095) -Fix: scenario editor road-build-gui works again altough shortcuts are screwed.
darkvater
parents:
651
diff
changeset
|
366 |
|
4937
a525d56a8d40
(svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents:
4848
diff
changeset
|
367 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_ROAD_NW, STR_180B_BUILD_ROAD_SECTION}, |
a525d56a8d40
(svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents:
4848
diff
changeset
|
368 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 22, 43, 14, 35, SPR_IMG_ROAD_NE, STR_180B_BUILD_ROAD_SECTION}, |
a525d56a8d40
(svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents:
4848
diff
changeset
|
369 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 44, 65, 14, 35, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC}, |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4212
diff
changeset
|
370 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4212
diff
changeset
|
371 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4212
diff
changeset
|
372 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
4937
a525d56a8d40
(svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents:
4848
diff
changeset
|
373 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 66, 107, 14, 35, SPR_IMG_BRIDGE, STR_180F_BUILD_ROAD_BRIDGE}, |
a525d56a8d40
(svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents:
4848
diff
changeset
|
374 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 108, 129, 14, 35, SPR_IMG_ROAD_TUNNEL, STR_1810_BUILD_ROAD_TUNNEL}, |
a525d56a8d40
(svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents:
4848
diff
changeset
|
375 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 130, 151, 14, 35, SPR_IMG_REMOVE, STR_1811_TOGGLE_BUILD_REMOVE_FOR}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
5
diff
changeset
|
376 |
{ WIDGETS_END}, |
0 | 377 |
}; |
378 |
||
379 |
static const WindowDesc _build_road_scen_desc = { |
|
5584
a2beaf8ed3a4
(svn r7586) -Fix (FS#473): remove the Landscaping toolbar option from the Road Construction toolbar in the scenario editor, as there is another Lanscaping GUI in the scenario editor and launching that one could confuse users.
rubidium
parents:
5147
diff
changeset
|
380 |
WDP_AUTO, WDP_AUTO, 152, 36, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6111
diff
changeset
|
381 |
WC_SCEN_BUILD_ROAD, WC_NONE, |
777
3d7798da0f10
(svn r1243) -Fix: Scenario road-building toolbar also stickified. Thx for the notice teeone
darkvater
parents:
756
diff
changeset
|
382 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON, |
0 | 383 |
_build_road_scen_widgets, |
384 |
BuildRoadToolbWndProc |
|
385 |
}; |
|
386 |
||
6573 | 387 |
void ShowBuildRoadScenToolbar() |
0 | 388 |
{ |
389 |
AllocateWindowDescFront(&_build_road_scen_desc, 0); |
|
390 |
} |
|
391 |
||
4171 | 392 |
static void BuildRoadDepotWndProc(Window *w, WindowEvent *e) |
2639 | 393 |
{ |
394 |
switch (e->event) { |
|
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
395 |
case WE_CREATE: LowerWindowWidget(w, _road_depot_orientation + 3); break; |
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
396 |
|
0 | 397 |
case WE_PAINT: |
398 |
DrawWindowWidgets(w); |
|
399 |
||
7162
b769c2b45103
(svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents:
7158
diff
changeset
|
400 |
DrawRoadDepotSprite(70, 17, DIAGDIR_NE, _cur_roadtype); |
b769c2b45103
(svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents:
7158
diff
changeset
|
401 |
DrawRoadDepotSprite(70, 69, DIAGDIR_SE, _cur_roadtype); |
b769c2b45103
(svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents:
7158
diff
changeset
|
402 |
DrawRoadDepotSprite( 2, 69, DIAGDIR_SW, _cur_roadtype); |
b769c2b45103
(svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents:
7158
diff
changeset
|
403 |
DrawRoadDepotSprite( 2, 17, DIAGDIR_NW, _cur_roadtype); |
0 | 404 |
break; |
405 |
||
406 |
case WE_CLICK: { |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4559
diff
changeset
|
407 |
switch (e->we.click.widget) { |
1116
a38aed715c95
(svn r1617) -Fix: Ugly hack to only call ResetObjectToPlaceon childwindows of build-toolbar if the window is closed manually (with 'X'); if not checked ResetObjectToPlace is called twice resulting in undesired actions (eg. clicked button is unclicked immediately).
darkvater
parents:
1109
diff
changeset
|
408 |
case 3: case 4: case 5: case 6: |
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
409 |
RaiseWindowWidget(w, _road_depot_orientation + 3); |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
410 |
_road_depot_orientation = (DiagDirection)(e->we.click.widget - 3); |
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
411 |
LowerWindowWidget(w, _road_depot_orientation + 3); |
541 | 412 |
SndPlayFx(SND_15_BEEP); |
0 | 413 |
SetWindowDirty(w); |
414 |
break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
415 |
} |
6988
76eba6a9cc6f
(svn r9673) -Cleanup: remove spaces before tabs and replace non-indenting tabs with spaces.
rubidium
parents:
6987
diff
changeset
|
416 |
} break; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
417 |
|
0 | 418 |
case WE_MOUSELOOP: |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6889
diff
changeset
|
419 |
if (WP(w, def_d).close) DeleteWindow(w); |
0 | 420 |
break; |
1072
01bf9fc64236
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1035
diff
changeset
|
421 |
|
01bf9fc64236
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1035
diff
changeset
|
422 |
case WE_DESTROY: |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6889
diff
changeset
|
423 |
if (!WP(w, def_d).close) ResetObjectToPlace(); |
1072
01bf9fc64236
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1035
diff
changeset
|
424 |
break; |
0 | 425 |
} |
426 |
} |
|
427 |
||
428 |
static const Widget _build_road_depot_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4212
diff
changeset
|
429 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
787
diff
changeset
|
430 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 139, 0, 13, STR_1806_ROAD_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4212
diff
changeset
|
431 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 139, 14, 121, 0x0, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4212
diff
changeset
|
432 |
{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 17, 66, 0x0, STR_1813_SELECT_ROAD_VEHICLE_DEPOT}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4212
diff
changeset
|
433 |
{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 69, 118, 0x0, STR_1813_SELECT_ROAD_VEHICLE_DEPOT}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4212
diff
changeset
|
434 |
{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 69, 118, 0x0, STR_1813_SELECT_ROAD_VEHICLE_DEPOT}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4212
diff
changeset
|
435 |
{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 17, 66, 0x0, STR_1813_SELECT_ROAD_VEHICLE_DEPOT}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
5
diff
changeset
|
436 |
{ WIDGETS_END}, |
0 | 437 |
}; |
438 |
||
439 |
static const WindowDesc _build_road_depot_desc = { |
|
5070
0bbf5264bfb7
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
440 |
WDP_AUTO, WDP_AUTO, 140, 122, |
0bbf5264bfb7
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
441 |
WC_BUILD_DEPOT, WC_BUILD_TOOLBAR, |
0 | 442 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
443 |
_build_road_depot_widgets, |
|
444 |
BuildRoadDepotWndProc |
|
445 |
}; |
|
446 |
||
6573 | 447 |
static void ShowRoadDepotPicker() |
0 | 448 |
{ |
449 |
AllocateWindowDesc(&_build_road_depot_desc); |
|
450 |
} |
|
451 |
||
987
ea47ad079de8
(svn r1485) -Fix: [1031451] Catchment area shows when buying sign. Catchment area wasn't reset when road station window was unselected
darkvater
parents:
946
diff
changeset
|
452 |
static void RoadStationPickerWndProc(Window *w, WindowEvent *e) |
ea47ad079de8
(svn r1485) -Fix: [1031451] Catchment area shows when buying sign. Catchment area wasn't reset when road station window was unselected
darkvater
parents:
946
diff
changeset
|
453 |
{ |
2952 | 454 |
switch (e->event) { |
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
455 |
case WE_CREATE: |
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
456 |
LowerWindowWidget(w, _road_station_picker_orientation + 3); |
6338
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
457 |
LowerWindowWidget(w, _station_show_coverage + 9); |
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
458 |
break; |
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
459 |
|
0 | 460 |
case WE_PAINT: { |
461 |
int image; |
|
462 |
||
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6889
diff
changeset
|
463 |
if (WP(w, def_d).close) return; |
987
ea47ad079de8
(svn r1485) -Fix: [1031451] Catchment area shows when buying sign. Catchment area wasn't reset when road station window was unselected
darkvater
parents:
946
diff
changeset
|
464 |
|
0 | 465 |
DrawWindowWidgets(w); |
466 |
||
987
ea47ad079de8
(svn r1485) -Fix: [1031451] Catchment area shows when buying sign. Catchment area wasn't reset when road station window was unselected
darkvater
parents:
946
diff
changeset
|
467 |
if (_station_show_coverage) { |
ea47ad079de8
(svn r1485) -Fix: [1031451] Catchment area shows when buying sign. Catchment area wasn't reset when road station window was unselected
darkvater
parents:
946
diff
changeset
|
468 |
int rad = _patches.modified_catchment ? CA_TRUCK /* = CA_BUS */ : 4; |
ea47ad079de8
(svn r1485) -Fix: [1031451] Catchment area shows when buying sign. Catchment area wasn't reset when road station window was unselected
darkvater
parents:
946
diff
changeset
|
469 |
SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad); |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4008
diff
changeset
|
470 |
} else { |
987
ea47ad079de8
(svn r1485) -Fix: [1031451] Catchment area shows when buying sign. Catchment area wasn't reset when road station window was unselected
darkvater
parents:
946
diff
changeset
|
471 |
SetTileSelectSize(1, 1); |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4008
diff
changeset
|
472 |
} |
0 | 473 |
|
6338
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
474 |
image = (w->window_class == WC_BUS_STATION) ? GFX_BUS_BASE : GFX_TRUCK_BASE; |
0 | 475 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
476 |
StationPickerDrawSprite(103, 35, RAILTYPE_BEGIN, image); |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6889
diff
changeset
|
477 |
StationPickerDrawSprite(103, 85, RAILTYPE_BEGIN, image + 1); |
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6889
diff
changeset
|
478 |
StationPickerDrawSprite(35, 85, RAILTYPE_BEGIN, image + 2); |
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6889
diff
changeset
|
479 |
StationPickerDrawSprite(35, 35, RAILTYPE_BEGIN, image + 3); |
0 | 480 |
|
6338
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
481 |
image = (w->window_class == WC_BUS_STATION) ? GFX_BUS_BASE_EXT : GFX_TRUCK_BASE_EXT; |
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
482 |
|
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
483 |
StationPickerDrawSprite(171, 35, RAILTYPE_BEGIN, image); |
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
484 |
StationPickerDrawSprite(171, 85, RAILTYPE_BEGIN, image + 1); |
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
485 |
|
0 | 486 |
DrawStationCoverageAreaText(2, 146, |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6889
diff
changeset
|
487 |
((w->window_class == WC_BUS_STATION) ? (1 << CT_PASSENGERS) : ~(1 << CT_PASSENGERS)), |
568
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
488 |
3); |
0 | 489 |
|
490 |
} break; |
|
491 |
||
492 |
case WE_CLICK: { |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4559
diff
changeset
|
493 |
switch (e->we.click.widget) { |
6338
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
494 |
case 3: case 4: case 5: case 6: case 7: case 8: |
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
495 |
RaiseWindowWidget(w, _road_station_picker_orientation + 3); |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
496 |
_road_station_picker_orientation = (DiagDirection)(e->we.click.widget - 3); |
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
497 |
LowerWindowWidget(w, _road_station_picker_orientation + 3); |
541 | 498 |
SndPlayFx(SND_15_BEEP); |
0 | 499 |
SetWindowDirty(w); |
500 |
break; |
|
6338
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
501 |
case 9: case 10: |
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
502 |
RaiseWindowWidget(w, _station_show_coverage + 9); |
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
503 |
_station_show_coverage = (e->we.click.widget != 9); |
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
504 |
LowerWindowWidget(w, _station_show_coverage + 9); |
541 | 505 |
SndPlayFx(SND_15_BEEP); |
0 | 506 |
SetWindowDirty(w); |
507 |
break; |
|
508 |
} |
|
509 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
510 |
|
0 | 511 |
case WE_MOUSELOOP: { |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6889
diff
changeset
|
512 |
if (WP(w, def_d).close) { |
0 | 513 |
DeleteWindow(w); |
514 |
return; |
|
515 |
} |
|
516 |
||
517 |
CheckRedrawStationCoverage(w); |
|
518 |
} break; |
|
1109
1bab892228cd
(svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents:
1093
diff
changeset
|
519 |
|
1072
01bf9fc64236
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1035
diff
changeset
|
520 |
case WE_DESTROY: |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6889
diff
changeset
|
521 |
if (!WP(w, def_d).close) ResetObjectToPlace(); |
1072
01bf9fc64236
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1035
diff
changeset
|
522 |
break; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
523 |
} |
0 | 524 |
} |
525 |
||
526 |
static const Widget _bus_station_picker_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4212
diff
changeset
|
527 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
6338
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
528 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 206, 0, 13, STR_3042_BUS_STATION_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
529 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 206, 14, 176, 0x0, STR_NULL}, |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4212
diff
changeset
|
530 |
{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 17, 66, 0x0, STR_3051_SELECT_BUS_STATION_ORIENTATION}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4212
diff
changeset
|
531 |
{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 69, 118, 0x0, STR_3051_SELECT_BUS_STATION_ORIENTATION}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4212
diff
changeset
|
532 |
{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 69, 118, 0x0, STR_3051_SELECT_BUS_STATION_ORIENTATION}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4212
diff
changeset
|
533 |
{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 17, 66, 0x0, STR_3051_SELECT_BUS_STATION_ORIENTATION}, |
6338
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
534 |
{ WWT_PANEL, RESIZE_NONE, 14, 139, 204, 17, 66, 0x0, STR_3051_SELECT_BUS_STATION_ORIENTATION}, |
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
535 |
{ WWT_PANEL, RESIZE_NONE, 14, 139, 204, 69, 118, 0x0, STR_3051_SELECT_BUS_STATION_ORIENTATION}, |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4212
diff
changeset
|
536 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 10, 69, 133, 144, STR_02DB_OFF, STR_3065_DON_T_HIGHLIGHT_COVERAGE}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4212
diff
changeset
|
537 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 70, 129, 133, 144, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA}, |
4938
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4937
diff
changeset
|
538 |
{ WWT_LABEL, RESIZE_NONE, 7, 0, 139, 120, 133, STR_3066_COVERAGE_AREA_HIGHLIGHT, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
5
diff
changeset
|
539 |
{ WIDGETS_END}, |
0 | 540 |
}; |
541 |
||
542 |
static const WindowDesc _bus_station_picker_desc = { |
|
6338
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
543 |
WDP_AUTO, WDP_AUTO, 207, 177, |
5070
0bbf5264bfb7
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
544 |
WC_BUS_STATION, WC_BUILD_TOOLBAR, |
0 | 545 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
546 |
_bus_station_picker_widgets, |
|
547 |
RoadStationPickerWndProc |
|
548 |
}; |
|
549 |
||
6573 | 550 |
static void ShowBusStationPicker() |
0 | 551 |
{ |
552 |
AllocateWindowDesc(&_bus_station_picker_desc); |
|
553 |
} |
|
554 |
||
555 |
static const Widget _truck_station_picker_widgets[] = { |
|
4345
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
556 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
6338
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
557 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 206, 0, 13, STR_3043_TRUCK_STATION_ORIENT, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
558 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 206, 14, 176, 0x0, STR_NULL}, |
4345
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
559 |
{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 17, 66, 0x0, STR_3052_SELECT_TRUCK_LOADING_BAY}, |
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
560 |
{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 69, 118, 0x0, STR_3052_SELECT_TRUCK_LOADING_BAY}, |
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
561 |
{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 69, 118, 0x0, STR_3052_SELECT_TRUCK_LOADING_BAY}, |
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
562 |
{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 17, 66, 0x0, STR_3052_SELECT_TRUCK_LOADING_BAY}, |
6338
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
563 |
{ WWT_PANEL, RESIZE_NONE, 14, 139, 204, 17, 66, 0x0, STR_3052_SELECT_TRUCK_LOADING_BAY}, |
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
564 |
{ WWT_PANEL, RESIZE_NONE, 14, 139, 204, 69, 118, 0x0, STR_3052_SELECT_TRUCK_LOADING_BAY}, |
4345
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
565 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 10, 69, 133, 144, STR_02DB_OFF, STR_3065_DON_T_HIGHLIGHT_COVERAGE}, |
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
566 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 70, 129, 133, 144, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA}, |
4938
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4937
diff
changeset
|
567 |
{ WWT_LABEL, RESIZE_NONE, 7, 0, 139, 120, 133, STR_3066_COVERAGE_AREA_HIGHLIGHT, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
5
diff
changeset
|
568 |
{ WIDGETS_END}, |
0 | 569 |
}; |
570 |
||
571 |
static const WindowDesc _truck_station_picker_desc = { |
|
6338
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
6144
diff
changeset
|
572 |
WDP_AUTO, WDP_AUTO, 207, 177, |
5070
0bbf5264bfb7
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
573 |
WC_TRUCK_STATION, WC_BUILD_TOOLBAR, |
0 | 574 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
575 |
_truck_station_picker_widgets, |
|
576 |
RoadStationPickerWndProc |
|
577 |
}; |
|
578 |
||
6573 | 579 |
static void ShowTruckStationPicker() |
0 | 580 |
{ |
581 |
AllocateWindowDesc(&_truck_station_picker_desc); |
|
582 |
} |
|
583 |
||
6573 | 584 |
void InitializeRoadGui() |
0 | 585 |
{ |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
586 |
_road_depot_orientation = DIAGDIR_NW; |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
587 |
_road_station_picker_orientation = DIAGDIR_NW; |
0 | 588 |
} |