| author | glx |
| Sat, 06 Oct 2007 22:30:24 +0000 | |
| branch | noai |
| changeset 9704 | 197cb8c6ae17 |
| parent 9703 | d2a6acdbd665 |
| child 9718 | f82a4facea8b |
| permissions | -rw-r--r-- |
| 2186 | 1 |
/* $Id$ */ |
2 |
||
|
6443
b8f06d8eb7be
(svn r8853) -Cleanup: doxygen changes. Correct forgotten c files to cpp files with the @file tag as well as a few general comments style
belugas
parents:
6432
diff
changeset
|
3 |
/** @file rail_gui.cpp File for dealing with rail construction user interface */ |
|
2274
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
4 |
|
| 0 | 5 |
#include "stdafx.h" |
|
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1884
diff
changeset
|
6 |
#include "openttd.h" |
|
1363
01d3de5d8039
(svn r1867) Include tables/sprites.h only in files which need it
tron
parents:
1227
diff
changeset
|
7 |
#include "table/sprites.h" |
|
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
449
diff
changeset
|
8 |
#include "table/strings.h" |
|
9686
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9641
diff
changeset
|
9 |
#include "strings.h" |
|
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
10 |
#include "functions.h" |
| 9599 | 11 |
#include "landscape.h" |
|
5939
77530457a36b
(svn r8151) -Feature: Automatically build semaphores before a configurable date, which can be set by each network player seperately.
maedhros
parents:
5933
diff
changeset
|
12 |
#include "date.h" |
|
679
e959706a3e4d
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
651
diff
changeset
|
13 |
#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:
1123
diff
changeset
|
14 |
#include "tile.h" |
| 0 | 15 |
#include "window.h" |
16 |
#include "gui.h" |
|
17 |
#include "viewport.h" |
|
18 |
#include "gfx.h" |
|
|
337
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
288
diff
changeset
|
19 |
#include "sound.h" |
| 0 | 20 |
#include "command.h" |
21 |
#include "vehicle.h" |
|
|
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
22 |
#include "station.h" |
|
1542
2ca6d1624e6d
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1363
diff
changeset
|
23 |
#include "waypoint.h" |
|
1738
6c7f9d12197d
(svn r2242) -Fix: [ 1193414 ] Fix for waypoint GUI, scrolling and button-actions (Hackykid)
Darkvater
parents:
1656
diff
changeset
|
24 |
#include "debug.h" |
|
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2049
diff
changeset
|
25 |
#include "variables.h" |
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
26 |
#include "newgrf_callbacks.h" |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
27 |
#include "newgrf_station.h" |
|
5116
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5105
diff
changeset
|
28 |
#include "train.h" |
| 0 | 29 |
|
| 9629 | 30 |
#include "bridge_map.h" |
31 |
#include "rail_map.h" |
|
32 |
#include "road_map.h" |
|
33 |
#include "station_map.h" |
|
34 |
#include "tunnel_map.h" |
|
35 |
||
|
2520
75eb66d6e371
(svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents:
2514
diff
changeset
|
36 |
static RailType _cur_railtype; |
| 0 | 37 |
static bool _remove_button_clicked; |
|
3157
40de8616c04c
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3132
diff
changeset
|
38 |
static DiagDirection _build_depot_direction; |
| 2639 | 39 |
static byte _waypoint_count = 1; |
|
395
4c990f33dab7
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
393
diff
changeset
|
40 |
static byte _cur_waypoint_type; |
| 0 | 41 |
|
| 2630 | 42 |
static struct {
|
| 0 | 43 |
byte orientation; |
44 |
byte numtracks; |
|
45 |
byte platlength; |
|
46 |
bool dragdrop; |
|
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
47 |
|
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
48 |
bool newstations; |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
49 |
StationClassIDByte station_class; |
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
50 |
byte station_type; |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
51 |
byte station_count; |
| 0 | 52 |
} _railstation; |
53 |
||
54 |
||
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
55 |
static void HandleStationPlacement(TileIndex start, TileIndex end); |
| 6573 | 56 |
static void ShowBuildTrainDepotPicker(); |
57 |
static void ShowBuildWaypointPicker(); |
|
58 |
static void ShowStationBuilder(); |
|
| 0 | 59 |
|
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
60 |
void CcPlaySound1E(bool success, TileIndex tile, uint32 p1, uint32 p2) |
| 0 | 61 |
{
|
| 541 | 62 |
if (success) SndPlayTileFx(SND_20_SPLAT_2, tile); |
| 0 | 63 |
} |
64 |
||
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
65 |
static void GenericPlaceRail(TileIndex tile, int cmd) |
| 0 | 66 |
{
|
67 |
DoCommandP(tile, _cur_railtype, cmd, CcPlaySound1E, |
|
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
68 |
_remove_button_clicked ? |
|
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9694
diff
changeset
|
69 |
CMD_REMOVE_SINGLE_RAIL | CMD_MSG(STR_1012_CAN_T_REMOVE_RAILROAD_TRACK) | CMD_NO_WATER : |
|
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9694
diff
changeset
|
70 |
CMD_BUILD_SINGLE_RAIL | CMD_MSG(STR_1011_CAN_T_BUILD_RAILROAD_TRACK) | CMD_NO_WATER |
| 2639 | 71 |
); |
| 0 | 72 |
} |
73 |
||
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
74 |
static void PlaceRail_N(TileIndex tile) |
| 0 | 75 |
{
|
76 |
int cmd = _tile_fract_coords.x > _tile_fract_coords.y ? 4 : 5; |
|
77 |
GenericPlaceRail(tile, cmd); |
|
78 |
} |
|
79 |
||
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
80 |
static void PlaceRail_NE(TileIndex tile) |
| 0 | 81 |
{
|
| 9624 | 82 |
VpStartPlaceSizing(tile, VPM_FIX_Y, DDSP_PLACE_RAIL_NE); |
| 0 | 83 |
} |
84 |
||
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
85 |
static void PlaceRail_E(TileIndex tile) |
| 0 | 86 |
{
|
87 |
int cmd = _tile_fract_coords.x + _tile_fract_coords.y <= 15 ? 2 : 3; |
|
88 |
GenericPlaceRail(tile, cmd); |
|
89 |
} |
|
90 |
||
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
91 |
static void PlaceRail_NW(TileIndex tile) |
| 0 | 92 |
{
|
| 9624 | 93 |
VpStartPlaceSizing(tile, VPM_FIX_X, DDSP_PLACE_RAIL_NW); |
| 0 | 94 |
} |
95 |
||
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
96 |
static void PlaceRail_AutoRail(TileIndex tile) |
| 0 | 97 |
{
|
| 9624 | 98 |
VpStartPlaceSizing(tile, VPM_RAILDIRS, DDSP_PLACE_AUTORAIL); |
| 0 | 99 |
} |
100 |
||
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
101 |
static void PlaceExtraDepotRail(TileIndex tile, uint16 extra) |
| 0 | 102 |
{
|
|
3792
2eb8388731bf
(svn r4788) - Codechange: RAILTYPE_{NORMAL,ELECTRIC,...} and RAIL_TYPE_{NORMAL,SIGNAL,...} have nearly the same name, rename RAIL_TYPE_* to RAIL_TILE_* of extra clarity
rubidium
parents:
3782
diff
changeset
|
103 |
if (GetRailTileType(tile) != RAIL_TILE_NORMAL) return; |
|
3269
95e7bffcb3c5
(svn r3981) More work for the rail accessing functions and enums
tron
parents:
3157
diff
changeset
|
104 |
if ((GetTrackBits(tile) & GB(extra, 8, 8)) == 0) return; |
| 0 | 105 |
|
|
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9694
diff
changeset
|
106 |
DoCommandP(tile, _cur_railtype, extra & 0xFF, NULL, CMD_BUILD_SINGLE_RAIL | CMD_NO_WATER); |
| 0 | 107 |
} |
108 |
||
109 |
static const uint16 _place_depot_extra[12] = {
|
|
|
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:
4171
diff
changeset
|
110 |
0x0604, 0x2102, 0x1202, 0x0505, |
|
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:
4171
diff
changeset
|
111 |
0x2400, 0x2801, 0x1800, 0x1401, |
|
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:
4171
diff
changeset
|
112 |
0x2203, 0x0904, 0x0A05, 0x1103, |
| 0 | 113 |
}; |
114 |
||
115 |
||
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
116 |
void CcRailDepot(bool success, TileIndex tile, uint32 p1, uint32 p2) |
| 0 | 117 |
{
|
118 |
if (success) {
|
|
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
119 |
DiagDirection dir = (DiagDirection)p2; |
| 0 | 120 |
|
| 541 | 121 |
SndPlayTileFx(SND_20_SPLAT_2, tile); |
| 0 | 122 |
ResetObjectToPlace(); |
123 |
||
|
4559
c853d2440065
(svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents:
4547
diff
changeset
|
124 |
tile += TileOffsByDiagDir(dir); |
| 0 | 125 |
|
|
1035
0a170deb6e33
(svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts
tron
parents:
980
diff
changeset
|
126 |
if (IsTileType(tile, MP_RAILWAY)) {
|
| 0 | 127 |
PlaceExtraDepotRail(tile, _place_depot_extra[dir]); |
128 |
PlaceExtraDepotRail(tile, _place_depot_extra[dir + 4]); |
|
129 |
PlaceExtraDepotRail(tile, _place_depot_extra[dir + 8]); |
|
130 |
} |
|
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
131 |
} |
| 0 | 132 |
} |
133 |
||
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
134 |
static void PlaceRail_Depot(TileIndex tile) |
| 0 | 135 |
{
|
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
136 |
DoCommandP(tile, _cur_railtype, _build_depot_direction, CcRailDepot, |
|
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9694
diff
changeset
|
137 |
CMD_BUILD_TRAIN_DEPOT | CMD_NO_WATER | CMD_MSG(STR_100E_CAN_T_BUILD_TRAIN_DEPOT)); |
| 0 | 138 |
} |
139 |
||
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
140 |
static void PlaceRail_Waypoint(TileIndex tile) |
| 0 | 141 |
{
|
142 |
if (!_remove_button_clicked) {
|
|
|
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2619
diff
changeset
|
143 |
DoCommandP(tile, _cur_waypoint_type, 0, CcPlaySound1E, CMD_BUILD_TRAIN_WAYPOINT | CMD_MSG(STR_CANT_BUILD_TRAIN_WAYPOINT)); |
| 0 | 144 |
} else {
|
|
395
4c990f33dab7
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
393
diff
changeset
|
145 |
DoCommandP(tile, 0, 0, CcPlaySound1E, CMD_REMOVE_TRAIN_WAYPOINT | CMD_MSG(STR_CANT_REMOVE_TRAIN_WAYPOINT)); |
| 0 | 146 |
} |
147 |
} |
|
148 |
||
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
149 |
void CcStation(bool success, TileIndex tile, uint32 p1, uint32 p2) |
| 0 | 150 |
{
|
151 |
if (success) {
|
|
| 541 | 152 |
SndPlayTileFx(SND_20_SPLAT_2, tile); |
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
153 |
/* Only close the station builder window if the default station is chosen. */ |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
154 |
if (_railstation.station_class == STAT_CLASS_DFLT && _railstation.station_type == 0) ResetObjectToPlace(); |
| 0 | 155 |
} |
156 |
} |
|
157 |
||
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
158 |
static void PlaceRail_Station(TileIndex tile) |
| 0 | 159 |
{
|
|
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3921
diff
changeset
|
160 |
if (_remove_button_clicked) {
|
| 9624 | 161 |
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_REMOVE_STATION); |
|
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3921
diff
changeset
|
162 |
} else if (_railstation.dragdrop) {
|
| 9624 | 163 |
VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_BUILD_STATION); |
| 0 | 164 |
VpSetPlaceSizingLimit(_patches.station_spread); |
165 |
} else {
|
|
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
166 |
DoCommandP(tile, |
| 9624 | 167 |
_railstation.orientation | (_railstation.numtracks << 8) | (_railstation.platlength << 16) | (_ctrl_pressed << 24), |
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
168 |
_cur_railtype | (_railstation.station_class << 8) | (_railstation.station_type << 16), CcStation, |
|
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9694
diff
changeset
|
169 |
CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION)); |
| 0 | 170 |
} |
171 |
} |
|
172 |
||
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
173 |
static void GenericPlaceSignals(TileIndex tile) |
| 0 | 174 |
{
|
| 9626 | 175 |
TrackBits trackbits = (TrackBits)GB(GetTileTrackStatus(tile, TRANSPORT_RAIL, 0), 0, 6); |
| 0 | 176 |
|
| 9626 | 177 |
if (trackbits & TRACK_BIT_VERT) { // N-S direction
|
178 |
trackbits = (_tile_fract_coords.x <= _tile_fract_coords.y) ? TRACK_BIT_RIGHT : TRACK_BIT_LEFT; |
|
| 2639 | 179 |
} |
| 0 | 180 |
|
| 9626 | 181 |
if (trackbits & TRACK_BIT_HORZ) { // E-W direction
|
182 |
trackbits = (_tile_fract_coords.x + _tile_fract_coords.y <= 15) ? TRACK_BIT_UPPER : TRACK_BIT_LOWER; |
|
183 |
} |
|
184 |
||
| 9627 | 185 |
Track track = FindFirstTrack(trackbits); |
| 9626 | 186 |
|
| 0 | 187 |
if (!_remove_button_clicked) {
|
| 9626 | 188 |
uint32 p1 = track; |
|
5986
1b9ab9629d36
(svn r8279) -Regression (r8274): Removing signals could fail under certain circumstances (not the proper bits of p1/p2 were set to trackbits). Moved trackbits back to bits 0..2, ctrl to 3, semaphore to 4. Also lower the decision of the ctrl-override of signal/semaphore from the GUI into the cmd function since we are passing the ctrl-bit anyways. Bug(s) found by Frostregen; thanks
Darkvater
parents:
5982
diff
changeset
|
189 |
SB(p1, 3, 1, _ctrl_pressed); |
|
1b9ab9629d36
(svn r8279) -Regression (r8274): Removing signals could fail under certain circumstances (not the proper bits of p1/p2 were set to trackbits). Moved trackbits back to bits 0..2, ctrl to 3, semaphore to 4. Also lower the decision of the ctrl-override of signal/semaphore from the GUI into the cmd function since we are passing the ctrl-bit anyways. Bug(s) found by Frostregen; thanks
Darkvater
parents:
5982
diff
changeset
|
190 |
SB(p1, 4, 1, _cur_year < _patches.semaphore_build_before); |
|
5982
54218ea5af1e
(svn r8274) -Codechange (r8151): Move the automatic semaphore/signal checks inside the CMD_ functions where they are supposed to be. Achieve this by adding a seperate bit to p1/p2 to hold the CTRL-modifier. While here, use proper types, and 'unify' the parameter bit-meanings. 0 - ctrl-pressed, 1 - signal/semaphore, 2-4 - trackbits, 5 - remove (internal), 24-31 - drag density.
Darkvater
parents:
5947
diff
changeset
|
191 |
|
|
54218ea5af1e
(svn r8274) -Codechange (r8151): Move the automatic semaphore/signal checks inside the CMD_ functions where they are supposed to be. Achieve this by adding a seperate bit to p1/p2 to hold the CTRL-modifier. While here, use proper types, and 'unify' the parameter bit-meanings. 0 - ctrl-pressed, 1 - signal/semaphore, 2-4 - trackbits, 5 - remove (internal), 24-31 - drag density.
Darkvater
parents:
5947
diff
changeset
|
192 |
DoCommandP(tile, p1, 0, CcPlaySound1E, |
|
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9694
diff
changeset
|
193 |
CMD_BUILD_SIGNALS | CMD_MSG(STR_1010_CAN_T_BUILD_SIGNALS_HERE)); |
| 0 | 194 |
} else {
|
| 9626 | 195 |
DoCommandP(tile, track, 0, CcPlaySound1E, |
|
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9694
diff
changeset
|
196 |
CMD_REMOVE_SIGNALS | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM)); |
| 0 | 197 |
} |
198 |
} |
|
199 |
||
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
200 |
static void PlaceRail_Bridge(TileIndex tile) |
| 0 | 201 |
{
|
| 9624 | 202 |
VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_BUILD_BRIDGE); |
| 0 | 203 |
} |
204 |
||
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
205 |
void CcBuildRailTunnel(bool success, TileIndex tile, uint32 p1, uint32 p2) |
| 0 | 206 |
{
|
207 |
if (success) {
|
|
| 541 | 208 |
SndPlayTileFx(SND_20_SPLAT_2, tile); |
| 0 | 209 |
ResetObjectToPlace(); |
210 |
} else {
|
|
211 |
SetRedErrorSquare(_build_tunnel_endtile); |
|
212 |
} |
|
213 |
} |
|
214 |
||
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
215 |
static void PlaceRail_Tunnel(TileIndex tile) |
| 0 | 216 |
{
|
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
217 |
DoCommandP(tile, _cur_railtype, 0, CcBuildRailTunnel, |
|
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9694
diff
changeset
|
218 |
CMD_BUILD_TUNNEL | CMD_MSG(STR_5016_CAN_T_BUILD_TUNNEL_HERE)); |
| 0 | 219 |
} |
220 |
||
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
221 |
void PlaceProc_BuyLand(TileIndex tile) |
| 0 | 222 |
{
|
|
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9694
diff
changeset
|
223 |
DoCommandP(tile, 0, 0, CcPlaySound1E, CMD_PURCHASE_LAND_AREA | CMD_NO_WATER | CMD_MSG(STR_5806_CAN_T_PURCHASE_THIS_LAND)); |
| 0 | 224 |
} |
225 |
||
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
226 |
static void PlaceRail_ConvertRail(TileIndex tile) |
| 0 | 227 |
{
|
| 9624 | 228 |
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CONVERT_RAIL); |
| 0 | 229 |
} |
230 |
||
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
231 |
static void PlaceRail_AutoSignals(TileIndex tile) |
|
58
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
0
diff
changeset
|
232 |
{
|
| 9624 | 233 |
VpStartPlaceSizing(tile, VPM_SIGNALDIRS, DDSP_BUILD_SIGNALS); |
|
58
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
0
diff
changeset
|
234 |
} |
|
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
0
diff
changeset
|
235 |
|
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
236 |
|
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
237 |
/** Enum referring to the widgets of the build rail toolbar */ |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
238 |
enum {
|
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
239 |
RTW_CAPTION = 1, |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
240 |
RTW_BUILD_NS = 4, |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
241 |
RTW_BUILD_X = 5, |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
242 |
RTW_BUILD_EW = 6, |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
243 |
RTW_BUILD_Y = 7, |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
244 |
RTW_AUTORAIL = 8, |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
245 |
RTW_DEMOLISH = 9, |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
246 |
RTW_BUILD_DEPOT = 10, |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
247 |
RTW_BUILD_WAYPOINT = 11, |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
248 |
RTW_BUILD_STATION = 12, |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
249 |
RTW_BUILD_SIGNALS = 13, |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
250 |
RTW_BUILD_BRIDGE = 14, |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
251 |
RTW_BUILD_TUNNEL = 15, |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
252 |
RTW_REMOVE = 16, |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
253 |
RTW_CONVERT_RAIL = 17 |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
254 |
}; |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
255 |
|
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
256 |
|
| 0 | 257 |
static void BuildRailClick_N(Window *w) |
258 |
{
|
|
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
259 |
HandlePlacePushButton(w, RTW_BUILD_NS, GetRailTypeInfo(_cur_railtype)->cursor.rail_ns, 1, PlaceRail_N); |
| 0 | 260 |
} |
261 |
||
262 |
static void BuildRailClick_NE(Window *w) |
|
263 |
{
|
|
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
264 |
HandlePlacePushButton(w, RTW_BUILD_X, GetRailTypeInfo(_cur_railtype)->cursor.rail_swne, 1, PlaceRail_NE); |
| 0 | 265 |
} |
266 |
||
267 |
static void BuildRailClick_E(Window *w) |
|
268 |
{
|
|
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
269 |
HandlePlacePushButton(w, RTW_BUILD_EW, GetRailTypeInfo(_cur_railtype)->cursor.rail_ew, 1, PlaceRail_E); |
| 0 | 270 |
} |
271 |
||
272 |
static void BuildRailClick_NW(Window *w) |
|
273 |
{
|
|
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
274 |
HandlePlacePushButton(w, RTW_BUILD_Y, GetRailTypeInfo(_cur_railtype)->cursor.rail_nwse, 1, PlaceRail_NW); |
|
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
275 |
} |
|
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
276 |
|
|
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
277 |
static void BuildRailClick_AutoRail(Window *w) |
|
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
278 |
{
|
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
279 |
HandlePlacePushButton(w, RTW_AUTORAIL, GetRailTypeInfo(_cur_railtype)->cursor.autorail, VHM_RAIL, PlaceRail_AutoRail); |
| 0 | 280 |
} |
281 |
||
282 |
static void BuildRailClick_Demolish(Window *w) |
|
283 |
{
|
|
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
284 |
HandlePlacePushButton(w, RTW_DEMOLISH, ANIMCURSOR_DEMOLISH, 1, PlaceProc_DemolishArea); |
| 0 | 285 |
} |
286 |
||
287 |
static void BuildRailClick_Depot(Window *w) |
|
288 |
{
|
|
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
289 |
if (HandlePlacePushButton(w, RTW_BUILD_DEPOT, GetRailTypeInfo(_cur_railtype)->cursor.depot, 1, PlaceRail_Depot)) {
|
|
2514
8887b1f005c7
(svn r3040) Don't deduce the cursor sprites when building rails from magic numbers, but fetch them from the central rail info array.
tron
parents:
2274
diff
changeset
|
290 |
ShowBuildTrainDepotPicker(); |
|
8887b1f005c7
(svn r3040) Don't deduce the cursor sprites when building rails from magic numbers, but fetch them from the central rail info array.
tron
parents:
2274
diff
changeset
|
291 |
} |
|
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
292 |
} |
|
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
293 |
|
|
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
294 |
static void BuildRailClick_Waypoint(Window *w) |
|
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
295 |
{
|
|
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2619
diff
changeset
|
296 |
_waypoint_count = GetNumCustomStations(STAT_CLASS_WAYP); |
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
297 |
if (HandlePlacePushButton(w, RTW_BUILD_WAYPOINT, SPR_CURSOR_WAYPOINT, 1, PlaceRail_Waypoint) && |
| 2639 | 298 |
_waypoint_count > 1) {
|
|
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
299 |
ShowBuildWaypointPicker(); |
| 2639 | 300 |
} |
| 0 | 301 |
} |
302 |
||
303 |
static void BuildRailClick_Station(Window *w) |
|
304 |
{
|
|
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
305 |
if (HandlePlacePushButton(w, RTW_BUILD_STATION, SPR_CURSOR_RAIL_STATION, 1, PlaceRail_Station)) ShowStationBuilder(); |
| 0 | 306 |
} |
307 |
||
|
58
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
0
diff
changeset
|
308 |
static void BuildRailClick_AutoSignals(Window *w) |
| 0 | 309 |
{
|
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
310 |
HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals); |
| 0 | 311 |
} |
312 |
||
313 |
static void BuildRailClick_Bridge(Window *w) |
|
314 |
{
|
|
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
315 |
HandlePlacePushButton(w, RTW_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, 1, PlaceRail_Bridge); |
| 0 | 316 |
} |
317 |
||
318 |
static void BuildRailClick_Tunnel(Window *w) |
|
319 |
{
|
|
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
320 |
HandlePlacePushButton(w, RTW_BUILD_TUNNEL, GetRailTypeInfo(_cur_railtype)->cursor.tunnel, 3, PlaceRail_Tunnel); |
| 0 | 321 |
} |
322 |
||
323 |
static void BuildRailClick_Remove(Window *w) |
|
324 |
{
|
|
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
325 |
if (IsWindowWidgetDisabled(w, RTW_REMOVE)) return; |
| 0 | 326 |
SetWindowDirty(w); |
| 541 | 327 |
SndPlayFx(SND_15_BEEP); |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
328 |
|
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
329 |
ToggleWidgetLoweredState(w, RTW_REMOVE); |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
330 |
_remove_button_clicked = IsWindowWidgetLowered(w, RTW_REMOVE); |
|
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
331 |
SetSelectionRed(_remove_button_clicked); |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
332 |
|
| 0 | 333 |
// handle station builder |
|
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
334 |
if (_remove_button_clicked) {
|
|
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
335 |
SetTileSelectSize(1, 1); |
| 0 | 336 |
} |
337 |
} |
|
338 |
||
|
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
339 |
static void BuildRailClick_Convert(Window *w) |
| 0 | 340 |
{
|
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
341 |
HandlePlacePushButton(w, RTW_CONVERT_RAIL, GetRailTypeInfo(_cur_railtype)->cursor.convert, 1, PlaceRail_ConvertRail); |
| 0 | 342 |
} |
343 |
||
344 |
||
345 |
static void DoRailroadTrack(int mode) |
|
346 |
{
|
|
|
1980
9ea0c89fbb58
(svn r2486) Turn TILE_FROM_XY into an inline function and rename it to TileVirtXY
tron
parents:
1977
diff
changeset
|
347 |
DoCommandP(TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), _cur_railtype | (mode << 4), NULL, |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
348 |
_remove_button_clicked ? |
|
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9694
diff
changeset
|
349 |
CMD_REMOVE_RAILROAD_TRACK | CMD_NO_WATER | CMD_MSG(STR_1012_CAN_T_REMOVE_RAILROAD_TRACK) : |
|
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9694
diff
changeset
|
350 |
CMD_BUILD_RAILROAD_TRACK | CMD_NO_WATER | CMD_MSG(STR_1011_CAN_T_BUILD_RAILROAD_TRACK) |
| 0 | 351 |
); |
352 |
} |
|
353 |
||
| 6573 | 354 |
static void HandleAutodirPlacement() |
| 0 | 355 |
{
|
356 |
TileHighlightData *thd = &_thd; |
|
|
1227
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
357 |
int trackstat = thd->drawstyle & 0xF; // 0..5 |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
358 |
|
|
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1035
diff
changeset
|
359 |
if (thd->drawstyle & HT_RAIL) { // one tile case
|
|
1980
9ea0c89fbb58
(svn r2486) Turn TILE_FROM_XY into an inline function and rename it to TileVirtXY
tron
parents:
1977
diff
changeset
|
360 |
GenericPlaceRail(TileVirtXY(thd->selend.x, thd->selend.y), trackstat); |
|
1227
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
361 |
return; |
| 0 | 362 |
} |
|
1227
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
363 |
|
|
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
364 |
DoRailroadTrack(trackstat); |
| 0 | 365 |
} |
366 |
||
| 6573 | 367 |
static void HandleAutoSignalPlacement() |
|
58
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
0
diff
changeset
|
368 |
{
|
|
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
0
diff
changeset
|
369 |
TileHighlightData *thd = &_thd; |
|
5986
1b9ab9629d36
(svn r8279) -Regression (r8274): Removing signals could fail under certain circumstances (not the proper bits of p1/p2 were set to trackbits). Moved trackbits back to bits 0..2, ctrl to 3, semaphore to 4. Also lower the decision of the ctrl-override of signal/semaphore from the GUI into the cmd function since we are passing the ctrl-bit anyways. Bug(s) found by Frostregen; thanks
Darkvater
parents:
5982
diff
changeset
|
370 |
uint32 p2 = GB(thd->drawstyle, 0, 3); // 0..5 |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
371 |
|
|
1123
449eb47ca680
(svn r1624) -Fix: [1106930] BugFix: placing signals with 2x1 drags is treated as placing a single signal thus providing an easy fix for a nasty problem.
darkvater
parents:
1116
diff
changeset
|
372 |
if (thd->drawstyle == HT_RECT) { // one tile case
|
|
1980
9ea0c89fbb58
(svn r2486) Turn TILE_FROM_XY into an inline function and rename it to TileVirtXY
tron
parents:
1977
diff
changeset
|
373 |
GenericPlaceSignals(TileVirtXY(thd->selend.x, thd->selend.y)); |
|
1123
449eb47ca680
(svn r1624) -Fix: [1106930] BugFix: placing signals with 2x1 drags is treated as placing a single signal thus providing an easy fix for a nasty problem.
darkvater
parents:
1116
diff
changeset
|
374 |
return; |
|
449eb47ca680
(svn r1624) -Fix: [1106930] BugFix: placing signals with 2x1 drags is treated as placing a single signal thus providing an easy fix for a nasty problem.
darkvater
parents:
1116
diff
changeset
|
375 |
} |
|
58
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
0
diff
changeset
|
376 |
|
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
377 |
/* XXX Steal ctrl for autosignal function, until we get some GUI */ |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
378 |
SB(p2, 3, 1, 0); |
|
5986
1b9ab9629d36
(svn r8279) -Regression (r8274): Removing signals could fail under certain circumstances (not the proper bits of p1/p2 were set to trackbits). Moved trackbits back to bits 0..2, ctrl to 3, semaphore to 4. Also lower the decision of the ctrl-override of signal/semaphore from the GUI into the cmd function since we are passing the ctrl-bit anyways. Bug(s) found by Frostregen; thanks
Darkvater
parents:
5982
diff
changeset
|
379 |
SB(p2, 4, 1, _cur_year < _patches.semaphore_build_before); |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
380 |
SB(p2, 6, 1, _ctrl_pressed); |
|
5982
54218ea5af1e
(svn r8274) -Codechange (r8151): Move the automatic semaphore/signal checks inside the CMD_ functions where they are supposed to be. Achieve this by adding a seperate bit to p1/p2 to hold the CTRL-modifier. While here, use proper types, and 'unify' the parameter bit-meanings. 0 - ctrl-pressed, 1 - signal/semaphore, 2-4 - trackbits, 5 - remove (internal), 24-31 - drag density.
Darkvater
parents:
5947
diff
changeset
|
381 |
SB(p2, 24, 8, _patches.drag_signals_density); |
|
5939
77530457a36b
(svn r8151) -Feature: Automatically build semaphores before a configurable date, which can be set by each network player seperately.
maedhros
parents:
5933
diff
changeset
|
382 |
|
|
5982
54218ea5af1e
(svn r8274) -Codechange (r8151): Move the automatic semaphore/signal checks inside the CMD_ functions where they are supposed to be. Achieve this by adding a seperate bit to p1/p2 to hold the CTRL-modifier. While here, use proper types, and 'unify' the parameter bit-meanings. 0 - ctrl-pressed, 1 - signal/semaphore, 2-4 - trackbits, 5 - remove (internal), 24-31 - drag density.
Darkvater
parents:
5947
diff
changeset
|
383 |
/* _patches.drag_signals_density is given as a parameter such that each user |
|
54218ea5af1e
(svn r8274) -Codechange (r8151): Move the automatic semaphore/signal checks inside the CMD_ functions where they are supposed to be. Achieve this by adding a seperate bit to p1/p2 to hold the CTRL-modifier. While here, use proper types, and 'unify' the parameter bit-meanings. 0 - ctrl-pressed, 1 - signal/semaphore, 2-4 - trackbits, 5 - remove (internal), 24-31 - drag density.
Darkvater
parents:
5947
diff
changeset
|
384 |
* in a network game can specify his/her own signal density */ |
| 2639 | 385 |
DoCommandP( |
|
5982
54218ea5af1e
(svn r8274) -Codechange (r8151): Move the automatic semaphore/signal checks inside the CMD_ functions where they are supposed to be. Achieve this by adding a seperate bit to p1/p2 to hold the CTRL-modifier. While here, use proper types, and 'unify' the parameter bit-meanings. 0 - ctrl-pressed, 1 - signal/semaphore, 2-4 - trackbits, 5 - remove (internal), 24-31 - drag density.
Darkvater
parents:
5947
diff
changeset
|
386 |
TileVirtXY(thd->selstart.x, thd->selstart.y), |
| 2639 | 387 |
TileVirtXY(thd->selend.x, thd->selend.y), |
|
5982
54218ea5af1e
(svn r8274) -Codechange (r8151): Move the automatic semaphore/signal checks inside the CMD_ functions where they are supposed to be. Achieve this by adding a seperate bit to p1/p2 to hold the CTRL-modifier. While here, use proper types, and 'unify' the parameter bit-meanings. 0 - ctrl-pressed, 1 - signal/semaphore, 2-4 - trackbits, 5 - remove (internal), 24-31 - drag density.
Darkvater
parents:
5947
diff
changeset
|
388 |
p2, |
| 2639 | 389 |
CcPlaySound1E, |
390 |
_remove_button_clicked ? |
|
|
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9694
diff
changeset
|
391 |
CMD_REMOVE_SIGNAL_TRACK | CMD_NO_WATER | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM) : |
|
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9694
diff
changeset
|
392 |
CMD_BUILD_SIGNAL_TRACK | CMD_NO_WATER | CMD_MSG(STR_1010_CAN_T_BUILD_SIGNALS_HERE) |
| 2639 | 393 |
); |
|
58
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
0
diff
changeset
|
394 |
} |
|
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
0
diff
changeset
|
395 |
|
| 2639 | 396 |
|
397 |
typedef void OnButtonClick(Window *w); |
|
398 |
||
| 0 | 399 |
static OnButtonClick * const _build_railroad_button_proc[] = {
|
400 |
BuildRailClick_N, |
|
401 |
BuildRailClick_NE, |
|
402 |
BuildRailClick_E, |
|
403 |
BuildRailClick_NW, |
|
|
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
404 |
BuildRailClick_AutoRail, |
| 0 | 405 |
BuildRailClick_Demolish, |
406 |
BuildRailClick_Depot, |
|
|
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
407 |
BuildRailClick_Waypoint, |
| 0 | 408 |
BuildRailClick_Station, |
|
58
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
0
diff
changeset
|
409 |
BuildRailClick_AutoSignals, |
| 0 | 410 |
BuildRailClick_Bridge, |
411 |
BuildRailClick_Tunnel, |
|
412 |
BuildRailClick_Remove, |
|
|
5933
0835f3342b79
(svn r8143) Remove the landscaping button from the build toolbars.
tron
parents:
5919
diff
changeset
|
413 |
BuildRailClick_Convert |
| 0 | 414 |
}; |
415 |
||
416 |
static const uint16 _rail_keycodes[] = {
|
|
417 |
'1', |
|
418 |
'2', |
|
419 |
'3', |
|
420 |
'4', |
|
|
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
421 |
'5', |
| 0 | 422 |
'6', |
|
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
423 |
'7', // depot |
|
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
424 |
'8', // waypoint |
|
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
425 |
'9', // station |
|
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
426 |
'S', // signals |
|
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
427 |
'B', // bridge |
|
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
428 |
'T', // tunnel |
|
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
429 |
'R', // remove |
|
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
430 |
'C', // convert rail |
| 0 | 431 |
}; |
432 |
||
433 |
||
|
4709
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
434 |
static void UpdateRemoveWidgetStatus(Window *w, int clicked_widget) |
|
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
435 |
{
|
|
4731
0febcf07eb48
(svn r6643) -Fix(r6631): Adjust proper disabled and lowered states of removal button on railtoolbar
belugas
parents:
4727
diff
changeset
|
436 |
/* If it is the removal button that has been clicked, do nothing, |
|
0febcf07eb48
(svn r6643) -Fix(r6631): Adjust proper disabled and lowered states of removal button on railtoolbar
belugas
parents:
4727
diff
changeset
|
437 |
* as it is up to the other buttons to drive removal status */ |
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
438 |
if (clicked_widget == RTW_REMOVE) return; |
|
4731
0febcf07eb48
(svn r6643) -Fix(r6631): Adjust proper disabled and lowered states of removal button on railtoolbar
belugas
parents:
4727
diff
changeset
|
439 |
|
|
4709
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
440 |
switch (clicked_widget) {
|
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
441 |
case RTW_BUILD_NS: |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
442 |
case RTW_BUILD_X: |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
443 |
case RTW_BUILD_EW: |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
444 |
case RTW_BUILD_Y: |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
445 |
case RTW_AUTORAIL: |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
446 |
case RTW_BUILD_WAYPOINT: |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
447 |
case RTW_BUILD_STATION: |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
448 |
case RTW_BUILD_SIGNALS: |
|
4731
0febcf07eb48
(svn r6643) -Fix(r6631): Adjust proper disabled and lowered states of removal button on railtoolbar
belugas
parents:
4727
diff
changeset
|
449 |
/* Removal button is enabled only if the rail/signal/waypoint/station |
|
0febcf07eb48
(svn r6643) -Fix(r6631): Adjust proper disabled and lowered states of removal button on railtoolbar
belugas
parents:
4727
diff
changeset
|
450 |
* button is still lowered. Once raised, it has to be disabled */ |
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
451 |
SetWindowWidgetDisabledState(w, RTW_REMOVE, !IsWindowWidgetLowered(w, clicked_widget)); |
|
4731
0febcf07eb48
(svn r6643) -Fix(r6631): Adjust proper disabled and lowered states of removal button on railtoolbar
belugas
parents:
4727
diff
changeset
|
452 |
break; |
|
0febcf07eb48
(svn r6643) -Fix(r6631): Adjust proper disabled and lowered states of removal button on railtoolbar
belugas
parents:
4727
diff
changeset
|
453 |
|
|
0febcf07eb48
(svn r6643) -Fix(r6631): Adjust proper disabled and lowered states of removal button on railtoolbar
belugas
parents:
4727
diff
changeset
|
454 |
default: |
|
0febcf07eb48
(svn r6643) -Fix(r6631): Adjust proper disabled and lowered states of removal button on railtoolbar
belugas
parents:
4727
diff
changeset
|
455 |
/* When any other buttons than rail/signal/waypoint/station, raise and |
|
0febcf07eb48
(svn r6643) -Fix(r6631): Adjust proper disabled and lowered states of removal button on railtoolbar
belugas
parents:
4727
diff
changeset
|
456 |
* disable the removal button*/ |
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
457 |
DisableWindowWidget(w, RTW_REMOVE); |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
458 |
RaiseWindowWidget(w, RTW_REMOVE); |
|
4731
0febcf07eb48
(svn r6643) -Fix(r6631): Adjust proper disabled and lowered states of removal button on railtoolbar
belugas
parents:
4727
diff
changeset
|
459 |
break; |
|
4709
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
460 |
} |
|
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
461 |
} |
|
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
462 |
|
| 0 | 463 |
static void BuildRailToolbWndProc(Window *w, WindowEvent *e) |
464 |
{
|
|
| 2639 | 465 |
switch (e->event) {
|
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
466 |
case WE_CREATE: DisableWindowWidget(w, RTW_REMOVE); break; |
|
4731
0febcf07eb48
(svn r6643) -Fix(r6631): Adjust proper disabled and lowered states of removal button on railtoolbar
belugas
parents:
4727
diff
changeset
|
467 |
|
|
4709
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
468 |
case WE_PAINT: DrawWindowWidgets(w); break; |
|
4731
0febcf07eb48
(svn r6643) -Fix(r6631): Adjust proper disabled and lowered states of removal button on railtoolbar
belugas
parents:
4727
diff
changeset
|
469 |
|
| 0 | 470 |
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
|
471 |
if (e->we.click.widget >= 4) {
|
| 0 | 472 |
_remove_button_clicked = false; |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4559
diff
changeset
|
473 |
_build_railroad_button_proc[e->we.click.widget - 4](w); |
| 0 | 474 |
} |
|
4709
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
475 |
UpdateRemoveWidgetStatus(w, e->we.click.widget); |
|
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
476 |
break; |
| 0 | 477 |
|
478 |
case WE_KEYPRESS: {
|
|
| 2639 | 479 |
uint i; |
|
616
3ab1124303e0
(svn r1040) Fix: All character hotkeys are disabled now when a window for typing is open
dominik
parents:
606
diff
changeset
|
480 |
|
| 2639 | 481 |
for (i = 0; i != lengthof(_rail_keycodes); i++) {
|
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4559
diff
changeset
|
482 |
if (e->we.keypress.keycode == _rail_keycodes[i]) {
|
|
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4559
diff
changeset
|
483 |
e->we.keypress.cont = false; |
| 0 | 484 |
_remove_button_clicked = false; |
485 |
_build_railroad_button_proc[i](w); |
|
|
4738
88248024964a
(svn r6650) - Fix (r6619): Fix widget state setting of the rail toolbar when using hotkeys.
peter1138
parents:
4731
diff
changeset
|
486 |
UpdateRemoveWidgetStatus(w, i + 4); |
| 0 | 487 |
break; |
488 |
} |
|
|
756
d1f1dc31b6f4
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
679
diff
changeset
|
489 |
} |
|
d1f1dc31b6f4
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
679
diff
changeset
|
490 |
MarkTileDirty(_thd.pos.x, _thd.pos.y); // redraw tile selection |
| 0 | 491 |
break; |
492 |
} |
|
493 |
||
494 |
case WE_PLACE_OBJ: |
|
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4559
diff
changeset
|
495 |
_place_proc(e->we.place.tile); |
| 0 | 496 |
return; |
497 |
||
498 |
case WE_PLACE_DRAG: {
|
|
| 9624 | 499 |
VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method); |
| 0 | 500 |
return; |
501 |
} |
|
502 |
||
503 |
case WE_PLACE_MOUSEUP: |
|
|
4994
ec6d8b5551f4
(svn r7000) -Fix: Incorrect use of e->we.click when the event is a 'place'. This didn't cause any
Darkvater
parents:
4939
diff
changeset
|
504 |
if (e->we.place.pt.x != -1) {
|
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4559
diff
changeset
|
505 |
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
|
506 |
TileIndex end_tile = e->we.place.tile; |
| 0 | 507 |
|
| 9624 | 508 |
switch (e->we.place.select_proc) {
|
509 |
case DDSP_BUILD_BRIDGE: |
|
510 |
ResetObjectToPlace(); |
|
511 |
ShowBuildBridgeWindow(start_tile, end_tile, _cur_railtype); |
|
512 |
break; |
|
|
1632
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1542
diff
changeset
|
513 |
|
| 9624 | 514 |
case DDSP_PLACE_AUTORAIL: {
|
515 |
bool old = _remove_button_clicked; |
|
516 |
if (_ctrl_pressed) _remove_button_clicked = true; |
|
517 |
HandleAutodirPlacement(); |
|
518 |
_remove_button_clicked = old; |
|
519 |
break; |
|
|
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9599
diff
changeset
|
520 |
} |
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9599
diff
changeset
|
521 |
|
| 9624 | 522 |
case DDSP_BUILD_SIGNALS: |
523 |
HandleAutoSignalPlacement(); |
|
524 |
break; |
|
525 |
||
526 |
case DDSP_DEMOLISH_AREA: |
|
527 |
GUIPlaceProcDragXY(e); |
|
528 |
break; |
|
529 |
||
530 |
case DDSP_REMOVE_STATION: |
|
531 |
DoCommandP(end_tile, start_tile, 0, CcPlaySound1E, CMD_REMOVE_FROM_RAILROAD_STATION | CMD_MSG(STR_CANT_REMOVE_PART_OF_STATION)); |
|
532 |
break; |
|
533 |
||
534 |
case DDSP_CONVERT_RAIL: |
|
|
1632
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1542
diff
changeset
|
535 |
DoCommandP(end_tile, start_tile, _cur_railtype, CcPlaySound10, CMD_CONVERT_RAIL | CMD_MSG(STR_CANT_CONVERT_RAIL)); |
| 9624 | 536 |
break; |
537 |
||
538 |
case DDSP_BUILD_STATION: |
|
539 |
HandleStationPlacement(start_tile, end_tile); |
|
540 |
break; |
|
541 |
||
542 |
case DDSP_PLACE_RAIL_NE: |
|
543 |
case DDSP_PLACE_RAIL_NW: |
|
544 |
DoRailroadTrack(e->we.place.select_proc == DDSP_PLACE_RAIL_NE ? TRACK_X : TRACK_Y); |
|
545 |
break; |
|
|
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3921
diff
changeset
|
546 |
} |
| 0 | 547 |
} |
548 |
break; |
|
549 |
||
550 |
case WE_ABORT_PLACE_OBJ: |
|
|
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
551 |
RaiseWindowButtons(w); |
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
552 |
DisableWindowWidget(w, RTW_REMOVE); |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
553 |
InvalidateWidget(w, RTW_REMOVE); |
| 0 | 554 |
|
555 |
w = FindWindowById(WC_BUILD_STATION, 0); |
|
| 2639 | 556 |
if (w != NULL) WP(w,def_d).close = true; |
| 0 | 557 |
w = FindWindowById(WC_BUILD_DEPOT, 0); |
| 2639 | 558 |
if (w != NULL) WP(w,def_d).close = true; |
| 0 | 559 |
break; |
560 |
||
561 |
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
|
562 |
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
|
563 |
|
|
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3269
diff
changeset
|
564 |
DoCommand(tile, 0, 0, DC_AUTO, CMD_BUILD_TUNNEL); |
| 2639 | 565 |
VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile); |
| 0 | 566 |
} break; |
|
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:
2571
diff
changeset
|
567 |
|
|
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:
2571
diff
changeset
|
568 |
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:
2571
diff
changeset
|
569 |
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:
2571
diff
changeset
|
570 |
break; |
| 0 | 571 |
} |
572 |
} |
|
573 |
||
|
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
574 |
|
|
2274
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
575 |
static const Widget _build_rail_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:
4171
diff
changeset
|
576 |
{ 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:
5919
diff
changeset
|
577 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 337, 0, 13, STR_100A_RAILROAD_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
0835f3342b79
(svn r8143) Remove the landscaping button from the build toolbars.
tron
parents:
5919
diff
changeset
|
578 |
{ WWT_STICKYBOX, RESIZE_NONE, 7, 338, 349, 0, 13, 0x0, STR_STICKY_BUTTON},
|
| 0 | 579 |
|
|
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:
4171
diff
changeset
|
580 |
{ WWT_PANEL, RESIZE_NONE, 7, 110, 113, 14, 35, 0x0, STR_NULL},
|
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
581 |
|
|
4938
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4937
diff
changeset
|
582 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_RAIL_NS, STR_1018_BUILD_RAILROAD_TRACK},
|
|
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4937
diff
changeset
|
583 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 22, 43, 14, 35, SPR_IMG_RAIL_NE, STR_1018_BUILD_RAILROAD_TRACK},
|
|
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4937
diff
changeset
|
584 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 44, 65, 14, 35, SPR_IMG_RAIL_EW, STR_1018_BUILD_RAILROAD_TRACK},
|
|
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4937
diff
changeset
|
585 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 66, 87, 14, 35, SPR_IMG_RAIL_NW, STR_1018_BUILD_RAILROAD_TRACK},
|
|
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4937
diff
changeset
|
586 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 88, 109, 14, 35, SPR_IMG_AUTORAIL, STR_BUILD_AUTORAIL_TIP},
|
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
587 |
|
|
4938
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4937
diff
changeset
|
588 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 114, 135, 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
|
589 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 136, 157, 14, 35, SPR_IMG_DEPOT_RAIL, STR_1019_BUILD_TRAIN_DEPOT_FOR_BUILDING},
|
|
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4937
diff
changeset
|
590 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 158, 179, 14, 35, SPR_IMG_WAYPOINT, STR_CONVERT_RAIL_TO_WAYPOINT_TIP},
|
|
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:
4171
diff
changeset
|
591 |
|
|
4938
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4937
diff
changeset
|
592 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 180, 221, 14, 35, SPR_IMG_RAIL_STATION, STR_101A_BUILD_RAILROAD_STATION},
|
|
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4937
diff
changeset
|
593 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 222, 243, 14, 35, SPR_IMG_RAIL_SIGNALS, STR_101B_BUILD_RAILROAD_SIGNALS},
|
|
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4937
diff
changeset
|
594 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 244, 285, 14, 35, SPR_IMG_BRIDGE, STR_101C_BUILD_RAILROAD_BRIDGE},
|
|
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4937
diff
changeset
|
595 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 286, 305, 14, 35, SPR_IMG_TUNNEL_RAIL, STR_101D_BUILD_RAILROAD_TUNNEL},
|
|
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4937
diff
changeset
|
596 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 306, 327, 14, 35, SPR_IMG_REMOVE, STR_101E_TOGGLE_BUILD_REMOVE_FOR},
|
|
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4937
diff
changeset
|
597 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 328, 349, 14, 35, SPR_IMG_CONVERT_RAIL, STR_CONVERT_RAIL_TIP},
|
|
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:
4171
diff
changeset
|
598 |
|
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
159
diff
changeset
|
599 |
{ WIDGETS_END},
|
| 0 | 600 |
}; |
601 |
||
|
2274
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
602 |
static const WindowDesc _build_rail_desc = {
|
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
603 |
WDP_ALIGN_TBR, 22, 350, 36, 350, 36, |
|
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6111
diff
changeset
|
604 |
WC_BUILD_TOOLBAR, WC_NONE, |
|
756
d1f1dc31b6f4
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
679
diff
changeset
|
605 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON, |
|
2274
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
606 |
_build_rail_widgets, |
| 0 | 607 |
BuildRailToolbWndProc |
608 |
}; |
|
609 |
||
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
610 |
|
|
2274
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
611 |
/** Configures the rail toolbar for railtype given |
|
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
612 |
* @param railtype the railtype to display |
|
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
613 |
* @param w the window to modify |
|
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
614 |
*/ |
| 4171 | 615 |
static void SetupRailToolbar(RailType railtype, Window *w) |
|
2274
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
616 |
{
|
|
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
617 |
const RailtypeInfo *rti = GetRailTypeInfo(railtype); |
| 0 | 618 |
|
|
2274
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
619 |
assert(railtype < RAILTYPE_END); |
|
4547
9786a24c4102
(svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents:
4429
diff
changeset
|
620 |
w->widget[RTW_CAPTION].data = rti->strings.toolbar_caption; |
|
9786a24c4102
(svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents:
4429
diff
changeset
|
621 |
w->widget[RTW_BUILD_NS].data = rti->gui_sprites.build_ns_rail; |
|
9786a24c4102
(svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents:
4429
diff
changeset
|
622 |
w->widget[RTW_BUILD_X].data = rti->gui_sprites.build_x_rail; |
|
9786a24c4102
(svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents:
4429
diff
changeset
|
623 |
w->widget[RTW_BUILD_EW].data = rti->gui_sprites.build_ew_rail; |
|
9786a24c4102
(svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents:
4429
diff
changeset
|
624 |
w->widget[RTW_BUILD_Y].data = rti->gui_sprites.build_y_rail; |
|
9786a24c4102
(svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents:
4429
diff
changeset
|
625 |
w->widget[RTW_AUTORAIL].data = rti->gui_sprites.auto_rail; |
|
9786a24c4102
(svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents:
4429
diff
changeset
|
626 |
w->widget[RTW_BUILD_DEPOT].data = rti->gui_sprites.build_depot; |
|
9786a24c4102
(svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents:
4429
diff
changeset
|
627 |
w->widget[RTW_CONVERT_RAIL].data = rti->gui_sprites.convert_rail; |
|
9786a24c4102
(svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents:
4429
diff
changeset
|
628 |
w->widget[RTW_BUILD_TUNNEL].data = rti->gui_sprites.build_tunnel; |
|
2274
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
629 |
} |
| 0 | 630 |
|
|
2520
75eb66d6e371
(svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents:
2514
diff
changeset
|
631 |
void ShowBuildRailToolbar(RailType railtype, int button) |
| 0 | 632 |
{
|
633 |
Window *w; |
|
634 |
||
|
5005
21e84e53c732
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4994
diff
changeset
|
635 |
if (!IsValidPlayer(_current_player)) return; |
|
4816
956f36063319
(svn r6740) -Fix: if a rail is not available, don't show toolbar even with hotkey 'A'
Darkvater
parents:
4747
diff
changeset
|
636 |
if (!ValParamRailtype(railtype)) return; |
|
946
81cf624bbdc5
(svn r1435) Fix: [ 1094092 ] Toolbars accessible via keyboard in spectator mode
dominik
parents:
926
diff
changeset
|
637 |
|
| 0 | 638 |
// don't recreate the window if we're clicking on a button and the window exists. |
639 |
if (button < 0 || !(w = FindWindowById(WC_BUILD_TOOLBAR, 0)) || w->wndproc != BuildRailToolbWndProc) {
|
|
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
640 |
DeleteWindowById(WC_BUILD_TOOLBAR, 0); |
|
2520
75eb66d6e371
(svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents:
2514
diff
changeset
|
641 |
_cur_railtype = railtype; |
|
2274
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
642 |
w = AllocateWindowDesc(&_build_rail_desc); |
|
2520
75eb66d6e371
(svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents:
2514
diff
changeset
|
643 |
SetupRailToolbar(railtype, w); |
| 0 | 644 |
} |
645 |
||
|
288
6bd97cdf1652
(svn r294) -Fix: autorail always builds rail, instead of occasional rail removal (on pressing hotkey after pressing 'bulldozer')
darkvater
parents:
201
diff
changeset
|
646 |
_remove_button_clicked = false; |
|
4747
c49af691700f
(svn r6659) -Fix r6619: Fix widget state setting of the rail toolbar when using global hotkeys.
glx
parents:
4738
diff
changeset
|
647 |
if (w != NULL && button >= 0) {
|
|
c49af691700f
(svn r6659) -Fix r6619: Fix widget state setting of the rail toolbar when using global hotkeys.
glx
parents:
4738
diff
changeset
|
648 |
_build_railroad_button_proc[button](w); |
|
c49af691700f
(svn r6659) -Fix r6619: Fix widget state setting of the rail toolbar when using global hotkeys.
glx
parents:
4738
diff
changeset
|
649 |
UpdateRemoveWidgetStatus(w, button + 4); |
|
c49af691700f
(svn r6659) -Fix r6619: Fix widget state setting of the rail toolbar when using global hotkeys.
glx
parents:
4738
diff
changeset
|
650 |
} |
| 6111 | 651 |
if (_patches.link_terraform_toolbar) ShowTerraformToolbar(w); |
| 0 | 652 |
} |
653 |
||
|
449
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
654 |
/* TODO: For custom stations, respect their allowed platforms/lengths bitmasks! |
|
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
655 |
* --pasky */ |
|
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
656 |
|
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
657 |
static void HandleStationPlacement(TileIndex start, TileIndex end) |
| 0 | 658 |
{
|
|
926
bd4312619522
(svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents:
909
diff
changeset
|
659 |
uint sx = TileX(start); |
|
bd4312619522
(svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents:
909
diff
changeset
|
660 |
uint sy = TileY(start); |
|
bd4312619522
(svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents:
909
diff
changeset
|
661 |
uint ex = TileX(end); |
|
bd4312619522
(svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents:
909
diff
changeset
|
662 |
uint ey = TileY(end); |
| 0 | 663 |
uint w,h; |
664 |
||
| 6432 | 665 |
if (sx > ex) Swap(sx, ex); |
666 |
if (sy > ey) Swap(sy, ey); |
|
| 0 | 667 |
w = ex - sx + 1; |
668 |
h = ey - sy + 1; |
|
| 6432 | 669 |
if (!_railstation.orientation) Swap(w, h); |
| 0 | 670 |
|
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
671 |
DoCommandP(TileXY(sx, sy), |
| 9624 | 672 |
_railstation.orientation | (w << 8) | (h << 16) | (_ctrl_pressed << 24), |
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
673 |
_cur_railtype | (_railstation.station_class << 8) | (_railstation.station_type << 16), CcStation, |
|
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9694
diff
changeset
|
674 |
CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION)); |
| 0 | 675 |
} |
676 |
||
|
5049
ddddf6e2da75
(svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents:
5005
diff
changeset
|
677 |
/* Check if the currently selected station size is allowed */ |
|
ddddf6e2da75
(svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents:
5005
diff
changeset
|
678 |
static void CheckSelectedSize(Window *w, const StationSpec *statspec) |
|
ddddf6e2da75
(svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents:
5005
diff
changeset
|
679 |
{
|
|
ddddf6e2da75
(svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents:
5005
diff
changeset
|
680 |
if (statspec == NULL || _railstation.dragdrop) return; |
|
ddddf6e2da75
(svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents:
5005
diff
changeset
|
681 |
|
|
ddddf6e2da75
(svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents:
5005
diff
changeset
|
682 |
if (HASBIT(statspec->disallowed_platforms, _railstation.numtracks - 1)) {
|
|
ddddf6e2da75
(svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents:
5005
diff
changeset
|
683 |
RaiseWindowWidget(w, _railstation.numtracks + 4); |
|
ddddf6e2da75
(svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents:
5005
diff
changeset
|
684 |
_railstation.numtracks = 1; |
|
ddddf6e2da75
(svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents:
5005
diff
changeset
|
685 |
while (HASBIT(statspec->disallowed_platforms, _railstation.numtracks - 1)) {
|
|
ddddf6e2da75
(svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents:
5005
diff
changeset
|
686 |
_railstation.numtracks++; |
|
ddddf6e2da75
(svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents:
5005
diff
changeset
|
687 |
} |
|
ddddf6e2da75
(svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents:
5005
diff
changeset
|
688 |
LowerWindowWidget(w, _railstation.numtracks + 4); |
|
ddddf6e2da75
(svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents:
5005
diff
changeset
|
689 |
} |
|
ddddf6e2da75
(svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents:
5005
diff
changeset
|
690 |
|
|
ddddf6e2da75
(svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents:
5005
diff
changeset
|
691 |
if (HASBIT(statspec->disallowed_lengths, _railstation.platlength - 1)) {
|
|
ddddf6e2da75
(svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents:
5005
diff
changeset
|
692 |
RaiseWindowWidget(w, _railstation.platlength + 11); |
|
ddddf6e2da75
(svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents:
5005
diff
changeset
|
693 |
_railstation.platlength = 1; |
|
ddddf6e2da75
(svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents:
5005
diff
changeset
|
694 |
while (HASBIT(statspec->disallowed_lengths, _railstation.platlength - 1)) {
|
|
ddddf6e2da75
(svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents:
5005
diff
changeset
|
695 |
_railstation.platlength++; |
|
ddddf6e2da75
(svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents:
5005
diff
changeset
|
696 |
} |
|
ddddf6e2da75
(svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents:
5005
diff
changeset
|
697 |
LowerWindowWidget(w, _railstation.platlength + 11); |
|
ddddf6e2da75
(svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents:
5005
diff
changeset
|
698 |
} |
|
ddddf6e2da75
(svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents:
5005
diff
changeset
|
699 |
} |
|
ddddf6e2da75
(svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents:
5005
diff
changeset
|
700 |
|
|
1781
92e08797c84b
(svn r2285) - Codechange: Fix up some of the missing things from server-checking; namely bridge-type, bridge-length, dragged end-tile (bridge/station), station_spread
Darkvater
parents:
1738
diff
changeset
|
701 |
static void StationBuildWndProc(Window *w, WindowEvent *e) |
|
92e08797c84b
(svn r2285) - Codechange: Fix up some of the missing things from server-checking; namely bridge-type, bridge-length, dragged end-tile (bridge/station), station_spread
Darkvater
parents:
1738
diff
changeset
|
702 |
{
|
|
92e08797c84b
(svn r2285) - Codechange: Fix up some of the missing things from server-checking; namely bridge-type, bridge-length, dragged end-tile (bridge/station), station_spread
Darkvater
parents:
1738
diff
changeset
|
703 |
switch (e->event) {
|
|
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
704 |
case WE_CREATE: |
|
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
705 |
LowerWindowWidget(w, _railstation.orientation + 3); |
|
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
706 |
if (_railstation.dragdrop) {
|
|
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
707 |
LowerWindowWidget(w, 19); |
|
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
708 |
} else {
|
|
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
709 |
LowerWindowWidget(w, _railstation.numtracks + 4); |
|
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
710 |
LowerWindowWidget(w, _railstation.platlength + 11); |
|
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
711 |
} |
|
4727
ba5bae41b004
(svn r6639) -CodeChange : Conversion of SetWidgetLoweredState to SetWindowWidgetLoweredState, in order to follow pre-established standard
belugas
parents:
4719
diff
changeset
|
712 |
SetWindowWidgetLoweredState(w, 20, !_station_show_coverage); |
|
ba5bae41b004
(svn r6639) -CodeChange : Conversion of SetWidgetLoweredState to SetWindowWidgetLoweredState, in order to follow pre-established standard
belugas
parents:
4719
diff
changeset
|
713 |
SetWindowWidgetLoweredState(w, 21, _station_show_coverage); |
|
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
714 |
break; |
|
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
715 |
|
| 0 | 716 |
case WE_PAINT: {
|
|
1781
92e08797c84b
(svn r2285) - Codechange: Fix up some of the missing things from server-checking; namely bridge-type, bridge-length, dragged end-tile (bridge/station), station_spread
Darkvater
parents:
1738
diff
changeset
|
717 |
int rad; |
| 0 | 718 |
uint bits; |
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
719 |
bool newstations = _railstation.newstations; |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
720 |
int y_offset; |
|
3921
1cde1b48313a
(svn r5048) - NewStations: Set up clipping areas to draw the station preview graphics in. This prevents larger station graphics from overflowing onto the list.
peter1138
parents:
3900
diff
changeset
|
721 |
DrawPixelInfo tmp_dpi, *old_dpi; |
|
5765
65eb8a67aca0
(svn r7812) -Fix: rail station build window was not correctly updated after station_spread change
glx
parents:
5726
diff
changeset
|
722 |
const StationSpec *statspec = newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL; |
| 0 | 723 |
|
|
1781
92e08797c84b
(svn r2285) - Codechange: Fix up some of the missing things from server-checking; namely bridge-type, bridge-length, dragged end-tile (bridge/station), station_spread
Darkvater
parents:
1738
diff
changeset
|
724 |
if (WP(w,def_d).close) return; |
| 0 | 725 |
|
726 |
if (_railstation.dragdrop) {
|
|
727 |
SetTileSelectSize(1, 1); |
|
728 |
} else {
|
|
729 |
int x = _railstation.numtracks; |
|
730 |
int y = _railstation.platlength; |
|
| 6432 | 731 |
if (_railstation.orientation == 0) Swap(x, y); |
| 2952 | 732 |
if (!_remove_button_clicked) |
| 0 | 733 |
SetTileSelectSize(x, y); |
734 |
} |
|
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
735 |
|
|
980
4d1b8af9866b
(svn r1476) -Fix: [1099209] Catchment area with drag&drop stations (Celestar)
darkvater
parents:
946
diff
changeset
|
736 |
rad = (_patches.modified_catchment) ? CA_TRAIN : 4; |
|
568
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
737 |
|
| 0 | 738 |
if (_station_show_coverage) |
|
568
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
739 |
SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad); |
| 0 | 740 |
|
|
5765
65eb8a67aca0
(svn r7812) -Fix: rail station build window was not correctly updated after station_spread change
glx
parents:
5726
diff
changeset
|
741 |
for (bits = 0; bits < 7; bits++) {
|
|
65eb8a67aca0
(svn r7812) -Fix: rail station build window was not correctly updated after station_spread change
glx
parents:
5726
diff
changeset
|
742 |
bool disable = bits >= _patches.station_spread; |
|
65eb8a67aca0
(svn r7812) -Fix: rail station build window was not correctly updated after station_spread change
glx
parents:
5726
diff
changeset
|
743 |
if (statspec == NULL) {
|
|
65eb8a67aca0
(svn r7812) -Fix: rail station build window was not correctly updated after station_spread change
glx
parents:
5726
diff
changeset
|
744 |
SetWindowWidgetDisabledState(w, bits + 5, disable); |
|
65eb8a67aca0
(svn r7812) -Fix: rail station build window was not correctly updated after station_spread change
glx
parents:
5726
diff
changeset
|
745 |
SetWindowWidgetDisabledState(w, bits + 12, disable); |
|
65eb8a67aca0
(svn r7812) -Fix: rail station build window was not correctly updated after station_spread change
glx
parents:
5726
diff
changeset
|
746 |
} else {
|
|
65eb8a67aca0
(svn r7812) -Fix: rail station build window was not correctly updated after station_spread change
glx
parents:
5726
diff
changeset
|
747 |
SetWindowWidgetDisabledState(w, bits + 5, HASBIT(statspec->disallowed_platforms, bits) || disable); |
|
65eb8a67aca0
(svn r7812) -Fix: rail station build window was not correctly updated after station_spread change
glx
parents:
5726
diff
changeset
|
748 |
SetWindowWidgetDisabledState(w, bits + 12, HASBIT(statspec->disallowed_lengths, bits) || disable); |
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
749 |
} |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
750 |
} |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
751 |
|
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
752 |
SetDParam(0, GetStationClassName(_railstation.station_class)); |
| 0 | 753 |
DrawWindowWidgets(w); |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
754 |
|
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
755 |
y_offset = newstations ? 90 : 0; |
| 0 | 756 |
|
|
3921
1cde1b48313a
(svn r5048) - NewStations: Set up clipping areas to draw the station preview graphics in. This prevents larger station graphics from overflowing onto the list.
peter1138
parents:
3900
diff
changeset
|
757 |
/* Set up a clipping area for the '/' station preview */ |
|
4429
1bb01569940c
(svn r6184) Remove the unused (because it was NULL in all callers) second parameter of FillDrawPixelInfo() and simplify some expressions
tron
parents:
4344
diff
changeset
|
758 |
if (FillDrawPixelInfo(&tmp_dpi, 7, 26 + y_offset, 66, 48)) {
|
|
3921
1cde1b48313a
(svn r5048) - NewStations: Set up clipping areas to draw the station preview graphics in. This prevents larger station graphics from overflowing onto the list.
peter1138
parents:
3900
diff
changeset
|
759 |
old_dpi = _cur_dpi; |
|
1cde1b48313a
(svn r5048) - NewStations: Set up clipping areas to draw the station preview graphics in. This prevents larger station graphics from overflowing onto the list.
peter1138
parents:
3900
diff
changeset
|
760 |
_cur_dpi = &tmp_dpi; |
|
1cde1b48313a
(svn r5048) - NewStations: Set up clipping areas to draw the station preview graphics in. This prevents larger station graphics from overflowing onto the list.
peter1138
parents:
3900
diff
changeset
|
761 |
if (!DrawStationTile(32, 16, _cur_railtype, AXIS_X, _railstation.station_class, _railstation.station_type)) {
|
|
9686
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9641
diff
changeset
|
762 |
StationPickerDrawSprite(32, 16, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 2); |
|
3921
1cde1b48313a
(svn r5048) - NewStations: Set up clipping areas to draw the station preview graphics in. This prevents larger station graphics from overflowing onto the list.
peter1138
parents:
3900
diff
changeset
|
763 |
} |
|
1cde1b48313a
(svn r5048) - NewStations: Set up clipping areas to draw the station preview graphics in. This prevents larger station graphics from overflowing onto the list.
peter1138
parents:
3900
diff
changeset
|
764 |
_cur_dpi = old_dpi; |
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
765 |
} |
|
3921
1cde1b48313a
(svn r5048) - NewStations: Set up clipping areas to draw the station preview graphics in. This prevents larger station graphics from overflowing onto the list.
peter1138
parents:
3900
diff
changeset
|
766 |
|
|
1cde1b48313a
(svn r5048) - NewStations: Set up clipping areas to draw the station preview graphics in. This prevents larger station graphics from overflowing onto the list.
peter1138
parents:
3900
diff
changeset
|
767 |
/* Set up a clipping area for the '\' station preview */ |
|
4429
1bb01569940c
(svn r6184) Remove the unused (because it was NULL in all callers) second parameter of FillDrawPixelInfo() and simplify some expressions
tron
parents:
4344
diff
changeset
|
768 |
if (FillDrawPixelInfo(&tmp_dpi, 75, 26 + y_offset, 66, 48)) {
|
|
3921
1cde1b48313a
(svn r5048) - NewStations: Set up clipping areas to draw the station preview graphics in. This prevents larger station graphics from overflowing onto the list.
peter1138
parents:
3900
diff
changeset
|
769 |
old_dpi = _cur_dpi; |
|
1cde1b48313a
(svn r5048) - NewStations: Set up clipping areas to draw the station preview graphics in. This prevents larger station graphics from overflowing onto the list.
peter1138
parents:
3900
diff
changeset
|
770 |
_cur_dpi = &tmp_dpi; |
|
1cde1b48313a
(svn r5048) - NewStations: Set up clipping areas to draw the station preview graphics in. This prevents larger station graphics from overflowing onto the list.
peter1138
parents:
3900
diff
changeset
|
771 |
if (!DrawStationTile(32, 16, _cur_railtype, AXIS_Y, _railstation.station_class, _railstation.station_type)) {
|
|
9686
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9641
diff
changeset
|
772 |
StationPickerDrawSprite(32, 16, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 3); |
|
3921
1cde1b48313a
(svn r5048) - NewStations: Set up clipping areas to draw the station preview graphics in. This prevents larger station graphics from overflowing onto the list.
peter1138
parents:
3900
diff
changeset
|
773 |
} |
|
1cde1b48313a
(svn r5048) - NewStations: Set up clipping areas to draw the station preview graphics in. This prevents larger station graphics from overflowing onto the list.
peter1138
parents:
3900
diff
changeset
|
774 |
_cur_dpi = old_dpi; |
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
775 |
} |
| 0 | 776 |
|
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
777 |
DrawStringCentered(74, 15 + y_offset, STR_3002_ORIENTATION, 0); |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
778 |
DrawStringCentered(74, 76 + y_offset, STR_3003_NUMBER_OF_TRACKS, 0); |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
779 |
DrawStringCentered(74, 101 + y_offset, STR_3004_PLATFORM_LENGTH, 0); |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
780 |
DrawStringCentered(74, 141 + y_offset, STR_3066_COVERAGE_AREA_HIGHLIGHT, 0); |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
781 |
|
|
9641
855e32c08c9b
(svn r10533) [NoAI] -Sync with trunk r10460:r10532.
truelight
parents:
9631
diff
changeset
|
782 |
DrawStationCoverageAreaText(2, 166 + y_offset, SCT_ALL, rad); |
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
783 |
|
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
784 |
if (newstations) {
|
|
3796
4176bf40364e
(svn r4792) - Codechange: change a uint to a uint16 to avoid a signed/unsigned warning from some compilers.
peter1138
parents:
3792
diff
changeset
|
785 |
uint16 i; |
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
786 |
uint y = 35; |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
787 |
|
|
3900
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3796
diff
changeset
|
788 |
for (i = w->vscroll.pos; i < _railstation.station_count && i < (uint)(w->vscroll.pos + w->vscroll.cap); i++) {
|
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
789 |
const StationSpec *statspec = GetCustomStationSpec(_railstation.station_class, i); |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
790 |
|
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
791 |
if (statspec != NULL && statspec->name != 0) {
|
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
792 |
if (HASBIT(statspec->callbackmask, CBM_STATION_AVAIL) && GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE) == 0) {
|
|
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
793 |
GfxFillRect(8, y - 2, 127, y + 10, (1 << PALETTE_MODIFIER_GREYOUT)); |
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
794 |
} |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
795 |
|
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
796 |
DrawStringTruncated(9, y, statspec->name, i == _railstation.station_type ? 12 : 16, 118); |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
797 |
} else {
|
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
798 |
DrawStringTruncated(9, y, STR_STAT_CLASS_DFLT, i == _railstation.station_type ? 12 : 16, 118); |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
799 |
} |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
800 |
|
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
801 |
y += 14; |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
802 |
} |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
803 |
} |
| 0 | 804 |
} break; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
805 |
|
| 0 | 806 |
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
|
807 |
switch (e->we.click.widget) {
|
| 0 | 808 |
case 3: |
809 |
case 4: |
|
|
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
810 |
RaiseWindowWidget(w, _railstation.orientation + 3); |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4559
diff
changeset
|
811 |
_railstation.orientation = e->we.click.widget - 3; |
|
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
812 |
LowerWindowWidget(w, _railstation.orientation + 3); |
| 541 | 813 |
SndPlayFx(SND_15_BEEP); |
| 0 | 814 |
SetWindowDirty(w); |
815 |
break; |
|
816 |
||
817 |
case 5: |
|
818 |
case 6: |
|
819 |
case 7: |
|
820 |
case 8: |
|
821 |
case 9: |
|
822 |
case 10: |
|
|
6533
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
823 |
case 11: {
|
|
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
824 |
RaiseWindowWidget(w, _railstation.numtracks + 4); |
|
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
825 |
RaiseWindowWidget(w, 19); |
|
6533
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
826 |
|
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4559
diff
changeset
|
827 |
_railstation.numtracks = (e->we.click.widget - 5) + 1; |
| 0 | 828 |
_railstation.dragdrop = false; |
|
6533
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
829 |
|
|
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
830 |
const StationSpec *statspec = _railstation.newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL; |
|
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
831 |
if (statspec != NULL && HASBIT(statspec->disallowed_lengths, _railstation.platlength - 1)) {
|
|
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
832 |
/* The previously selected number of platforms in invalid */ |
|
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
833 |
for (uint i = 0; i < 7; i++) {
|
|
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
834 |
if (!HASBIT(statspec->disallowed_lengths, i)) {
|
|
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
835 |
RaiseWindowWidget(w, _railstation.platlength + 11); |
|
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
836 |
_railstation.platlength = i + 1; |
|
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
837 |
break; |
|
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
838 |
} |
|
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
839 |
} |
|
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
840 |
} |
|
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
841 |
|
|
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
842 |
LowerWindowWidget(w, _railstation.platlength + 11); |
|
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
843 |
LowerWindowWidget(w, _railstation.numtracks + 4); |
| 541 | 844 |
SndPlayFx(SND_15_BEEP); |
| 0 | 845 |
SetWindowDirty(w); |
846 |
break; |
|
|
6533
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
847 |
} |
| 0 | 848 |
|
849 |
case 12: |
|
850 |
case 13: |
|
851 |
case 14: |
|
852 |
case 15: |
|
853 |
case 16: |
|
854 |
case 17: |
|
|
6533
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
855 |
case 18: {
|
|
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
856 |
RaiseWindowWidget(w, _railstation.platlength + 11); |
|
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
857 |
RaiseWindowWidget(w, 19); |
|
6533
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
858 |
|
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4559
diff
changeset
|
859 |
_railstation.platlength = (e->we.click.widget - 12) + 1; |
| 0 | 860 |
_railstation.dragdrop = false; |
|
6533
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
861 |
|
|
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
862 |
const StationSpec *statspec = _railstation.newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL; |
|
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
863 |
if (statspec != NULL && HASBIT(statspec->disallowed_platforms, _railstation.numtracks - 1)) {
|
|
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
864 |
/* The previously selected number of tracks in invalid */ |
|
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
865 |
for (uint i = 0; i < 7; i++) {
|
|
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
866 |
if (!HASBIT(statspec->disallowed_platforms, i)) {
|
|
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
867 |
RaiseWindowWidget(w, _railstation.numtracks + 4); |
|
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
868 |
_railstation.numtracks = i + 1; |
|
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
869 |
break; |
|
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
870 |
} |
|
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
871 |
} |
|
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
872 |
} |
|
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
873 |
|
|
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
874 |
LowerWindowWidget(w, _railstation.platlength + 11); |
|
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
875 |
LowerWindowWidget(w, _railstation.numtracks + 4); |
| 541 | 876 |
SndPlayFx(SND_15_BEEP); |
| 0 | 877 |
SetWindowDirty(w); |
878 |
break; |
|
|
6533
8c40cbf81651
(svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents:
6443
diff
changeset
|
879 |
} |
| 0 | 880 |
|
881 |
case 19: |
|
882 |
_railstation.dragdrop ^= true; |
|
|
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
883 |
ToggleWidgetLoweredState(w, 19); |
|
4727
ba5bae41b004
(svn r6639) -CodeChange : Conversion of SetWidgetLoweredState to SetWindowWidgetLoweredState, in order to follow pre-established standard
belugas
parents:
4719
diff
changeset
|
884 |
SetWindowWidgetLoweredState(w, _railstation.numtracks + 4, !_railstation.dragdrop); |
|
ba5bae41b004
(svn r6639) -CodeChange : Conversion of SetWidgetLoweredState to SetWindowWidgetLoweredState, in order to follow pre-established standard
belugas
parents:
4719
diff
changeset
|
885 |
SetWindowWidgetLoweredState(w, _railstation.platlength + 11, !_railstation.dragdrop); |
| 541 | 886 |
SndPlayFx(SND_15_BEEP); |
| 0 | 887 |
SetWindowDirty(w); |
888 |
break; |
|
889 |
||
890 |
case 20: |
|
891 |
case 21: |
|
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
892 |
_station_show_coverage = (e->we.click.widget != 20); |
|
4727
ba5bae41b004
(svn r6639) -CodeChange : Conversion of SetWidgetLoweredState to SetWindowWidgetLoweredState, in order to follow pre-established standard
belugas
parents:
4719
diff
changeset
|
893 |
SetWindowWidgetLoweredState(w, 20, !_station_show_coverage); |
|
ba5bae41b004
(svn r6639) -CodeChange : Conversion of SetWidgetLoweredState to SetWindowWidgetLoweredState, in order to follow pre-established standard
belugas
parents:
4719
diff
changeset
|
894 |
SetWindowWidgetLoweredState(w, 21, _station_show_coverage); |
| 541 | 895 |
SndPlayFx(SND_15_BEEP); |
| 0 | 896 |
SetWindowDirty(w); |
897 |
break; |
|
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
898 |
|
|
3782
89858a50ee93
(svn r4775) - Newstations: allow clicking on any part of the station class dropdown to bring up the list, instead of just the button (thanks tron)
peter1138
parents:
3781
diff
changeset
|
899 |
case 22: |
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
900 |
case 23: |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
901 |
ShowDropDownMenu(w, BuildStationClassDropdown(), _railstation.station_class, 23, 0, 1 << STAT_CLASS_WAYP); |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
902 |
break; |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
903 |
|
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
904 |
case 24: {
|
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
905 |
const StationSpec *statspec; |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4559
diff
changeset
|
906 |
int y = (e->we.click.pt.y - 32) / 14; |
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
907 |
|
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
908 |
if (y >= w->vscroll.cap) return; |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
909 |
y += w->vscroll.pos; |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
910 |
if (y >= _railstation.station_count) return; |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
911 |
|
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
912 |
/* Check station availability callback */ |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
913 |
statspec = GetCustomStationSpec(_railstation.station_class, y); |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
914 |
if (statspec != NULL && |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
915 |
HASBIT(statspec->callbackmask, CBM_STATION_AVAIL) && |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
916 |
GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE) == 0) return; |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
917 |
|
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
918 |
_railstation.station_type = y; |
|
5049
ddddf6e2da75
(svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents:
5005
diff
changeset
|
919 |
|
|
ddddf6e2da75
(svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents:
5005
diff
changeset
|
920 |
CheckSelectedSize(w, statspec); |
|
ddddf6e2da75
(svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents:
5005
diff
changeset
|
921 |
|
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
922 |
SndPlayFx(SND_15_BEEP); |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
923 |
SetWindowDirty(w); |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
924 |
break; |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
925 |
} |
| 0 | 926 |
} |
927 |
} break; |
|
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
928 |
|
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
929 |
case WE_DROPDOWN_SELECT: |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4559
diff
changeset
|
930 |
if (_railstation.station_class != e->we.dropdown.index) {
|
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
931 |
_railstation.station_class = (StationClassID)e->we.dropdown.index; |
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
932 |
_railstation.station_type = 0; |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
933 |
_railstation.station_count = GetNumCustomStations(_railstation.station_class); |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
934 |
|
|
5049
ddddf6e2da75
(svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents:
5005
diff
changeset
|
935 |
CheckSelectedSize(w, GetCustomStationSpec(_railstation.station_class, _railstation.station_type)); |
|
ddddf6e2da75
(svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents:
5005
diff
changeset
|
936 |
|
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
937 |
w->vscroll.count = _railstation.station_count; |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
938 |
w->vscroll.pos = _railstation.station_type; |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
939 |
} |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
940 |
|
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
941 |
SndPlayFx(SND_15_BEEP); |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
942 |
SetWindowDirty(w); |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
943 |
break; |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
944 |
|
| 2639 | 945 |
case WE_MOUSELOOP: |
| 0 | 946 |
if (WP(w,def_d).close) {
|
947 |
DeleteWindow(w); |
|
948 |
return; |
|
949 |
} |
|
950 |
CheckRedrawStationCoverage(w); |
|
| 2639 | 951 |
break; |
|
1074
5f45c1b03f2f
(svn r1575) -Fix: Forgot to exit the construction phase for the waypoint window (if
Celestar
parents:
1072
diff
changeset
|
952 |
|
|
1072
01bf9fc64236
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1071
diff
changeset
|
953 |
case WE_DESTROY: |
| 2639 | 954 |
if (!WP(w,def_d).close) ResetObjectToPlace(); |
|
1072
01bf9fc64236
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1071
diff
changeset
|
955 |
break; |
| 0 | 956 |
} |
957 |
} |
|
958 |
||
959 |
static const Widget _station_builder_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:
4171
diff
changeset
|
960 |
{ 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:
855
diff
changeset
|
961 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_3000_RAIL_STATION_SELECTION, 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:
4171
diff
changeset
|
962 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 147, 14, 199, 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:
4171
diff
changeset
|
963 |
{ WWT_PANEL, RESIZE_NONE, 14, 7, 72, 26, 73, 0x0, STR_304E_SELECT_RAILROAD_STATION},
|
|
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:
4171
diff
changeset
|
964 |
{ WWT_PANEL, RESIZE_NONE, 14, 75, 140, 26, 73, 0x0, STR_304E_SELECT_RAILROAD_STATION},
|
| 0 | 965 |
|
|
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:
4171
diff
changeset
|
966 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 22, 36, 87, 98, STR_00CB_1, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
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:
4171
diff
changeset
|
967 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 37, 51, 87, 98, STR_00CC_2, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
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:
4171
diff
changeset
|
968 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 52, 66, 87, 98, STR_00CD_3, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
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:
4171
diff
changeset
|
969 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 67, 81, 87, 98, STR_00CE_4, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
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:
4171
diff
changeset
|
970 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 82, 96, 87, 98, STR_00CF_5, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
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:
4171
diff
changeset
|
971 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 97, 111, 87, 98, STR_0335_6, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
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:
4171
diff
changeset
|
972 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 112, 126, 87, 98, STR_0336_7, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
| 0 | 973 |
|
|
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:
4171
diff
changeset
|
974 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 22, 36, 112, 123, STR_00CB_1, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
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:
4171
diff
changeset
|
975 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 37, 51, 112, 123, STR_00CC_2, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
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:
4171
diff
changeset
|
976 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 52, 66, 112, 123, STR_00CD_3, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
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:
4171
diff
changeset
|
977 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 67, 81, 112, 123, STR_00CE_4, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
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:
4171
diff
changeset
|
978 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 82, 96, 112, 123, STR_00CF_5, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
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:
4171
diff
changeset
|
979 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 97, 111, 112, 123, STR_0335_6, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
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:
4171
diff
changeset
|
980 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 112, 126, 112, 123, STR_0336_7, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
| 0 | 981 |
|
|
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:
4171
diff
changeset
|
982 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 37, 111, 126, 137, STR_DRAG_DROP, STR_STATION_DRAG_DROP},
|
|
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:
4171
diff
changeset
|
983 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 14, 73, 152, 163, 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:
4171
diff
changeset
|
984 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 74, 133, 152, 163, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA},
|
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
159
diff
changeset
|
985 |
{ WIDGETS_END},
|
| 0 | 986 |
}; |
987 |
||
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
988 |
static const Widget _newstation_builder_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:
4171
diff
changeset
|
989 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
990 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_3000_RAIL_STATION_SELECTION, 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:
4171
diff
changeset
|
991 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 147, 14, 289, 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:
4171
diff
changeset
|
992 |
{ WWT_PANEL, RESIZE_NONE, 14, 7, 72, 116, 163, 0x0, STR_304E_SELECT_RAILROAD_STATION},
|
|
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:
4171
diff
changeset
|
993 |
{ WWT_PANEL, RESIZE_NONE, 14, 75, 140, 116, 163, 0x0, STR_304E_SELECT_RAILROAD_STATION},
|
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
994 |
|
|
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:
4171
diff
changeset
|
995 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 22, 36, 177, 188, STR_00CB_1, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
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:
4171
diff
changeset
|
996 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 37, 51, 177, 188, STR_00CC_2, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
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:
4171
diff
changeset
|
997 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 52, 66, 177, 188, STR_00CD_3, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
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:
4171
diff
changeset
|
998 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 67, 81, 177, 188, STR_00CE_4, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
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:
4171
diff
changeset
|
999 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 82, 96, 177, 188, STR_00CF_5, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
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:
4171
diff
changeset
|
1000 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 97, 111, 177, 188, STR_0335_6, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
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:
4171
diff
changeset
|
1001 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 112, 126, 177, 188, STR_0336_7, STR_304F_SELECT_NUMBER_OF_PLATFORMS},
|
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1002 |
|
|
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:
4171
diff
changeset
|
1003 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 22, 36, 202, 213, STR_00CB_1, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
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:
4171
diff
changeset
|
1004 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 37, 51, 202, 213, STR_00CC_2, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
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:
4171
diff
changeset
|
1005 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 52, 66, 202, 213, STR_00CD_3, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
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:
4171
diff
changeset
|
1006 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 67, 81, 202, 213, STR_00CE_4, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
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:
4171
diff
changeset
|
1007 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 82, 96, 202, 213, STR_00CF_5, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
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:
4171
diff
changeset
|
1008 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 97, 111, 202, 213, STR_0335_6, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
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:
4171
diff
changeset
|
1009 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 112, 126, 202, 213, STR_0336_7, STR_3050_SELECT_LENGTH_OF_RAILROAD},
|
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1010 |
|
|
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:
4171
diff
changeset
|
1011 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 37, 111, 216, 227, STR_DRAG_DROP, STR_STATION_DRAG_DROP},
|
|
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:
4171
diff
changeset
|
1012 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 14, 73, 242, 253, 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:
4171
diff
changeset
|
1013 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 74, 133, 242, 253, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA},
|
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1014 |
|
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1015 |
/* newstations gui additions */ |
|
4939
ede0f6777b3c
(svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents:
4938
diff
changeset
|
1016 |
{ WWT_INSET, RESIZE_NONE, 14, 7, 140, 17, 28, STR_02BD, STR_SELECT_STATION_CLASS_TIP},
|
|
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:
4171
diff
changeset
|
1017 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 129, 139, 18, 27, STR_0225, STR_SELECT_STATION_CLASS_TIP},
|
|
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:
4171
diff
changeset
|
1018 |
{ WWT_MATRIX, RESIZE_NONE, 14, 7, 128, 32, 102, 0x501, STR_SELECT_STATION_TYPE_TIP},
|
|
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:
4171
diff
changeset
|
1019 |
{ WWT_SCROLLBAR, RESIZE_NONE, 14, 129, 140, 32, 102, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1020 |
{ WIDGETS_END},
|
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1021 |
}; |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1022 |
|
| 0 | 1023 |
static const WindowDesc _station_builder_desc = {
|
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1024 |
WDP_AUTO, WDP_AUTO, 148, 200, 148, 200, |
|
5070
0bbf5264bfb7
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5049
diff
changeset
|
1025 |
WC_BUILD_STATION, WC_BUILD_TOOLBAR, |
| 0 | 1026 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
1027 |
_station_builder_widgets, |
|
1028 |
StationBuildWndProc |
|
1029 |
}; |
|
1030 |
||
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1031 |
static const WindowDesc _newstation_builder_desc = {
|
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1032 |
WDP_AUTO, WDP_AUTO, 148, 290, 148, 290, |
|
5070
0bbf5264bfb7
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5049
diff
changeset
|
1033 |
WC_BUILD_STATION, WC_BUILD_TOOLBAR, |
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1034 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1035 |
_newstation_builder_widgets, |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1036 |
StationBuildWndProc |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1037 |
}; |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1038 |
|
| 6573 | 1039 |
static void ShowStationBuilder() |
| 0 | 1040 |
{
|
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1041 |
Window *w; |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1042 |
if (GetNumStationClasses() <= 2 && GetNumCustomStations(STAT_CLASS_DFLT) == 1) {
|
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1043 |
w = AllocateWindowDesc(&_station_builder_desc); |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1044 |
_railstation.newstations = false; |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1045 |
} else {
|
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1046 |
w = AllocateWindowDesc(&_newstation_builder_desc); |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1047 |
_railstation.newstations = true; |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1048 |
_railstation.station_count = GetNumCustomStations(_railstation.station_class); |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1049 |
|
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1050 |
w->vscroll.count = _railstation.station_count; |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1051 |
w->vscroll.cap = 5; |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1052 |
w->vscroll.pos = clamp(_railstation.station_type - 2, 0, w->vscroll.count - w->vscroll.cap); |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1053 |
} |
| 0 | 1054 |
} |
1055 |
||
1056 |
static void BuildTrainDepotWndProc(Window *w, WindowEvent *e) |
|
1057 |
{
|
|
| 2952 | 1058 |
switch (e->event) {
|
|
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1059 |
case WE_CREATE: LowerWindowWidget(w, _build_depot_direction + 3); break; |
|
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1060 |
|
| 0 | 1061 |
case WE_PAINT: {
|
|
2520
75eb66d6e371
(svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents:
2514
diff
changeset
|
1062 |
RailType r; |
| 0 | 1063 |
|
1064 |
DrawWindowWidgets(w); |
|
1065 |
||
1066 |
r = _cur_railtype; |
|
1067 |
DrawTrainDepotSprite(70, 17, 0, r); |
|
1068 |
DrawTrainDepotSprite(70, 69, 1, r); |
|
| 2639 | 1069 |
DrawTrainDepotSprite( 2, 69, 2, r); |
1070 |
DrawTrainDepotSprite( 2, 17, 3, r); |
|
| 0 | 1071 |
break; |
1072 |
} |
|
| 2639 | 1073 |
|
1074 |
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
|
1075 |
switch (e->we.click.widget) {
|
| 2639 | 1076 |
case 3: |
1077 |
case 4: |
|
1078 |
case 5: |
|
1079 |
case 6: |
|
|
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1080 |
RaiseWindowWidget(w, _build_depot_direction + 3); |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1081 |
_build_depot_direction = (DiagDirection)(e->we.click.widget - 3); |
|
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1082 |
LowerWindowWidget(w, _build_depot_direction + 3); |
| 2639 | 1083 |
SndPlayFx(SND_15_BEEP); |
1084 |
SetWindowDirty(w); |
|
1085 |
break; |
|
| 0 | 1086 |
} |
| 2639 | 1087 |
break; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
1088 |
|
| 0 | 1089 |
case WE_MOUSELOOP: |
| 2639 | 1090 |
if (WP(w,def_d).close) DeleteWindow(w); |
| 0 | 1091 |
return; |
|
1072
01bf9fc64236
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1071
diff
changeset
|
1092 |
|
|
01bf9fc64236
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1071
diff
changeset
|
1093 |
case WE_DESTROY: |
| 2639 | 1094 |
if (!WP(w,def_d).close) ResetObjectToPlace(); |
|
1072
01bf9fc64236
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1071
diff
changeset
|
1095 |
break; |
| 0 | 1096 |
} |
1097 |
} |
|
1098 |
||
1099 |
static const Widget _build_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:
4171
diff
changeset
|
1100 |
{ 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:
855
diff
changeset
|
1101 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 139, 0, 13, STR_1014_TRAIN_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:
4171
diff
changeset
|
1102 |
{ 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:
4171
diff
changeset
|
1103 |
{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 17, 66, 0x0, STR_1020_SELECT_RAILROAD_DEPOT_ORIENTATIO},
|
|
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:
4171
diff
changeset
|
1104 |
{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 69, 118, 0x0, STR_1020_SELECT_RAILROAD_DEPOT_ORIENTATIO},
|
|
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:
4171
diff
changeset
|
1105 |
{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 69, 118, 0x0, STR_1020_SELECT_RAILROAD_DEPOT_ORIENTATIO},
|
|
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:
4171
diff
changeset
|
1106 |
{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 17, 66, 0x0, STR_1020_SELECT_RAILROAD_DEPOT_ORIENTATIO},
|
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
159
diff
changeset
|
1107 |
{ WIDGETS_END},
|
| 0 | 1108 |
}; |
1109 |
||
1110 |
static const WindowDesc _build_depot_desc = {
|
|
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1111 |
WDP_AUTO, WDP_AUTO, 140, 122, 140, 122, |
|
5070
0bbf5264bfb7
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5049
diff
changeset
|
1112 |
WC_BUILD_DEPOT, WC_BUILD_TOOLBAR, |
| 0 | 1113 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
1114 |
_build_depot_widgets, |
|
1115 |
BuildTrainDepotWndProc |
|
1116 |
}; |
|
1117 |
||
| 6573 | 1118 |
static void ShowBuildTrainDepotPicker() |
| 0 | 1119 |
{
|
1120 |
AllocateWindowDesc(&_build_depot_desc); |
|
1121 |
} |
|
1122 |
||
|
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1123 |
|
|
395
4c990f33dab7
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
393
diff
changeset
|
1124 |
static void BuildWaypointWndProc(Window *w, WindowEvent *e) |
|
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1125 |
{
|
|
1738
6c7f9d12197d
(svn r2242) -Fix: [ 1193414 ] Fix for waypoint GUI, scrolling and button-actions (Hackykid)
Darkvater
parents:
1656
diff
changeset
|
1126 |
switch (e->event) {
|
|
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1127 |
case WE_PAINT: {
|
| 2639 | 1128 |
uint i; |
1129 |
||
|
4853
ce3345eb82be
(svn r6779) -Fix r6631: waypoint selector now correctly shows the current selected waypoint type (thx Maedhros)
glx
parents:
4848
diff
changeset
|
1130 |
for (i = 0; i < w->hscroll.cap; i++) {
|
|
ce3345eb82be
(svn r6779) -Fix r6631: waypoint selector now correctly shows the current selected waypoint type (thx Maedhros)
glx
parents:
4848
diff
changeset
|
1131 |
SetWindowWidgetLoweredState(w, i + 3, (w->hscroll.pos + i) == _cur_waypoint_type); |
|
ce3345eb82be
(svn r6779) -Fix r6631: waypoint selector now correctly shows the current selected waypoint type (thx Maedhros)
glx
parents:
4848
diff
changeset
|
1132 |
} |
|
ce3345eb82be
(svn r6779) -Fix r6631: waypoint selector now correctly shows the current selected waypoint type (thx Maedhros)
glx
parents:
4848
diff
changeset
|
1133 |
|
|
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1134 |
DrawWindowWidgets(w); |
|
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1135 |
|
|
4853
ce3345eb82be
(svn r6779) -Fix r6631: waypoint selector now correctly shows the current selected waypoint type (thx Maedhros)
glx
parents:
4848
diff
changeset
|
1136 |
for (i = 0; i < w->hscroll.cap; i++) {
|
|
ce3345eb82be
(svn r6779) -Fix r6631: waypoint selector now correctly shows the current selected waypoint type (thx Maedhros)
glx
parents:
4848
diff
changeset
|
1137 |
if (w->hscroll.pos + i < w->hscroll.count) {
|
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1138 |
const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, w->hscroll.pos + i); |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1139 |
|
|
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2619
diff
changeset
|
1140 |
DrawWaypointSprite(2 + i * 68, 25, w->hscroll.pos + i, _cur_railtype); |
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1141 |
|
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1142 |
if (statspec != NULL && |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1143 |
HASBIT(statspec->callbackmask, CBM_STATION_AVAIL) && |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1144 |
GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE) == 0) {
|
|
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
1145 |
GfxFillRect(4 + i * 68, 18, 67 + i * 68, 75, (1 << PALETTE_MODIFIER_GREYOUT)); |
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1146 |
} |
| 2639 | 1147 |
} |
|
2627
8c964f74bd7b
(svn r3169) Little bit of coding style fixing, and change from value to lengthof()
peter1138
parents:
2625
diff
changeset
|
1148 |
} |
|
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1149 |
break; |
|
1738
6c7f9d12197d
(svn r2242) -Fix: [ 1193414 ] Fix for waypoint GUI, scrolling and button-actions (Hackykid)
Darkvater
parents:
1656
diff
changeset
|
1150 |
} |
|
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1151 |
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
|
1152 |
switch (e->we.click.widget) {
|
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1153 |
case 3: case 4: case 5: case 6: case 7: {
|
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4559
diff
changeset
|
1154 |
byte type = e->we.click.widget - 3 + w->hscroll.pos; |
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1155 |
|
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1156 |
/* Check station availability callback */ |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1157 |
const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, type); |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1158 |
if (statspec != NULL && |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1159 |
HASBIT(statspec->callbackmask, CBM_STATION_AVAIL) && |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1160 |
GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE) == 0) return; |
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1161 |
|
|
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1162 |
_cur_waypoint_type = type; |
| 541 | 1163 |
SndPlayFx(SND_15_BEEP); |
|
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1164 |
SetWindowDirty(w); |
|
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1165 |
break; |
|
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1166 |
} |
|
3776
1a8d467577f4
(svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents:
3567
diff
changeset
|
1167 |
} |
|
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1168 |
break; |
|
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1169 |
} |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
1170 |
|
|
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1171 |
case WE_MOUSELOOP: |
| 2639 | 1172 |
if (WP(w,def_d).close) DeleteWindow(w); |
|
1738
6c7f9d12197d
(svn r2242) -Fix: [ 1193414 ] Fix for waypoint GUI, scrolling and button-actions (Hackykid)
Darkvater
parents:
1656
diff
changeset
|
1173 |
break; |
|
1074
5f45c1b03f2f
(svn r1575) -Fix: Forgot to exit the construction phase for the waypoint window (if
Celestar
parents:
1072
diff
changeset
|
1174 |
|
|
5f45c1b03f2f
(svn r1575) -Fix: Forgot to exit the construction phase for the waypoint window (if
Celestar
parents:
1072
diff
changeset
|
1175 |
case WE_DESTROY: |
| 2639 | 1176 |
if (!WP(w,def_d).close) ResetObjectToPlace(); |
|
1074
5f45c1b03f2f
(svn r1575) -Fix: Forgot to exit the construction phase for the waypoint window (if
Celestar
parents:
1072
diff
changeset
|
1177 |
break; |
|
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1178 |
} |
|
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1179 |
} |
|
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1180 |
|
|
395
4c990f33dab7
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
393
diff
changeset
|
1181 |
static const Widget _build_waypoint_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:
4171
diff
changeset
|
1182 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
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:
4171
diff
changeset
|
1183 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 343, 0, 13, STR_WAYPOINT, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
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:
4171
diff
changeset
|
1184 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 343, 14, 91, 0x0, 0},
|
|
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1185 |
|
|
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:
4171
diff
changeset
|
1186 |
{ WWT_PANEL, RESIZE_NONE, 7, 3, 68, 17, 76, 0x0, STR_WAYPOINT_GRAPHICS_TIP},
|
|
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:
4171
diff
changeset
|
1187 |
{ WWT_PANEL, RESIZE_NONE, 7, 71, 136, 17, 76, 0x0, STR_WAYPOINT_GRAPHICS_TIP},
|
|
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:
4171
diff
changeset
|
1188 |
{ WWT_PANEL, RESIZE_NONE, 7, 139, 204, 17, 76, 0x0, STR_WAYPOINT_GRAPHICS_TIP},
|
|
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:
4171
diff
changeset
|
1189 |
{ WWT_PANEL, RESIZE_NONE, 7, 207, 272, 17, 76, 0x0, STR_WAYPOINT_GRAPHICS_TIP},
|
|
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:
4171
diff
changeset
|
1190 |
{ WWT_PANEL, RESIZE_NONE, 7, 275, 340, 17, 76, 0x0, STR_WAYPOINT_GRAPHICS_TIP},
|
|
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1191 |
|
|
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:
4171
diff
changeset
|
1192 |
{ WWT_HSCROLLBAR, RESIZE_NONE, 7, 1, 343, 80, 91, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
| 417 | 1193 |
{ WIDGETS_END},
|
|
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1194 |
}; |
|
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1195 |
|
|
395
4c990f33dab7
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
393
diff
changeset
|
1196 |
static const WindowDesc _build_waypoint_desc = {
|
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1197 |
WDP_AUTO, WDP_AUTO, 344, 92, 344, 92, |
|
5070
0bbf5264bfb7
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5049
diff
changeset
|
1198 |
WC_BUILD_DEPOT, WC_BUILD_TOOLBAR, |
|
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1199 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
395
4c990f33dab7
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
393
diff
changeset
|
1200 |
_build_waypoint_widgets, |
|
4c990f33dab7
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
393
diff
changeset
|
1201 |
BuildWaypointWndProc |
|
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1202 |
}; |
|
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1203 |
|
| 6573 | 1204 |
static void ShowBuildWaypointPicker() |
|
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1205 |
{
|
|
395
4c990f33dab7
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
393
diff
changeset
|
1206 |
Window *w = AllocateWindowDesc(&_build_waypoint_desc); |
|
411
18495773b26e
(svn r608) [newgrf] enabled possibility to build default waypoint when custom waypoints are enabled
dominik
parents:
410
diff
changeset
|
1207 |
w->hscroll.cap = 5; |
|
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2619
diff
changeset
|
1208 |
w->hscroll.count = _waypoint_count; |
|
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1209 |
} |
|
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1210 |
|
|
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1211 |
|
| 6573 | 1212 |
void InitializeRailGui() |
| 0 | 1213 |
{
|
|
3157
40de8616c04c
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3132
diff
changeset
|
1214 |
_build_depot_direction = DIAGDIR_NW; |
| 0 | 1215 |
_railstation.numtracks = 1; |
1216 |
_railstation.platlength = 1; |
|
1217 |
_railstation.dragdrop = true; |
|
1218 |
} |
|
|
5116
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5105
diff
changeset
|
1219 |
|
|
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5105
diff
changeset
|
1220 |
void ReinitGuiAfterToggleElrail(bool disable) |
|
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5105
diff
changeset
|
1221 |
{
|
|
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5105
diff
changeset
|
1222 |
extern RailType _last_built_railtype; |
|
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5105
diff
changeset
|
1223 |
if (disable && _last_built_railtype == RAILTYPE_ELECTRIC) {
|
|
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5105
diff
changeset
|
1224 |
Window *w; |
|
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5105
diff
changeset
|
1225 |
_last_built_railtype = _cur_railtype = RAILTYPE_RAIL; |
|
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5105
diff
changeset
|
1226 |
w = FindWindowById(WC_BUILD_TOOLBAR, 0); |
|
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5105
diff
changeset
|
1227 |
if (w != NULL && w->wndproc == BuildRailToolbWndProc) {
|
|
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5105
diff
changeset
|
1228 |
SetupRailToolbar(_cur_railtype, w); |
|
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5105
diff
changeset
|
1229 |
SetWindowDirty(w); |
|
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5105
diff
changeset
|
1230 |
} |
|
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5105
diff
changeset
|
1231 |
} |
|
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5105
diff
changeset
|
1232 |
MarkWholeScreenDirty(); |
|
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5105
diff
changeset
|
1233 |
} |
|
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5105
diff
changeset
|
1234 |
|
| 9629 | 1235 |
void SetDefaultRailGui() |
1236 |
{
|
|
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1237 |
if (_local_player == PLAYER_SPECTATOR || !IsValidPlayer(_local_player)) return; |
|
5116
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5105
diff
changeset
|
1238 |
|
| 9629 | 1239 |
extern RailType _last_built_railtype; |
1240 |
RailType rt = (RailType)_patches.default_rail_type; |
|
1241 |
if (rt >= RAILTYPE_END) {
|
|
1242 |
if (rt == RAILTYPE_END + 2) {
|
|
1243 |
/* Find the most used rail type */ |
|
1244 |
RailType count[RAILTYPE_END]; |
|
1245 |
memset(count, 0, sizeof(count)); |
|
1246 |
for (TileIndex t = 0; t < MapSize(); t++) {
|
|
1247 |
if (IsTileType(t, MP_RAILWAY) || |
|
1248 |
IsLevelCrossingTile(t) || |
|
1249 |
IsRailwayStationTile(t) || |
|
1250 |
(IsTunnelTile(t) && GetTunnelTransportType(t) == TRANSPORT_RAIL) || |
|
1251 |
(IsBridgeTile(t) && GetBridgeTransportType(t) == TRANSPORT_RAIL) |
|
1252 |
) {
|
|
1253 |
count[GetRailType(t)]++; |
|
1254 |
} |
|
1255 |
} |
|
1256 |
||
1257 |
rt = RAILTYPE_RAIL; |
|
1258 |
for (RailType r = RAILTYPE_ELECTRIC; r < RAILTYPE_END; r++) {
|
|
1259 |
if (count[r] >= count[rt]) rt = r; |
|
1260 |
} |
|
1261 |
||
1262 |
/* No rail, just get the first available one */ |
|
1263 |
if (count[rt] == 0) rt = RAILTYPE_END; |
|
1264 |
} |
|
1265 |
switch (rt) {
|
|
1266 |
case RAILTYPE_END + 0: |
|
1267 |
rt = RAILTYPE_RAIL; |
|
1268 |
while (rt < RAILTYPE_END && !HasRailtypeAvail(GetPlayer(_local_player), rt)) rt++; |
|
1269 |
break; |
|
1270 |
||
1271 |
case RAILTYPE_END + 1: |
|
1272 |
rt = GetBestRailtype(GetPlayer(_local_player)); |
|
1273 |
break; |
|
1274 |
||
1275 |
default: |
|
1276 |
break; |
|
1277 |
} |
|
1278 |
} |
|
1279 |
||
1280 |
_last_built_railtype = _cur_railtype = rt; |
|
1281 |
Window *w = FindWindowById(WC_BUILD_TOOLBAR, 0); |
|
1282 |
if (w != NULL && w->wndproc == BuildRailToolbWndProc) {
|
|
1283 |
SetupRailToolbar(_cur_railtype, w); |
|
1284 |
SetWindowDirty(w); |
|
1285 |
} |
|
1286 |
} |
|
1287 |