author | rubidium |
Sun, 06 Apr 2008 23:07:42 +0000 | |
branch | noai |
changeset 9869 | 6404afe43575 |
parent 9837 | c9ec4f82e0d0 |
child 10249 | 58810805030e |
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" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
7 |
#include "tile_cmd.h" |
9599 | 8 |
#include "landscape.h" |
0 | 9 |
#include "gui.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
10 |
#include "window_gui.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
11 |
#include "station_gui.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
12 |
#include "terraform_gui.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
13 |
#include "viewport_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
14 |
#include "gfx_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
15 |
#include "command_func.h" |
9837
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9732
diff
changeset
|
16 |
#include "town_type.h" |
1542
2ca6d1624e6d
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1363
diff
changeset
|
17 |
#include "waypoint.h" |
1738
6c7f9d12197d
(svn r2242) -Fix: [ 1193414 ] Fix for waypoint GUI, scrolling and button-actions (Hackykid)
Darkvater
parents:
1656
diff
changeset
|
18 |
#include "debug.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2049
diff
changeset
|
19 |
#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
|
20 |
#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
|
21 |
#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
|
22 |
#include "train.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
23 |
#include "strings_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
24 |
#include "functions.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
25 |
#include "window_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
26 |
#include "date_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
27 |
#include "sound_func.h" |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
28 |
#include "player_func.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
29 |
#include "settings_type.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
30 |
#include "widgets/dropdown_type.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
31 |
#include "widgets/dropdown_func.h" |
0 | 32 |
|
9629 | 33 |
#include "bridge_map.h" |
34 |
#include "rail_map.h" |
|
35 |
#include "road_map.h" |
|
36 |
#include "station_map.h" |
|
37 |
#include "tunnel_map.h" |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
38 |
#include "tunnelbridge_map.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
39 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
40 |
#include "table/sprites.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
41 |
#include "table/strings.h" |
9629 | 42 |
|
2520
75eb66d6e371
(svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents:
2514
diff
changeset
|
43 |
static RailType _cur_railtype; |
0 | 44 |
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
|
45 |
static DiagDirection _build_depot_direction; |
2639 | 46 |
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
|
47 |
static byte _cur_waypoint_type; |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
48 |
static bool _convert_signal_button; ///< convert signal button in the signal GUI pressed |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
49 |
static SignalVariant _cur_signal_variant; ///< set the signal variant (for signal GUI) |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
50 |
static SignalType _cur_signal_type; ///< set the signal type (for signal GUI) |
0 | 51 |
|
2630 | 52 |
static struct { |
0 | 53 |
byte orientation; |
54 |
byte numtracks; |
|
55 |
byte platlength; |
|
56 |
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
|
57 |
|
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
|
58 |
bool newstations; |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
59 |
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
|
60 |
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
|
61 |
byte station_count; |
0 | 62 |
} _railstation; |
63 |
||
64 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
65 |
static void HandleStationPlacement(TileIndex start, TileIndex end); |
6573 | 66 |
static void ShowBuildTrainDepotPicker(); |
67 |
static void ShowBuildWaypointPicker(); |
|
68 |
static void ShowStationBuilder(); |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
69 |
static void ShowSignalBuilder(); |
0 | 70 |
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
71 |
void CcPlaySound1E(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 72 |
{ |
541 | 73 |
if (success) SndPlayTileFx(SND_20_SPLAT_2, tile); |
0 | 74 |
} |
75 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
76 |
static void GenericPlaceRail(TileIndex tile, int cmd) |
0 | 77 |
{ |
78 |
DoCommandP(tile, _cur_railtype, cmd, CcPlaySound1E, |
|
9732 | 79 |
_remove_button_clicked ? |
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9694
diff
changeset
|
80 |
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
|
81 |
CMD_BUILD_SINGLE_RAIL | CMD_MSG(STR_1011_CAN_T_BUILD_RAILROAD_TRACK) | CMD_NO_WATER |
2639 | 82 |
); |
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_N(TileIndex tile) |
0 | 86 |
{ |
87 |
int cmd = _tile_fract_coords.x > _tile_fract_coords.y ? 4 : 5; |
|
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_NE(TileIndex tile) |
0 | 92 |
{ |
9624 | 93 |
VpStartPlaceSizing(tile, VPM_FIX_Y, DDSP_PLACE_RAIL_NE); |
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_E(TileIndex tile) |
0 | 97 |
{ |
98 |
int cmd = _tile_fract_coords.x + _tile_fract_coords.y <= 15 ? 2 : 3; |
|
99 |
GenericPlaceRail(tile, cmd); |
|
100 |
} |
|
101 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
102 |
static void PlaceRail_NW(TileIndex tile) |
0 | 103 |
{ |
9624 | 104 |
VpStartPlaceSizing(tile, VPM_FIX_X, DDSP_PLACE_RAIL_NW); |
0 | 105 |
} |
106 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
107 |
static void PlaceRail_AutoRail(TileIndex tile) |
0 | 108 |
{ |
9624 | 109 |
VpStartPlaceSizing(tile, VPM_RAILDIRS, DDSP_PLACE_AUTORAIL); |
0 | 110 |
} |
111 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
112 |
static void PlaceExtraDepotRail(TileIndex tile, uint16 extra) |
0 | 113 |
{ |
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
|
114 |
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
|
115 |
if ((GetTrackBits(tile) & GB(extra, 8, 8)) == 0) return; |
0 | 116 |
|
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9694
diff
changeset
|
117 |
DoCommandP(tile, _cur_railtype, extra & 0xFF, NULL, CMD_BUILD_SINGLE_RAIL | CMD_NO_WATER); |
0 | 118 |
} |
119 |
||
120 |
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
|
121 |
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
|
122 |
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
|
123 |
0x2203, 0x0904, 0x0A05, 0x1103, |
0 | 124 |
}; |
125 |
||
126 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
127 |
void CcRailDepot(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 128 |
{ |
129 |
if (success) { |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
130 |
DiagDirection dir = (DiagDirection)p2; |
0 | 131 |
|
541 | 132 |
SndPlayTileFx(SND_20_SPLAT_2, tile); |
0 | 133 |
ResetObjectToPlace(); |
134 |
||
4559
c853d2440065
(svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents:
4547
diff
changeset
|
135 |
tile += TileOffsByDiagDir(dir); |
0 | 136 |
|
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
|
137 |
if (IsTileType(tile, MP_RAILWAY)) { |
0 | 138 |
PlaceExtraDepotRail(tile, _place_depot_extra[dir]); |
139 |
PlaceExtraDepotRail(tile, _place_depot_extra[dir + 4]); |
|
140 |
PlaceExtraDepotRail(tile, _place_depot_extra[dir + 8]); |
|
141 |
} |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
142 |
} |
0 | 143 |
} |
144 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
145 |
static void PlaceRail_Depot(TileIndex tile) |
0 | 146 |
{ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
147 |
DoCommandP(tile, _cur_railtype, _build_depot_direction, CcRailDepot, |
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9694
diff
changeset
|
148 |
CMD_BUILD_TRAIN_DEPOT | CMD_NO_WATER | CMD_MSG(STR_100E_CAN_T_BUILD_TRAIN_DEPOT)); |
0 | 149 |
} |
150 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
151 |
static void PlaceRail_Waypoint(TileIndex tile) |
0 | 152 |
{ |
9732 | 153 |
if (_remove_button_clicked) { |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
154 |
DoCommandP(tile, 0, 0, CcPlaySound1E, CMD_REMOVE_TRAIN_WAYPOINT | CMD_MSG(STR_CANT_REMOVE_TRAIN_WAYPOINT)); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
155 |
} else { |
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2619
diff
changeset
|
156 |
DoCommandP(tile, _cur_waypoint_type, 0, CcPlaySound1E, CMD_BUILD_TRAIN_WAYPOINT | CMD_MSG(STR_CANT_BUILD_TRAIN_WAYPOINT)); |
0 | 157 |
} |
158 |
} |
|
159 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
160 |
void CcStation(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 161 |
{ |
162 |
if (success) { |
|
541 | 163 |
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
|
164 |
/* 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
|
165 |
if (_railstation.station_class == STAT_CLASS_DFLT && _railstation.station_type == 0) ResetObjectToPlace(); |
0 | 166 |
} |
167 |
} |
|
168 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
169 |
static void PlaceRail_Station(TileIndex tile) |
0 | 170 |
{ |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3921
diff
changeset
|
171 |
if (_remove_button_clicked) { |
9732 | 172 |
VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_REMOVE_STATION); |
173 |
VpSetPlaceSizingLimit(-1); |
|
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3921
diff
changeset
|
174 |
} else if (_railstation.dragdrop) { |
9624 | 175 |
VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_BUILD_STATION); |
0 | 176 |
VpSetPlaceSizingLimit(_patches.station_spread); |
177 |
} 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
|
178 |
DoCommandP(tile, |
9624 | 179 |
_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
|
180 |
_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
|
181 |
CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION)); |
0 | 182 |
} |
183 |
} |
|
184 |
||
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
185 |
/** |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
186 |
* Build a new signal or edit/remove a present signal, use CmdBuildSingleSignal() or CmdRemoveSingleSignal() in rail_cmd.cpp |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
187 |
* |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
188 |
* @param tile The tile where the signal will build or edit |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
189 |
*/ |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
190 |
static void GenericPlaceSignals(TileIndex tile) |
0 | 191 |
{ |
9732 | 192 |
TrackBits trackbits = TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_RAIL, 0)); |
0 | 193 |
|
9626 | 194 |
if (trackbits & TRACK_BIT_VERT) { // N-S direction |
195 |
trackbits = (_tile_fract_coords.x <= _tile_fract_coords.y) ? TRACK_BIT_RIGHT : TRACK_BIT_LEFT; |
|
2639 | 196 |
} |
0 | 197 |
|
9626 | 198 |
if (trackbits & TRACK_BIT_HORZ) { // E-W direction |
199 |
trackbits = (_tile_fract_coords.x + _tile_fract_coords.y <= 15) ? TRACK_BIT_UPPER : TRACK_BIT_LOWER; |
|
200 |
} |
|
201 |
||
9627 | 202 |
Track track = FindFirstTrack(trackbits); |
9626 | 203 |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
204 |
if (_remove_button_clicked) { |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
205 |
DoCommandP(tile, track, 0, CcPlaySound1E, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
206 |
CMD_REMOVE_SIGNALS | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM)); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
207 |
} else { |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
208 |
const Window *w = FindWindowById(WC_BUILD_SIGNAL, 0); |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
209 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
210 |
/* various bitstuffed elements for CmdBuildSingleSignal() */ |
9626 | 211 |
uint32 p1 = track; |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
212 |
|
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
213 |
if (w != NULL) { |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
214 |
/* signal GUI is used */ |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
215 |
SB(p1, 3, 1, _ctrl_pressed); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
216 |
SB(p1, 4, 1, _cur_signal_variant); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
217 |
SB(p1, 5, 2, _cur_signal_type); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
218 |
SB(p1, 7, 1, _convert_signal_button); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
219 |
} else { |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
220 |
SB(p1, 3, 1, _ctrl_pressed); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
221 |
SB(p1, 4, 1, (_cur_year < _patches.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC)); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
222 |
SB(p1, 5, 2, SIGTYPE_NORMAL); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
223 |
SB(p1, 7, 1, 0); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
224 |
} |
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
|
225 |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
226 |
DoCommandP(tile, p1, 0, CcPlaySound1E, CMD_BUILD_SIGNALS | |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
227 |
CMD_MSG((w != NULL && _convert_signal_button) ? STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE : STR_1010_CAN_T_BUILD_SIGNALS_HERE)); |
0 | 228 |
} |
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_Bridge(TileIndex tile) |
0 | 232 |
{ |
9624 | 233 |
VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_BUILD_BRIDGE); |
0 | 234 |
} |
235 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
236 |
void CcBuildRailTunnel(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 237 |
{ |
238 |
if (success) { |
|
541 | 239 |
SndPlayTileFx(SND_20_SPLAT_2, tile); |
0 | 240 |
ResetObjectToPlace(); |
241 |
} else { |
|
242 |
SetRedErrorSquare(_build_tunnel_endtile); |
|
243 |
} |
|
244 |
} |
|
245 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
246 |
static void PlaceRail_Tunnel(TileIndex tile) |
0 | 247 |
{ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
248 |
DoCommandP(tile, _cur_railtype, 0, CcBuildRailTunnel, |
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9694
diff
changeset
|
249 |
CMD_BUILD_TUNNEL | CMD_MSG(STR_5016_CAN_T_BUILD_TUNNEL_HERE)); |
0 | 250 |
} |
251 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
252 |
void PlaceProc_BuyLand(TileIndex tile) |
0 | 253 |
{ |
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9694
diff
changeset
|
254 |
DoCommandP(tile, 0, 0, CcPlaySound1E, CMD_PURCHASE_LAND_AREA | CMD_NO_WATER | CMD_MSG(STR_5806_CAN_T_PURCHASE_THIS_LAND)); |
0 | 255 |
} |
256 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
257 |
static void PlaceRail_ConvertRail(TileIndex tile) |
0 | 258 |
{ |
9624 | 259 |
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CONVERT_RAIL); |
0 | 260 |
} |
261 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
262 |
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
|
263 |
{ |
9624 | 264 |
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
|
265 |
} |
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
|
266 |
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
267 |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
268 |
/** Enum referring to the widgets of the build rail toolbar */ |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
269 |
enum RailToolbarWidgets { |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
270 |
RTW_CLOSEBOX = 0, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
271 |
RTW_CAPTION, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
272 |
RTW_STICKY, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
273 |
RTW_SPACER, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
274 |
RTW_BUILD_NS, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
275 |
RTW_BUILD_X, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
276 |
RTW_BUILD_EW, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
277 |
RTW_BUILD_Y, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
278 |
RTW_AUTORAIL, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
279 |
RTW_DEMOLISH, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
280 |
RTW_BUILD_DEPOT, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
281 |
RTW_BUILD_WAYPOINT, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
282 |
RTW_BUILD_STATION, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
283 |
RTW_BUILD_SIGNALS, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
284 |
RTW_BUILD_BRIDGE, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
285 |
RTW_BUILD_TUNNEL, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
286 |
RTW_REMOVE, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
287 |
RTW_CONVERT_RAIL, |
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
288 |
}; |
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
289 |
|
9732 | 290 |
|
291 |
/** Toogles state of the Remove button of Build rail toolbar |
|
292 |
* @param w window the button belongs to |
|
293 |
*/ |
|
294 |
static void ToggleRailButton_Remove(Window *w) |
|
295 |
{ |
|
296 |
w->ToggleWidgetLoweredState(RTW_REMOVE); |
|
297 |
w->InvalidateWidget(RTW_REMOVE); |
|
298 |
_remove_button_clicked = w->IsWidgetLowered(RTW_REMOVE); |
|
299 |
SetSelectionRed(_remove_button_clicked); |
|
300 |
} |
|
301 |
||
302 |
/** Updates the Remove button because of Ctrl state change |
|
303 |
* @param w window the button belongs to |
|
304 |
* @return true iff the remove buton was changed |
|
305 |
*/ |
|
306 |
static bool RailToolbar_CtrlChanged(Window *w) |
|
307 |
{ |
|
308 |
if (w->IsWidgetDisabled(RTW_REMOVE)) return false; |
|
309 |
||
310 |
/* allow ctrl to switch remove mode only for these widgets */ |
|
311 |
for (uint i = RTW_BUILD_NS; i <= RTW_BUILD_STATION; i++) { |
|
312 |
if ((i <= RTW_AUTORAIL || i >= RTW_BUILD_WAYPOINT) && w->IsWidgetLowered(i)) { |
|
313 |
ToggleRailButton_Remove(w); |
|
314 |
return true; |
|
315 |
} |
|
316 |
} |
|
317 |
||
318 |
return false; |
|
319 |
} |
|
320 |
||
321 |
||
0 | 322 |
static void BuildRailClick_N(Window *w) |
323 |
{ |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
324 |
HandlePlacePushButton(w, RTW_BUILD_NS, GetRailTypeInfo(_cur_railtype)->cursor.rail_ns, VHM_RECT, PlaceRail_N); |
0 | 325 |
} |
326 |
||
327 |
static void BuildRailClick_NE(Window *w) |
|
328 |
{ |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
329 |
HandlePlacePushButton(w, RTW_BUILD_X, GetRailTypeInfo(_cur_railtype)->cursor.rail_swne, VHM_RECT, PlaceRail_NE); |
0 | 330 |
} |
331 |
||
332 |
static void BuildRailClick_E(Window *w) |
|
333 |
{ |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
334 |
HandlePlacePushButton(w, RTW_BUILD_EW, GetRailTypeInfo(_cur_railtype)->cursor.rail_ew, VHM_RECT, PlaceRail_E); |
0 | 335 |
} |
336 |
||
337 |
static void BuildRailClick_NW(Window *w) |
|
338 |
{ |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
339 |
HandlePlacePushButton(w, RTW_BUILD_Y, GetRailTypeInfo(_cur_railtype)->cursor.rail_nwse, VHM_RECT, PlaceRail_NW); |
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
340 |
} |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
341 |
|
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
342 |
static void BuildRailClick_AutoRail(Window *w) |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
343 |
{ |
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
344 |
HandlePlacePushButton(w, RTW_AUTORAIL, GetRailTypeInfo(_cur_railtype)->cursor.autorail, VHM_RAIL, PlaceRail_AutoRail); |
0 | 345 |
} |
346 |
||
347 |
static void BuildRailClick_Demolish(Window *w) |
|
348 |
{ |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
349 |
HandlePlacePushButton(w, RTW_DEMOLISH, ANIMCURSOR_DEMOLISH, VHM_RECT, PlaceProc_DemolishArea); |
0 | 350 |
} |
351 |
||
352 |
static void BuildRailClick_Depot(Window *w) |
|
353 |
{ |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
354 |
if (HandlePlacePushButton(w, RTW_BUILD_DEPOT, GetRailTypeInfo(_cur_railtype)->cursor.depot, VHM_RECT, 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
|
355 |
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
|
356 |
} |
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
357 |
} |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
358 |
|
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
359 |
static void BuildRailClick_Waypoint(Window *w) |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
360 |
{ |
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2619
diff
changeset
|
361 |
_waypoint_count = GetNumCustomStations(STAT_CLASS_WAYP); |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
362 |
if (HandlePlacePushButton(w, RTW_BUILD_WAYPOINT, SPR_CURSOR_WAYPOINT, VHM_RECT, PlaceRail_Waypoint) && |
2639 | 363 |
_waypoint_count > 1) { |
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
364 |
ShowBuildWaypointPicker(); |
2639 | 365 |
} |
0 | 366 |
} |
367 |
||
368 |
static void BuildRailClick_Station(Window *w) |
|
369 |
{ |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
370 |
if (HandlePlacePushButton(w, RTW_BUILD_STATION, SPR_CURSOR_RAIL_STATION, VHM_RECT, PlaceRail_Station)) ShowStationBuilder(); |
0 | 371 |
} |
372 |
||
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
373 |
/** The "build signal"-button proc from BuildRailToolbWndProc() (start ShowSignalBuilder() and/or 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
|
374 |
static void BuildRailClick_AutoSignals(Window *w) |
0 | 375 |
{ |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
376 |
if (_patches.enable_signal_gui != _ctrl_pressed) { |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
377 |
if (HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals)) ShowSignalBuilder(); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
378 |
} else { |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
379 |
HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
380 |
} |
0 | 381 |
} |
382 |
||
383 |
static void BuildRailClick_Bridge(Window *w) |
|
384 |
{ |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
385 |
HandlePlacePushButton(w, RTW_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, VHM_RECT, PlaceRail_Bridge); |
0 | 386 |
} |
387 |
||
388 |
static void BuildRailClick_Tunnel(Window *w) |
|
389 |
{ |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
390 |
HandlePlacePushButton(w, RTW_BUILD_TUNNEL, GetRailTypeInfo(_cur_railtype)->cursor.tunnel, VHM_SPECIAL, PlaceRail_Tunnel); |
0 | 391 |
} |
392 |
||
393 |
static void BuildRailClick_Remove(Window *w) |
|
394 |
{ |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
395 |
if (w->IsWidgetDisabled(RTW_REMOVE)) return; |
9732 | 396 |
ToggleRailButton_Remove(w); |
541 | 397 |
SndPlayFx(SND_15_BEEP); |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
398 |
|
9732 | 399 |
/* handle station builder */ |
400 |
if (w->IsWidgetLowered(RTW_BUILD_STATION)) { |
|
401 |
if (_remove_button_clicked) { |
|
402 |
/* starting drag & drop remove */ |
|
403 |
if (!_railstation.dragdrop) { |
|
404 |
SetTileSelectSize(1, 1); |
|
405 |
} else { |
|
406 |
VpSetPlaceSizingLimit(-1); |
|
407 |
} |
|
408 |
} else { |
|
409 |
/* starting station build mode */ |
|
410 |
if (!_railstation.dragdrop) { |
|
411 |
int x = _railstation.numtracks; |
|
412 |
int y = _railstation.platlength; |
|
413 |
if (_railstation.orientation == 0) Swap(x, y); |
|
414 |
SetTileSelectSize(x, y); |
|
415 |
} else { |
|
416 |
VpSetPlaceSizingLimit(_patches.station_spread); |
|
417 |
} |
|
418 |
} |
|
0 | 419 |
} |
420 |
} |
|
421 |
||
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
422 |
static void BuildRailClick_Convert(Window *w) |
0 | 423 |
{ |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
424 |
HandlePlacePushButton(w, RTW_CONVERT_RAIL, GetRailTypeInfo(_cur_railtype)->cursor.convert, VHM_RECT, PlaceRail_ConvertRail); |
0 | 425 |
} |
426 |
||
427 |
||
428 |
static void DoRailroadTrack(int mode) |
|
429 |
{ |
|
1980
9ea0c89fbb58
(svn r2486) Turn TILE_FROM_XY into an inline function and rename it to TileVirtXY
tron
parents:
1977
diff
changeset
|
430 |
DoCommandP(TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), _cur_railtype | (mode << 4), NULL, |
9732 | 431 |
_remove_button_clicked ? |
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9694
diff
changeset
|
432 |
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
|
433 |
CMD_BUILD_RAILROAD_TRACK | CMD_NO_WATER | CMD_MSG(STR_1011_CAN_T_BUILD_RAILROAD_TRACK) |
0 | 434 |
); |
435 |
} |
|
436 |
||
6573 | 437 |
static void HandleAutodirPlacement() |
0 | 438 |
{ |
439 |
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
|
440 |
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
|
441 |
|
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1035
diff
changeset
|
442 |
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
|
443 |
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
|
444 |
return; |
0 | 445 |
} |
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
|
446 |
|
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
|
447 |
DoRailroadTrack(trackstat); |
0 | 448 |
} |
449 |
||
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
450 |
/** |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
451 |
* Build new signals or remove signals or (if only one tile marked) edit a signal. |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
452 |
* |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
453 |
* If one tile marked abort and use GenericPlaceSignals() |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
454 |
* else use CmdBuildSingleSignal() or CmdRemoveSingleSignal() in rail_cmd.cpp to build many signals |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
455 |
*/ |
6573 | 456 |
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
|
457 |
{ |
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
|
458 |
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
|
459 |
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
|
460 |
|
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
|
461 |
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
|
462 |
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
|
463 |
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
|
464 |
} |
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
|
465 |
|
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
466 |
const Window *w = FindWindowById(WC_BUILD_SIGNAL, 0); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
467 |
|
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
468 |
if (w != NULL) { |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
469 |
/* signal GUI is used */ |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
470 |
SB(p2, 3, 1, 0); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
471 |
SB(p2, 4, 1, _cur_signal_variant); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
472 |
SB(p2, 6, 1, _ctrl_pressed); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
473 |
SB(p2, 24, 8, _patches.drag_signals_density); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
474 |
} else { |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
475 |
SB(p2, 3, 1, 0); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
476 |
SB(p2, 4, 1, (_cur_year < _patches.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC)); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
477 |
SB(p2, 6, 1, _ctrl_pressed); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
478 |
SB(p2, 24, 8, _patches.drag_signals_density); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
479 |
} |
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
|
480 |
|
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
|
481 |
/* _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
|
482 |
* in a network game can specify his/her own signal density */ |
2639 | 483 |
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
|
484 |
TileVirtXY(thd->selstart.x, thd->selstart.y), |
2639 | 485 |
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
|
486 |
p2, |
2639 | 487 |
CcPlaySound1E, |
488 |
_remove_button_clicked ? |
|
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9694
diff
changeset
|
489 |
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
|
490 |
CMD_BUILD_SIGNAL_TRACK | CMD_NO_WATER | CMD_MSG(STR_1010_CAN_T_BUILD_SIGNALS_HERE) |
2639 | 491 |
); |
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
|
492 |
} |
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
|
493 |
|
2639 | 494 |
|
495 |
typedef void OnButtonClick(Window *w); |
|
496 |
||
0 | 497 |
static OnButtonClick * const _build_railroad_button_proc[] = { |
498 |
BuildRailClick_N, |
|
499 |
BuildRailClick_NE, |
|
500 |
BuildRailClick_E, |
|
501 |
BuildRailClick_NW, |
|
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
502 |
BuildRailClick_AutoRail, |
0 | 503 |
BuildRailClick_Demolish, |
504 |
BuildRailClick_Depot, |
|
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
505 |
BuildRailClick_Waypoint, |
0 | 506 |
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
|
507 |
BuildRailClick_AutoSignals, |
0 | 508 |
BuildRailClick_Bridge, |
509 |
BuildRailClick_Tunnel, |
|
510 |
BuildRailClick_Remove, |
|
5933
0835f3342b79
(svn r8143) Remove the landscaping button from the build toolbars.
tron
parents:
5919
diff
changeset
|
511 |
BuildRailClick_Convert |
0 | 512 |
}; |
513 |
||
514 |
static const uint16 _rail_keycodes[] = { |
|
515 |
'1', |
|
516 |
'2', |
|
517 |
'3', |
|
518 |
'4', |
|
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
519 |
'5', |
0 | 520 |
'6', |
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
521 |
'7', // depot |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
522 |
'8', // waypoint |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
523 |
'9', // station |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
524 |
'S', // signals |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
525 |
'B', // bridge |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
526 |
'T', // tunnel |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
527 |
'R', // remove |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
528 |
'C', // convert rail |
0 | 529 |
}; |
530 |
||
531 |
||
4709
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
532 |
static void UpdateRemoveWidgetStatus(Window *w, int clicked_widget) |
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
533 |
{ |
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
534 |
switch (clicked_widget) { |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
535 |
case RTW_REMOVE: |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
536 |
/* If it is the removal button that has been clicked, do nothing, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
537 |
* as it is up to the other buttons to drive removal status */ |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
538 |
return; |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
539 |
break; |
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
540 |
case RTW_BUILD_NS: |
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
541 |
case RTW_BUILD_X: |
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
542 |
case RTW_BUILD_EW: |
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
543 |
case RTW_BUILD_Y: |
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
544 |
case RTW_AUTORAIL: |
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
545 |
case RTW_BUILD_WAYPOINT: |
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
546 |
case RTW_BUILD_STATION: |
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5116
diff
changeset
|
547 |
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
|
548 |
/* 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
|
549 |
* button is still lowered. Once raised, it has to be disabled */ |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
550 |
w->SetWidgetDisabledState(RTW_REMOVE, !w->IsWidgetLowered(clicked_widget)); |
4731
0febcf07eb48
(svn r6643) -Fix(r6631): Adjust proper disabled and lowered states of removal button on railtoolbar
belugas
parents:
4727
diff
changeset
|
551 |
break; |
0febcf07eb48
(svn r6643) -Fix(r6631): Adjust proper disabled and lowered states of removal button on railtoolbar
belugas
parents:
4727
diff
changeset
|
552 |
|
0febcf07eb48
(svn r6643) -Fix(r6631): Adjust proper disabled and lowered states of removal button on railtoolbar
belugas
parents:
4727
diff
changeset
|
553 |
default: |
0febcf07eb48
(svn r6643) -Fix(r6631): Adjust proper disabled and lowered states of removal button on railtoolbar
belugas
parents:
4727
diff
changeset
|
554 |
/* When any other buttons than rail/signal/waypoint/station, raise and |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
555 |
* disable the removal button */ |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
556 |
w->DisableWidget(RTW_REMOVE); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
557 |
w->RaiseWidget(RTW_REMOVE); |
4731
0febcf07eb48
(svn r6643) -Fix(r6631): Adjust proper disabled and lowered states of removal button on railtoolbar
belugas
parents:
4727
diff
changeset
|
558 |
break; |
4709
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
559 |
} |
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
560 |
} |
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
561 |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
562 |
/** |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
563 |
* Railway toolbar window event definition |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
564 |
* |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
565 |
* @param w window pointer |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
566 |
* @param e event been triggered |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
567 |
*/ |
0 | 568 |
static void BuildRailToolbWndProc(Window *w, WindowEvent *e) |
569 |
{ |
|
2639 | 570 |
switch (e->event) { |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
571 |
case WE_CREATE: w->DisableWidget(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
|
572 |
|
4709
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
573 |
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
|
574 |
|
0 | 575 |
case WE_CLICK: |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
576 |
if (e->we.click.widget >= RTW_BUILD_NS) { |
0 | 577 |
_remove_button_clicked = false; |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
578 |
_build_railroad_button_proc[e->we.click.widget - RTW_BUILD_NS](w); |
0 | 579 |
} |
4709
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
580 |
UpdateRemoveWidgetStatus(w, e->we.click.widget); |
9732 | 581 |
if (_ctrl_pressed) RailToolbar_CtrlChanged(w); |
4709
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
582 |
break; |
0 | 583 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
584 |
case WE_KEYPRESS: |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
585 |
for (uint8 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
|
586 |
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
|
587 |
e->we.keypress.cont = false; |
0 | 588 |
_remove_button_clicked = false; |
589 |
_build_railroad_button_proc[i](w); |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
590 |
UpdateRemoveWidgetStatus(w, i + RTW_BUILD_NS); |
9732 | 591 |
if (_ctrl_pressed) RailToolbar_CtrlChanged(w); |
0 | 592 |
break; |
593 |
} |
|
756
d1f1dc31b6f4
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
679
diff
changeset
|
594 |
} |
d1f1dc31b6f4
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
679
diff
changeset
|
595 |
MarkTileDirty(_thd.pos.x, _thd.pos.y); // redraw tile selection |
0 | 596 |
break; |
597 |
||
598 |
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
|
599 |
_place_proc(e->we.place.tile); |
0 | 600 |
return; |
601 |
||
602 |
case WE_PLACE_DRAG: { |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
603 |
/* no dragging if you have pressed the convert button */ |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
604 |
if (FindWindowById(WC_BUILD_SIGNAL, 0) != NULL && _convert_signal_button && w->IsWidgetLowered(RTW_BUILD_SIGNALS)) return; |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
605 |
|
9624 | 606 |
VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method); |
0 | 607 |
return; |
608 |
} |
|
609 |
||
610 |
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
|
611 |
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
|
612 |
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
|
613 |
TileIndex end_tile = e->we.place.tile; |
0 | 614 |
|
9624 | 615 |
switch (e->we.place.select_proc) { |
616 |
case DDSP_BUILD_BRIDGE: |
|
617 |
ResetObjectToPlace(); |
|
9732 | 618 |
ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_RAIL, _cur_railtype); |
9624 | 619 |
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
|
620 |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
621 |
case DDSP_PLACE_AUTORAIL: |
9624 | 622 |
HandleAutodirPlacement(); |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
623 |
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
|
624 |
|
9624 | 625 |
case DDSP_BUILD_SIGNALS: |
626 |
HandleAutoSignalPlacement(); |
|
627 |
break; |
|
628 |
||
629 |
case DDSP_DEMOLISH_AREA: |
|
630 |
GUIPlaceProcDragXY(e); |
|
631 |
break; |
|
632 |
||
633 |
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
|
634 |
DoCommandP(end_tile, start_tile, _cur_railtype, CcPlaySound10, CMD_CONVERT_RAIL | CMD_MSG(STR_CANT_CONVERT_RAIL)); |
9624 | 635 |
break; |
636 |
||
9732 | 637 |
case DDSP_REMOVE_STATION: |
9624 | 638 |
case DDSP_BUILD_STATION: |
9732 | 639 |
if (_remove_button_clicked) { |
640 |
DoCommandP(end_tile, start_tile, 0, CcPlaySound1E, CMD_REMOVE_FROM_RAILROAD_STATION | CMD_MSG(STR_CANT_REMOVE_PART_OF_STATION)); |
|
641 |
break; |
|
642 |
} |
|
9624 | 643 |
HandleStationPlacement(start_tile, end_tile); |
644 |
break; |
|
645 |
||
646 |
case DDSP_PLACE_RAIL_NE: |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
647 |
case DDSP_PLACE_RAIL_NW: |
9624 | 648 |
DoRailroadTrack(e->we.place.select_proc == DDSP_PLACE_RAIL_NE ? TRACK_X : TRACK_Y); |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
649 |
break; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3921
diff
changeset
|
650 |
} |
0 | 651 |
} |
652 |
break; |
|
653 |
||
654 |
case WE_ABORT_PLACE_OBJ: |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
655 |
w->RaiseButtons(); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
656 |
w->DisableWidget(RTW_REMOVE); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
657 |
w->InvalidateWidget(RTW_REMOVE); |
0 | 658 |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
659 |
w = FindWindowById(WC_BUILD_SIGNAL, 0); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
660 |
if (w != NULL) WP(w, def_d).close = true; |
0 | 661 |
w = FindWindowById(WC_BUILD_STATION, 0); |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
662 |
if (w != NULL) WP(w, def_d).close = true; |
0 | 663 |
w = FindWindowById(WC_BUILD_DEPOT, 0); |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
664 |
if (w != NULL) WP(w, def_d).close = true; |
0 | 665 |
break; |
666 |
||
667 |
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
|
668 |
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
|
669 |
|
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
|
670 |
DoCommand(tile, 0, 0, DC_AUTO, CMD_BUILD_TUNNEL); |
2639 | 671 |
VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile); |
0 | 672 |
} 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
|
673 |
|
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
|
674 |
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
|
675 |
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
|
676 |
break; |
9732 | 677 |
|
678 |
case WE_CTRL_CHANGED: |
|
679 |
/* do not toggle Remove button by Ctrl when placing station */ |
|
680 |
if (!w->IsWidgetLowered(RTW_BUILD_STATION) && RailToolbar_CtrlChanged(w)) e->we.ctrl.cont = false; |
|
681 |
break; |
|
0 | 682 |
} |
683 |
} |
|
684 |
||
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
685 |
/** Widget definition for the rail toolbar */ |
2274
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
686 |
static const Widget _build_rail_widgets[] = { |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
687 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // RTW_CLOSEBOX |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
688 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 337, 0, 13, STR_100A_RAILROAD_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // RTW_CAPTION |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
689 |
{ WWT_STICKYBOX, RESIZE_NONE, 7, 338, 349, 0, 13, 0x0, STR_STICKY_BUTTON}, // RTW_STICKY |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
690 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
691 |
{ WWT_PANEL, RESIZE_NONE, 7, 110, 113, 14, 35, 0x0, STR_NULL}, // RTW_SPACER |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
692 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
693 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_RAIL_NS, STR_1018_BUILD_RAILROAD_TRACK}, // RTW_BUILD_NS |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
694 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 22, 43, 14, 35, SPR_IMG_RAIL_NE, STR_1018_BUILD_RAILROAD_TRACK}, // RTW_BUILD_X |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
695 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 44, 65, 14, 35, SPR_IMG_RAIL_EW, STR_1018_BUILD_RAILROAD_TRACK}, // RTW_BUILD_EW |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
696 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 66, 87, 14, 35, SPR_IMG_RAIL_NW, STR_1018_BUILD_RAILROAD_TRACK}, // RTW_BUILD_Y |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
697 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 88, 109, 14, 35, SPR_IMG_AUTORAIL, STR_BUILD_AUTORAIL_TIP}, // RTW_AUTORAIL |
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
|
698 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
699 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 114, 135, 14, 35, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC}, // RTW_DEMOLISH |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
700 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 136, 157, 14, 35, SPR_IMG_DEPOT_RAIL, STR_1019_BUILD_TRAIN_DEPOT_FOR_BUILDING}, // RTW_BUILD_DEPOT |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
701 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 158, 179, 14, 35, SPR_IMG_WAYPOINT, STR_CONVERT_RAIL_TO_WAYPOINT_TIP}, // RTW_BUILD_WAYPOINT |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
702 |
|
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
703 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 180, 221, 14, 35, SPR_IMG_RAIL_STATION, STR_101A_BUILD_RAILROAD_STATION}, // RTW_BUILD_STATION |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
704 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 222, 243, 14, 35, SPR_IMG_RAIL_SIGNALS, STR_101B_BUILD_RAILROAD_SIGNALS}, // RTW_BUILD_SIGNALS |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
705 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 244, 285, 14, 35, SPR_IMG_BRIDGE, STR_101C_BUILD_RAILROAD_BRIDGE}, // RTW_BUILD_BRIDGE |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
706 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 286, 305, 14, 35, SPR_IMG_TUNNEL_RAIL, STR_101D_BUILD_RAILROAD_TUNNEL}, // RTW_BUILD_TUNNEL |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
707 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 306, 327, 14, 35, SPR_IMG_REMOVE, STR_101E_TOGGLE_BUILD_REMOVE_FOR}, // RTW_REMOVE |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
708 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 328, 349, 14, 35, SPR_IMG_CONVERT_RAIL, STR_CONVERT_RAIL_TIP}, // RTW_CONVERT_RAIL |
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
|
709 |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
159
diff
changeset
|
710 |
{ WIDGETS_END}, |
0 | 711 |
}; |
712 |
||
2274
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
713 |
static const WindowDesc _build_rail_desc = { |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
714 |
WDP_ALIGN_TBR, 22, 350, 36, 350, 36, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6111
diff
changeset
|
715 |
WC_BUILD_TOOLBAR, WC_NONE, |
756
d1f1dc31b6f4
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
679
diff
changeset
|
716 |
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
|
717 |
_build_rail_widgets, |
0 | 718 |
BuildRailToolbWndProc |
719 |
}; |
|
720 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
721 |
|
2274
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
722 |
/** 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
|
723 |
* @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
|
724 |
* @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
|
725 |
*/ |
4171 | 726 |
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
|
727 |
{ |
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
728 |
const RailtypeInfo *rti = GetRailTypeInfo(railtype); |
0 | 729 |
|
2274
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
730 |
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
|
731 |
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
|
732 |
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
|
733 |
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
|
734 |
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
|
735 |
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
|
736 |
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
|
737 |
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
|
738 |
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
|
739 |
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
|
740 |
} |
0 | 741 |
|
2520
75eb66d6e371
(svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents:
2514
diff
changeset
|
742 |
void ShowBuildRailToolbar(RailType railtype, int button) |
0 | 743 |
{ |
744 |
Window *w; |
|
745 |
||
5005
21e84e53c732
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4994
diff
changeset
|
746 |
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
|
747 |
if (!ValParamRailtype(railtype)) return; |
946
81cf624bbdc5
(svn r1435) Fix: [ 1094092 ] Toolbars accessible via keyboard in spectator mode
dominik
parents:
926
diff
changeset
|
748 |
|
0 | 749 |
// don't recreate the window if we're clicking on a button and the window exists. |
750 |
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
|
751 |
DeleteWindowById(WC_BUILD_TOOLBAR, 0); |
2520
75eb66d6e371
(svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents:
2514
diff
changeset
|
752 |
_cur_railtype = railtype; |
2274
d94004c14b6c
(svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents:
2186
diff
changeset
|
753 |
w = AllocateWindowDesc(&_build_rail_desc); |
2520
75eb66d6e371
(svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents:
2514
diff
changeset
|
754 |
SetupRailToolbar(railtype, w); |
0 | 755 |
} |
756 |
||
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
|
757 |
_remove_button_clicked = false; |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
758 |
if (w != NULL && button >= RTW_CLOSEBOX) { |
4747
c49af691700f
(svn r6659) -Fix r6619: Fix widget state setting of the rail toolbar when using global hotkeys.
glx
parents:
4738
diff
changeset
|
759 |
_build_railroad_button_proc[button](w); |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
760 |
UpdateRemoveWidgetStatus(w, button + RTW_BUILD_NS); |
4747
c49af691700f
(svn r6659) -Fix r6619: Fix widget state setting of the rail toolbar when using global hotkeys.
glx
parents:
4738
diff
changeset
|
761 |
} |
6111 | 762 |
if (_patches.link_terraform_toolbar) ShowTerraformToolbar(w); |
0 | 763 |
} |
764 |
||
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
765 |
/** Enum referring to the widgets of the rail stations window */ |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
766 |
enum BuildRailStationWidgets { |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
767 |
BRSW_CLOSEBOX = 0, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
768 |
BRSW_CAPTION, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
769 |
BRSW_BACKGROUND, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
770 |
|
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
771 |
BRSW_PLATFORM_DIR_X, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
772 |
BRSW_PLATFORM_DIR_Y, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
773 |
|
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
774 |
BRSW_PLATFORM_NUM_BEGIN = BRSW_PLATFORM_DIR_Y, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
775 |
BRSW_PLATFORM_NUM_1, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
776 |
BRSW_PLATFORM_NUM_2, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
777 |
BRSW_PLATFORM_NUM_3, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
778 |
BRSW_PLATFORM_NUM_4, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
779 |
BRSW_PLATFORM_NUM_5, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
780 |
BRSW_PLATFORM_NUM_6, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
781 |
BRSW_PLATFORM_NUM_7, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
782 |
|
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
783 |
BRSW_PLATFORM_LEN_BEGIN = BRSW_PLATFORM_NUM_7, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
784 |
BRSW_PLATFORM_LEN_1, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
785 |
BRSW_PLATFORM_LEN_2, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
786 |
BRSW_PLATFORM_LEN_3, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
787 |
BRSW_PLATFORM_LEN_4, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
788 |
BRSW_PLATFORM_LEN_5, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
789 |
BRSW_PLATFORM_LEN_6, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
790 |
BRSW_PLATFORM_LEN_7, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
791 |
|
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
792 |
BRSW_PLATFORM_DRAG_N_DROP, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
793 |
|
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
794 |
BRSW_HIGHLIGHT_OFF, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
795 |
BRSW_HIGHLIGHT_ON, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
796 |
|
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
797 |
BRSW_NEWST_DROPDOWN, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
798 |
BRSW_NEWST_LIST, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
799 |
BRSW_NEWST_SCROLL |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
800 |
}; |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
801 |
|
449
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
802 |
/* 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
|
803 |
* --pasky */ |
d9325d9f24bb
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
804 |
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
805 |
static void HandleStationPlacement(TileIndex start, TileIndex end) |
0 | 806 |
{ |
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
|
807 |
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
|
808 |
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
|
809 |
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
|
810 |
uint ey = TileY(end); |
0 | 811 |
uint w,h; |
812 |
||
6432 | 813 |
if (sx > ex) Swap(sx, ex); |
814 |
if (sy > ey) Swap(sy, ey); |
|
0 | 815 |
w = ex - sx + 1; |
816 |
h = ey - sy + 1; |
|
6432 | 817 |
if (!_railstation.orientation) Swap(w, h); |
0 | 818 |
|
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
|
819 |
DoCommandP(TileXY(sx, sy), |
9624 | 820 |
_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
|
821 |
_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
|
822 |
CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION)); |
0 | 823 |
} |
824 |
||
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
|
825 |
/* 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
|
826 |
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
|
827 |
{ |
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
|
828 |
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
|
829 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
830 |
if (HasBit(statspec->disallowed_platforms, _railstation.numtracks - 1)) { |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
831 |
w->RaiseWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN); |
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
|
832 |
_railstation.numtracks = 1; |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
833 |
while (HasBit(statspec->disallowed_platforms, _railstation.numtracks - 1)) { |
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
|
834 |
_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
|
835 |
} |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
836 |
w->LowerWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN); |
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
|
837 |
} |
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
|
838 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
839 |
if (HasBit(statspec->disallowed_lengths, _railstation.platlength - 1)) { |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
840 |
w->RaiseWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN); |
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
|
841 |
_railstation.platlength = 1; |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
842 |
while (HasBit(statspec->disallowed_lengths, _railstation.platlength - 1)) { |
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
|
843 |
_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
|
844 |
} |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
845 |
w->LowerWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN); |
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
|
846 |
} |
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
|
847 |
} |
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
|
848 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
849 |
static DropDownList *BuildStationClassDropDown() |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
850 |
{ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
851 |
DropDownList *list = new DropDownList(); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
852 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
853 |
for (uint i = 0; i < GetNumStationClasses(); i++) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
854 |
if (i == STAT_CLASS_WAYP) continue; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
855 |
list->push_back(new DropDownListStringItem(GetStationClassName((StationClassID)i), i, false)); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
856 |
} |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
857 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
858 |
return list; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
859 |
} |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
860 |
|
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
|
861 |
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
|
862 |
{ |
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
|
863 |
switch (e->event) { |
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
864 |
case WE_CREATE: |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
865 |
w->LowerWidget(_railstation.orientation + BRSW_PLATFORM_DIR_X); |
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
866 |
if (_railstation.dragdrop) { |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
867 |
w->LowerWidget(BRSW_PLATFORM_DRAG_N_DROP); |
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
868 |
} else { |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
869 |
w->LowerWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
870 |
w->LowerWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN); |
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
871 |
} |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
872 |
w->SetWidgetLoweredState(BRSW_HIGHLIGHT_OFF, !_station_show_coverage); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
873 |
w->SetWidgetLoweredState(BRSW_HIGHLIGHT_ON, _station_show_coverage); |
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
874 |
break; |
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
875 |
|
0 | 876 |
case WE_PAINT: { |
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
|
877 |
bool newstations = _railstation.newstations; |
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
|
878 |
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
|
879 |
const StationSpec *statspec = newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL; |
0 | 880 |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
881 |
if (WP(w, def_d).close) return; |
0 | 882 |
|
883 |
if (_railstation.dragdrop) { |
|
884 |
SetTileSelectSize(1, 1); |
|
885 |
} else { |
|
886 |
int x = _railstation.numtracks; |
|
887 |
int y = _railstation.platlength; |
|
6432 | 888 |
if (_railstation.orientation == 0) Swap(x, y); |
2952 | 889 |
if (!_remove_button_clicked) |
0 | 890 |
SetTileSelectSize(x, y); |
891 |
} |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
892 |
|
9732 | 893 |
int rad = (_patches.modified_catchment) ? CA_TRAIN : CA_UNMODIFIED; |
568
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
894 |
|
0 | 895 |
if (_station_show_coverage) |
568
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
896 |
SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad); |
0 | 897 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
898 |
for (uint bits = 0; bits < 7; bits++) { |
5765
65eb8a67aca0
(svn r7812) -Fix: rail station build window was not correctly updated after station_spread change
glx
parents:
5726
diff
changeset
|
899 |
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
|
900 |
if (statspec == NULL) { |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
901 |
w->SetWidgetDisabledState(bits + BRSW_PLATFORM_NUM_1, disable); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
902 |
w->SetWidgetDisabledState(bits + BRSW_PLATFORM_LEN_1, disable); |
5765
65eb8a67aca0
(svn r7812) -Fix: rail station build window was not correctly updated after station_spread change
glx
parents:
5726
diff
changeset
|
903 |
} else { |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
904 |
w->SetWidgetDisabledState(bits + BRSW_PLATFORM_NUM_1, HasBit(statspec->disallowed_platforms, bits) || disable); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
905 |
w->SetWidgetDisabledState(bits + BRSW_PLATFORM_LEN_1, 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
|
906 |
} |
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 |
|
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 |
SetDParam(0, GetStationClassName(_railstation.station_class)); |
0 | 910 |
DrawWindowWidgets(w); |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
911 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
912 |
int y_offset = newstations ? 90 : 0; |
0 | 913 |
|
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
|
914 |
/* 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
|
915 |
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
|
916 |
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
|
917 |
_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
|
918 |
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
|
919 |
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
|
920 |
} |
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
|
921 |
_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
|
922 |
} |
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
|
923 |
|
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
|
924 |
/* 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
|
925 |
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
|
926 |
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
|
927 |
_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
|
928 |
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
|
929 |
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
|
930 |
} |
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
|
931 |
_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
|
932 |
} |
0 | 933 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
934 |
DrawStringCentered(74, 15 + y_offset, STR_3002_ORIENTATION, TC_FROMSTRING); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
935 |
DrawStringCentered(74, 76 + y_offset, STR_3003_NUMBER_OF_TRACKS, TC_FROMSTRING); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
936 |
DrawStringCentered(74, 101 + y_offset, STR_3004_PLATFORM_LENGTH, TC_FROMSTRING); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
937 |
DrawStringCentered(74, 141 + y_offset, STR_3066_COVERAGE_AREA_HIGHLIGHT, TC_FROMSTRING); |
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
|
938 |
|
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
939 |
int text_end = DrawStationCoverageAreaText(2, 166 + y_offset, SCT_ALL, rad, false); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
940 |
text_end = DrawStationCoverageAreaText(2, text_end + 4, SCT_ALL, rad, true) + 4; |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
941 |
if (text_end != w->widget[BRSW_BACKGROUND].bottom) { |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
942 |
SetWindowDirty(w); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
943 |
ResizeWindowForWidget(w, BRSW_BACKGROUND, 0, text_end - w->widget[BRSW_BACKGROUND].bottom); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
944 |
SetWindowDirty(w); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
945 |
} |
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
|
946 |
|
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
|
947 |
if (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
|
948 |
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
|
949 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
950 |
for (uint16 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
|
951 |
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
|
952 |
|
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
|
953 |
if (statspec != NULL && statspec->name != 0) { |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
954 |
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
|
955 |
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
|
956 |
} |
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
|
957 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
958 |
DrawStringTruncated(9, y, statspec->name, i == _railstation.station_type ? TC_WHITE : TC_BLACK, 118); |
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
|
959 |
} else { |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
960 |
DrawStringTruncated(9, y, STR_STAT_CLASS_DFLT, i == _railstation.station_type ? TC_WHITE : TC_BLACK, 118); |
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
|
961 |
} |
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
|
962 |
|
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
|
963 |
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
|
964 |
} |
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
|
965 |
} |
0 | 966 |
} break; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
967 |
|
0 | 968 |
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
|
969 |
switch (e->we.click.widget) { |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
970 |
case BRSW_PLATFORM_DIR_X: |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
971 |
case BRSW_PLATFORM_DIR_Y: |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
972 |
w->RaiseWidget(_railstation.orientation + BRSW_PLATFORM_DIR_X); |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
973 |
_railstation.orientation = e->we.click.widget - BRSW_PLATFORM_DIR_X; |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
974 |
w->LowerWidget(_railstation.orientation + BRSW_PLATFORM_DIR_X); |
541 | 975 |
SndPlayFx(SND_15_BEEP); |
0 | 976 |
SetWindowDirty(w); |
977 |
break; |
|
978 |
||
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
979 |
case BRSW_PLATFORM_NUM_1: |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
980 |
case BRSW_PLATFORM_NUM_2: |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
981 |
case BRSW_PLATFORM_NUM_3: |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
982 |
case BRSW_PLATFORM_NUM_4: |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
983 |
case BRSW_PLATFORM_NUM_5: |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
984 |
case BRSW_PLATFORM_NUM_6: |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
985 |
case BRSW_PLATFORM_NUM_7: { |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
986 |
w->RaiseWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
987 |
w->RaiseWidget(BRSW_PLATFORM_DRAG_N_DROP); |
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
|
988 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
989 |
_railstation.numtracks = e->we.click.widget - BRSW_PLATFORM_NUM_BEGIN; |
0 | 990 |
_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
|
991 |
|
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
|
992 |
const StationSpec *statspec = _railstation.newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL; |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
993 |
if (statspec != NULL && HasBit(statspec->disallowed_lengths, _railstation.platlength - 1)) { |
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
|
994 |
/* 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
|
995 |
for (uint i = 0; i < 7; i++) { |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
996 |
if (!HasBit(statspec->disallowed_lengths, i)) { |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
997 |
w->RaiseWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN); |
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
|
998 |
_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
|
999 |
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
|
1000 |
} |
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
|
1001 |
} |
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
|
1002 |
} |
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
|
1003 |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1004 |
w->LowerWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1005 |
w->LowerWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN); |
541 | 1006 |
SndPlayFx(SND_15_BEEP); |
0 | 1007 |
SetWindowDirty(w); |
1008 |
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
|
1009 |
} |
0 | 1010 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1011 |
case BRSW_PLATFORM_LEN_1: |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1012 |
case BRSW_PLATFORM_LEN_2: |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1013 |
case BRSW_PLATFORM_LEN_3: |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1014 |
case BRSW_PLATFORM_LEN_4: |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1015 |
case BRSW_PLATFORM_LEN_5: |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1016 |
case BRSW_PLATFORM_LEN_6: |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1017 |
case BRSW_PLATFORM_LEN_7: { |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1018 |
w->RaiseWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1019 |
w->RaiseWidget(BRSW_PLATFORM_DRAG_N_DROP); |
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
|
1020 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1021 |
_railstation.platlength = e->we.click.widget - BRSW_PLATFORM_LEN_BEGIN; |
0 | 1022 |
_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
|
1023 |
|
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
|
1024 |
const StationSpec *statspec = _railstation.newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL; |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1025 |
if (statspec != NULL && HasBit(statspec->disallowed_platforms, _railstation.numtracks - 1)) { |
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
|
1026 |
/* 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
|
1027 |
for (uint i = 0; i < 7; i++) { |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1028 |
if (!HasBit(statspec->disallowed_platforms, i)) { |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1029 |
w->RaiseWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN); |
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
|
1030 |
_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
|
1031 |
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
|
1032 |
} |
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
|
1033 |
} |
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
|
1034 |
} |
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
|
1035 |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1036 |
w->LowerWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1037 |
w->LowerWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN); |
541 | 1038 |
SndPlayFx(SND_15_BEEP); |
0 | 1039 |
SetWindowDirty(w); |
1040 |
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
|
1041 |
} |
0 | 1042 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1043 |
case BRSW_PLATFORM_DRAG_N_DROP: { |
0 | 1044 |
_railstation.dragdrop ^= true; |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1045 |
w->ToggleWidgetLoweredState(BRSW_PLATFORM_DRAG_N_DROP); |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1046 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1047 |
/* get the first allowed length/number of platforms */ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1048 |
const StationSpec *statspec = _railstation.newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1049 |
if (statspec != NULL && HasBit(statspec->disallowed_lengths, _railstation.platlength - 1)) { |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1050 |
for (uint i = 0; i < 7; i++) { |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1051 |
if (!HasBit(statspec->disallowed_lengths, i)) { |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1052 |
w->RaiseWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN); |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1053 |
_railstation.platlength = i + 1; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1054 |
break; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1055 |
} |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1056 |
} |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1057 |
} |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1058 |
if (statspec != NULL && HasBit(statspec->disallowed_platforms, _railstation.numtracks - 1)) { |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1059 |
for (uint i = 0; i < 7; i++) { |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1060 |
if (!HasBit(statspec->disallowed_platforms, i)) { |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1061 |
w->RaiseWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN); |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1062 |
_railstation.numtracks = i + 1; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1063 |
break; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1064 |
} |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1065 |
} |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1066 |
} |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1067 |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1068 |
w->SetWidgetLoweredState(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN, !_railstation.dragdrop); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1069 |
w->SetWidgetLoweredState(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN, !_railstation.dragdrop); |
541 | 1070 |
SndPlayFx(SND_15_BEEP); |
0 | 1071 |
SetWindowDirty(w); |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1072 |
} break; |
0 | 1073 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1074 |
case BRSW_HIGHLIGHT_OFF: |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1075 |
case BRSW_HIGHLIGHT_ON: |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1076 |
_station_show_coverage = (e->we.click.widget != BRSW_HIGHLIGHT_OFF); |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1077 |
w->SetWidgetLoweredState(BRSW_HIGHLIGHT_OFF, !_station_show_coverage); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1078 |
w->SetWidgetLoweredState(BRSW_HIGHLIGHT_ON, _station_show_coverage); |
541 | 1079 |
SndPlayFx(SND_15_BEEP); |
0 | 1080 |
SetWindowDirty(w); |
1081 |
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
|
1082 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1083 |
case BRSW_NEWST_DROPDOWN: |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1084 |
ShowDropDownList(w, BuildStationClassDropDown(), _railstation.station_class, BRSW_NEWST_DROPDOWN); |
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
|
1085 |
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
|
1086 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1087 |
case BRSW_NEWST_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
|
1088 |
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
|
1089 |
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
|
1090 |
|
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
|
1091 |
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
|
1092 |
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
|
1093 |
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
|
1094 |
|
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
|
1095 |
/* 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
|
1096 |
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
|
1097 |
if (statspec != NULL && |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1098 |
HasBit(statspec->callbackmask, CBM_STATION_AVAIL) && |
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
|
1099 |
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
|
1100 |
|
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
|
1101 |
_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
|
1102 |
|
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
|
1103 |
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
|
1104 |
|
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
|
1105 |
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
|
1106 |
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
|
1107 |
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
|
1108 |
} |
0 | 1109 |
} |
1110 |
} break; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
1111 |
|
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
|
1112 |
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
|
1113 |
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
|
1114 |
_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
|
1115 |
_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
|
1116 |
_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
|
1117 |
|
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
|
1118 |
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
|
1119 |
|
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
|
1120 |
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
|
1121 |
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
|
1122 |
} |
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
|
1123 |
|
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
|
1124 |
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
|
1125 |
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
|
1126 |
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
|
1127 |
|
2639 | 1128 |
case WE_MOUSELOOP: |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1129 |
if (WP(w, def_d).close) { |
0 | 1130 |
DeleteWindow(w); |
1131 |
return; |
|
1132 |
} |
|
1133 |
CheckRedrawStationCoverage(w); |
|
2639 | 1134 |
break; |
1074
5f45c1b03f2f
(svn r1575) -Fix: Forgot to exit the construction phase for the waypoint window (if
Celestar
parents:
1072
diff
changeset
|
1135 |
|
1072
01bf9fc64236
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1071
diff
changeset
|
1136 |
case WE_DESTROY: |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1137 |
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
|
1138 |
break; |
0 | 1139 |
} |
1140 |
} |
|
1141 |
||
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1142 |
/** Widget definition of the standard build rail station window */ |
0 | 1143 |
static const Widget _station_builder_widgets[] = { |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1144 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // BRSW_CLOSEBOX |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1145 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_3000_RAIL_STATION_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // BRSW_CAPTION |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1146 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 147, 14, 199, 0x0, STR_NULL}, // BRSW_BACKGROUND |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1147 |
{ WWT_PANEL, RESIZE_NONE, 14, 7, 72, 26, 73, 0x0, STR_304E_SELECT_RAILROAD_STATION}, // BRSW_PLATFORM_DIR_X |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1148 |
{ WWT_PANEL, RESIZE_NONE, 14, 75, 140, 26, 73, 0x0, STR_304E_SELECT_RAILROAD_STATION}, // BRSW_PLATFORM_DIR_Y |
0 | 1149 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1150 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 22, 36, 87, 98, STR_00CB_1, STR_304F_SELECT_NUMBER_OF_PLATFORMS}, // BRSW_PLATFORM_NUM_1 |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1151 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 37, 51, 87, 98, STR_00CC_2, STR_304F_SELECT_NUMBER_OF_PLATFORMS}, // BRSW_PLATFORM_NUM_2 |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1152 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 52, 66, 87, 98, STR_00CD_3, STR_304F_SELECT_NUMBER_OF_PLATFORMS}, // BRSW_PLATFORM_NUM_3 |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1153 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 67, 81, 87, 98, STR_00CE_4, STR_304F_SELECT_NUMBER_OF_PLATFORMS}, // BRSW_PLATFORM_NUM_4 |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1154 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 82, 96, 87, 98, STR_00CF_5, STR_304F_SELECT_NUMBER_OF_PLATFORMS}, // BRSW_PLATFORM_NUM_5 |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1155 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 97, 111, 87, 98, STR_6, STR_304F_SELECT_NUMBER_OF_PLATFORMS}, // BRSW_PLATFORM_NUM_6 |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1156 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 112, 126, 87, 98, STR_7, STR_304F_SELECT_NUMBER_OF_PLATFORMS}, // BRSW_PLATFORM_NUM_7 |
0 | 1157 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1158 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 22, 36, 112, 123, STR_00CB_1, STR_3050_SELECT_LENGTH_OF_RAILROAD}, // BRSW_PLATFORM_LEN_1 |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1159 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 37, 51, 112, 123, STR_00CC_2, STR_3050_SELECT_LENGTH_OF_RAILROAD}, // BRSW_PLATFORM_LEN_2 |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1160 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 52, 66, 112, 123, STR_00CD_3, STR_3050_SELECT_LENGTH_OF_RAILROAD}, // BRSW_PLATFORM_LEN_3 |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1161 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 67, 81, 112, 123, STR_00CE_4, STR_3050_SELECT_LENGTH_OF_RAILROAD}, // BRSW_PLATFORM_LEN_4 |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1162 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 82, 96, 112, 123, STR_00CF_5, STR_3050_SELECT_LENGTH_OF_RAILROAD}, // BRSW_PLATFORM_LEN_5 |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1163 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 97, 111, 112, 123, STR_6, STR_3050_SELECT_LENGTH_OF_RAILROAD}, // BRSW_PLATFORM_LEN_6 |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1164 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 112, 126, 112, 123, STR_7, STR_3050_SELECT_LENGTH_OF_RAILROAD}, // BRSW_PLATFORM_LEN_7 |
0 | 1165 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1166 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 37, 111, 126, 137, STR_DRAG_DROP, STR_STATION_DRAG_DROP}, // BRSW_PLATFORM_DRAG_N_DROP |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1167 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 14, 73, 152, 163, STR_02DB_OFF, STR_3065_DON_T_HIGHLIGHT_COVERAGE}, // BRSW_HIGHLIGHT_OFF |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1168 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 74, 133, 152, 163, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA}, // BRSW_HIGHLIGHT_ON |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
159
diff
changeset
|
1169 |
{ WIDGETS_END}, |
0 | 1170 |
}; |
1171 |
||
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1172 |
/** Widget definition of the build NewGRF rail station 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
|
1173 |
static const Widget _newstation_builder_widgets[] = { |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1174 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // BRSW_CLOSEBOX |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1175 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_3000_RAIL_STATION_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // BRSW_CAPTION |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1176 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 147, 14, 289, 0x0, STR_NULL}, // BRSW_BACKGROUND |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1177 |
{ WWT_PANEL, RESIZE_NONE, 14, 7, 72, 116, 163, 0x0, STR_304E_SELECT_RAILROAD_STATION}, // BRSW_PLATFORM_DIR_X |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1178 |
{ WWT_PANEL, RESIZE_NONE, 14, 75, 140, 116, 163, 0x0, STR_304E_SELECT_RAILROAD_STATION}, // BRSW_PLATFORM_DIR_Y |
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
|
1179 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1180 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 22, 36, 177, 188, STR_00CB_1, STR_304F_SELECT_NUMBER_OF_PLATFORMS}, // BRSW_PLATFORM_NUM_1 |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1181 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 37, 51, 177, 188, STR_00CC_2, STR_304F_SELECT_NUMBER_OF_PLATFORMS}, // BRSW_PLATFORM_NUM_2 |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1182 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 52, 66, 177, 188, STR_00CD_3, STR_304F_SELECT_NUMBER_OF_PLATFORMS}, // BRSW_PLATFORM_NUM_3 |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1183 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 67, 81, 177, 188, STR_00CE_4, STR_304F_SELECT_NUMBER_OF_PLATFORMS}, // BRSW_PLATFORM_NUM_4 |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1184 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 82, 96, 177, 188, STR_00CF_5, STR_304F_SELECT_NUMBER_OF_PLATFORMS}, // BRSW_PLATFORM_NUM_5 |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1185 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 97, 111, 177, 188, STR_6, STR_304F_SELECT_NUMBER_OF_PLATFORMS}, // BRSW_PLATFORM_NUM_6 |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1186 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 112, 126, 177, 188, STR_7, STR_304F_SELECT_NUMBER_OF_PLATFORMS}, // BRSW_PLATFORM_NUM_7 |
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
|
1187 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1188 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 22, 36, 202, 213, STR_00CB_1, STR_3050_SELECT_LENGTH_OF_RAILROAD}, // BRSW_PLATFORM_LEN_1 |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1189 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 37, 51, 202, 213, STR_00CC_2, STR_3050_SELECT_LENGTH_OF_RAILROAD}, // BRSW_PLATFORM_LEN_2 |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1190 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 52, 66, 202, 213, STR_00CD_3, STR_3050_SELECT_LENGTH_OF_RAILROAD}, // BRSW_PLATFORM_LEN_3 |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1191 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 67, 81, 202, 213, STR_00CE_4, STR_3050_SELECT_LENGTH_OF_RAILROAD}, // BRSW_PLATFORM_LEN_4 |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1192 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 82, 96, 202, 213, STR_00CF_5, STR_3050_SELECT_LENGTH_OF_RAILROAD}, // BRSW_PLATFORM_LEN_5 |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1193 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 97, 111, 202, 213, STR_6, STR_3050_SELECT_LENGTH_OF_RAILROAD}, // BRSW_PLATFORM_LEN_6 |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1194 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 112, 126, 202, 213, STR_7, STR_3050_SELECT_LENGTH_OF_RAILROAD}, // BRSW_PLATFORM_LEN_7 |
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
|
1195 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1196 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 37, 111, 216, 227, STR_DRAG_DROP, STR_STATION_DRAG_DROP}, // BRSW_PLATFORM_DRAG_N_DROP |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1197 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 14, 73, 242, 253, STR_02DB_OFF, STR_3065_DON_T_HIGHLIGHT_COVERAGE}, // BRSW_HIGHLIGHT_OFF |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1198 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 74, 133, 242, 253, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA}, // BRSW_HIGHLIGHT_ON |
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
|
1199 |
|
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
|
1200 |
/* newstations gui additions */ |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1201 |
{ WWT_DROPDOWNIN, RESIZE_NONE, 14, 7, 140, 17, 28, STR_02BD, STR_SELECT_STATION_CLASS_TIP}, // BRSW_NEWST_DROPDOWN |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1202 |
{ WWT_MATRIX, RESIZE_NONE, 14, 7, 128, 32, 102, 0x501, STR_SELECT_STATION_TYPE_TIP}, // BRSW_NEWST_LIST |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1203 |
{ WWT_SCROLLBAR, RESIZE_NONE, 14, 129, 140, 32, 102, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, // BRSW_NEWST_SCROLL |
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
|
1204 |
{ 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
|
1205 |
}; |
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
|
1206 |
|
0 | 1207 |
static const WindowDesc _station_builder_desc = { |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1208 |
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
|
1209 |
WC_BUILD_STATION, WC_BUILD_TOOLBAR, |
0 | 1210 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
1211 |
_station_builder_widgets, |
|
1212 |
StationBuildWndProc |
|
1213 |
}; |
|
1214 |
||
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
|
1215 |
static const WindowDesc _newstation_builder_desc = { |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1216 |
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
|
1217 |
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
|
1218 |
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
|
1219 |
_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
|
1220 |
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
|
1221 |
}; |
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
|
1222 |
|
6573 | 1223 |
static void ShowStationBuilder() |
0 | 1224 |
{ |
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
|
1225 |
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
|
1226 |
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
|
1227 |
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
|
1228 |
_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
|
1229 |
} 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
|
1230 |
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
|
1231 |
_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
|
1232 |
_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
|
1233 |
|
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
|
1234 |
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
|
1235 |
w->vscroll.cap = 5; |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1236 |
w->vscroll.pos = Clamp(_railstation.station_type - 2, 0, w->vscroll.count - w->vscroll.cap); |
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
|
1237 |
} |
0 | 1238 |
} |
1239 |
||
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1240 |
/** Enum referring to the widgets of the signal window */ |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1241 |
enum BuildSignalWidgets { |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1242 |
BSW_CLOSEBOX = 0, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1243 |
BSW_CAPTION, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1244 |
BSW_SEMAPHORE_NORM, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1245 |
BSW_SEMAPHORE_ENTRY, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1246 |
BSW_SEMAPHORE_EXIT, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1247 |
BSW_SEMAPHORE_COMBO, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1248 |
BSW_ELECTRIC_NORM, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1249 |
BSW_ELECTRIC_ENTRY, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1250 |
BSW_ELECTRIC_EXIT, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1251 |
BSW_ELECTRIC_COMBO, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1252 |
BSW_CONVERT, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1253 |
BSW_DRAG_SIGNALS_DENSITY, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1254 |
BSW_DRAG_SIGNALS_DENSITY_DECREASE, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1255 |
BSW_DRAG_SIGNALS_DENSITY_INCREASE, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1256 |
}; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1257 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1258 |
/** |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1259 |
* Draw dynamic a signal-sprite in a button in the signal GUI |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1260 |
* Draw the sprite +1px to the right and down if the button is lowered and change the sprite to sprite + 1 (red to green light) |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1261 |
* |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1262 |
* @param w Window on which the widget is located |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1263 |
* @param widget_index index of this widget in the window |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1264 |
* @param image the sprite to draw |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1265 |
* @param xrel the relativ x value of the sprite in the grf |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1266 |
* @param xsize the width of the sprite |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1267 |
*/ |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1268 |
static void DrawSignalSprite(const Window *w, byte widget_index, SpriteID image, int8 xrel, uint8 xsize) |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1269 |
{ |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1270 |
DrawSprite(image + w->IsWidgetLowered(widget_index), PAL_NONE, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1271 |
w->widget[widget_index].left + (w->widget[widget_index].right - w->widget[widget_index].left) / 2 - xrel - xsize / 2 + |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1272 |
w->IsWidgetLowered(widget_index), w->widget[widget_index].bottom - 3 + w->IsWidgetLowered(widget_index)); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1273 |
} |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1274 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1275 |
/** |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1276 |
* Signal selection window event definition |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1277 |
* |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1278 |
* @param w window pointer |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1279 |
* @param e event been triggered |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1280 |
*/ |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1281 |
static void SignalBuildWndProc(Window *w, WindowEvent *e) |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1282 |
{ |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1283 |
switch (e->event) { |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1284 |
case WE_PAINT: |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1285 |
w->LowerWidget((_cur_signal_variant == SIG_ELECTRIC ? BSW_ELECTRIC_NORM : BSW_SEMAPHORE_NORM) + _cur_signal_type); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1286 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1287 |
w->SetWidgetLoweredState(BSW_CONVERT, _convert_signal_button); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1288 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1289 |
w->SetWidgetDisabledState(BSW_DRAG_SIGNALS_DENSITY_DECREASE, _patches.drag_signals_density == 1); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1290 |
w->SetWidgetDisabledState(BSW_DRAG_SIGNALS_DENSITY_INCREASE, _patches.drag_signals_density == 20); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1291 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1292 |
DrawWindowWidgets(w); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1293 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1294 |
/* The 'hardcoded' off sets are needed because they are reused sprites. */ |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1295 |
DrawSignalSprite(w, BSW_SEMAPHORE_NORM, SPR_IMG_SIGNAL_SEMAPHORE_NORM, 0, 12); // xsize of sprite + 1 == 9 |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1296 |
DrawSignalSprite(w, BSW_SEMAPHORE_ENTRY, SPR_IMG_SIGNAL_SEMAPHORE_ENTRY, -1, 13); // xsize of sprite + 1 == 10 |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1297 |
DrawSignalSprite(w, BSW_SEMAPHORE_EXIT, SPR_IMG_SIGNAL_SEMAPHORE_EXIT, 0, 12); // xsize of sprite + 1 == 9 |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1298 |
DrawSignalSprite(w, BSW_SEMAPHORE_COMBO, SPR_IMG_SIGNAL_SEMAPHORE_COMBO, 0, 12); // xsize of sprite + 1 == 9 |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1299 |
DrawSignalSprite(w, BSW_ELECTRIC_NORM, SPR_IMG_SIGNAL_ELECTRIC_NORM, -1, 4); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1300 |
DrawSignalSprite(w, BSW_ELECTRIC_ENTRY, SPR_IMG_SIGNAL_ELECTRIC_ENTRY, -2, 6); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1301 |
DrawSignalSprite(w, BSW_ELECTRIC_EXIT, SPR_IMG_SIGNAL_ELECTRIC_EXIT, -2, 6); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1302 |
DrawSignalSprite(w, BSW_ELECTRIC_COMBO, SPR_IMG_SIGNAL_ELECTRIC_COMBO, -2, 6); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1303 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1304 |
/* Draw dragging signal density value in the BSW_DRAG_SIGNALS_DENSITY widget */ |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1305 |
SetDParam(0, _patches.drag_signals_density); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1306 |
DrawStringCentered(w->widget[BSW_DRAG_SIGNALS_DENSITY].left + (w->widget[BSW_DRAG_SIGNALS_DENSITY].right - |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1307 |
w->widget[BSW_DRAG_SIGNALS_DENSITY].left) / 2 + 1, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1308 |
w->widget[BSW_DRAG_SIGNALS_DENSITY].top + 2, STR_JUST_INT, TC_ORANGE); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1309 |
break; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1310 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1311 |
case WE_CLICK: |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1312 |
switch (e->we.click.widget) { |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1313 |
case BSW_SEMAPHORE_NORM: |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1314 |
case BSW_SEMAPHORE_ENTRY: |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1315 |
case BSW_SEMAPHORE_EXIT: |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1316 |
case BSW_SEMAPHORE_COMBO: |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1317 |
case BSW_ELECTRIC_NORM: |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1318 |
case BSW_ELECTRIC_ENTRY: |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1319 |
case BSW_ELECTRIC_EXIT: |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1320 |
case BSW_ELECTRIC_COMBO: |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1321 |
w->RaiseWidget((_cur_signal_variant == SIG_ELECTRIC ? BSW_ELECTRIC_NORM : BSW_SEMAPHORE_NORM) + _cur_signal_type); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1322 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1323 |
_cur_signal_type = (SignalType)((uint)((e->we.click.widget - BSW_SEMAPHORE_NORM) % (SIGTYPE_COMBO + 1))); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1324 |
_cur_signal_variant = e->we.click.widget >= BSW_ELECTRIC_NORM ? SIG_ELECTRIC : SIG_SEMAPHORE; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1325 |
break; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1326 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1327 |
case BSW_CONVERT: |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1328 |
_convert_signal_button = !_convert_signal_button; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1329 |
break; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1330 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1331 |
case BSW_DRAG_SIGNALS_DENSITY_DECREASE: |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1332 |
if (_patches.drag_signals_density > 1) { |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1333 |
_patches.drag_signals_density--; |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1334 |
const Window *w = FindWindowById(WC_GAME_OPTIONS, 0); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1335 |
if (w != NULL) SetWindowDirty(w); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1336 |
} |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1337 |
break; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1338 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1339 |
case BSW_DRAG_SIGNALS_DENSITY_INCREASE: |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1340 |
if (_patches.drag_signals_density < 20) { |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1341 |
_patches.drag_signals_density++; |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1342 |
const Window *w = FindWindowById(WC_GAME_OPTIONS, 0); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1343 |
if (w != NULL) SetWindowDirty(w); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1344 |
} |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1345 |
break; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1346 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1347 |
default: break; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1348 |
} |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1349 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1350 |
SetWindowDirty(w); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1351 |
break; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1352 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1353 |
case WE_MOUSELOOP: |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1354 |
if (WP(w, def_d).close) DeleteWindow(w); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1355 |
return; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1356 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1357 |
case WE_DESTROY: |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1358 |
if (!WP(w, def_d).close) ResetObjectToPlace(); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1359 |
break; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1360 |
} |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1361 |
} |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1362 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1363 |
/** Widget definition of the build signal window */ |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1364 |
static const Widget _signal_builder_widgets[] = { |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1365 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // BSW_CLOSEBOX |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1366 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 109, 0, 13, STR_SIGNAL_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // BSW_CAPTION |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1367 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1368 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 21, 14, 40, STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP}, // BSW_SEMAPHORE_NORM |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1369 |
{ WWT_PANEL, RESIZE_NONE, 7, 22, 43, 14, 40, STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP}, // BSW_SEMAPHORE_ENTRY |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1370 |
{ WWT_PANEL, RESIZE_NONE, 7, 44, 65, 14, 40, STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP}, // BSW_SEMAPHORE_EXIT |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1371 |
{ WWT_PANEL, RESIZE_NONE, 7, 66, 87, 14, 40, STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP}, // BSW_SEMAPHORE_COMBO |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1372 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1373 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 21, 41, 67, STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP}, // BSW_ELECTRIC_NORM |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1374 |
{ WWT_PANEL, RESIZE_NONE, 7, 22, 43, 41, 67, STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP}, // BSW_ELECTRIC_ENTRY |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1375 |
{ WWT_PANEL, RESIZE_NONE, 7, 44, 65, 41, 67, STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP}, // BSW_ELECTRIC_EXIT |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1376 |
{ WWT_PANEL, RESIZE_NONE, 7, 66, 87, 41, 67, STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP}, // BSW_ELECTRIC_COMBO |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1377 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1378 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 88, 109, 14, 40, SPR_IMG_SIGNAL_CONVERT, STR_SIGNAL_CONVERT_TIP}, // BSW_CONVERT |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1379 |
{ WWT_PANEL, RESIZE_NONE, 7, 88, 109, 41, 67, STR_NULL, STR_DRAG_SIGNALS_DENSITY_TIP}, // BSW_DRAG_SIGNALS_DENSITY |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1380 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 90, 98, 54, 65, SPR_ARROW_LEFT, STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP}, // BSW_DRAG_SIGNALS_DENSITY_DECREASE |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1381 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 99, 107, 54, 65, SPR_ARROW_RIGHT, STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP}, // BSW_DRAG_SIGNALS_DENSITY_INCREASE |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1382 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1383 |
{ WIDGETS_END}, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1384 |
}; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1385 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1386 |
/** Signal selection window description */ |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1387 |
static const WindowDesc _signal_builder_desc = { |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1388 |
WDP_AUTO, WDP_AUTO, 110, 68, 110, 68, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1389 |
WC_BUILD_SIGNAL, WC_BUILD_TOOLBAR, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1390 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1391 |
_signal_builder_widgets, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1392 |
SignalBuildWndProc |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1393 |
}; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1394 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1395 |
/** |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1396 |
* Open the signal selection window |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1397 |
*/ |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1398 |
static void ShowSignalBuilder() |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1399 |
{ |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1400 |
AllocateWindowDesc(&_signal_builder_desc); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1401 |
} |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1402 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1403 |
/** Enum referring to the widgets of the build rail depot window */ |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1404 |
enum BuildRailDepotWidgets { |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1405 |
BRDW_CLOSEBOX = 0, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1406 |
BRDW_CAPTION, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1407 |
BRDW_BACKGROUND, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1408 |
BRDW_DEPOT_NE, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1409 |
BRDW_DEPOT_SE, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1410 |
BRDW_DEPOT_SW, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1411 |
BRDW_DEPOT_NW, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1412 |
}; |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1413 |
|
0 | 1414 |
static void BuildTrainDepotWndProc(Window *w, WindowEvent *e) |
1415 |
{ |
|
2952 | 1416 |
switch (e->event) { |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1417 |
case WE_CREATE: w->LowerWidget(_build_depot_direction + BRDW_DEPOT_NE); break; |
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
1418 |
|
0 | 1419 |
case WE_PAINT: { |
1420 |
DrawWindowWidgets(w); |
|
1421 |
||
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1422 |
DrawTrainDepotSprite(70, 17, DIAGDIR_NE, _cur_railtype); |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1423 |
DrawTrainDepotSprite(70, 69, DIAGDIR_SE, _cur_railtype); |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1424 |
DrawTrainDepotSprite( 2, 69, DIAGDIR_SW, _cur_railtype); |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1425 |
DrawTrainDepotSprite( 2, 17, DIAGDIR_NW, _cur_railtype); |
0 | 1426 |
break; |
1427 |
} |
|
2639 | 1428 |
|
1429 |
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
|
1430 |
switch (e->we.click.widget) { |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1431 |
case BRDW_DEPOT_NE: |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1432 |
case BRDW_DEPOT_SE: |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1433 |
case BRDW_DEPOT_SW: |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1434 |
case BRDW_DEPOT_NW: |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1435 |
w->RaiseWidget(_build_depot_direction + BRDW_DEPOT_NE); |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1436 |
_build_depot_direction = (DiagDirection)(e->we.click.widget - BRDW_DEPOT_NE); |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1437 |
w->LowerWidget(_build_depot_direction + BRDW_DEPOT_NE); |
2639 | 1438 |
SndPlayFx(SND_15_BEEP); |
1439 |
SetWindowDirty(w); |
|
1440 |
break; |
|
0 | 1441 |
} |
2639 | 1442 |
break; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
1443 |
|
0 | 1444 |
case WE_MOUSELOOP: |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1445 |
if (WP(w, def_d).close) DeleteWindow(w); |
0 | 1446 |
return; |
1072
01bf9fc64236
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1071
diff
changeset
|
1447 |
|
01bf9fc64236
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1071
diff
changeset
|
1448 |
case WE_DESTROY: |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1449 |
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
|
1450 |
break; |
0 | 1451 |
} |
1452 |
} |
|
1453 |
||
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1454 |
/** Widget definition of the build rail depot window */ |
0 | 1455 |
static const Widget _build_depot_widgets[] = { |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1456 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // BRDW_CLOSEBOX |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1457 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 139, 0, 13, STR_1014_TRAIN_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // BRDW_CAPTION |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1458 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 139, 14, 121, 0x0, STR_NULL}, // BRDW_BACKGROUND |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1459 |
{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 17, 66, 0x0, STR_1020_SELECT_RAILROAD_DEPOT_ORIENTATIO}, // BRDW_DEPOT_NE |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1460 |
{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 69, 118, 0x0, STR_1020_SELECT_RAILROAD_DEPOT_ORIENTATIO}, // BRDW_DEPOT_SE |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1461 |
{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 69, 118, 0x0, STR_1020_SELECT_RAILROAD_DEPOT_ORIENTATIO}, // BRDW_DEPOT_SW |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1462 |
{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 17, 66, 0x0, STR_1020_SELECT_RAILROAD_DEPOT_ORIENTATIO}, // BRDW_DEPOT_NW |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
159
diff
changeset
|
1463 |
{ WIDGETS_END}, |
0 | 1464 |
}; |
1465 |
||
1466 |
static const WindowDesc _build_depot_desc = { |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1467 |
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
|
1468 |
WC_BUILD_DEPOT, WC_BUILD_TOOLBAR, |
0 | 1469 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
1470 |
_build_depot_widgets, |
|
1471 |
BuildTrainDepotWndProc |
|
1472 |
}; |
|
1473 |
||
6573 | 1474 |
static void ShowBuildTrainDepotPicker() |
0 | 1475 |
{ |
1476 |
AllocateWindowDesc(&_build_depot_desc); |
|
1477 |
} |
|
1478 |
||
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1479 |
/** Enum referring to the widgets of the build NewGRF rail waypoint window */ |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1480 |
enum BuildRailWaypointWidgets { |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1481 |
BRWW_CLOSEBOX = 0, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1482 |
BRWW_CAPTION, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1483 |
BRWW_BACKGROUND, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1484 |
BRWW_WAYPOINT_1, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1485 |
BRWW_WAYPOINT_2, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1486 |
BRWW_WAYPOINT_3, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1487 |
BRWW_WAYPOINT_4, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1488 |
BRWW_WAYPOINT_5, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1489 |
BRWW_SCROLL, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1490 |
}; |
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1491 |
|
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
|
1492 |
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
|
1493 |
{ |
1738
6c7f9d12197d
(svn r2242) -Fix: [ 1193414 ] Fix for waypoint GUI, scrolling and button-actions (Hackykid)
Darkvater
parents:
1656
diff
changeset
|
1494 |
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
|
1495 |
case WE_PAINT: { |
2639 | 1496 |
uint i; |
1497 |
||
4853
ce3345eb82be
(svn r6779) -Fix r6631: waypoint selector now correctly shows the current selected waypoint type (thx Maedhros)
glx
parents:
4848
diff
changeset
|
1498 |
for (i = 0; i < w->hscroll.cap; i++) { |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1499 |
w->SetWidgetLoweredState(i + BRWW_WAYPOINT_1, (w->hscroll.pos + i) == _cur_waypoint_type); |
4853
ce3345eb82be
(svn r6779) -Fix r6631: waypoint selector now correctly shows the current selected waypoint type (thx Maedhros)
glx
parents:
4848
diff
changeset
|
1500 |
} |
ce3345eb82be
(svn r6779) -Fix r6631: waypoint selector now correctly shows the current selected waypoint type (thx Maedhros)
glx
parents:
4848
diff
changeset
|
1501 |
|
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1502 |
DrawWindowWidgets(w); |
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1503 |
|
4853
ce3345eb82be
(svn r6779) -Fix r6631: waypoint selector now correctly shows the current selected waypoint type (thx Maedhros)
glx
parents:
4848
diff
changeset
|
1504 |
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
|
1505 |
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
|
1506 |
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
|
1507 |
|
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2619
diff
changeset
|
1508 |
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
|
1509 |
|
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
|
1510 |
if (statspec != NULL && |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1511 |
HasBit(statspec->callbackmask, CBM_STATION_AVAIL) && |
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
|
1512 |
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
|
1513 |
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
|
1514 |
} |
2639 | 1515 |
} |
2627
8c964f74bd7b
(svn r3169) Little bit of coding style fixing, and change from value to lengthof()
peter1138
parents:
2625
diff
changeset
|
1516 |
} |
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1517 |
break; |
1738
6c7f9d12197d
(svn r2242) -Fix: [ 1193414 ] Fix for waypoint GUI, scrolling and button-actions (Hackykid)
Darkvater
parents:
1656
diff
changeset
|
1518 |
} |
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1519 |
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
|
1520 |
switch (e->we.click.widget) { |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1521 |
case BRWW_WAYPOINT_1: |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1522 |
case BRWW_WAYPOINT_2: |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1523 |
case BRWW_WAYPOINT_3: |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1524 |
case BRWW_WAYPOINT_4: |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1525 |
case BRWW_WAYPOINT_5: { |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1526 |
byte type = e->we.click.widget - BRWW_WAYPOINT_1 + 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
|
1527 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1528 |
/* Check station availability callback */ |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1529 |
const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, type); |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1530 |
if (statspec != NULL && |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1531 |
HasBit(statspec->callbackmask, CBM_STATION_AVAIL) && |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1532 |
GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE) == 0) return; |
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
|
1533 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1534 |
_cur_waypoint_type = type; |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1535 |
SndPlayFx(SND_15_BEEP); |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1536 |
SetWindowDirty(w); |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1537 |
break; |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1538 |
} |
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
|
1539 |
} |
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1540 |
break; |
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1541 |
} |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
855
diff
changeset
|
1542 |
|
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1543 |
case WE_MOUSELOOP: |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1544 |
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
|
1545 |
break; |
1074
5f45c1b03f2f
(svn r1575) -Fix: Forgot to exit the construction phase for the waypoint window (if
Celestar
parents:
1072
diff
changeset
|
1546 |
|
5f45c1b03f2f
(svn r1575) -Fix: Forgot to exit the construction phase for the waypoint window (if
Celestar
parents:
1072
diff
changeset
|
1547 |
case WE_DESTROY: |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1548 |
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
|
1549 |
break; |
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1550 |
} |
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1551 |
} |
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1552 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1553 |
/** Widget definition for the build NewGRF rail waypoint window */ |
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
|
1554 |
static const Widget _build_waypoint_widgets[] = { |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1555 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // BRWW_CLOSEBOX |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1556 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 343, 0, 13, STR_WAYPOINT, STR_018C_WINDOW_TITLE_DRAG_THIS}, // BRWW_CAPTION |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1557 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 343, 14, 91, 0x0, STR_NULL}, // BRWW_BACKGROUND |
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1558 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1559 |
{ WWT_PANEL, RESIZE_NONE, 7, 3, 68, 17, 76, 0x0, STR_WAYPOINT_GRAPHICS_TIP}, // BRWW_WAYPOINT_1 |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1560 |
{ WWT_PANEL, RESIZE_NONE, 7, 71, 136, 17, 76, 0x0, STR_WAYPOINT_GRAPHICS_TIP}, // BRWW_WAYPOINT_2 |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1561 |
{ WWT_PANEL, RESIZE_NONE, 7, 139, 204, 17, 76, 0x0, STR_WAYPOINT_GRAPHICS_TIP}, // BRWW_WAYPOINT_3 |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1562 |
{ WWT_PANEL, RESIZE_NONE, 7, 207, 272, 17, 76, 0x0, STR_WAYPOINT_GRAPHICS_TIP}, // BRWW_WAYPOINT_4 |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1563 |
{ WWT_PANEL, RESIZE_NONE, 7, 275, 340, 17, 76, 0x0, STR_WAYPOINT_GRAPHICS_TIP}, // BRWW_WAYPOINT_5 |
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1564 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
1565 |
{ WWT_HSCROLLBAR, RESIZE_NONE, 7, 1, 343, 80, 91, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, // BRWW_SCROLL |
417 | 1566 |
{ 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
|
1567 |
}; |
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1568 |
|
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
|
1569 |
static const WindowDesc _build_waypoint_desc = { |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1570 |
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
|
1571 |
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
|
1572 |
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
|
1573 |
_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
|
1574 |
BuildWaypointWndProc |
393
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1575 |
}; |
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1576 |
|
6573 | 1577 |
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
|
1578 |
{ |
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
|
1579 |
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
|
1580 |
w->hscroll.cap = 5; |
2625
66b3d632dcd2
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2619
diff
changeset
|
1581 |
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
|
1582 |
} |
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1583 |
|
82c2bf635cd9
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
1584 |
|
6573 | 1585 |
void InitializeRailGui() |
0 | 1586 |
{ |
3157
40de8616c04c
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3132
diff
changeset
|
1587 |
_build_depot_direction = DIAGDIR_NW; |
0 | 1588 |
_railstation.numtracks = 1; |
1589 |
_railstation.platlength = 1; |
|
1590 |
_railstation.dragdrop = true; |
|
1591 |
} |
|
5116
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5105
diff
changeset
|
1592 |
|
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5105
diff
changeset
|
1593 |
void ReinitGuiAfterToggleElrail(bool disable) |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5105
diff
changeset
|
1594 |
{ |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5105
diff
changeset
|
1595 |
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
|
1596 |
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
|
1597 |
Window *w; |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5105
diff
changeset
|
1598 |
_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
|
1599 |
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
|
1600 |
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
|
1601 |
SetupRailToolbar(_cur_railtype, w); |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5105
diff
changeset
|
1602 |
SetWindowDirty(w); |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5105
diff
changeset
|
1603 |
} |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5105
diff
changeset
|
1604 |
} |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5105
diff
changeset
|
1605 |
MarkWholeScreenDirty(); |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5105
diff
changeset
|
1606 |
} |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5105
diff
changeset
|
1607 |
|
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1608 |
static void SetDefaultRailGui() |
9629 | 1609 |
{ |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
1610 |
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
|
1611 |
|
9629 | 1612 |
extern RailType _last_built_railtype; |
1613 |
RailType rt = (RailType)_patches.default_rail_type; |
|
1614 |
if (rt >= RAILTYPE_END) { |
|
1615 |
if (rt == RAILTYPE_END + 2) { |
|
1616 |
/* Find the most used rail type */ |
|
1617 |
RailType count[RAILTYPE_END]; |
|
1618 |
memset(count, 0, sizeof(count)); |
|
1619 |
for (TileIndex t = 0; t < MapSize(); t++) { |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1620 |
if (IsTileType(t, MP_RAILWAY) || IsLevelCrossingTile(t) || IsRailwayStationTile(t) || |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1621 |
(IsTileType(t, MP_TUNNELBRIDGE) && GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL)) { |
9629 | 1622 |
count[GetRailType(t)]++; |
1623 |
} |
|
1624 |
} |
|
1625 |
||
1626 |
rt = RAILTYPE_RAIL; |
|
1627 |
for (RailType r = RAILTYPE_ELECTRIC; r < RAILTYPE_END; r++) { |
|
1628 |
if (count[r] >= count[rt]) rt = r; |
|
1629 |
} |
|
1630 |
||
1631 |
/* No rail, just get the first available one */ |
|
1632 |
if (count[rt] == 0) rt = RAILTYPE_END; |
|
1633 |
} |
|
1634 |
switch (rt) { |
|
1635 |
case RAILTYPE_END + 0: |
|
1636 |
rt = RAILTYPE_RAIL; |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1637 |
while (rt < RAILTYPE_END && !HasRailtypeAvail(_local_player, rt)) rt++; |
9629 | 1638 |
break; |
1639 |
||
1640 |
case RAILTYPE_END + 1: |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1641 |
rt = GetBestRailtype(_local_player); |
9629 | 1642 |
break; |
1643 |
||
1644 |
default: |
|
1645 |
break; |
|
1646 |
} |
|
1647 |
} |
|
1648 |
||
1649 |
_last_built_railtype = _cur_railtype = rt; |
|
1650 |
Window *w = FindWindowById(WC_BUILD_TOOLBAR, 0); |
|
1651 |
if (w != NULL && w->wndproc == BuildRailToolbWndProc) { |
|
1652 |
SetupRailToolbar(_cur_railtype, w); |
|
1653 |
SetWindowDirty(w); |
|
1654 |
} |
|
1655 |
} |
|
1656 |
||
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1657 |
/** |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1658 |
* Updates the current signal variant used in the signal GUI |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1659 |
* to the one adequate to current year. |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1660 |
* @param 0 needed to be called when a patch setting changes |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1661 |
* @return success, needed for patch settings |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1662 |
*/ |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1663 |
int32 ResetSignalVariant(int32 = 0) |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1664 |
{ |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1665 |
SignalVariant new_variant = (_cur_year < _patches.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC); |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1666 |
|
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1667 |
if (new_variant != _cur_signal_variant) { |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1668 |
Window *w = FindWindowById(WC_BUILD_SIGNAL, 0); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1669 |
if (w != NULL) { |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1670 |
SetWindowDirty(w); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1671 |
w->RaiseWidget((_cur_signal_variant == SIG_ELECTRIC ? BSW_ELECTRIC_NORM : BSW_SEMAPHORE_NORM) + _cur_signal_type); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1672 |
} |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1673 |
_cur_signal_variant = new_variant; |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1674 |
} |
9732 | 1675 |
|
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1676 |
return 0; |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1677 |
} |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1678 |
|
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1679 |
/** Resets the rail GUI - sets default railtype to build |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1680 |
* and resets the signal GUI |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1681 |
*/ |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1682 |
void InitializeRailGUI() |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1683 |
{ |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1684 |
SetDefaultRailGui(); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1685 |
|
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1686 |
_convert_signal_button = false; |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1687 |
_cur_signal_type = SIGTYPE_NORMAL; |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1688 |
ResetSignalVariant(); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1689 |
} |