annotate src/rail_gui.cpp @ 14396:4de60292e2a6 draft

(svn r18953) -Feature: [NoAI] allow editing AI settings while an AI is running Only settings with the AICONFIG_INGAME flag can be editted in this way
author yexo <yexo@openttd.org>
date Fri, 29 Jan 2010 21:38:55 +0000
parents a899d4e5ee1a
children 1eaefde497fd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1 /* $Id$ */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2
12778
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12632
diff changeset
3 /*
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12632
diff changeset
4 * This file is part of OpenTTD.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12632
diff changeset
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12632
diff changeset
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12632
diff changeset
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12632
diff changeset
8 */
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12632
diff changeset
9
6117
6def6ecb1bf7 (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 <belugas@openttd.org>
parents: 6106
diff changeset
10 /** @file rail_gui.cpp File for dealing with rail construction user interface */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
11
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
12 #include "stdafx.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
13 #include "gui.h"
8107
f65cf2bc3255 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium <rubidium@openttd.org>
parents: 8106
diff changeset
14 #include "window_gui.h"
f65cf2bc3255 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium <rubidium@openttd.org>
parents: 8106
diff changeset
15 #include "station_gui.h"
8205
0d3299690c51 (svn r11768) -Codechange: move some terraform related gui stuff from main_gui.cpp to terraform_gui.cpp (and introduce terraform_gui.h). Based on a patch by Roujin.
rubidium <rubidium@openttd.org>
parents: 8157
diff changeset
16 #include "terraform_gui.h"
8224
c45446125bf0 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents: 8205
diff changeset
17 #include "viewport_func.h"
8116
9cc845deddfe (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium <rubidium@openttd.org>
parents: 8114
diff changeset
18 #include "command_func.h"
12475
c133b51890f4 (svn r16912) -Codechange: split waypoint.h in waypoint_base.h and waypoint_func.h
rubidium <rubidium@openttd.org>
parents: 12469
diff changeset
19 #include "waypoint_func.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
20 #include "newgrf_station.h"
10960
a4e5b5d2837c (svn r15299) -Cleanup: remove many redundant includes
smatz <smatz@openttd.org>
parents: 10738
diff changeset
21 #include "company_base.h"
8114
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents: 8108
diff changeset
22 #include "strings_func.h"
8131
e300ac8001ae (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium <rubidium@openttd.org>
parents: 8128
diff changeset
23 #include "functions.h"
e300ac8001ae (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium <rubidium@openttd.org>
parents: 8128
diff changeset
24 #include "window_func.h"
8140
fb8a05d579da (svn r11702) -Codechange: move all date related stuff to date*.
rubidium <rubidium@openttd.org>
parents: 8139
diff changeset
25 #include "date_func.h"
8157
019833e42fda (svn r11719) -Codechange: split sound.h in a header with types and one with functions.
rubidium <rubidium@openttd.org>
parents: 8144
diff changeset
26 #include "sound_func.h"
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents: 10207
diff changeset
27 #include "company_func.h"
8295
9b35e1d5ebed (svn r11859) -Codechange: Update newgrf station class dropdown to use new method of generating list.
peter1138 <peter1138@openttd.org>
parents: 8284
diff changeset
28 #include "widgets/dropdown_type.h"
8973
f8dda7737158 (svn r12765) -Codechange: move some stuff out of variables.h that required including other headers in variables.h.
rubidium <rubidium@openttd.org>
parents: 8846
diff changeset
29 #include "tunnelbridge.h"
9127
428852b86d4d (svn r12987) -Codechange: split viewport and tile selection.
rubidium <rubidium@openttd.org>
parents: 9116
diff changeset
30 #include "tilehighlight_func.h"
13152
19482cfa7559 (svn r17657) -Fix [FS#3242]: some semaphore signals fell outside of the signal GUI. Now the signals are properly centered which should make that problem go away
rubidium <rubidium@openttd.org>
parents: 13079
diff changeset
31 #include "spritecache.h"
14258
a899d4e5ee1a (svn r18809) -Codechange/Cleanup: remove unneeded headers from some files, if a header require a header make it include that header
rubidium <rubidium@openttd.org>
parents: 14230
diff changeset
32 #include "core/geometry_func.hpp"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
33
7064
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
34 #include "station_map.h"
8083
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents: 8032
diff changeset
35 #include "tunnelbridge_map.h"
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents: 8032
diff changeset
36
8264
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8254
diff changeset
37 #include "table/sprites.h"
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8254
diff changeset
38 #include "table/strings.h"
7064
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
39
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
40 static RailType _cur_railtype; ///< Rail type of the current build-rail toolbar.
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
41 static bool _remove_button_clicked; ///< Flag whether 'remove' toggle-button is currently enabled
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
42 static DiagDirection _build_depot_direction; ///< Currently selected depot direction
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
43 static byte _waypoint_count = 1; ///< Number of waypoint types
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
44 static byte _cur_waypoint_type; ///< Currently selected waypoint type
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
45 static bool _convert_signal_button; ///< convert signal button in the signal GUI pressed
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
46 static SignalVariant _cur_signal_variant; ///< set the signal variant (for signal GUI)
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
47 static SignalType _cur_signal_type; ///< set the signal type (for signal GUI)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
48
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10998
diff changeset
49 /* Map the setting: default_signal_type to the corresponding signal type */
9793
7a1f095154a8 (svn r13935) -Codechange [YAPP]: PBS signals can now be built with the normal signal tools. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9772
diff changeset
50 static const SignalType _default_signal_type[] = {SIGTYPE_NORMAL, SIGTYPE_PBS, SIGTYPE_PBS_ONEWAY};
7a1f095154a8 (svn r13935) -Codechange [YAPP]: PBS signals can now be built with the normal signal tools. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9772
diff changeset
51
9772
9d8bf03ff7fa (svn r13909) -Codechange: use the same type before CmdBuildRailStation as it used in the command itself (Alberth)
rubidium <rubidium@openttd.org>
parents: 9771
diff changeset
52 struct RailStationGUISettings {
9d8bf03ff7fa (svn r13909) -Codechange: use the same type before CmdBuildRailStation as it used in the command itself (Alberth)
rubidium <rubidium@openttd.org>
parents: 9771
diff changeset
53 Axis orientation; ///< Currently selected rail station orientation
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
54
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
55 bool newstations; ///< Are custom station definitions available?
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
56 StationClassIDByte station_class; ///< Currently selected custom station class (if newstations is \c true )
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
57 byte station_type; ///< Station type within the currently selected custom station class (if newstations is \c true )
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
58 byte station_count; ///< Number of custom stations (if newstations is \c true )
9772
9d8bf03ff7fa (svn r13909) -Codechange: use the same type before CmdBuildRailStation as it used in the command itself (Alberth)
rubidium <rubidium@openttd.org>
parents: 9771
diff changeset
59 };
9d8bf03ff7fa (svn r13909) -Codechange: use the same type before CmdBuildRailStation as it used in the command itself (Alberth)
rubidium <rubidium@openttd.org>
parents: 9771
diff changeset
60 static RailStationGUISettings _railstation; ///< Settings of the station builder GUI
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
61
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
62
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
63 static void HandleStationPlacement(TileIndex start, TileIndex end);
9338
9f0982110dda (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch <frosch@openttd.org>
parents: 9317
diff changeset
64 static void ShowBuildTrainDepotPicker(Window *parent);
9f0982110dda (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch <frosch@openttd.org>
parents: 9317
diff changeset
65 static void ShowBuildWaypointPicker(Window *parent);
9f0982110dda (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch <frosch@openttd.org>
parents: 9317
diff changeset
66 static void ShowStationBuilder(Window *parent);
9f0982110dda (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch <frosch@openttd.org>
parents: 9317
diff changeset
67 static void ShowSignalBuilder(Window *parent);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
68
14230
95250f9a5035 (svn r18781) -Codechange: pass the CommandCost to the callback instead of whether it succeeded or not.
rubidium <rubidium@openttd.org>
parents: 13986
diff changeset
69 void CcPlaySound1E(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
70 {
14230
95250f9a5035 (svn r18781) -Codechange: pass the CommandCost to the callback instead of whether it succeeded or not.
rubidium <rubidium@openttd.org>
parents: 13986
diff changeset
71 if (result.Succeeded()) SndPlayTileFx(SND_20_SPLAT_2, tile);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
72 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
73
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
74 static void GenericPlaceRail(TileIndex tile, int cmd)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
75 {
10499
45ca88a8de7d (svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents: 10208
diff changeset
76 DoCommandP(tile, _cur_railtype, cmd,
8586
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
77 _remove_button_clicked ?
11730
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11709
diff changeset
78 CMD_REMOVE_SINGLE_RAIL | CMD_MSG(STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK) :
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11709
diff changeset
79 CMD_BUILD_SINGLE_RAIL | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK),
10499
45ca88a8de7d (svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents: 10208
diff changeset
80 CcPlaySound1E
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
81 );
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
82 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
83
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
84 static void PlaceRail_N(TileIndex tile)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
85 {
11709
886f2a4f8cba (svn r16095) -Change/Feature-ish: make the first 4 rail building tools behave more like autorail
rubidium <rubidium@openttd.org>
parents: 11702
diff changeset
86 VpStartPlaceSizing(tile, VPM_FIX_VERTICAL | VPM_RAILDIRS, DDSP_PLACE_RAIL);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
87 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
88
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
89 static void PlaceRail_NE(TileIndex tile)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
90 {
11709
886f2a4f8cba (svn r16095) -Change/Feature-ish: make the first 4 rail building tools behave more like autorail
rubidium <rubidium@openttd.org>
parents: 11702
diff changeset
91 VpStartPlaceSizing(tile, VPM_FIX_Y | VPM_RAILDIRS, DDSP_PLACE_RAIL);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
92 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
93
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
94 static void PlaceRail_E(TileIndex tile)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
95 {
11709
886f2a4f8cba (svn r16095) -Change/Feature-ish: make the first 4 rail building tools behave more like autorail
rubidium <rubidium@openttd.org>
parents: 11702
diff changeset
96 VpStartPlaceSizing(tile, VPM_FIX_HORIZONTAL | VPM_RAILDIRS, DDSP_PLACE_RAIL);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
97 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
98
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
99 static void PlaceRail_NW(TileIndex tile)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
100 {
11709
886f2a4f8cba (svn r16095) -Change/Feature-ish: make the first 4 rail building tools behave more like autorail
rubidium <rubidium@openttd.org>
parents: 11702
diff changeset
101 VpStartPlaceSizing(tile, VPM_FIX_X | VPM_RAILDIRS, DDSP_PLACE_RAIL);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
102 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
103
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
104 static void PlaceRail_AutoRail(TileIndex tile)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
105 {
11709
886f2a4f8cba (svn r16095) -Change/Feature-ish: make the first 4 rail building tools behave more like autorail
rubidium <rubidium@openttd.org>
parents: 11702
diff changeset
106 VpStartPlaceSizing(tile, VPM_RAILDIRS, DDSP_PLACE_RAIL);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
107 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
108
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
109 /**
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
110 * Try to add an additional rail-track at the entrance of a depot
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
111 * @param tile Tile to use for adding the rail-track
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
112 * @param extra Track to add
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
113 * @see CcRailDepot()
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
114 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
115 static void PlaceExtraDepotRail(TileIndex tile, uint16 extra)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
116 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
117 if (GetRailTileType(tile) != RAIL_TILE_NORMAL) return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
118 if ((GetTrackBits(tile) & GB(extra, 8, 8)) == 0) return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
119
10606
4b69f32abb9d (svn r14895) -Change: move CMD_NO_WATER from all DoCommandPs to the command table
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
120 DoCommandP(tile, _cur_railtype, extra & 0xFF, CMD_BUILD_SINGLE_RAIL);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
121 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
122
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
123 /** Additional pieces of track to add at the entrance of a depot. */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
124 static const uint16 _place_depot_extra[12] = {
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
125 0x0604, 0x2102, 0x1202, 0x0505, // First additional track for directions 0..3
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
126 0x2400, 0x2801, 0x1800, 0x1401, // Second additional track
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
127 0x2203, 0x0904, 0x0A05, 0x1103, // Third additional track
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
128 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
129
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
130
14230
95250f9a5035 (svn r18781) -Codechange: pass the CommandCost to the callback instead of whether it succeeded or not.
rubidium <rubidium@openttd.org>
parents: 13986
diff changeset
131 void CcRailDepot(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
132 {
14230
95250f9a5035 (svn r18781) -Codechange: pass the CommandCost to the callback instead of whether it succeeded or not.
rubidium <rubidium@openttd.org>
parents: 13986
diff changeset
133 if (result.Failed()) return;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
134
14230
95250f9a5035 (svn r18781) -Codechange: pass the CommandCost to the callback instead of whether it succeeded or not.
rubidium <rubidium@openttd.org>
parents: 13986
diff changeset
135 DiagDirection dir = (DiagDirection)p2;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
136
14230
95250f9a5035 (svn r18781) -Codechange: pass the CommandCost to the callback instead of whether it succeeded or not.
rubidium <rubidium@openttd.org>
parents: 13986
diff changeset
137 SndPlayTileFx(SND_20_SPLAT_2, tile);
95250f9a5035 (svn r18781) -Codechange: pass the CommandCost to the callback instead of whether it succeeded or not.
rubidium <rubidium@openttd.org>
parents: 13986
diff changeset
138 if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
95250f9a5035 (svn r18781) -Codechange: pass the CommandCost to the callback instead of whether it succeeded or not.
rubidium <rubidium@openttd.org>
parents: 13986
diff changeset
139
95250f9a5035 (svn r18781) -Codechange: pass the CommandCost to the callback instead of whether it succeeded or not.
rubidium <rubidium@openttd.org>
parents: 13986
diff changeset
140 tile += TileOffsByDiagDir(dir);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
141
14230
95250f9a5035 (svn r18781) -Codechange: pass the CommandCost to the callback instead of whether it succeeded or not.
rubidium <rubidium@openttd.org>
parents: 13986
diff changeset
142 if (IsTileType(tile, MP_RAILWAY)) {
95250f9a5035 (svn r18781) -Codechange: pass the CommandCost to the callback instead of whether it succeeded or not.
rubidium <rubidium@openttd.org>
parents: 13986
diff changeset
143 PlaceExtraDepotRail(tile, _place_depot_extra[dir]);
95250f9a5035 (svn r18781) -Codechange: pass the CommandCost to the callback instead of whether it succeeded or not.
rubidium <rubidium@openttd.org>
parents: 13986
diff changeset
144 PlaceExtraDepotRail(tile, _place_depot_extra[dir + 4]);
95250f9a5035 (svn r18781) -Codechange: pass the CommandCost to the callback instead of whether it succeeded or not.
rubidium <rubidium@openttd.org>
parents: 13986
diff changeset
145 PlaceExtraDepotRail(tile, _place_depot_extra[dir + 8]);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
146 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
147 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
148
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
149 static void PlaceRail_Depot(TileIndex tile)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
150 {
10499
45ca88a8de7d (svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents: 10208
diff changeset
151 DoCommandP(tile, _cur_railtype, _build_depot_direction,
11730
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11709
diff changeset
152 CMD_BUILD_TRAIN_DEPOT | CMD_MSG(STR_ERROR_CAN_T_BUILD_TRAIN_DEPOT),
10499
45ca88a8de7d (svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents: 10208
diff changeset
153 CcRailDepot);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
154 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
155
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
156 static void PlaceRail_Waypoint(TileIndex tile)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
157 {
8587
5475f6785dcf (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz <smatz@openttd.org>
parents: 8586
diff changeset
158 if (_remove_button_clicked) {
12553
8d5c10ef911d (svn r16991) -Change: make 'remove waypoint' draggable
rubidium <rubidium@openttd.org>
parents: 12552
diff changeset
159 VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_REMOVE_STATION);
12555
e814b879d2e1 (svn r16993) -Change: make the rail waypoint builder draggable
rubidium <rubidium@openttd.org>
parents: 12553
diff changeset
160 return;
e814b879d2e1 (svn r16993) -Change: make the rail waypoint builder draggable
rubidium <rubidium@openttd.org>
parents: 12553
diff changeset
161 }
e814b879d2e1 (svn r16993) -Change: make the rail waypoint builder draggable
rubidium <rubidium@openttd.org>
parents: 12553
diff changeset
162
12562
e6b8a343eb13 (svn r17000) -Change: allow overbuilding/extending waypoints
rubidium <rubidium@openttd.org>
parents: 12555
diff changeset
163 Axis axis = GetAxisForNewWaypoint(tile);
e6b8a343eb13 (svn r17000) -Change: allow overbuilding/extending waypoints
rubidium <rubidium@openttd.org>
parents: 12555
diff changeset
164 if (IsValidAxis(axis)) {
12555
e814b879d2e1 (svn r16993) -Change: make the rail waypoint builder draggable
rubidium <rubidium@openttd.org>
parents: 12553
diff changeset
165 /* Valid tile for waypoints */
12562
e6b8a343eb13 (svn r17000) -Change: allow overbuilding/extending waypoints
rubidium <rubidium@openttd.org>
parents: 12555
diff changeset
166 VpStartPlaceSizing(tile, axis == AXIS_X ? VPM_FIX_X : VPM_FIX_Y, DDSP_BUILD_STATION);
7949
f24a967a1eb9 (svn r11505) -Fix/Feature: make CTRL work on all road/rail construction options that 'work' with the 'Bulldozer' button instead of only a few.
rubidium <rubidium@openttd.org>
parents: 7928
diff changeset
167 } else {
12555
e814b879d2e1 (svn r16993) -Change: make the rail waypoint builder draggable
rubidium <rubidium@openttd.org>
parents: 12553
diff changeset
168 /* Tile where we can't build rail waypoints. This is always going to fail,
e814b879d2e1 (svn r16993) -Change: make the rail waypoint builder draggable
rubidium <rubidium@openttd.org>
parents: 12553
diff changeset
169 * but provides the user with a proper error message. */
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12619
diff changeset
170 DoCommandP(tile, 1 << 8 | 1 << 16, STAT_CLASS_WAYP | INVALID_STATION << 16, CMD_BUILD_RAIL_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_BUILD_TRAIN_WAYPOINT));
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
171 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
172 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
173
14230
95250f9a5035 (svn r18781) -Codechange: pass the CommandCost to the callback instead of whether it succeeded or not.
rubidium <rubidium@openttd.org>
parents: 13986
diff changeset
174 void CcStation(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
175 {
14230
95250f9a5035 (svn r18781) -Codechange: pass the CommandCost to the callback instead of whether it succeeded or not.
rubidium <rubidium@openttd.org>
parents: 13986
diff changeset
176 if (result.Failed()) return;
95250f9a5035 (svn r18781) -Codechange: pass the CommandCost to the callback instead of whether it succeeded or not.
rubidium <rubidium@openttd.org>
parents: 13986
diff changeset
177
95250f9a5035 (svn r18781) -Codechange: pass the CommandCost to the callback instead of whether it succeeded or not.
rubidium <rubidium@openttd.org>
parents: 13986
diff changeset
178 SndPlayTileFx(SND_20_SPLAT_2, tile);
95250f9a5035 (svn r18781) -Codechange: pass the CommandCost to the callback instead of whether it succeeded or not.
rubidium <rubidium@openttd.org>
parents: 13986
diff changeset
179 /* Only close the station builder window if the default station and non persistent building is chosen. */
95250f9a5035 (svn r18781) -Codechange: pass the CommandCost to the callback instead of whether it succeeded or not.
rubidium <rubidium@openttd.org>
parents: 13986
diff changeset
180 if (_railstation.station_class == STAT_CLASS_DFLT && _railstation.station_type == 0 && !_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
181 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
182
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
183 static void PlaceRail_Station(TileIndex tile)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
184 {
7955
c08de05b67c2 (svn r11511) -Revert parts of r11505: forgot that CTRL might be used for other features, like adjacent stations or signals.
rubidium <rubidium@openttd.org>
parents: 7949
diff changeset
185 if (_remove_button_clicked) {
12562
e6b8a343eb13 (svn r17000) -Change: allow overbuilding/extending waypoints
rubidium <rubidium@openttd.org>
parents: 12555
diff changeset
186 VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_REMOVE_STATION);
e6b8a343eb13 (svn r17000) -Change: allow overbuilding/extending waypoints
rubidium <rubidium@openttd.org>
parents: 12555
diff changeset
187 VpSetPlaceSizingLimit(-1);
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
188 } else if (_settings_client.gui.station_dragdrop) {
6670
5ff577cb6c43 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros <maedhros@openttd.org>
parents: 6669
diff changeset
189 VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_BUILD_STATION);
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
190 VpSetPlaceSizingLimit(_settings_game.station.station_spread);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
191 } else {
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10611
diff changeset
192 uint32 p1 = _cur_railtype | _railstation.orientation << 4 | _settings_client.gui.station_numtracks << 8 | _settings_client.gui.station_platlength << 16 | _ctrl_pressed << 24;
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10611
diff changeset
193 uint32 p2 = _railstation.station_class | _railstation.station_type << 8 | INVALID_STATION << 16;
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10611
diff changeset
194
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10611
diff changeset
195 int w = _settings_client.gui.station_numtracks;
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10611
diff changeset
196 int h = _settings_client.gui.station_platlength;
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10611
diff changeset
197 if (!_railstation.orientation) Swap(w, h);
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10611
diff changeset
198
12552
92b34b5e5b00 (svn r16990) -Codechange: unify some (command) naming w.r.t. stations/waypoints.
rubidium <rubidium@openttd.org>
parents: 12528
diff changeset
199 CommandContainer cmdcont = { tile, p1, p2, CMD_BUILD_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION), CcStation, "" };
12528
a8b8bcd7f03d (svn r16965) -Codechange: use tile area instead of sets of variables for the station joiner code.
rubidium <rubidium@openttd.org>
parents: 12516
diff changeset
200 ShowSelectStationIfNeeded(cmdcont, TileArea(tile, w, h));
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
201 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
202 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
203
7991
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
204 /**
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
205 * Build a new signal or edit/remove a present signal, use CmdBuildSingleSignal() or CmdRemoveSingleSignal() in rail_cmd.cpp
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
206 *
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
207 * @param tile The tile where the signal will build or edit
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
208 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
209 static void GenericPlaceSignals(TileIndex tile)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
210 {
8616
9e46ac001a8c (svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch <frosch@openttd.org>
parents: 8587
diff changeset
211 TrackBits trackbits = TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_RAIL, 0));
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
212
6846
a5bd2c7b1159 (svn r10086) -Codechange: Use more sensible types and functions in GenericPlaceSignals.
maedhros <maedhros@openttd.org>
parents: 6683
diff changeset
213 if (trackbits & TRACK_BIT_VERT) { // N-S direction
a5bd2c7b1159 (svn r10086) -Codechange: Use more sensible types and functions in GenericPlaceSignals.
maedhros <maedhros@openttd.org>
parents: 6683
diff changeset
214 trackbits = (_tile_fract_coords.x <= _tile_fract_coords.y) ? TRACK_BIT_RIGHT : TRACK_BIT_LEFT;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
215 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
216
6846
a5bd2c7b1159 (svn r10086) -Codechange: Use more sensible types and functions in GenericPlaceSignals.
maedhros <maedhros@openttd.org>
parents: 6683
diff changeset
217 if (trackbits & TRACK_BIT_HORZ) { // E-W direction
a5bd2c7b1159 (svn r10086) -Codechange: Use more sensible types and functions in GenericPlaceSignals.
maedhros <maedhros@openttd.org>
parents: 6683
diff changeset
218 trackbits = (_tile_fract_coords.x + _tile_fract_coords.y <= 15) ? TRACK_BIT_UPPER : TRACK_BIT_LOWER;
a5bd2c7b1159 (svn r10086) -Codechange: Use more sensible types and functions in GenericPlaceSignals.
maedhros <maedhros@openttd.org>
parents: 6683
diff changeset
219 }
a5bd2c7b1159 (svn r10086) -Codechange: Use more sensible types and functions in GenericPlaceSignals.
maedhros <maedhros@openttd.org>
parents: 6683
diff changeset
220
6863
e41ca23029ed (svn r10103) -Fix (r10086): TrackBitsToTrack doesn't cope well with TRACK_BIT_NONE (e.g. non-rail tiles), so use FindFirstTrack instead.
maedhros <maedhros@openttd.org>
parents: 6846
diff changeset
221 Track track = FindFirstTrack(trackbits);
6846
a5bd2c7b1159 (svn r10086) -Codechange: Use more sensible types and functions in GenericPlaceSignals.
maedhros <maedhros@openttd.org>
parents: 6683
diff changeset
222
7955
c08de05b67c2 (svn r11511) -Revert parts of r11505: forgot that CTRL might be used for other features, like adjacent stations or signals.
rubidium <rubidium@openttd.org>
parents: 7949
diff changeset
223 if (_remove_button_clicked) {
11730
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11709
diff changeset
224 DoCommandP(tile, track, 0, CMD_REMOVE_SIGNALS | CMD_MSG(STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM), CcPlaySound1E);
7949
f24a967a1eb9 (svn r11505) -Fix/Feature: make CTRL work on all road/rail construction options that 'work' with the 'Bulldozer' button instead of only a few.
rubidium <rubidium@openttd.org>
parents: 7928
diff changeset
225 } else {
8808
2d40645f197f (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz <smatz@openttd.org>
parents: 8785
diff changeset
226 const Window *w = FindWindowById(WC_BUILD_SIGNAL, 0);
7991
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
227
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10998
diff changeset
228 /* Map the setting cycle_signal_types to the lower and upper allowed signal type. */
9793
7a1f095154a8 (svn r13935) -Codechange [YAPP]: PBS signals can now be built with the normal signal tools. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9772
diff changeset
229 static const uint cycle_bounds[] = {SIGTYPE_NORMAL | (SIGTYPE_LAST_NOPBS << 3), SIGTYPE_PBS | (SIGTYPE_LAST << 3), SIGTYPE_NORMAL | (SIGTYPE_LAST << 3)};
7a1f095154a8 (svn r13935) -Codechange [YAPP]: PBS signals can now be built with the normal signal tools. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9772
diff changeset
230
7991
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
231 /* various bitstuffed elements for CmdBuildSingleSignal() */
6846
a5bd2c7b1159 (svn r10086) -Codechange: Use more sensible types and functions in GenericPlaceSignals.
maedhros <maedhros@openttd.org>
parents: 6683
diff changeset
232 uint32 p1 = track;
8808
2d40645f197f (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz <smatz@openttd.org>
parents: 8785
diff changeset
233
2d40645f197f (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz <smatz@openttd.org>
parents: 8785
diff changeset
234 if (w != NULL) {
2d40645f197f (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz <smatz@openttd.org>
parents: 8785
diff changeset
235 /* signal GUI is used */
2d40645f197f (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz <smatz@openttd.org>
parents: 8785
diff changeset
236 SB(p1, 3, 1, _ctrl_pressed);
2d40645f197f (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz <smatz@openttd.org>
parents: 8785
diff changeset
237 SB(p1, 4, 1, _cur_signal_variant);
9793
7a1f095154a8 (svn r13935) -Codechange [YAPP]: PBS signals can now be built with the normal signal tools. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9772
diff changeset
238 SB(p1, 5, 3, _cur_signal_type);
7a1f095154a8 (svn r13935) -Codechange [YAPP]: PBS signals can now be built with the normal signal tools. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9772
diff changeset
239 SB(p1, 8, 1, _convert_signal_button);
7a1f095154a8 (svn r13935) -Codechange [YAPP]: PBS signals can now be built with the normal signal tools. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9772
diff changeset
240 SB(p1, 9, 6, cycle_bounds[_settings_client.gui.cycle_signal_types]);
8808
2d40645f197f (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz <smatz@openttd.org>
parents: 8785
diff changeset
241 } else {
2d40645f197f (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz <smatz@openttd.org>
parents: 8785
diff changeset
242 SB(p1, 3, 1, _ctrl_pressed);
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
243 SB(p1, 4, 1, (_cur_year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC));
9793
7a1f095154a8 (svn r13935) -Codechange [YAPP]: PBS signals can now be built with the normal signal tools. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9772
diff changeset
244 SB(p1, 5, 3, _default_signal_type[_settings_client.gui.default_signal_type]);
7a1f095154a8 (svn r13935) -Codechange [YAPP]: PBS signals can now be built with the normal signal tools. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9772
diff changeset
245 SB(p1, 8, 1, 0);
7a1f095154a8 (svn r13935) -Codechange [YAPP]: PBS signals can now be built with the normal signal tools. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9772
diff changeset
246 SB(p1, 9, 6, cycle_bounds[_settings_client.gui.cycle_signal_types]);
8808
2d40645f197f (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz <smatz@openttd.org>
parents: 8785
diff changeset
247 }
5731
1842c1520d72 (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 <Darkvater@openttd.org>
parents: 5696
diff changeset
248
10499
45ca88a8de7d (svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents: 10208
diff changeset
249 DoCommandP(tile, p1, 0, CMD_BUILD_SIGNALS |
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12619
diff changeset
250 CMD_MSG((w != NULL && _convert_signal_button) ? STR_ERROR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE : STR_ERROR_CAN_T_BUILD_SIGNALS_HERE),
10499
45ca88a8de7d (svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents: 10208
diff changeset
251 CcPlaySound1E);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
252 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
253 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
254
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
255 static void PlaceRail_Bridge(TileIndex tile)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
256 {
6670
5ff577cb6c43 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros <maedhros@openttd.org>
parents: 6669
diff changeset
257 VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_BUILD_BRIDGE);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
258 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
259
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
260 /** Command callback for building a tunnel */
14230
95250f9a5035 (svn r18781) -Codechange: pass the CommandCost to the callback instead of whether it succeeded or not.
rubidium <rubidium@openttd.org>
parents: 13986
diff changeset
261 void CcBuildRailTunnel(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
262 {
14230
95250f9a5035 (svn r18781) -Codechange: pass the CommandCost to the callback instead of whether it succeeded or not.
rubidium <rubidium@openttd.org>
parents: 13986
diff changeset
263 if (result.Succeeded()) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
264 SndPlayTileFx(SND_20_SPLAT_2, tile);
10611
979ddadfaabf (svn r14902) -Feature: Advanced setting to keep various building tools active, which are usually closed after placing an object. (planetmaker)
frosch <frosch@openttd.org>
parents: 10606
diff changeset
265 if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
266 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
267 SetRedErrorSquare(_build_tunnel_endtile);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
268 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
269 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
270
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
271 static void PlaceRail_Tunnel(TileIndex tile)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
272 {
11730
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11709
diff changeset
273 DoCommandP(tile, _cur_railtype, 0, CMD_BUILD_TUNNEL | CMD_MSG(STR_ERROR_CAN_T_BUILD_TUNNEL_HERE), CcBuildRailTunnel);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
274 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
275
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
276 static void PlaceRail_ConvertRail(TileIndex tile)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
277 {
6670
5ff577cb6c43 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros <maedhros@openttd.org>
parents: 6669
diff changeset
278 VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CONVERT_RAIL);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
279 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
280
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
281 static void PlaceRail_AutoSignals(TileIndex tile)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
282 {
6670
5ff577cb6c43 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros <maedhros@openttd.org>
parents: 6669
diff changeset
283 VpStartPlaceSizing(tile, VPM_SIGNALDIRS, DDSP_BUILD_SIGNALS);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
284 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
285
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
286
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
287 /** Enum referring to the widgets of the build rail toolbar */
7729
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
288 enum RailToolbarWidgets {
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
289 RTW_CAPTION,
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
290 RTW_BUILD_NS,
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
291 RTW_BUILD_X,
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
292 RTW_BUILD_EW,
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
293 RTW_BUILD_Y,
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
294 RTW_AUTORAIL,
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
295 RTW_DEMOLISH,
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
296 RTW_BUILD_DEPOT,
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
297 RTW_BUILD_WAYPOINT,
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
298 RTW_BUILD_STATION,
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
299 RTW_BUILD_SIGNALS,
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
300 RTW_BUILD_BRIDGE,
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
301 RTW_BUILD_TUNNEL,
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
302 RTW_REMOVE,
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
303 RTW_CONVERT_RAIL,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
304 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
305
8586
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
306
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
307 /** Toggles state of the Remove button of Build rail toolbar
8586
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
308 * @param w window the button belongs to
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
309 */
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
310 static void ToggleRailButton_Remove(Window *w)
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
311 {
11074
b1484309e4ec (svn r15415) -Change: close the (station) joiner window when pressing the bulldozer.
rubidium <rubidium@openttd.org>
parents: 11073
diff changeset
312 DeleteWindowById(WC_SELECT_STATION, 0);
8586
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
313 w->ToggleWidgetLoweredState(RTW_REMOVE);
13034
6eb3f749890a (svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents: 13027
diff changeset
314 w->SetWidgetDirty(RTW_REMOVE);
8586
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
315 _remove_button_clicked = w->IsWidgetLowered(RTW_REMOVE);
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
316 SetSelectionRed(_remove_button_clicked);
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
317 }
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
318
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
319 /** Updates the Remove button because of Ctrl state change
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
320 * @param w window the button belongs to
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
321 * @return true iff the remove buton was changed
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
322 */
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
323 static bool RailToolbar_CtrlChanged(Window *w)
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
324 {
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
325 if (w->IsWidgetDisabled(RTW_REMOVE)) return false;
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
326
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
327 /* allow ctrl to switch remove mode only for these widgets */
8587
5475f6785dcf (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz <smatz@openttd.org>
parents: 8586
diff changeset
328 for (uint i = RTW_BUILD_NS; i <= RTW_BUILD_STATION; i++) {
5475f6785dcf (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz <smatz@openttd.org>
parents: 8586
diff changeset
329 if ((i <= RTW_AUTORAIL || i >= RTW_BUILD_WAYPOINT) && w->IsWidgetLowered(i)) {
8586
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
330 ToggleRailButton_Remove(w);
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
331 return true;
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
332 }
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
333 }
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
334
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
335 return false;
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
336 }
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
337
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
338
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
339 /**
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
340 * The "rail N"-button click proc of the build-rail toolbar.
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
341 * @param w Build-rail toolbar window
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
342 * @see BuildRailToolbWndProc()
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
343 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
344 static void BuildRailClick_N(Window *w)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
345 {
11709
886f2a4f8cba (svn r16095) -Change/Feature-ish: make the first 4 rail building tools behave more like autorail
rubidium <rubidium@openttd.org>
parents: 11702
diff changeset
346 HandlePlacePushButton(w, RTW_BUILD_NS, GetRailTypeInfo(_cur_railtype)->cursor.rail_ns, HT_LINE | HT_DIR_VL, PlaceRail_N);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
347 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
348
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
349 /**
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
350 * The "rail NE"-button click proc of the build-rail toolbar.
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
351 * @param w Build-rail toolbar window
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
352 * @see BuildRailToolbWndProc()
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
353 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
354 static void BuildRailClick_NE(Window *w)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
355 {
11709
886f2a4f8cba (svn r16095) -Change/Feature-ish: make the first 4 rail building tools behave more like autorail
rubidium <rubidium@openttd.org>
parents: 11702
diff changeset
356 HandlePlacePushButton(w, RTW_BUILD_X, GetRailTypeInfo(_cur_railtype)->cursor.rail_swne, HT_LINE | HT_DIR_X, PlaceRail_NE);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
357 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
358
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
359 /**
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
360 * The "rail E"-button click proc of the build-rail toolbar.
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
361 * @param w Build-rail toolbar window
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
362 * @see BuildRailToolbWndProc()
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
363 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
364 static void BuildRailClick_E(Window *w)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
365 {
11709
886f2a4f8cba (svn r16095) -Change/Feature-ish: make the first 4 rail building tools behave more like autorail
rubidium <rubidium@openttd.org>
parents: 11702
diff changeset
366 HandlePlacePushButton(w, RTW_BUILD_EW, GetRailTypeInfo(_cur_railtype)->cursor.rail_ew, HT_LINE | HT_DIR_HL, PlaceRail_E);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
367 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
368
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
369 /**
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
370 * The "rail NW"-button click proc of the build-rail toolbar.
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
371 * @param w Build-rail toolbar window
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
372 * @see BuildRailToolbWndProc()
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
373 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
374 static void BuildRailClick_NW(Window *w)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
375 {
11709
886f2a4f8cba (svn r16095) -Change/Feature-ish: make the first 4 rail building tools behave more like autorail
rubidium <rubidium@openttd.org>
parents: 11702
diff changeset
376 HandlePlacePushButton(w, RTW_BUILD_Y, GetRailTypeInfo(_cur_railtype)->cursor.rail_nwse, HT_LINE | HT_DIR_Y, PlaceRail_NW);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
377 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
378
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
379 /**
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
380 * The "auto-rail"-button click proc of the build-rail toolbar.
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
381 * @param w Build-rail toolbar window
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
382 * @see BuildRailToolbWndProc()
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
383 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
384 static void BuildRailClick_AutoRail(Window *w)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
385 {
11702
cdaad565efe5 (svn r16088) -Codechange: merge HighLightStyle and ViewportHighlightMode as they are basically the same thing
rubidium <rubidium@openttd.org>
parents: 11501
diff changeset
386 HandlePlacePushButton(w, RTW_AUTORAIL, GetRailTypeInfo(_cur_railtype)->cursor.autorail, HT_RAIL, PlaceRail_AutoRail);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
387 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
388
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
389 /**
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
390 * The "demolish"-button click proc of the build-rail toolbar.
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
391 * @param w Build-rail toolbar window
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
392 * @see BuildRailToolbWndProc()
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
393 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
394 static void BuildRailClick_Demolish(Window *w)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
395 {
11702
cdaad565efe5 (svn r16088) -Codechange: merge HighLightStyle and ViewportHighlightMode as they are basically the same thing
rubidium <rubidium@openttd.org>
parents: 11501
diff changeset
396 HandlePlacePushButton(w, RTW_DEMOLISH, ANIMCURSOR_DEMOLISH, HT_RECT, PlaceProc_DemolishArea);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
397 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
398
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
399 /**
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
400 * The "build depot"-button click proc of the build-rail toolbar.
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
401 * @param w Build-rail toolbar window
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
402 * @see BuildRailToolbWndProc()
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
403 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
404 static void BuildRailClick_Depot(Window *w)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
405 {
11702
cdaad565efe5 (svn r16088) -Codechange: merge HighLightStyle and ViewportHighlightMode as they are basically the same thing
rubidium <rubidium@openttd.org>
parents: 11501
diff changeset
406 if (HandlePlacePushButton(w, RTW_BUILD_DEPOT, GetRailTypeInfo(_cur_railtype)->cursor.depot, HT_RECT, PlaceRail_Depot)) {
9338
9f0982110dda (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch <frosch@openttd.org>
parents: 9317
diff changeset
407 ShowBuildTrainDepotPicker(w);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
408 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
409 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
410
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
411 /**
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
412 * The "build waypoint"-button click proc of the build-rail toolbar.
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
413 * If there are newGRF waypoints, also open a window to pick the waypoint type.
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
414 * @param w Build-rail toolbar window
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
415 * @see BuildRailToolbWndProc()
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
416 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
417 static void BuildRailClick_Waypoint(Window *w)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
418 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
419 _waypoint_count = GetNumCustomStations(STAT_CLASS_WAYP);
11702
cdaad565efe5 (svn r16088) -Codechange: merge HighLightStyle and ViewportHighlightMode as they are basically the same thing
rubidium <rubidium@openttd.org>
parents: 11501
diff changeset
420 if (HandlePlacePushButton(w, RTW_BUILD_WAYPOINT, SPR_CURSOR_WAYPOINT, HT_RECT, PlaceRail_Waypoint) &&
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
421 _waypoint_count > 1) {
9338
9f0982110dda (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch <frosch@openttd.org>
parents: 9317
diff changeset
422 ShowBuildWaypointPicker(w);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
423 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
424 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
425
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
426 /**
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
427 * The "build station"-button click proc of the build-rail toolbar.
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
428 * @param w Build-rail toolbar window
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
429 * @see BuildRailToolbWndProc()
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
430 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
431 static void BuildRailClick_Station(Window *w)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
432 {
11702
cdaad565efe5 (svn r16088) -Codechange: merge HighLightStyle and ViewportHighlightMode as they are basically the same thing
rubidium <rubidium@openttd.org>
parents: 11501
diff changeset
433 if (HandlePlacePushButton(w, RTW_BUILD_STATION, SPR_CURSOR_RAIL_STATION, HT_RECT, PlaceRail_Station)) ShowStationBuilder(w);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
434 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
435
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
436 /**
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
437 * The "build signal"-button click proc of the build-rail toolbar.
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
438 * Start ShowSignalBuilder() and/or HandleAutoSignalPlacement().
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
439 * @param w Build-rail toolbar window
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
440 * @see BuildRailToolbWndProc()
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
441 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
442 static void BuildRailClick_AutoSignals(Window *w)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
443 {
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
444 if (_settings_client.gui.enable_signal_gui != _ctrl_pressed) {
11702
cdaad565efe5 (svn r16088) -Codechange: merge HighLightStyle and ViewportHighlightMode as they are basically the same thing
rubidium <rubidium@openttd.org>
parents: 11501
diff changeset
445 if (HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, HT_RECT, PlaceRail_AutoSignals)) ShowSignalBuilder(w);
7991
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
446 } else {
11702
cdaad565efe5 (svn r16088) -Codechange: merge HighLightStyle and ViewportHighlightMode as they are basically the same thing
rubidium <rubidium@openttd.org>
parents: 11501
diff changeset
447 HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, HT_RECT, PlaceRail_AutoSignals);
7991
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
448 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
449 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
450
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
451 /**
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
452 * The "build bridge"-button click proc of the build-rail toolbar.
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
453 * @param w Build-rail toolbar window
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
454 * @see BuildRailToolbWndProc()
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
455 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
456 static void BuildRailClick_Bridge(Window *w)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
457 {
11702
cdaad565efe5 (svn r16088) -Codechange: merge HighLightStyle and ViewportHighlightMode as they are basically the same thing
rubidium <rubidium@openttd.org>
parents: 11501
diff changeset
458 HandlePlacePushButton(w, RTW_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, HT_RECT, PlaceRail_Bridge);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
459 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
460
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
461 /**
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
462 * The "build tunnel"-button click proc of the build-rail toolbar.
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
463 * @param w Build-rail toolbar window
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
464 * @see BuildRailToolbWndProc()
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
465 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
466 static void BuildRailClick_Tunnel(Window *w)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
467 {
11702
cdaad565efe5 (svn r16088) -Codechange: merge HighLightStyle and ViewportHighlightMode as they are basically the same thing
rubidium <rubidium@openttd.org>
parents: 11501
diff changeset
468 HandlePlacePushButton(w, RTW_BUILD_TUNNEL, GetRailTypeInfo(_cur_railtype)->cursor.tunnel, HT_SPECIAL, PlaceRail_Tunnel);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
469 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
470
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
471 /**
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
472 * The "remove"-button click proc of the build-rail toolbar.
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
473 * @param w Build-rail toolbar window
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
474 * @see BuildRailToolbWndProc()
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
475 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
476 static void BuildRailClick_Remove(Window *w)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
477 {
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7991
diff changeset
478 if (w->IsWidgetDisabled(RTW_REMOVE)) return;
8586
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
479 ToggleRailButton_Remove(w);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
480 SndPlayFx(SND_15_BEEP);
8587
5475f6785dcf (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz <smatz@openttd.org>
parents: 8586
diff changeset
481
5475f6785dcf (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz <smatz@openttd.org>
parents: 8586
diff changeset
482 /* handle station builder */
5475f6785dcf (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz <smatz@openttd.org>
parents: 8586
diff changeset
483 if (w->IsWidgetLowered(RTW_BUILD_STATION)) {
5475f6785dcf (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz <smatz@openttd.org>
parents: 8586
diff changeset
484 if (_remove_button_clicked) {
5475f6785dcf (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz <smatz@openttd.org>
parents: 8586
diff changeset
485 /* starting drag & drop remove */
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
486 if (!_settings_client.gui.station_dragdrop) {
8587
5475f6785dcf (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz <smatz@openttd.org>
parents: 8586
diff changeset
487 SetTileSelectSize(1, 1);
5475f6785dcf (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz <smatz@openttd.org>
parents: 8586
diff changeset
488 } else {
5475f6785dcf (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz <smatz@openttd.org>
parents: 8586
diff changeset
489 VpSetPlaceSizingLimit(-1);
5475f6785dcf (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz <smatz@openttd.org>
parents: 8586
diff changeset
490 }
5475f6785dcf (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz <smatz@openttd.org>
parents: 8586
diff changeset
491 } else {
5475f6785dcf (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz <smatz@openttd.org>
parents: 8586
diff changeset
492 /* starting station build mode */
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
493 if (!_settings_client.gui.station_dragdrop) {
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
494 int x = _settings_client.gui.station_numtracks;
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
495 int y = _settings_client.gui.station_platlength;
8587
5475f6785dcf (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz <smatz@openttd.org>
parents: 8586
diff changeset
496 if (_railstation.orientation == 0) Swap(x, y);
5475f6785dcf (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz <smatz@openttd.org>
parents: 8586
diff changeset
497 SetTileSelectSize(x, y);
5475f6785dcf (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz <smatz@openttd.org>
parents: 8586
diff changeset
498 } else {
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
499 VpSetPlaceSizingLimit(_settings_game.station.station_spread);
8587
5475f6785dcf (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz <smatz@openttd.org>
parents: 8586
diff changeset
500 }
5475f6785dcf (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz <smatz@openttd.org>
parents: 8586
diff changeset
501 }
5475f6785dcf (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz <smatz@openttd.org>
parents: 8586
diff changeset
502 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
503 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
504
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
505 /**
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
506 * The "convert-rail"-button click proc of the build-rail toolbar.
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
507 * Switches to 'convert-rail' mode
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
508 * @param w Build-rail toolbar window
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
509 * @see BuildRailToolbWndProc()
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
510 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
511 static void BuildRailClick_Convert(Window *w)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
512 {
11702
cdaad565efe5 (svn r16088) -Codechange: merge HighLightStyle and ViewportHighlightMode as they are basically the same thing
rubidium <rubidium@openttd.org>
parents: 11501
diff changeset
513 HandlePlacePushButton(w, RTW_CONVERT_RAIL, GetRailTypeInfo(_cur_railtype)->cursor.convert, HT_RECT, PlaceRail_ConvertRail);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
514 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
515
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
516
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
517 static void DoRailroadTrack(int mode)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
518 {
10499
45ca88a8de7d (svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents: 10208
diff changeset
519 DoCommandP(TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), _cur_railtype | (mode << 4),
8586
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
520 _remove_button_clicked ?
11730
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11709
diff changeset
521 CMD_REMOVE_RAILROAD_TRACK | CMD_MSG(STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK) :
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11709
diff changeset
522 CMD_BUILD_RAILROAD_TRACK | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
523 );
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
524 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
525
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6207
diff changeset
526 static void HandleAutodirPlacement()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
527 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
528 TileHighlightData *thd = &_thd;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
529 int trackstat = thd->drawstyle & 0xF; // 0..5
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
530
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
531 if (thd->drawstyle & HT_RAIL) { // one tile case
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
532 GenericPlaceRail(TileVirtXY(thd->selend.x, thd->selend.y), trackstat);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
533 return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
534 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
535
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
536 DoRailroadTrack(trackstat);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
537 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
538
7991
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
539 /**
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
540 * Build new signals or remove signals or (if only one tile marked) edit a signal.
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
541 *
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
542 * If one tile marked abort and use GenericPlaceSignals()
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
543 * else use CmdBuildSingleSignal() or CmdRemoveSingleSignal() in rail_cmd.cpp to build many signals
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
544 */
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6207
diff changeset
545 static void HandleAutoSignalPlacement()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
546 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
547 TileHighlightData *thd = &_thd;
5735
6dcf717d732f (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 <Darkvater@openttd.org>
parents: 5731
diff changeset
548 uint32 p2 = GB(thd->drawstyle, 0, 3); // 0..5
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
549
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
550 if (thd->drawstyle == HT_RECT) { // one tile case
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
551 GenericPlaceSignals(TileVirtXY(thd->selend.x, thd->selend.y));
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
552 return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
553 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
554
8808
2d40645f197f (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz <smatz@openttd.org>
parents: 8785
diff changeset
555 const Window *w = FindWindowById(WC_BUILD_SIGNAL, 0);
2d40645f197f (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz <smatz@openttd.org>
parents: 8785
diff changeset
556
2d40645f197f (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz <smatz@openttd.org>
parents: 8785
diff changeset
557 if (w != NULL) {
2d40645f197f (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz <smatz@openttd.org>
parents: 8785
diff changeset
558 /* signal GUI is used */
2d40645f197f (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz <smatz@openttd.org>
parents: 8785
diff changeset
559 SB(p2, 3, 1, 0);
2d40645f197f (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz <smatz@openttd.org>
parents: 8785
diff changeset
560 SB(p2, 4, 1, _cur_signal_variant);
2d40645f197f (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz <smatz@openttd.org>
parents: 8785
diff changeset
561 SB(p2, 6, 1, _ctrl_pressed);
9794
3afdf3caa398 (svn r13936) -Codechange [YAPP]: Enable the auto-signal tool to build PBS signals and honor the default signal type. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9793
diff changeset
562 SB(p2, 7, 3, _cur_signal_type);
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
563 SB(p2, 24, 8, _settings_client.gui.drag_signals_density);
8808
2d40645f197f (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz <smatz@openttd.org>
parents: 8785
diff changeset
564 } else {
2d40645f197f (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz <smatz@openttd.org>
parents: 8785
diff changeset
565 SB(p2, 3, 1, 0);
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
566 SB(p2, 4, 1, (_cur_year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC));
8808
2d40645f197f (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz <smatz@openttd.org>
parents: 8785
diff changeset
567 SB(p2, 6, 1, _ctrl_pressed);
9794
3afdf3caa398 (svn r13936) -Codechange [YAPP]: Enable the auto-signal tool to build PBS signals and honor the default signal type. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9793
diff changeset
568 SB(p2, 7, 3, _default_signal_type[_settings_client.gui.default_signal_type]);
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
569 SB(p2, 24, 8, _settings_client.gui.drag_signals_density);
8808
2d40645f197f (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz <smatz@openttd.org>
parents: 8785
diff changeset
570 }
5688
4d109cf909b6 (svn r8151) -Feature: Automatically build semaphores before a configurable date, which can be set by each network player seperately.
maedhros <maedhros@openttd.org>
parents: 5682
diff changeset
571
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
572 /* _settings_client.gui.drag_signals_density is given as a parameter such that each user
5731
1842c1520d72 (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 <Darkvater@openttd.org>
parents: 5696
diff changeset
573 * in a network game can specify his/her own signal density */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
574 DoCommandP(
5731
1842c1520d72 (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 <Darkvater@openttd.org>
parents: 5696
diff changeset
575 TileVirtXY(thd->selstart.x, thd->selstart.y),
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
576 TileVirtXY(thd->selend.x, thd->selend.y),
5731
1842c1520d72 (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 <Darkvater@openttd.org>
parents: 5696
diff changeset
577 p2,
7955
c08de05b67c2 (svn r11511) -Revert parts of r11505: forgot that CTRL might be used for other features, like adjacent stations or signals.
rubidium <rubidium@openttd.org>
parents: 7949
diff changeset
578 _remove_button_clicked ?
11730
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11709
diff changeset
579 CMD_REMOVE_SIGNAL_TRACK | CMD_MSG(STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM) :
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11709
diff changeset
580 CMD_BUILD_SIGNAL_TRACK | CMD_MSG(STR_ERROR_CAN_T_BUILD_SIGNALS_HERE),
10499
45ca88a8de7d (svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents: 10208
diff changeset
581 CcPlaySound1E);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
582 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
583
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
585 typedef void OnButtonClick(Window *w);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
586
9771
2dd0e71c4356 (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium <rubidium@openttd.org>
parents: 9762
diff changeset
587 /** Data associated with a push button in the build rail toolbar window */
2dd0e71c4356 (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium <rubidium@openttd.org>
parents: 9762
diff changeset
588 struct RailBuildingGUIButtonData {
2dd0e71c4356 (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium <rubidium@openttd.org>
parents: 9762
diff changeset
589 uint16 keycode; ///< Keycode associated with the button
2dd0e71c4356 (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium <rubidium@openttd.org>
parents: 9762
diff changeset
590 OnButtonClick *click_proc; ///< Procedure to call when button is clicked
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
591 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
592
9771
2dd0e71c4356 (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium <rubidium@openttd.org>
parents: 9762
diff changeset
593 /**
2dd0e71c4356 (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium <rubidium@openttd.org>
parents: 9762
diff changeset
594 * GUI rail-building button data constants.
2dd0e71c4356 (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium <rubidium@openttd.org>
parents: 9762
diff changeset
595 * Offsets match widget order, starting at RTW_BUILD_NS
2dd0e71c4356 (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium <rubidium@openttd.org>
parents: 9762
diff changeset
596 */
2dd0e71c4356 (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium <rubidium@openttd.org>
parents: 9762
diff changeset
597 static const RailBuildingGUIButtonData _rail_build_button_data[] = {
2dd0e71c4356 (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium <rubidium@openttd.org>
parents: 9762
diff changeset
598 {'1', BuildRailClick_N },
2dd0e71c4356 (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium <rubidium@openttd.org>
parents: 9762
diff changeset
599 {'2', BuildRailClick_NE },
2dd0e71c4356 (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium <rubidium@openttd.org>
parents: 9762
diff changeset
600 {'3', BuildRailClick_E },
2dd0e71c4356 (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium <rubidium@openttd.org>
parents: 9762
diff changeset
601 {'4', BuildRailClick_NW },
2dd0e71c4356 (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium <rubidium@openttd.org>
parents: 9762
diff changeset
602 {'5', BuildRailClick_AutoRail },
2dd0e71c4356 (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium <rubidium@openttd.org>
parents: 9762
diff changeset
603 {'6', BuildRailClick_Demolish },
2dd0e71c4356 (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium <rubidium@openttd.org>
parents: 9762
diff changeset
604 {'7', BuildRailClick_Depot },
2dd0e71c4356 (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium <rubidium@openttd.org>
parents: 9762
diff changeset
605 {'8', BuildRailClick_Waypoint },
2dd0e71c4356 (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium <rubidium@openttd.org>
parents: 9762
diff changeset
606 {'9', BuildRailClick_Station },
2dd0e71c4356 (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium <rubidium@openttd.org>
parents: 9762
diff changeset
607 {'S', BuildRailClick_AutoSignals},
2dd0e71c4356 (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium <rubidium@openttd.org>
parents: 9762
diff changeset
608 {'B', BuildRailClick_Bridge },
2dd0e71c4356 (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium <rubidium@openttd.org>
parents: 9762
diff changeset
609 {'T', BuildRailClick_Tunnel },
2dd0e71c4356 (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium <rubidium@openttd.org>
parents: 9762
diff changeset
610 {'R', BuildRailClick_Remove },
2dd0e71c4356 (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium <rubidium@openttd.org>
parents: 9762
diff changeset
611 {'C', BuildRailClick_Convert }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
612 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
613
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
614 /**
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
615 * Based on the widget clicked, update the status of the 'remove' button.
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
616 * @param w Rail toolbar window
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
617 * @param clicked_widget Widget clicked in the toolbar
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
618 */
9303
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
619 struct BuildRailToolbarWindow : Window {
12329
923c27b30ed6 (svn r16749) -Codechange: Rail toolbar uses nested widget tree only.
alberth <alberth@openttd.org>
parents: 12087
diff changeset
620 BuildRailToolbarWindow(const WindowDesc *desc, WindowNumber window_number, RailType railtype) : Window()
9303
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
621 {
12329
923c27b30ed6 (svn r16749) -Codechange: Rail toolbar uses nested widget tree only.
alberth <alberth@openttd.org>
parents: 12087
diff changeset
622 this->InitNested(desc);
923c27b30ed6 (svn r16749) -Codechange: Rail toolbar uses nested widget tree only.
alberth <alberth@openttd.org>
parents: 12087
diff changeset
623 this->SetupRailToolbar(railtype);
9303
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
624 this->DisableWidget(RTW_REMOVE);
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
625
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
626 if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
9303
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
627 }
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
628
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
629 ~BuildRailToolbarWindow()
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
630 {
10530
21ebd351f607 (svn r14787) -Fix: landscape toolbar getting closed when rail/road/water/airport toolbar gets closed with linked toolbars turned on.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
631 if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0, false);
9303
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
632 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
633
12329
923c27b30ed6 (svn r16749) -Codechange: Rail toolbar uses nested widget tree only.
alberth <alberth@openttd.org>
parents: 12087
diff changeset
634 /** Configures the rail toolbar for railtype given
923c27b30ed6 (svn r16749) -Codechange: Rail toolbar uses nested widget tree only.
alberth <alberth@openttd.org>
parents: 12087
diff changeset
635 * @param railtype the railtype to display
923c27b30ed6 (svn r16749) -Codechange: Rail toolbar uses nested widget tree only.
alberth <alberth@openttd.org>
parents: 12087
diff changeset
636 */
923c27b30ed6 (svn r16749) -Codechange: Rail toolbar uses nested widget tree only.
alberth <alberth@openttd.org>
parents: 12087
diff changeset
637 void SetupRailToolbar(RailType railtype)
923c27b30ed6 (svn r16749) -Codechange: Rail toolbar uses nested widget tree only.
alberth <alberth@openttd.org>
parents: 12087
diff changeset
638 {
923c27b30ed6 (svn r16749) -Codechange: Rail toolbar uses nested widget tree only.
alberth <alberth@openttd.org>
parents: 12087
diff changeset
639 const RailtypeInfo *rti = GetRailTypeInfo(railtype);
923c27b30ed6 (svn r16749) -Codechange: Rail toolbar uses nested widget tree only.
alberth <alberth@openttd.org>
parents: 12087
diff changeset
640
923c27b30ed6 (svn r16749) -Codechange: Rail toolbar uses nested widget tree only.
alberth <alberth@openttd.org>
parents: 12087
diff changeset
641 assert(railtype < RAILTYPE_END);
13072
75bd67594af2 (svn r17572) -Codechange: Use the Window::GetWidget() function to access nested widgets through the nested_array.
alberth <alberth@openttd.org>
parents: 13036
diff changeset
642 this->GetWidget<NWidgetCore>(RTW_CAPTION)->widget_data = rti->strings.toolbar_caption;
75bd67594af2 (svn r17572) -Codechange: Use the Window::GetWidget() function to access nested widgets through the nested_array.
alberth <alberth@openttd.org>
parents: 13036
diff changeset
643 this->GetWidget<NWidgetCore>(RTW_BUILD_NS)->widget_data = rti->gui_sprites.build_ns_rail;
75bd67594af2 (svn r17572) -Codechange: Use the Window::GetWidget() function to access nested widgets through the nested_array.
alberth <alberth@openttd.org>
parents: 13036
diff changeset
644 this->GetWidget<NWidgetCore>(RTW_BUILD_X)->widget_data = rti->gui_sprites.build_x_rail;
75bd67594af2 (svn r17572) -Codechange: Use the Window::GetWidget() function to access nested widgets through the nested_array.
alberth <alberth@openttd.org>
parents: 13036
diff changeset
645 this->GetWidget<NWidgetCore>(RTW_BUILD_EW)->widget_data = rti->gui_sprites.build_ew_rail;
75bd67594af2 (svn r17572) -Codechange: Use the Window::GetWidget() function to access nested widgets through the nested_array.
alberth <alberth@openttd.org>
parents: 13036
diff changeset
646 this->GetWidget<NWidgetCore>(RTW_BUILD_Y)->widget_data = rti->gui_sprites.build_y_rail;
75bd67594af2 (svn r17572) -Codechange: Use the Window::GetWidget() function to access nested widgets through the nested_array.
alberth <alberth@openttd.org>
parents: 13036
diff changeset
647 this->GetWidget<NWidgetCore>(RTW_AUTORAIL)->widget_data = rti->gui_sprites.auto_rail;
75bd67594af2 (svn r17572) -Codechange: Use the Window::GetWidget() function to access nested widgets through the nested_array.
alberth <alberth@openttd.org>
parents: 13036
diff changeset
648 this->GetWidget<NWidgetCore>(RTW_BUILD_DEPOT)->widget_data = rti->gui_sprites.build_depot;
75bd67594af2 (svn r17572) -Codechange: Use the Window::GetWidget() function to access nested widgets through the nested_array.
alberth <alberth@openttd.org>
parents: 13036
diff changeset
649 this->GetWidget<NWidgetCore>(RTW_CONVERT_RAIL)->widget_data = rti->gui_sprites.convert_rail;
75bd67594af2 (svn r17572) -Codechange: Use the Window::GetWidget() function to access nested widgets through the nested_array.
alberth <alberth@openttd.org>
parents: 13036
diff changeset
650 this->GetWidget<NWidgetCore>(RTW_BUILD_TUNNEL)->widget_data = rti->gui_sprites.build_tunnel;
12329
923c27b30ed6 (svn r16749) -Codechange: Rail toolbar uses nested widget tree only.
alberth <alberth@openttd.org>
parents: 12087
diff changeset
651 }
923c27b30ed6 (svn r16749) -Codechange: Rail toolbar uses nested widget tree only.
alberth <alberth@openttd.org>
parents: 12087
diff changeset
652
923c27b30ed6 (svn r16749) -Codechange: Rail toolbar uses nested widget tree only.
alberth <alberth@openttd.org>
parents: 12087
diff changeset
653 /** Switch to another rail type.
923c27b30ed6 (svn r16749) -Codechange: Rail toolbar uses nested widget tree only.
alberth <alberth@openttd.org>
parents: 12087
diff changeset
654 * @param railtype New rail type.
923c27b30ed6 (svn r16749) -Codechange: Rail toolbar uses nested widget tree only.
alberth <alberth@openttd.org>
parents: 12087
diff changeset
655 */
923c27b30ed6 (svn r16749) -Codechange: Rail toolbar uses nested widget tree only.
alberth <alberth@openttd.org>
parents: 12087
diff changeset
656 void ModifyRailType(RailType railtype)
923c27b30ed6 (svn r16749) -Codechange: Rail toolbar uses nested widget tree only.
alberth <alberth@openttd.org>
parents: 12087
diff changeset
657 {
923c27b30ed6 (svn r16749) -Codechange: Rail toolbar uses nested widget tree only.
alberth <alberth@openttd.org>
parents: 12087
diff changeset
658 this->SetupRailToolbar(railtype);
923c27b30ed6 (svn r16749) -Codechange: Rail toolbar uses nested widget tree only.
alberth <alberth@openttd.org>
parents: 12087
diff changeset
659 this->ReInit();
923c27b30ed6 (svn r16749) -Codechange: Rail toolbar uses nested widget tree only.
alberth <alberth@openttd.org>
parents: 12087
diff changeset
660 }
923c27b30ed6 (svn r16749) -Codechange: Rail toolbar uses nested widget tree only.
alberth <alberth@openttd.org>
parents: 12087
diff changeset
661
9303
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
662 void UpdateRemoveWidgetStatus(int clicked_widget)
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
663 {
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
664 switch (clicked_widget) {
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
665 case RTW_REMOVE:
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
666 /* If it is the removal button that has been clicked, do nothing,
11361
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11074
diff changeset
667 * as it is up to the other buttons to drive removal status */
9303
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
668 return;
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
669 break;
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
670 case RTW_BUILD_NS:
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
671 case RTW_BUILD_X:
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
672 case RTW_BUILD_EW:
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
673 case RTW_BUILD_Y:
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
674 case RTW_AUTORAIL:
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
675 case RTW_BUILD_WAYPOINT:
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
676 case RTW_BUILD_STATION:
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
677 case RTW_BUILD_SIGNALS:
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
678 /* Removal button is enabled only if the rail/signal/waypoint/station
11361
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11074
diff changeset
679 * button is still lowered. Once raised, it has to be disabled */
9303
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
680 this->SetWidgetDisabledState(RTW_REMOVE, !this->IsWidgetLowered(clicked_widget));
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
681 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
682
9303
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
683 default:
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
684 /* When any other buttons than rail/signal/waypoint/station, raise and
11361
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11074
diff changeset
685 * disable the removal button */
9303
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
686 this->DisableWidget(RTW_REMOVE);
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
687 this->RaiseWidget(RTW_REMOVE);
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
688 break;
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
689 }
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
690 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
691
9303
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
692 virtual void OnPaint()
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
693 {
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
694 this->DrawWidgets();
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
695 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
696
9303
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
697 virtual void OnClick(Point pt, int widget)
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
698 {
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
699 if (widget >= RTW_BUILD_NS) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
700 _remove_button_clicked = false;
9771
2dd0e71c4356 (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium <rubidium@openttd.org>
parents: 9762
diff changeset
701 _rail_build_button_data[widget - RTW_BUILD_NS].click_proc(this);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
702 }
9303
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
703 this->UpdateRemoveWidgetStatus(widget);
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
704 if (_ctrl_pressed) RailToolbar_CtrlChanged(this);
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
705 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
706
9303
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
707 virtual EventState OnKeyPress(uint16 key, uint16 keycode)
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
708 {
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
709 EventState state = ES_NOT_HANDLED;
9771
2dd0e71c4356 (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium <rubidium@openttd.org>
parents: 9762
diff changeset
710 for (uint8 i = 0; i != lengthof(_rail_build_button_data); i++) {
2dd0e71c4356 (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium <rubidium@openttd.org>
parents: 9762
diff changeset
711 if (keycode == _rail_build_button_data[i].keycode) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
712 _remove_button_clicked = false;
9771
2dd0e71c4356 (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium <rubidium@openttd.org>
parents: 9762
diff changeset
713 _rail_build_button_data[i].click_proc(this);
9303
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
714 this->UpdateRemoveWidgetStatus(i + RTW_BUILD_NS);
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
715 if (_ctrl_pressed) RailToolbar_CtrlChanged(this);
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
716 state = ES_HANDLED;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
717 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
718 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
719 }
11765
5f99176348d3 (svn r16155) -Codechange: remove MarkTileDirty, use MarkTileDirtyByTile instead
smatz <smatz@openttd.org>
parents: 11730
diff changeset
720 MarkTileDirtyByTile(TileVirtXY(_thd.pos.x, _thd.pos.y)); // redraw tile selection
9303
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
721 return state;
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
722 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
723
9303
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
724 virtual void OnPlaceObject(Point pt, TileIndex tile)
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
725 {
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
726 _place_proc(tile);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
727 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
728
9303
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
729 virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
730 {
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
731 /* no dragging if you have pressed the convert button */
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
732 if (FindWindowById(WC_BUILD_SIGNAL, 0) != NULL && _convert_signal_button && this->IsWidgetLowered(RTW_BUILD_SIGNALS)) return;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
733
9303
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
734 VpSelectTilesWithMethod(pt.x, pt.y, select_method);
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
735 }
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
736
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
737 virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
738 {
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
739 if (pt.x != -1) {
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
740 switch (select_proc) {
9293
d14fbfc20940 (svn r13160) -Codechange: prepare GUIPlaceProcDragXY for the removal of WindowEvent.
rubidium <rubidium@openttd.org>
parents: 9277
diff changeset
741 default: NOT_REACHED();
6670
5ff577cb6c43 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros <maedhros@openttd.org>
parents: 6669
diff changeset
742 case DDSP_BUILD_BRIDGE:
10611
979ddadfaabf (svn r14902) -Feature: Advanced setting to keep various building tools active, which are usually closed after placing an object. (planetmaker)
frosch <frosch@openttd.org>
parents: 10606
diff changeset
743 if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
8557
b78d027fd703 (svn r12135) -Codechange: Road and rail bridge selection windows were identical apart the caption. So remove one window definition and set manually the caption accordingly.
belugas <belugas@openttd.org>
parents: 8424
diff changeset
744 ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_RAIL, _cur_railtype);
6669
66456dace92f (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros <maedhros@openttd.org>
parents: 6596
diff changeset
745 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
746
11709
886f2a4f8cba (svn r16095) -Change/Feature-ish: make the first 4 rail building tools behave more like autorail
rubidium <rubidium@openttd.org>
parents: 11702
diff changeset
747 case DDSP_PLACE_RAIL:
6669
66456dace92f (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros <maedhros@openttd.org>
parents: 6596
diff changeset
748 HandleAutodirPlacement();
7949
f24a967a1eb9 (svn r11505) -Fix/Feature: make CTRL work on all road/rail construction options that 'work' with the 'Bulldozer' button instead of only a few.
rubidium <rubidium@openttd.org>
parents: 7928
diff changeset
749 break;
6596
25eb42436c22 (svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138 <peter1138@openttd.org>
parents: 6453
diff changeset
750
6670
5ff577cb6c43 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros <maedhros@openttd.org>
parents: 6669
diff changeset
751 case DDSP_BUILD_SIGNALS:
6669
66456dace92f (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros <maedhros@openttd.org>
parents: 6596
diff changeset
752 HandleAutoSignalPlacement();
66456dace92f (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros <maedhros@openttd.org>
parents: 6596
diff changeset
753 break;
66456dace92f (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros <maedhros@openttd.org>
parents: 6596
diff changeset
754
6670
5ff577cb6c43 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros <maedhros@openttd.org>
parents: 6669
diff changeset
755 case DDSP_DEMOLISH_AREA:
9303
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
756 GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
6669
66456dace92f (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros <maedhros@openttd.org>
parents: 6596
diff changeset
757 break;
66456dace92f (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros <maedhros@openttd.org>
parents: 6596
diff changeset
758
6670
5ff577cb6c43 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros <maedhros@openttd.org>
parents: 6669
diff changeset
759 case DDSP_CONVERT_RAIL:
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12619
diff changeset
760 DoCommandP(end_tile, start_tile, _cur_railtype, CMD_CONVERT_RAIL | CMD_MSG(STR_ERROR_CAN_T_CONVERT_RAIL), CcPlaySound10);
6670
5ff577cb6c43 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros <maedhros@openttd.org>
parents: 6669
diff changeset
761 break;
5ff577cb6c43 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros <maedhros@openttd.org>
parents: 6669
diff changeset
762
8587
5475f6785dcf (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz <smatz@openttd.org>
parents: 8586
diff changeset
763 case DDSP_REMOVE_STATION:
6670
5ff577cb6c43 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros <maedhros@openttd.org>
parents: 6669
diff changeset
764 case DDSP_BUILD_STATION:
12553
8d5c10ef911d (svn r16991) -Change: make 'remove waypoint' draggable
rubidium <rubidium@openttd.org>
parents: 12552
diff changeset
765 if (this->IsWidgetLowered(RTW_BUILD_STATION)) {
8d5c10ef911d (svn r16991) -Change: make 'remove waypoint' draggable
rubidium <rubidium@openttd.org>
parents: 12552
diff changeset
766 /* Station */
8d5c10ef911d (svn r16991) -Change: make 'remove waypoint' draggable
rubidium <rubidium@openttd.org>
parents: 12552
diff changeset
767 if (_remove_button_clicked) {
12977
45ddb1d44728 (svn r17471) -Change: when removing a station or waypoint keep the rail unless Ctrl is pressed. This makes the behaviour consistent between the two.
rubidium <rubidium@openttd.org>
parents: 12880
diff changeset
768 DoCommandP(end_tile, start_tile, _ctrl_pressed ? 0 : 1, CMD_REMOVE_FROM_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_REMOVE_PART_OF_STATION), CcPlaySound1E);
12553
8d5c10ef911d (svn r16991) -Change: make 'remove waypoint' draggable
rubidium <rubidium@openttd.org>
parents: 12552
diff changeset
769 } else {
8d5c10ef911d (svn r16991) -Change: make 'remove waypoint' draggable
rubidium <rubidium@openttd.org>
parents: 12552
diff changeset
770 HandleStationPlacement(start_tile, end_tile);
8d5c10ef911d (svn r16991) -Change: make 'remove waypoint' draggable
rubidium <rubidium@openttd.org>
parents: 12552
diff changeset
771 }
8d5c10ef911d (svn r16991) -Change: make 'remove waypoint' draggable
rubidium <rubidium@openttd.org>
parents: 12552
diff changeset
772 } else {
8d5c10ef911d (svn r16991) -Change: make 'remove waypoint' draggable
rubidium <rubidium@openttd.org>
parents: 12552
diff changeset
773 /* Waypoint */
8d5c10ef911d (svn r16991) -Change: make 'remove waypoint' draggable
rubidium <rubidium@openttd.org>
parents: 12552
diff changeset
774 if (_remove_button_clicked) {
12977
45ddb1d44728 (svn r17471) -Change: when removing a station or waypoint keep the rail unless Ctrl is pressed. This makes the behaviour consistent between the two.
rubidium <rubidium@openttd.org>
parents: 12880
diff changeset
775 DoCommandP(end_tile, start_tile, _ctrl_pressed ? 0 : 1, CMD_REMOVE_FROM_RAIL_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_REMOVE_TRAIN_WAYPOINT), CcPlaySound1E);
12555
e814b879d2e1 (svn r16993) -Change: make the rail waypoint builder draggable
rubidium <rubidium@openttd.org>
parents: 12553
diff changeset
776 } else {
e814b879d2e1 (svn r16993) -Change: make the rail waypoint builder draggable
rubidium <rubidium@openttd.org>
parents: 12553
diff changeset
777 TileArea ta(start_tile, end_tile);
e814b879d2e1 (svn r16993) -Change: make the rail waypoint builder draggable
rubidium <rubidium@openttd.org>
parents: 12553
diff changeset
778 uint32 p1 = _cur_railtype | (select_method == VPM_FIX_X ? AXIS_X : AXIS_Y) << 4 | ta.w << 8 | ta.h << 16 | _ctrl_pressed << 24;
e814b879d2e1 (svn r16993) -Change: make the rail waypoint builder draggable
rubidium <rubidium@openttd.org>
parents: 12553
diff changeset
779 uint32 p2 = STAT_CLASS_WAYP | _cur_waypoint_type << 8 | INVALID_STATION << 16;
e814b879d2e1 (svn r16993) -Change: make the rail waypoint builder draggable
rubidium <rubidium@openttd.org>
parents: 12553
diff changeset
780
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12619
diff changeset
781 CommandContainer cmdcont = { ta.tile, p1, p2, CMD_BUILD_RAIL_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_BUILD_TRAIN_WAYPOINT), CcPlaySound1E, "" };
12564
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12562
diff changeset
782 ShowSelectWaypointIfNeeded(cmdcont, ta);
12553
8d5c10ef911d (svn r16991) -Change: make 'remove waypoint' draggable
rubidium <rubidium@openttd.org>
parents: 12552
diff changeset
783 }
8587
5475f6785dcf (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz <smatz@openttd.org>
parents: 8586
diff changeset
784 }
6669
66456dace92f (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros <maedhros@openttd.org>
parents: 6596
diff changeset
785 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
786 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
787 }
9303
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
788 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
789
9303
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
790 virtual void OnPlaceObjectAbort()
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
791 {
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
792 this->RaiseButtons();
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
793 this->DisableWidget(RTW_REMOVE);
13034
6eb3f749890a (svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents: 13027
diff changeset
794 this->SetWidgetDirty(RTW_REMOVE);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
795
12469
933d81fbf8e8 (svn r16906) -Fix (r12939): Child windows of build toolbars were placed inconsistently.
alberth <alberth@openttd.org>
parents: 12464
diff changeset
796 DeleteWindowById(WC_BUILD_SIGNAL, TRANSPORT_RAIL);
933d81fbf8e8 (svn r16906) -Fix (r12939): Child windows of build toolbars were placed inconsistently.
alberth <alberth@openttd.org>
parents: 12464
diff changeset
797 DeleteWindowById(WC_BUILD_STATION, TRANSPORT_RAIL);
933d81fbf8e8 (svn r16906) -Fix (r12939): Child windows of build toolbars were placed inconsistently.
alberth <alberth@openttd.org>
parents: 12464
diff changeset
798 DeleteWindowById(WC_BUILD_DEPOT, TRANSPORT_RAIL);
11073
9f899b8c0460 (svn r15414) -Codechange: s/delete FindWindowById/DeleteWindowById/
rubidium <rubidium@openttd.org>
parents: 11072
diff changeset
799 DeleteWindowById(WC_SELECT_STATION, 0);
12469
933d81fbf8e8 (svn r16906) -Fix (r12939): Child windows of build toolbars were placed inconsistently.
alberth <alberth@openttd.org>
parents: 12464
diff changeset
800 DeleteWindowByClass(WC_BUILD_BRIDGE);
9303
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
801 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
802
9303
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
803 virtual void OnPlacePresize(Point pt, TileIndex tile)
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
804 {
12781
ab5d32767a5b (svn r17251) -Fix [FS#3141]: other tunnel end not shown if building rail tunnels and the first railtype is not available yet
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
805 DoCommand(tile, _cur_railtype, 0, DC_AUTO, CMD_BUILD_TUNNEL);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
806 VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile);
9303
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
807 }
8586
5f272b02ff37 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents: 8573
diff changeset
808
9303
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
809 virtual EventState OnCTRLStateChange()
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
810 {
8587
5475f6785dcf (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz <smatz@openttd.org>
parents: 8586
diff changeset
811 /* do not toggle Remove button by Ctrl when placing station */
12562
e6b8a343eb13 (svn r17000) -Change: allow overbuilding/extending waypoints
rubidium <rubidium@openttd.org>
parents: 12555
diff changeset
812 if (!this->IsWidgetLowered(RTW_BUILD_STATION) && !this->IsWidgetLowered(RTW_BUILD_WAYPOINT) && RailToolbar_CtrlChanged(this)) return ES_HANDLED;
9303
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
813 return ES_NOT_HANDLED;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
814 }
9303
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
815 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
816
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
817 static const NWidgetPart _nested_build_rail_widgets[] = {
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
818 NWidget(NWID_HORIZONTAL),
13752
517d77f53919 (svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents: 13749
diff changeset
819 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
820 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, RTW_CAPTION), SetDataTip(STR_RAIL_TOOLBAR_RAILROAD_CONSTRUCTION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
13752
517d77f53919 (svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents: 13749
diff changeset
821 NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
822 EndContainer(),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
823 NWidget(NWID_HORIZONTAL),
12422
e05e7e7e34f6 (svn r16856) -Fix: Allow the rail toobar window to align vertically for larger sprites.
alberth <alberth@openttd.org>
parents: 12410
diff changeset
824 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, RTW_BUILD_NS),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
825 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_RAIL_NS, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_TRACK),
12422
e05e7e7e34f6 (svn r16856) -Fix: Allow the rail toobar window to align vertically for larger sprites.
alberth <alberth@openttd.org>
parents: 12410
diff changeset
826 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, RTW_BUILD_X),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
827 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_RAIL_NE, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_TRACK),
12422
e05e7e7e34f6 (svn r16856) -Fix: Allow the rail toobar window to align vertically for larger sprites.
alberth <alberth@openttd.org>
parents: 12410
diff changeset
828 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, RTW_BUILD_EW),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
829 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_RAIL_EW, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_TRACK),
12422
e05e7e7e34f6 (svn r16856) -Fix: Allow the rail toobar window to align vertically for larger sprites.
alberth <alberth@openttd.org>
parents: 12410
diff changeset
830 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, RTW_BUILD_Y),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
831 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_RAIL_NW, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_TRACK),
12422
e05e7e7e34f6 (svn r16856) -Fix: Allow the rail toobar window to align vertically for larger sprites.
alberth <alberth@openttd.org>
parents: 12410
diff changeset
832 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, RTW_AUTORAIL),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
833 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTORAIL, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_AUTORAIL),
12422
e05e7e7e34f6 (svn r16856) -Fix: Allow the rail toobar window to align vertically for larger sprites.
alberth <alberth@openttd.org>
parents: 12410
diff changeset
834
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
835 NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetMinimalSize(4, 22), SetDataTip(0x0, STR_NULL), EndContainer(),
12422
e05e7e7e34f6 (svn r16856) -Fix: Allow the rail toobar window to align vertically for larger sprites.
alberth <alberth@openttd.org>
parents: 12410
diff changeset
836
e05e7e7e34f6 (svn r16856) -Fix: Allow the rail toobar window to align vertically for larger sprites.
alberth <alberth@openttd.org>
parents: 12410
diff changeset
837 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, RTW_DEMOLISH),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
838 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
12422
e05e7e7e34f6 (svn r16856) -Fix: Allow the rail toobar window to align vertically for larger sprites.
alberth <alberth@openttd.org>
parents: 12410
diff changeset
839 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, RTW_BUILD_DEPOT),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
840 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DEPOT_RAIL, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_TRAIN_DEPOT_FOR_BUILDING),
12422
e05e7e7e34f6 (svn r16856) -Fix: Allow the rail toobar window to align vertically for larger sprites.
alberth <alberth@openttd.org>
parents: 12410
diff changeset
841 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, RTW_BUILD_WAYPOINT),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
842 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_WAYPOINT, STR_RAIL_TOOLBAR_TOOLTIP_CONVERT_RAIL_TO_WAYPOINT),
12422
e05e7e7e34f6 (svn r16856) -Fix: Allow the rail toobar window to align vertically for larger sprites.
alberth <alberth@openttd.org>
parents: 12410
diff changeset
843 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, RTW_BUILD_STATION),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
844 SetFill(0, 1), SetMinimalSize(42, 22), SetDataTip(SPR_IMG_RAIL_STATION, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_STATION),
12422
e05e7e7e34f6 (svn r16856) -Fix: Allow the rail toobar window to align vertically for larger sprites.
alberth <alberth@openttd.org>
parents: 12410
diff changeset
845 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, RTW_BUILD_SIGNALS),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
846 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_RAIL_SIGNALS, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_SIGNALS),
12422
e05e7e7e34f6 (svn r16856) -Fix: Allow the rail toobar window to align vertically for larger sprites.
alberth <alberth@openttd.org>
parents: 12410
diff changeset
847 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, RTW_BUILD_BRIDGE),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
848 SetFill(0, 1), SetMinimalSize(42, 22), SetDataTip(SPR_IMG_BRIDGE, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_BRIDGE),
12422
e05e7e7e34f6 (svn r16856) -Fix: Allow the rail toobar window to align vertically for larger sprites.
alberth <alberth@openttd.org>
parents: 12410
diff changeset
849 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, RTW_BUILD_TUNNEL),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
850 SetFill(0, 1), SetMinimalSize(20, 22), SetDataTip(SPR_IMG_TUNNEL_RAIL, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_TUNNEL),
12422
e05e7e7e34f6 (svn r16856) -Fix: Allow the rail toobar window to align vertically for larger sprites.
alberth <alberth@openttd.org>
parents: 12410
diff changeset
851 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, RTW_REMOVE),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
852 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_RAIL_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR),
12422
e05e7e7e34f6 (svn r16856) -Fix: Allow the rail toobar window to align vertically for larger sprites.
alberth <alberth@openttd.org>
parents: 12410
diff changeset
853 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, RTW_CONVERT_RAIL),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
854 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_CONVERT_RAIL, STR_RAIL_TOOLBAR_TOOLTIP_CONVERT_RAIL),
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
855 EndContainer(),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
856 };
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
857
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
858 static const WindowDesc _build_rail_desc(
13798
6f820ae12bb3 (svn r18324) -Codechange: there's no need for a default size when the window isn't resizable
rubidium <rubidium@openttd.org>
parents: 13796
diff changeset
859 WDP_ALIGN_TOOLBAR, 0, 0,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5860
diff changeset
860 WC_BUILD_TOOLBAR, WC_NONE,
13749
fc3ab8256c95 (svn r18274) -Codechange: remove the unused WDF flags
rubidium <rubidium@openttd.org>
parents: 13716
diff changeset
861 WDF_CONSTRUCTION,
13564
bae287664b02 (svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents: 13186
diff changeset
862 _nested_build_rail_widgets, lengthof(_nested_build_rail_widgets)
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
863 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
864
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
865
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
866 /**
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
867 * Open the build rail toolbar window for a specific rail type.
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
868 * The window may be opened in the 'normal' way by clicking at the rail icon in
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
869 * the main toolbar, or by means of selecting one of the functions of the
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
870 * toolbar. In the latter case, the corresponding widget is also selected.
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
871 *
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
872 * If the terraform toolbar is linked to the toolbar, that window is also opened.
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
873 *
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
874 * @param railtype Rail type to open the window for
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
875 * @param button Widget clicked (\c -1 means no button clicked)
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
876 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
877 void ShowBuildRailToolbar(RailType railtype, int button)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
878 {
11924
fccc9cea27a7 (svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents: 11835
diff changeset
879 if (!Company::IsValidID(_local_company)) return;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
880 if (!ValParamRailtype(railtype)) return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
881
12087
6a834ab923fc (svn r16496) -Codechange: remove one useless dynamic_cast<>
smatz <smatz@openttd.org>
parents: 11959
diff changeset
882 BuildRailToolbarWindow *w = (BuildRailToolbarWindow *)FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL);
6a834ab923fc (svn r16496) -Codechange: remove one useless dynamic_cast<>
smatz <smatz@openttd.org>
parents: 11959
diff changeset
883
11368
82c90cd591ab (svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents: 11361
diff changeset
884 /* don't recreate the window if we're clicking on a button and the window exists. */
12087
6a834ab923fc (svn r16496) -Codechange: remove one useless dynamic_cast<>
smatz <smatz@openttd.org>
parents: 11959
diff changeset
885 if (button < 0 || w == NULL) {
9080
8c913db734c9 (svn r12939) -Codechange: do not use the window proc to determine whether a toolbar is a rail toolbar, but use the window number.
rubidium <rubidium@openttd.org>
parents: 9020
diff changeset
886 DeleteWindowByClass(WC_BUILD_TOOLBAR);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
887 _cur_railtype = railtype;
12329
923c27b30ed6 (svn r16749) -Codechange: Rail toolbar uses nested widget tree only.
alberth <alberth@openttd.org>
parents: 12087
diff changeset
888 w = new BuildRailToolbarWindow(&_build_rail_desc, TRANSPORT_RAIL, railtype);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
889 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
890
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
891 _remove_button_clicked = false;
13752
517d77f53919 (svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents: 13749
diff changeset
892 if (w != NULL && button >= 0) {
9771
2dd0e71c4356 (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium <rubidium@openttd.org>
parents: 9762
diff changeset
893 _rail_build_button_data[button].click_proc(w);
9303
aa452fe94fa0 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium <rubidium@openttd.org>
parents: 9293
diff changeset
894 w->UpdateRemoveWidgetStatus(button + RTW_BUILD_NS);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
895 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
896 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
897
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
898 /* TODO: For custom stations, respect their allowed platforms/lengths bitmasks!
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
899 * --pasky */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
900
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
901 static void HandleStationPlacement(TileIndex start, TileIndex end)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
902 {
12528
a8b8bcd7f03d (svn r16965) -Codechange: use tile area instead of sets of variables for the station joiner code.
rubidium <rubidium@openttd.org>
parents: 12516
diff changeset
903 TileArea ta(start, end);
a8b8bcd7f03d (svn r16965) -Codechange: use tile area instead of sets of variables for the station joiner code.
rubidium <rubidium@openttd.org>
parents: 12516
diff changeset
904 uint numtracks = ta.w;
a8b8bcd7f03d (svn r16965) -Codechange: use tile area instead of sets of variables for the station joiner code.
rubidium <rubidium@openttd.org>
parents: 12516
diff changeset
905 uint platlength = ta.h;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
906
10738
7be25381e84a (svn r15071) -Fix (r14919): When drag&dropping rail-stations with X orientation, distant-join scanned a wrong area for stations.
frosch <frosch@openttd.org>
parents: 10626
diff changeset
907 if (_railstation.orientation == AXIS_X) Swap(numtracks, platlength);
7be25381e84a (svn r15071) -Fix (r14919): When drag&dropping rail-stations with X orientation, distant-join scanned a wrong area for stations.
frosch <frosch@openttd.org>
parents: 10626
diff changeset
908
12528
a8b8bcd7f03d (svn r16965) -Codechange: use tile area instead of sets of variables for the station joiner code.
rubidium <rubidium@openttd.org>
parents: 12516
diff changeset
909 uint32 p1 = _cur_railtype | _railstation.orientation << 4 | numtracks << 8 | platlength << 16 | _ctrl_pressed << 24;
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10611
diff changeset
910 uint32 p2 = _railstation.station_class | _railstation.station_type << 8 | INVALID_STATION << 16;
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10611
diff changeset
911
12552
92b34b5e5b00 (svn r16990) -Codechange: unify some (command) naming w.r.t. stations/waypoints.
rubidium <rubidium@openttd.org>
parents: 12528
diff changeset
912 CommandContainer cmdcont = { ta.tile, p1, p2, CMD_BUILD_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION), CcStation, "" };
12528
a8b8bcd7f03d (svn r16965) -Codechange: use tile area instead of sets of variables for the station joiner code.
rubidium <rubidium@openttd.org>
parents: 12516
diff changeset
913 ShowSelectStationIfNeeded(cmdcont, ta);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
914 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
915
11834
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
916 /** Enum referring to the widgets of the rail stations window */
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
917 enum BuildRailStationWidgets {
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
918 BRSW_BACKGROUND,
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
919
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
920 BRSW_PLATFORM_DIR_X,
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
921 BRSW_PLATFORM_DIR_Y,
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
922
13761
a77efd3589ac (svn r18286) -Fix (r18280): Number of platforms and platform length start with 1.
frosch <frosch@openttd.org>
parents: 13755
diff changeset
923 BRSW_PLATFORM_NUM_1,
11834
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
924 BRSW_PLATFORM_NUM_2,
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
925 BRSW_PLATFORM_NUM_3,
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
926 BRSW_PLATFORM_NUM_4,
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
927 BRSW_PLATFORM_NUM_5,
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
928 BRSW_PLATFORM_NUM_6,
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
929 BRSW_PLATFORM_NUM_7,
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
930
13761
a77efd3589ac (svn r18286) -Fix (r18280): Number of platforms and platform length start with 1.
frosch <frosch@openttd.org>
parents: 13755
diff changeset
931 BRSW_PLATFORM_LEN_1,
11834
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
932 BRSW_PLATFORM_LEN_2,
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
933 BRSW_PLATFORM_LEN_3,
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
934 BRSW_PLATFORM_LEN_4,
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
935 BRSW_PLATFORM_LEN_5,
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
936 BRSW_PLATFORM_LEN_6,
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
937 BRSW_PLATFORM_LEN_7,
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
938
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
939 BRSW_PLATFORM_DRAG_N_DROP,
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
940
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
941 BRSW_HIGHLIGHT_OFF,
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
942 BRSW_HIGHLIGHT_ON,
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
943
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
944 BRSW_NEWST_DROPDOWN,
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
945 BRSW_NEWST_LIST,
13761
a77efd3589ac (svn r18286) -Fix (r18280): Number of platforms and platform length start with 1.
frosch <frosch@openttd.org>
parents: 13755
diff changeset
946 BRSW_NEWST_SCROLL,
a77efd3589ac (svn r18286) -Fix (r18280): Number of platforms and platform length start with 1.
frosch <frosch@openttd.org>
parents: 13755
diff changeset
947
a77efd3589ac (svn r18286) -Fix (r18280): Number of platforms and platform length start with 1.
frosch <frosch@openttd.org>
parents: 13755
diff changeset
948 BRSW_PLATFORM_NUM_BEGIN = BRSW_PLATFORM_NUM_1 - 1,
a77efd3589ac (svn r18286) -Fix (r18280): Number of platforms and platform length start with 1.
frosch <frosch@openttd.org>
parents: 13755
diff changeset
949 BRSW_PLATFORM_LEN_BEGIN = BRSW_PLATFORM_LEN_1 - 1,
11834
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
950 };
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
951
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
952 struct BuildRailStationWindow : public PickerWindowBase {
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
953 private:
12448
ff222c0a40c0 (svn r16882) -Codechange: Introduce a line_height variable in the station picker window.
alberth <alberth@openttd.org>
parents: 12445
diff changeset
954 uint line_height; ///< Height of a single line in the newstation selection matrix (#BRSW_NEWST_LIST widget).
ff222c0a40c0 (svn r16882) -Codechange: Introduce a line_height variable in the station picker window.
alberth <alberth@openttd.org>
parents: 12445
diff changeset
955
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
956 /**
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
957 * Verify whether the currently selected station size is allowed after selecting a new station class/type.
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
958 * If not, change the station size variables ( _settings_client.gui.station_numtracks and _settings_client.gui.station_platlength ).
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
959 * @param statspec Specification of the new station class/type
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
960 */
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
961 void CheckSelectedSize(const StationSpec *statspec)
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
962 {
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
963 if (statspec == NULL || _settings_client.gui.station_dragdrop) return;
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
964
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
965 /* If current number of tracks is not allowed, make it as big as possible (which is always less than currently selected) */
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
966 if (HasBit(statspec->disallowed_platforms, _settings_client.gui.station_numtracks - 1)) {
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
967 this->RaiseWidget(_settings_client.gui.station_numtracks + BRSW_PLATFORM_NUM_BEGIN);
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
968 _settings_client.gui.station_numtracks = 1;
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
969 while (HasBit(statspec->disallowed_platforms, _settings_client.gui.station_numtracks - 1)) {
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
970 _settings_client.gui.station_numtracks++;
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
971 }
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
972 this->LowerWidget(_settings_client.gui.station_numtracks + BRSW_PLATFORM_NUM_BEGIN);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
973 }
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
974
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
975 if (HasBit(statspec->disallowed_lengths, _settings_client.gui.station_platlength - 1)) {
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
976 this->RaiseWidget(_settings_client.gui.station_platlength + BRSW_PLATFORM_LEN_BEGIN);
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
977 _settings_client.gui.station_platlength = 1;
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
978 while (HasBit(statspec->disallowed_lengths, _settings_client.gui.station_platlength - 1)) {
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
979 _settings_client.gui.station_platlength++;
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
980 }
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
981 this->LowerWidget(_settings_client.gui.station_platlength + BRSW_PLATFORM_LEN_BEGIN);
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
982 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
983 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
984
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
985 /** Build a dropdown list of available station classes */
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
986 static DropDownList *BuildStationClassDropDown()
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
987 {
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
988 DropDownList *list = new DropDownList();
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
989
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
990 for (uint i = 0; i < GetNumStationClasses(); i++) {
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
991 if (i == STAT_CLASS_WAYP) continue;
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
992 list->push_back(new DropDownListStringItem(GetStationClassName((StationClassID)i), i, false));
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
993 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
994
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
995 return list;
8295
9b35e1d5ebed (svn r11859) -Codechange: Update newgrf station class dropdown to use new method of generating list.
peter1138 <peter1138@openttd.org>
parents: 8284
diff changeset
996 }
9b35e1d5ebed (svn r11859) -Codechange: Update newgrf station class dropdown to use new method of generating list.
peter1138 <peter1138@openttd.org>
parents: 8284
diff changeset
997
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
998 public:
12464
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
999 BuildRailStationWindow(const WindowDesc *desc, Window *parent, bool newstation) : PickerWindowBase(parent)
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1000 {
12469
933d81fbf8e8 (svn r16906) -Fix (r12939): Child windows of build toolbars were placed inconsistently.
alberth <alberth@openttd.org>
parents: 12464
diff changeset
1001 this->InitNested(desc, TRANSPORT_RAIL);
12448
ff222c0a40c0 (svn r16882) -Codechange: Introduce a line_height variable in the station picker window.
alberth <alberth@openttd.org>
parents: 12445
diff changeset
1002
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1003 this->LowerWidget(_railstation.orientation + BRSW_PLATFORM_DIR_X);
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1004 if (_settings_client.gui.station_dragdrop) {
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1005 this->LowerWidget(BRSW_PLATFORM_DRAG_N_DROP);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1006 } else {
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1007 this->LowerWidget(_settings_client.gui.station_numtracks + BRSW_PLATFORM_NUM_BEGIN);
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1008 this->LowerWidget(_settings_client.gui.station_platlength + BRSW_PLATFORM_LEN_BEGIN);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1009 }
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1010 this->SetWidgetLoweredState(BRSW_HIGHLIGHT_OFF, !_settings_client.gui.station_show_coverage);
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1011 this->SetWidgetLoweredState(BRSW_HIGHLIGHT_ON, _settings_client.gui.station_show_coverage);
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1012
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1013 _railstation.newstations = newstation;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1014
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1015 if (newstation) {
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1016 _railstation.station_count = GetNumCustomStations(_railstation.station_class);
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1017
12880
09381837656b (svn r17372) -Codechange: make the settings, rail and sign GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12815
diff changeset
1018 this->vscroll.SetCount(_railstation.station_count);
13072
75bd67594af2 (svn r17572) -Codechange: Use the Window::GetWidget() function to access nested widgets through the nested_array.
alberth <alberth@openttd.org>
parents: 13036
diff changeset
1019 this->vscroll.SetCapacity(GB(this->GetWidget<NWidgetCore>(BRSW_NEWST_LIST)->widget_data, MAT_ROW_START, MAT_ROW_BITS));
13970
bf79f84b8631 (svn r18508) -Fix [FS#3372]: if a rail station class had less data than capacity it would try to set a negative position
rubidium <rubidium@openttd.org>
parents: 13965
diff changeset
1020 this->vscroll.SetPosition(Clamp(_railstation.station_type - 2, 0, max(this->vscroll.GetCount() - this->vscroll.GetCapacity(), 0)));
11959
cd370db5acc0 (svn r16363) -Fix: The previously selected newgrf station type was still remembered after switching to a different game without newstations enabled, preventing stations from being built.
peter1138 <peter1138@openttd.org>
parents: 11924
diff changeset
1021 } else {
cd370db5acc0 (svn r16363) -Fix: The previously selected newgrf station type was still remembered after switching to a different game without newstations enabled, preventing stations from being built.
peter1138 <peter1138@openttd.org>
parents: 11924
diff changeset
1022 /* New stations are not available, so ensure the default station
cd370db5acc0 (svn r16363) -Fix: The previously selected newgrf station type was still remembered after switching to a different game without newstations enabled, preventing stations from being built.
peter1138 <peter1138@openttd.org>
parents: 11924
diff changeset
1023 * type is 'selected'. */
cd370db5acc0 (svn r16363) -Fix: The previously selected newgrf station type was still remembered after switching to a different game without newstations enabled, preventing stations from being built.
peter1138 <peter1138@openttd.org>
parents: 11924
diff changeset
1024 _railstation.station_class = STAT_CLASS_DFLT;
cd370db5acc0 (svn r16363) -Fix: The previously selected newgrf station type was still remembered after switching to a different game without newstations enabled, preventing stations from being built.
peter1138 <peter1138@openttd.org>
parents: 11924
diff changeset
1025 _railstation.station_type = 0;
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1026 }
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1027 }
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1028
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10611
diff changeset
1029 virtual ~BuildRailStationWindow()
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10611
diff changeset
1030 {
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10611
diff changeset
1031 DeleteWindowById(WC_SELECT_STATION, 0);
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10611
diff changeset
1032 }
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10611
diff changeset
1033
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1034 virtual void OnPaint()
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1035 {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1036 bool newstations = _railstation.newstations;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1037 const StationSpec *statspec = newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1038
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1039 if (_settings_client.gui.station_dragdrop) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1040 SetTileSelectSize(1, 1);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1041 } else {
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1042 int x = _settings_client.gui.station_numtracks;
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1043 int y = _settings_client.gui.station_platlength;
9772
9d8bf03ff7fa (svn r13909) -Codechange: use the same type before CmdBuildRailStation as it used in the command itself (Alberth)
rubidium <rubidium@openttd.org>
parents: 9771
diff changeset
1044 if (_railstation.orientation == AXIS_X) Swap(x, y);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1045 if (!_remove_button_clicked)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1046 SetTileSelectSize(x, y);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1047 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1048
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
1049 int rad = (_settings_game.station.modified_catchment) ? CA_TRAIN : CA_UNMODIFIED;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1050
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1051 if (_settings_client.gui.station_show_coverage)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1052 SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1053
7729
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
1054 for (uint bits = 0; bits < 7; bits++) {
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
1055 bool disable = bits >= _settings_game.station.station_spread;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1056 if (statspec == NULL) {
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1057 this->SetWidgetDisabledState(bits + BRSW_PLATFORM_NUM_1, disable);
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1058 this->SetWidgetDisabledState(bits + BRSW_PLATFORM_LEN_1, disable);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1059 } else {
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1060 this->SetWidgetDisabledState(bits + BRSW_PLATFORM_NUM_1, HasBit(statspec->disallowed_platforms, bits) || disable);
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1061 this->SetWidgetDisabledState(bits + BRSW_PLATFORM_LEN_1, HasBit(statspec->disallowed_lengths, bits) || disable);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1062 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1063 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1064
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1065 this->DrawWidgets();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1066
12464
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1067 /* 'Accepts' and 'Supplies' texts. */
13072
75bd67594af2 (svn r17572) -Codechange: Use the Window::GetWidget() function to access nested widgets through the nested_array.
alberth <alberth@openttd.org>
parents: 13036
diff changeset
1068 int top = this->GetWidget<NWidgetBase>(BRSW_HIGHLIGHT_ON)->pos_y + this->GetWidget<NWidgetBase>(BRSW_HIGHLIGHT_ON)->current_y + WD_PAR_VSEP_NORMAL;
75bd67594af2 (svn r17572) -Codechange: Use the Window::GetWidget() function to access nested widgets through the nested_array.
alberth <alberth@openttd.org>
parents: 13036
diff changeset
1069 NWidgetBase *back_nwi = this->GetWidget<NWidgetBase>(BRSW_BACKGROUND);
12464
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1070 int right = back_nwi->pos_x + back_nwi->current_x;
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1071 int bottom = back_nwi->pos_y + back_nwi->current_y;
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1072 top = DrawStationCoverageAreaText(back_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, false) + WD_PAR_VSEP_NORMAL;
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1073 top = DrawStationCoverageAreaText(back_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, true) + WD_PAR_VSEP_NORMAL;
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1074 /* Resize background if the text is not equally long as the window. */
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1075 if (top > bottom || (top < bottom && back_nwi->current_y > back_nwi->smallest_y)) {
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1076 ResizeWindow(this, 0, top - bottom);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1077 }
12464
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1078 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1079
13705
8dee47e001b2 (svn r18230) -Codechange: Allow fill stepsize to be set from Window::UpdateWidgetSize().
alberth <alberth@openttd.org>
parents: 13704
diff changeset
1080 virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
12499
a8f90a362fc5 (svn r16936) -Fix [FS#3053]: Rail station build window with NewGRFs could crash due to uninitialized string parameter.
alberth <alberth@openttd.org>
parents: 12493
diff changeset
1081 {
12570
79d0f650f0f1 (svn r17008) -Fix [FS#3061]: Resize matrix in station build window vertically according to font height.
alberth <alberth@openttd.org>
parents: 12564
diff changeset
1082 switch (widget) {
79d0f650f0f1 (svn r17008) -Fix [FS#3061]: Resize matrix in station build window vertically according to font height.
alberth <alberth@openttd.org>
parents: 12564
diff changeset
1083 case BRSW_NEWST_DROPDOWN: {
79d0f650f0f1 (svn r17008) -Fix [FS#3061]: Resize matrix in station build window vertically according to font height.
alberth <alberth@openttd.org>
parents: 12564
diff changeset
1084 Dimension d = {0, 0};
79d0f650f0f1 (svn r17008) -Fix [FS#3061]: Resize matrix in station build window vertically according to font height.
alberth <alberth@openttd.org>
parents: 12564
diff changeset
1085 for (uint i = 0; i < GetNumStationClasses(); i++) {
79d0f650f0f1 (svn r17008) -Fix [FS#3061]: Resize matrix in station build window vertically according to font height.
alberth <alberth@openttd.org>
parents: 12564
diff changeset
1086 if (i == STAT_CLASS_WAYP) continue;
79d0f650f0f1 (svn r17008) -Fix [FS#3061]: Resize matrix in station build window vertically according to font height.
alberth <alberth@openttd.org>
parents: 12564
diff changeset
1087 SetDParam(0, GetStationClassName((StationClassID)i));
79d0f650f0f1 (svn r17008) -Fix [FS#3061]: Resize matrix in station build window vertically according to font height.
alberth <alberth@openttd.org>
parents: 12564
diff changeset
1088 d = maxdim(d, GetStringBoundingBox(STR_BLACK_STRING));
79d0f650f0f1 (svn r17008) -Fix [FS#3061]: Resize matrix in station build window vertically according to font height.
alberth <alberth@openttd.org>
parents: 12564
diff changeset
1089 }
79d0f650f0f1 (svn r17008) -Fix [FS#3061]: Resize matrix in station build window vertically according to font height.
alberth <alberth@openttd.org>
parents: 12564
diff changeset
1090 d.width += padding.width;
79d0f650f0f1 (svn r17008) -Fix [FS#3061]: Resize matrix in station build window vertically according to font height.
alberth <alberth@openttd.org>
parents: 12564
diff changeset
1091 d.height += padding.height;
79d0f650f0f1 (svn r17008) -Fix [FS#3061]: Resize matrix in station build window vertically according to font height.
alberth <alberth@openttd.org>
parents: 12564
diff changeset
1092 *size = maxdim(*size, d);
79d0f650f0f1 (svn r17008) -Fix [FS#3061]: Resize matrix in station build window vertically according to font height.
alberth <alberth@openttd.org>
parents: 12564
diff changeset
1093 break;
79d0f650f0f1 (svn r17008) -Fix [FS#3061]: Resize matrix in station build window vertically according to font height.
alberth <alberth@openttd.org>
parents: 12564
diff changeset
1094 }
79d0f650f0f1 (svn r17008) -Fix [FS#3061]: Resize matrix in station build window vertically according to font height.
alberth <alberth@openttd.org>
parents: 12564
diff changeset
1095 case BRSW_NEWST_LIST: {
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12619
diff changeset
1096 Dimension d = GetStringBoundingBox(STR_STATION_CLASS_DFLT);
12578
8d1801a245ad (svn r17018) -Fix [FS#1833]: Take width of station type names into account in station builder window.
alberth <alberth@openttd.org>
parents: 12570
diff changeset
1097 for (StationClassID statclass = STAT_CLASS_BEGIN; statclass < (StationClassID)GetNumStationClasses(); statclass++) {
8d1801a245ad (svn r17018) -Fix [FS#1833]: Take width of station type names into account in station builder window.
alberth <alberth@openttd.org>
parents: 12570
diff changeset
1098 if (statclass == STAT_CLASS_WAYP) continue;
8d1801a245ad (svn r17018) -Fix [FS#1833]: Take width of station type names into account in station builder window.
alberth <alberth@openttd.org>
parents: 12570
diff changeset
1099 for (uint16 j = 0; j < GetNumCustomStations(statclass); j++) {
8d1801a245ad (svn r17018) -Fix [FS#1833]: Take width of station type names into account in station builder window.
alberth <alberth@openttd.org>
parents: 12570
diff changeset
1100 const StationSpec *statspec = GetCustomStationSpec(statclass, j);
8d1801a245ad (svn r17018) -Fix [FS#1833]: Take width of station type names into account in station builder window.
alberth <alberth@openttd.org>
parents: 12570
diff changeset
1101 if (statspec != NULL && statspec->name != 0) d = maxdim(d, GetStringBoundingBox(statspec->name));
8d1801a245ad (svn r17018) -Fix [FS#1833]: Take width of station type names into account in station builder window.
alberth <alberth@openttd.org>
parents: 12570
diff changeset
1102 }
8d1801a245ad (svn r17018) -Fix [FS#1833]: Take width of station type names into account in station builder window.
alberth <alberth@openttd.org>
parents: 12570
diff changeset
1103 }
8d1801a245ad (svn r17018) -Fix [FS#1833]: Take width of station type names into account in station builder window.
alberth <alberth@openttd.org>
parents: 12570
diff changeset
1104 size->width = max(size->width, d.width + padding.width);
8d1801a245ad (svn r17018) -Fix [FS#1833]: Take width of station type names into account in station builder window.
alberth <alberth@openttd.org>
parents: 12570
diff changeset
1105
12570
79d0f650f0f1 (svn r17008) -Fix [FS#3061]: Resize matrix in station build window vertically according to font height.
alberth <alberth@openttd.org>
parents: 12564
diff changeset
1106 this->line_height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM;
13072
75bd67594af2 (svn r17572) -Codechange: Use the Window::GetWidget() function to access nested widgets through the nested_array.
alberth <alberth@openttd.org>
parents: 13036
diff changeset
1107 size->height = GB(this->GetWidget<NWidgetCore>(widget)->widget_data, MAT_ROW_START, MAT_ROW_BITS) * this->line_height;
12570
79d0f650f0f1 (svn r17008) -Fix [FS#3061]: Resize matrix in station build window vertically according to font height.
alberth <alberth@openttd.org>
parents: 12564
diff changeset
1108 break;
79d0f650f0f1 (svn r17008) -Fix [FS#3061]: Resize matrix in station build window vertically according to font height.
alberth <alberth@openttd.org>
parents: 12564
diff changeset
1109 }
12499
a8f90a362fc5 (svn r16936) -Fix [FS#3053]: Rail station build window with NewGRFs could crash due to uninitialized string parameter.
alberth <alberth@openttd.org>
parents: 12493
diff changeset
1110 }
a8f90a362fc5 (svn r16936) -Fix [FS#3053]: Rail station build window with NewGRFs could crash due to uninitialized string parameter.
alberth <alberth@openttd.org>
parents: 12493
diff changeset
1111 }
a8f90a362fc5 (svn r16936) -Fix [FS#3053]: Rail station build window with NewGRFs could crash due to uninitialized string parameter.
alberth <alberth@openttd.org>
parents: 12493
diff changeset
1112
12464
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1113 virtual void DrawWidget(const Rect &r, int widget) const
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1114 {
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1115 DrawPixelInfo tmp_dpi;
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1116
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1117 switch (widget) {
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1118 case BRSW_PLATFORM_DIR_X:
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1119 /* Set up a clipping area for the '/' station preview */
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1120 if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.right - r.left + 1, r.bottom - r.top + 1)) {
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1121 DrawPixelInfo *old_dpi = _cur_dpi;
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1122 _cur_dpi = &tmp_dpi;
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1123 if (!DrawStationTile(32, 16, _cur_railtype, AXIS_X, _railstation.station_class, _railstation.station_type)) {
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1124 StationPickerDrawSprite(32, 16, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 2);
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1125 }
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1126 _cur_dpi = old_dpi;
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1127 }
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1128 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1129
12464
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1130 case BRSW_PLATFORM_DIR_Y:
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1131 /* Set up a clipping area for the '\' station preview */
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1132 if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.right - r.left + 1, r.bottom - r.top + 1)) {
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1133 DrawPixelInfo *old_dpi = _cur_dpi;
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1134 _cur_dpi = &tmp_dpi;
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1135 if (!DrawStationTile(32, 16, _cur_railtype, AXIS_Y, _railstation.station_class, _railstation.station_type)) {
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1136 StationPickerDrawSprite(32, 16, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 3);
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1137 }
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1138 _cur_dpi = old_dpi;
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1139 }
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1140 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1141
12464
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1142 case BRSW_NEWST_LIST: {
12570
79d0f650f0f1 (svn r17008) -Fix [FS#3061]: Resize matrix in station build window vertically according to font height.
alberth <alberth@openttd.org>
parents: 12564
diff changeset
1143 uint y = r.top;
12880
09381837656b (svn r17372) -Codechange: make the settings, rail and sign GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12815
diff changeset
1144 for (uint16 i = this->vscroll.GetPosition(); i < _railstation.station_count && this->vscroll.IsVisible(i); i++) {
12464
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1145 const StationSpec *statspec = GetCustomStationSpec(_railstation.station_class, i);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1146
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12619
diff changeset
1147 StringID str = STR_STATION_CLASS_DFLT;
12464
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1148 if (statspec != NULL && statspec->name != 0) {
13036
8e2a0e8fa275 (svn r17534) -Codechange: unify the naming of callback masks/flags
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
1149 if (HasBit(statspec->callback_mask, CBM_STATION_AVAIL) && GB(GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE), 0, 8) == 0) {
12570
79d0f650f0f1 (svn r17008) -Fix [FS#3061]: Resize matrix in station build window vertically according to font height.
alberth <alberth@openttd.org>
parents: 12564
diff changeset
1150 GfxFillRect(r.left + 1, y + 1, r.right - 1, y + this->line_height - 2, 0, FILLRECT_CHECKER);
12464
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1151 }
12570
79d0f650f0f1 (svn r17008) -Fix [FS#3061]: Resize matrix in station build window vertically according to font height.
alberth <alberth@openttd.org>
parents: 12564
diff changeset
1152 str = statspec->name;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1153 }
12570
79d0f650f0f1 (svn r17008) -Fix [FS#3061]: Resize matrix in station build window vertically according to font height.
alberth <alberth@openttd.org>
parents: 12564
diff changeset
1154 DrawString(r.left + WD_MATRIX_LEFT, r.right - WD_MATRIX_RIGHT, y + WD_MATRIX_TOP, str, i == _railstation.station_type ? TC_WHITE : TC_BLACK);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1155
12464
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1156 y += this->line_height;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1157 }
12464
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1158 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1159 }
12516
49534d3a6b57 (svn r16953) -Codechange: Use SetStringParameters() for simple parameterized strings.
alberth <alberth@openttd.org>
parents: 12501
diff changeset
1160 }
49534d3a6b57 (svn r16953) -Codechange: Use SetStringParameters() for simple parameterized strings.
alberth <alberth@openttd.org>
parents: 12501
diff changeset
1161 }
12499
a8f90a362fc5 (svn r16936) -Fix [FS#3053]: Rail station build window with NewGRFs could crash due to uninitialized string parameter.
alberth <alberth@openttd.org>
parents: 12493
diff changeset
1162
12516
49534d3a6b57 (svn r16953) -Codechange: Use SetStringParameters() for simple parameterized strings.
alberth <alberth@openttd.org>
parents: 12501
diff changeset
1163 virtual void SetStringParameters(int widget) const
49534d3a6b57 (svn r16953) -Codechange: Use SetStringParameters() for simple parameterized strings.
alberth <alberth@openttd.org>
parents: 12501
diff changeset
1164 {
49534d3a6b57 (svn r16953) -Codechange: Use SetStringParameters() for simple parameterized strings.
alberth <alberth@openttd.org>
parents: 12501
diff changeset
1165 if (widget == BRSW_NEWST_DROPDOWN) SetDParam(0, GetStationClassName(_railstation.station_class));
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1166 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1167
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1168 virtual void OnClick(Point pt, int widget)
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1169 {
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1170 switch (widget) {
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1171 case BRSW_PLATFORM_DIR_X:
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1172 case BRSW_PLATFORM_DIR_Y:
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1173 this->RaiseWidget(_railstation.orientation + BRSW_PLATFORM_DIR_X);
9772
9d8bf03ff7fa (svn r13909) -Codechange: use the same type before CmdBuildRailStation as it used in the command itself (Alberth)
rubidium <rubidium@openttd.org>
parents: 9771
diff changeset
1174 _railstation.orientation = (Axis)(widget - BRSW_PLATFORM_DIR_X);
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1175 this->LowerWidget(_railstation.orientation + BRSW_PLATFORM_DIR_X);
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1176 SndPlayFx(SND_15_BEEP);
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1177 this->SetDirty();
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10611
diff changeset
1178 DeleteWindowById(WC_SELECT_STATION, 0);
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1179 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1180
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1181 case BRSW_PLATFORM_NUM_1:
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1182 case BRSW_PLATFORM_NUM_2:
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1183 case BRSW_PLATFORM_NUM_3:
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1184 case BRSW_PLATFORM_NUM_4:
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1185 case BRSW_PLATFORM_NUM_5:
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1186 case BRSW_PLATFORM_NUM_6:
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1187 case BRSW_PLATFORM_NUM_7: {
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1188 this->RaiseWidget(_settings_client.gui.station_numtracks + BRSW_PLATFORM_NUM_BEGIN);
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1189 this->RaiseWidget(BRSW_PLATFORM_DRAG_N_DROP);
6207
37978eaf16dc (svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium <rubidium@openttd.org>
parents: 6117
diff changeset
1190
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1191 _settings_client.gui.station_numtracks = widget - BRSW_PLATFORM_NUM_BEGIN;
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1192 _settings_client.gui.station_dragdrop = false;
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1193
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1194 _settings_client.gui.station_dragdrop = false;
6207
37978eaf16dc (svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium <rubidium@openttd.org>
parents: 6117
diff changeset
1195
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1196 const StationSpec *statspec = _railstation.newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL;
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1197 if (statspec != NULL && HasBit(statspec->disallowed_lengths, _settings_client.gui.station_platlength - 1)) {
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1198 /* The previously selected number of platforms in invalid */
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1199 for (uint i = 0; i < 7; i++) {
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1200 if (!HasBit(statspec->disallowed_lengths, i)) {
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1201 this->RaiseWidget(_settings_client.gui.station_platlength + BRSW_PLATFORM_LEN_BEGIN);
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1202 _settings_client.gui.station_platlength = i + 1;
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1203 break;
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1204 }
6207
37978eaf16dc (svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium <rubidium@openttd.org>
parents: 6117
diff changeset
1205 }
37978eaf16dc (svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium <rubidium@openttd.org>
parents: 6117
diff changeset
1206 }
37978eaf16dc (svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium <rubidium@openttd.org>
parents: 6117
diff changeset
1207
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1208 this->LowerWidget(_settings_client.gui.station_numtracks + BRSW_PLATFORM_NUM_BEGIN);
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1209 this->LowerWidget(_settings_client.gui.station_platlength + BRSW_PLATFORM_LEN_BEGIN);
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1210 SndPlayFx(SND_15_BEEP);
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1211 this->SetDirty();
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10611
diff changeset
1212 DeleteWindowById(WC_SELECT_STATION, 0);
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1213 break;
6207
37978eaf16dc (svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium <rubidium@openttd.org>
parents: 6117
diff changeset
1214 }
37978eaf16dc (svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium <rubidium@openttd.org>
parents: 6117
diff changeset
1215
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1216 case BRSW_PLATFORM_LEN_1:
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1217 case BRSW_PLATFORM_LEN_2:
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1218 case BRSW_PLATFORM_LEN_3:
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1219 case BRSW_PLATFORM_LEN_4:
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1220 case BRSW_PLATFORM_LEN_5:
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1221 case BRSW_PLATFORM_LEN_6:
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1222 case BRSW_PLATFORM_LEN_7: {
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1223 this->RaiseWidget(_settings_client.gui.station_platlength + BRSW_PLATFORM_LEN_BEGIN);
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1224 this->RaiseWidget(BRSW_PLATFORM_DRAG_N_DROP);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1225
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1226 _settings_client.gui.station_platlength = widget - BRSW_PLATFORM_LEN_BEGIN;
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1227 _settings_client.gui.station_dragdrop = false;
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1228
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1229 _settings_client.gui.station_dragdrop = false;
7773
908d789588b1 (svn r11322) -Codechange: select an allowed station size when drag&drop is disabled. Patch by Wolf01.
rubidium <rubidium@openttd.org>
parents: 7729
diff changeset
1230
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1231 const StationSpec *statspec = _railstation.newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL;
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1232 if (statspec != NULL && HasBit(statspec->disallowed_platforms, _settings_client.gui.station_numtracks - 1)) {
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1233 /* The previously selected number of tracks in invalid */
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1234 for (uint i = 0; i < 7; i++) {
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1235 if (!HasBit(statspec->disallowed_platforms, i)) {
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1236 this->RaiseWidget(_settings_client.gui.station_numtracks + BRSW_PLATFORM_NUM_BEGIN);
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1237 _settings_client.gui.station_numtracks = i + 1;
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1238 break;
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1239 }
7773
908d789588b1 (svn r11322) -Codechange: select an allowed station size when drag&drop is disabled. Patch by Wolf01.
rubidium <rubidium@openttd.org>
parents: 7729
diff changeset
1240 }
908d789588b1 (svn r11322) -Codechange: select an allowed station size when drag&drop is disabled. Patch by Wolf01.
rubidium <rubidium@openttd.org>
parents: 7729
diff changeset
1241 }
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1242
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1243 this->LowerWidget(_settings_client.gui.station_numtracks + BRSW_PLATFORM_NUM_BEGIN);
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1244 this->LowerWidget(_settings_client.gui.station_platlength + BRSW_PLATFORM_LEN_BEGIN);
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1245 SndPlayFx(SND_15_BEEP);
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1246 this->SetDirty();
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10611
diff changeset
1247 DeleteWindowById(WC_SELECT_STATION, 0);
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1248 break;
7773
908d789588b1 (svn r11322) -Codechange: select an allowed station size when drag&drop is disabled. Patch by Wolf01.
rubidium <rubidium@openttd.org>
parents: 7729
diff changeset
1249 }
908d789588b1 (svn r11322) -Codechange: select an allowed station size when drag&drop is disabled. Patch by Wolf01.
rubidium <rubidium@openttd.org>
parents: 7729
diff changeset
1250
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1251 case BRSW_PLATFORM_DRAG_N_DROP: {
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1252 _settings_client.gui.station_dragdrop ^= true;
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1253
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1254 this->ToggleWidgetLoweredState(BRSW_PLATFORM_DRAG_N_DROP);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1255
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1256 /* get the first allowed length/number of platforms */
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1257 const StationSpec *statspec = _railstation.newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL;
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1258 if (statspec != NULL && HasBit(statspec->disallowed_lengths, _settings_client.gui.station_platlength - 1)) {
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1259 for (uint i = 0; i < 7; i++) {
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1260 if (!HasBit(statspec->disallowed_lengths, i)) {
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1261 this->RaiseWidget(_settings_client.gui.station_platlength + BRSW_PLATFORM_LEN_BEGIN);
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1262 _settings_client.gui.station_platlength = i + 1;
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1263 break;
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1264 }
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1265 }
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1266 }
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1267 if (statspec != NULL && HasBit(statspec->disallowed_platforms, _settings_client.gui.station_numtracks - 1)) {
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1268 for (uint i = 0; i < 7; i++) {
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1269 if (!HasBit(statspec->disallowed_platforms, i)) {
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1270 this->RaiseWidget(_settings_client.gui.station_numtracks + BRSW_PLATFORM_NUM_BEGIN);
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1271 _settings_client.gui.station_numtracks = i + 1;
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1272 break;
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1273 }
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1274 }
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1275 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1276
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1277 this->SetWidgetLoweredState(_settings_client.gui.station_numtracks + BRSW_PLATFORM_NUM_BEGIN, !_settings_client.gui.station_dragdrop);
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1278 this->SetWidgetLoweredState(_settings_client.gui.station_platlength + BRSW_PLATFORM_LEN_BEGIN, !_settings_client.gui.station_dragdrop);
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1279 SndPlayFx(SND_15_BEEP);
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1280 this->SetDirty();
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10611
diff changeset
1281 DeleteWindowById(WC_SELECT_STATION, 0);
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1282 } break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1283
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1284 case BRSW_HIGHLIGHT_OFF:
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1285 case BRSW_HIGHLIGHT_ON:
10565
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1286 _settings_client.gui.station_show_coverage = (widget != BRSW_HIGHLIGHT_OFF);
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1287
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1288 this->SetWidgetLoweredState(BRSW_HIGHLIGHT_OFF, !_settings_client.gui.station_show_coverage);
fc05c0f28834 (svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)
rubidium <rubidium@openttd.org>
parents: 10530
diff changeset
1289 this->SetWidgetLoweredState(BRSW_HIGHLIGHT_ON, _settings_client.gui.station_show_coverage);
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1290 SndPlayFx(SND_15_BEEP);
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1291 this->SetDirty();
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1292 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1293
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1294 case BRSW_NEWST_DROPDOWN:
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1295 ShowDropDownList(this, BuildStationClassDropDown(), _railstation.station_class, BRSW_NEWST_DROPDOWN);
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1296 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1297
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1298 case BRSW_NEWST_LIST: {
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1299 const StationSpec *statspec;
13072
75bd67594af2 (svn r17572) -Codechange: Use the Window::GetWidget() function to access nested widgets through the nested_array.
alberth <alberth@openttd.org>
parents: 13036
diff changeset
1300 int y = (pt.y - this->GetWidget<NWidgetBase>(BRSW_NEWST_LIST)->pos_y) / this->line_height;
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1301
12880
09381837656b (svn r17372) -Codechange: make the settings, rail and sign GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12815
diff changeset
1302 if (y >= this->vscroll.GetCapacity()) return;
09381837656b (svn r17372) -Codechange: make the settings, rail and sign GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12815
diff changeset
1303 y += this->vscroll.GetPosition();
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1304 if (y >= _railstation.station_count) return;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1305
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1306 /* Check station availability callback */
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1307 statspec = GetCustomStationSpec(_railstation.station_class, y);
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1308 if (statspec != NULL &&
13036
8e2a0e8fa275 (svn r17534) -Codechange: unify the naming of callback masks/flags
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
1309 HasBit(statspec->callback_mask, CBM_STATION_AVAIL) &&
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1310 GB(GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE), 0, 8) == 0) return;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1311
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1312 _railstation.station_type = y;
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1313
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1314 this->CheckSelectedSize(statspec);
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1315
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1316 SndPlayFx(SND_15_BEEP);
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1317 this->SetDirty();
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10611
diff changeset
1318 DeleteWindowById(WC_SELECT_STATION, 0);
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1319 break;
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1320 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1321 }
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1322 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1323
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1324 virtual void OnDropdownSelect(int widget, int index)
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1325 {
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1326 if (_railstation.station_class != index) {
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1327 _railstation.station_class = (StationClassID)index;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1328 _railstation.station_type = 0;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1329 _railstation.station_count = GetNumCustomStations(_railstation.station_class);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1330
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1331 this->CheckSelectedSize(GetCustomStationSpec(_railstation.station_class, _railstation.station_type));
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1332
12880
09381837656b (svn r17372) -Codechange: make the settings, rail and sign GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12815
diff changeset
1333 this->vscroll.SetCount(_railstation.station_count);
09381837656b (svn r17372) -Codechange: make the settings, rail and sign GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12815
diff changeset
1334 this->vscroll.SetPosition(_railstation.station_type);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1335 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1336
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1337 SndPlayFx(SND_15_BEEP);
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1338 this->SetDirty();
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10611
diff changeset
1339 DeleteWindowById(WC_SELECT_STATION, 0);
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1340 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1341
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1342 virtual void OnTick()
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1343 {
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1344 CheckRedrawStationCoverage(this);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1345 }
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1346 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1347
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1348 static const NWidgetPart _nested_station_builder_widgets[] = {
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1349 NWidget(NWID_HORIZONTAL),
13752
517d77f53919 (svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents: 13749
diff changeset
1350 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
517d77f53919 (svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents: 13749
diff changeset
1351 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_RAIL_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1352 EndContainer(),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1353 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BRSW_BACKGROUND),
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
1354 NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(144, 11), SetDataTip(STR_STATION_BUILD_ORIENTATION, STR_NULL), SetPadding(1, 2, 0, 2),
12500
a2a6b7d5affc (svn r16937) -Codechange: Make the station build window look good when resized.
alberth <alberth@openttd.org>
parents: 12499
diff changeset
1355 NWidget(NWID_HORIZONTAL),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1356 NWidget(NWID_SPACER), SetMinimalSize(7, 0), SetFill(1, 0),
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1357 NWidget(WWT_PANEL, COLOUR_GREY, BRSW_PLATFORM_DIR_X), SetMinimalSize(66, 48), SetFill(0, 0), SetDataTip(0x0, STR_STATION_BUILD_RAILROAD_ORIENTATION_TOOLTIP), EndContainer(),
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1358 NWidget(NWID_SPACER), SetMinimalSize(2, 0), SetFill(1, 0),
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1359 NWidget(WWT_PANEL, COLOUR_GREY, BRSW_PLATFORM_DIR_Y), SetMinimalSize(66, 48), SetFill(0, 0), SetDataTip(0x0, STR_STATION_BUILD_RAILROAD_ORIENTATION_TOOLTIP), EndContainer(),
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1360 NWidget(NWID_SPACER), SetMinimalSize(7, 0), SetFill(1, 0),
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1361 EndContainer(),
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
1362 NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(144, 11), SetDataTip(STR_STATION_BUILD_NUMBER_OF_TRACKS, STR_NULL), SetPadding(2, 2, 0, 2),
13965
b9936cadbb95 (svn r18503) -Fix [FS#3370]: the length and platform buttons in the station window weren't always properly centered
rubidium <rubidium@openttd.org>
parents: 13798
diff changeset
1363 NWidget(NWID_HORIZONTAL),
b9936cadbb95 (svn r18503) -Fix [FS#3370]: the length and platform buttons in the station window weren't always properly centered
rubidium <rubidium@openttd.org>
parents: 13798
diff changeset
1364 NWidget(NWID_SPACER), SetFill(1, 0),
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1365 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_PLATFORM_NUM_1), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_1, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1366 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_PLATFORM_NUM_2), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_2, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1367 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_PLATFORM_NUM_3), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_3, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1368 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_PLATFORM_NUM_4), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_4, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1369 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_PLATFORM_NUM_5), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_5, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
12493
32e2de3d509a (svn r16930) -Codechange: more StringID name unification and grouping
rubidium <rubidium@openttd.org>
parents: 12480
diff changeset
1370 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_PLATFORM_NUM_6), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_6, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
32e2de3d509a (svn r16930) -Codechange: more StringID name unification and grouping
rubidium <rubidium@openttd.org>
parents: 12480
diff changeset
1371 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_PLATFORM_NUM_7), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_7, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
13965
b9936cadbb95 (svn r18503) -Fix [FS#3370]: the length and platform buttons in the station window weren't always properly centered
rubidium <rubidium@openttd.org>
parents: 13798
diff changeset
1372 NWidget(NWID_SPACER), SetFill(1, 0),
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1373 EndContainer(),
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
1374 NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(144, 11), SetDataTip(STR_STATION_BUILD_PLATFORM_LENGTH, STR_NULL), SetPadding(2, 2, 0, 2),
13965
b9936cadbb95 (svn r18503) -Fix [FS#3370]: the length and platform buttons in the station window weren't always properly centered
rubidium <rubidium@openttd.org>
parents: 13798
diff changeset
1375 NWidget(NWID_HORIZONTAL),
b9936cadbb95 (svn r18503) -Fix [FS#3370]: the length and platform buttons in the station window weren't always properly centered
rubidium <rubidium@openttd.org>
parents: 13798
diff changeset
1376 NWidget(NWID_SPACER), SetFill(1, 0),
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1377 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_PLATFORM_LEN_1), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_1, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1378 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_PLATFORM_LEN_2), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_2, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1379 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_PLATFORM_LEN_3), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_3, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1380 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_PLATFORM_LEN_4), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_4, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1381 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_PLATFORM_LEN_5), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_5, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
12493
32e2de3d509a (svn r16930) -Codechange: more StringID name unification and grouping
rubidium <rubidium@openttd.org>
parents: 12480
diff changeset
1382 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_PLATFORM_LEN_6), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_6, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
32e2de3d509a (svn r16930) -Codechange: more StringID name unification and grouping
rubidium <rubidium@openttd.org>
parents: 12480
diff changeset
1383 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_PLATFORM_LEN_7), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_7, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
13965
b9936cadbb95 (svn r18503) -Fix [FS#3370]: the length and platform buttons in the station window weren't always properly centered
rubidium <rubidium@openttd.org>
parents: 13798
diff changeset
1384 NWidget(NWID_SPACER), SetFill(1, 0),
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1385 EndContainer(),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1386 NWidget(NWID_SPACER), SetMinimalSize(0, 2),
12500
a2a6b7d5affc (svn r16937) -Codechange: Make the station build window look good when resized.
alberth <alberth@openttd.org>
parents: 12499
diff changeset
1387 NWidget(NWID_HORIZONTAL),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1388 NWidget(NWID_SPACER), SetMinimalSize(2, 0), SetFill(1, 0),
12619
2f530108f787 (svn r17062) -Change: unify the naming of some 125 strings
rubidium <rubidium@openttd.org>
parents: 12616
diff changeset
1389 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_PLATFORM_DRAG_N_DROP), SetMinimalSize(75, 12), SetDataTip(STR_STATION_BUILD_DRAG_DROP, STR_STATION_BUILD_DRAG_DROP_TOOLTIP),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1390 NWidget(NWID_SPACER), SetMinimalSize(2, 0), SetFill(1, 0),
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1391 EndContainer(),
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
1392 NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(144, 11), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetPadding(3, 2, 0, 2),
12500
a2a6b7d5affc (svn r16937) -Codechange: Make the station build window look good when resized.
alberth <alberth@openttd.org>
parents: 12499
diff changeset
1393 NWidget(NWID_HORIZONTAL),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1394 NWidget(NWID_SPACER), SetMinimalSize(2, 0), SetFill(1, 0),
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1395 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_HIGHLIGHT_OFF), SetMinimalSize(60, 12),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1396 SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1397 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_HIGHLIGHT_ON), SetMinimalSize(60, 12),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1398 SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1399 NWidget(NWID_SPACER), SetMinimalSize(2, 0), SetFill(1, 0),
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1400 EndContainer(),
12464
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1401 NWidget(NWID_SPACER), SetMinimalSize(0, 20), SetResize(0, 1),
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1402 EndContainer(),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1403 };
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1404
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1405 static const NWidgetPart _nested_newstation_builder_widgets[] = {
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1406 NWidget(NWID_HORIZONTAL),
13752
517d77f53919 (svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents: 13749
diff changeset
1407 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
517d77f53919 (svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents: 13749
diff changeset
1408 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_RAIL_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1409 EndContainer(),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1410 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BRSW_BACKGROUND),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1411 /* begin newstations gui additions. */
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1412 NWidget(WWT_DROPDOWN, COLOUR_GREY, BRSW_NEWST_DROPDOWN), SetMinimalSize(134, 12), SetFill(1, 0), SetPadding(3, 7, 3, 7), SetDataTip(STR_BLACK_STRING, STR_STATION_BUILD_STATION_CLASS_TOOLTIP),
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1413 NWidget(NWID_HORIZONTAL), SetPIP(7, 0, 7),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1414 NWidget(WWT_MATRIX, COLOUR_GREY, BRSW_NEWST_LIST), SetMinimalSize(122, 71), SetFill(1, 0), SetDataTip(0x501, STR_STATION_BUILD_STATION_TYPE_TOOLTIP),
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1415 NWidget(WWT_SCROLLBAR, COLOUR_GREY, BRSW_NEWST_SCROLL),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1416 EndContainer(),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1417 NWidget(NWID_SPACER), SetMinimalSize(0, 1),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1418 /* end newstations gui additions. */
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
1419 NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(144, 11), SetDataTip(STR_STATION_BUILD_ORIENTATION, STR_NULL), SetPadding(1, 2, 0, 2),
12500
a2a6b7d5affc (svn r16937) -Codechange: Make the station build window look good when resized.
alberth <alberth@openttd.org>
parents: 12499
diff changeset
1420 NWidget(NWID_HORIZONTAL),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1421 NWidget(NWID_SPACER), SetMinimalSize(7, 0), SetFill(1, 0),
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1422 NWidget(WWT_PANEL, COLOUR_GREY, BRSW_PLATFORM_DIR_X), SetMinimalSize(66, 48), SetFill(0, 0), SetDataTip(0x0, STR_STATION_BUILD_RAILROAD_ORIENTATION_TOOLTIP), EndContainer(),
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1423 NWidget(NWID_SPACER), SetMinimalSize(2, 0), SetFill(1, 0),
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1424 NWidget(WWT_PANEL, COLOUR_GREY, BRSW_PLATFORM_DIR_Y), SetMinimalSize(66, 48), SetFill(0, 0), SetDataTip(0x0, STR_STATION_BUILD_RAILROAD_ORIENTATION_TOOLTIP), EndContainer(),
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1425 NWidget(NWID_SPACER), SetMinimalSize(7, 0), SetFill(1, 0),
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1426 EndContainer(),
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
1427 NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(144, 11), SetDataTip(STR_STATION_BUILD_NUMBER_OF_TRACKS, STR_NULL), SetPadding(2, 2, 0, 2),
13986
698552f00a71 (svn r18528) -Fix (FS#3370): Platform length/count buttons not centred when NewGRF stations in use.
peter1138 <peter1138@openttd.org>
parents: 13970
diff changeset
1428 NWidget(NWID_HORIZONTAL),
698552f00a71 (svn r18528) -Fix (FS#3370): Platform length/count buttons not centred when NewGRF stations in use.
peter1138 <peter1138@openttd.org>
parents: 13970
diff changeset
1429 NWidget(NWID_SPACER), SetFill(1, 0),
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1430 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_PLATFORM_NUM_1), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_1, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1431 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_PLATFORM_NUM_2), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_2, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1432 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_PLATFORM_NUM_3), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_3, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1433 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_PLATFORM_NUM_4), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_4, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1434 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_PLATFORM_NUM_5), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_5, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
12493
32e2de3d509a (svn r16930) -Codechange: more StringID name unification and grouping
rubidium <rubidium@openttd.org>
parents: 12480
diff changeset
1435 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_PLATFORM_NUM_6), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_6, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
32e2de3d509a (svn r16930) -Codechange: more StringID name unification and grouping
rubidium <rubidium@openttd.org>
parents: 12480
diff changeset
1436 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_PLATFORM_NUM_7), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_7, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
13986
698552f00a71 (svn r18528) -Fix (FS#3370): Platform length/count buttons not centred when NewGRF stations in use.
peter1138 <peter1138@openttd.org>
parents: 13970
diff changeset
1437 NWidget(NWID_SPACER), SetFill(1, 0),
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1438 EndContainer(),
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
1439 NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(144, 11), SetDataTip(STR_STATION_BUILD_PLATFORM_LENGTH, STR_NULL), SetPadding(2, 2, 0, 2),
13986
698552f00a71 (svn r18528) -Fix (FS#3370): Platform length/count buttons not centred when NewGRF stations in use.
peter1138 <peter1138@openttd.org>
parents: 13970
diff changeset
1440 NWidget(NWID_HORIZONTAL),
698552f00a71 (svn r18528) -Fix (FS#3370): Platform length/count buttons not centred when NewGRF stations in use.
peter1138 <peter1138@openttd.org>
parents: 13970
diff changeset
1441 NWidget(NWID_SPACER), SetFill(1, 0),
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1442 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_PLATFORM_LEN_1), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_1, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1443 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_PLATFORM_LEN_2), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_2, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1444 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_PLATFORM_LEN_3), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_3, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1445 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_PLATFORM_LEN_4), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_4, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1446 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_PLATFORM_LEN_5), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_5, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
12493
32e2de3d509a (svn r16930) -Codechange: more StringID name unification and grouping
rubidium <rubidium@openttd.org>
parents: 12480
diff changeset
1447 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_PLATFORM_LEN_6), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_6, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
32e2de3d509a (svn r16930) -Codechange: more StringID name unification and grouping
rubidium <rubidium@openttd.org>
parents: 12480
diff changeset
1448 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_PLATFORM_LEN_7), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_7, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
13986
698552f00a71 (svn r18528) -Fix (FS#3370): Platform length/count buttons not centred when NewGRF stations in use.
peter1138 <peter1138@openttd.org>
parents: 13970
diff changeset
1449 NWidget(NWID_SPACER), SetFill(1, 0),
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1450 EndContainer(),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1451 NWidget(NWID_SPACER), SetMinimalSize(0, 2),
12500
a2a6b7d5affc (svn r16937) -Codechange: Make the station build window look good when resized.
alberth <alberth@openttd.org>
parents: 12499
diff changeset
1452 NWidget(NWID_HORIZONTAL),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1453 NWidget(NWID_SPACER), SetMinimalSize(2, 0), SetFill(1, 0),
12619
2f530108f787 (svn r17062) -Change: unify the naming of some 125 strings
rubidium <rubidium@openttd.org>
parents: 12616
diff changeset
1454 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_PLATFORM_DRAG_N_DROP), SetMinimalSize(75, 12), SetDataTip(STR_STATION_BUILD_DRAG_DROP, STR_STATION_BUILD_DRAG_DROP_TOOLTIP),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1455 NWidget(NWID_SPACER), SetMinimalSize(2, 0), SetFill(1, 0),
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1456 EndContainer(),
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
1457 NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(144, 11), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetPadding(3, 2, 0, 2),
12500
a2a6b7d5affc (svn r16937) -Codechange: Make the station build window look good when resized.
alberth <alberth@openttd.org>
parents: 12499
diff changeset
1458 NWidget(NWID_HORIZONTAL),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1459 NWidget(NWID_SPACER), SetMinimalSize(2, 0), SetFill(1, 0),
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1460 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_HIGHLIGHT_OFF), SetMinimalSize(60, 12),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1461 SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1462 NWidget(WWT_TEXTBTN, COLOUR_GREY, BRSW_HIGHLIGHT_ON), SetMinimalSize(60, 12),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1463 SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1464 NWidget(NWID_SPACER), SetMinimalSize(2, 0), SetFill(1, 0),
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1465 EndContainer(),
12464
f5a44fd5438b (svn r16898) -Codechange: Station build window uses nested widget tree.
alberth <alberth@openttd.org>
parents: 12448
diff changeset
1466 NWidget(NWID_SPACER), SetMinimalSize(0, 20), SetResize(0, 1),
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1467 EndContainer(),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1468 };
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1469
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
1470 /** High level window description of the default station-build window */
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
1471 static const WindowDesc _station_builder_desc(
13798
6f820ae12bb3 (svn r18324) -Codechange: there's no need for a default size when the window isn't resizable
rubidium <rubidium@openttd.org>
parents: 13796
diff changeset
1472 WDP_AUTO, 0, 0,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1473 WC_BUILD_STATION, WC_BUILD_TOOLBAR,
13749
fc3ab8256c95 (svn r18274) -Codechange: remove the unused WDF flags
rubidium <rubidium@openttd.org>
parents: 13716
diff changeset
1474 WDF_CONSTRUCTION,
13564
bae287664b02 (svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents: 13186
diff changeset
1475 _nested_station_builder_widgets, lengthof(_nested_station_builder_widgets)
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
1476 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1477
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
1478 /** High level window description of the newGRF station-build window */
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
1479 static const WindowDesc _newstation_builder_desc(
13798
6f820ae12bb3 (svn r18324) -Codechange: there's no need for a default size when the window isn't resizable
rubidium <rubidium@openttd.org>
parents: 13796
diff changeset
1480 WDP_AUTO, 0, 0,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1481 WC_BUILD_STATION, WC_BUILD_TOOLBAR,
13749
fc3ab8256c95 (svn r18274) -Codechange: remove the unused WDF flags
rubidium <rubidium@openttd.org>
parents: 13716
diff changeset
1482 WDF_CONSTRUCTION,
13564
bae287664b02 (svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents: 13186
diff changeset
1483 _nested_newstation_builder_widgets, lengthof(_nested_newstation_builder_widgets)
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
1484 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1485
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
1486 /** Open station build window */
9338
9f0982110dda (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch <frosch@openttd.org>
parents: 9317
diff changeset
1487 static void ShowStationBuilder(Window *parent)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1488 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1489 if (GetNumStationClasses() <= 2 && GetNumCustomStations(STAT_CLASS_DFLT) == 1) {
9338
9f0982110dda (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch <frosch@openttd.org>
parents: 9317
diff changeset
1490 new BuildRailStationWindow(&_station_builder_desc, parent, false);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1491 } else {
9338
9f0982110dda (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch <frosch@openttd.org>
parents: 9317
diff changeset
1492 new BuildRailStationWindow(&_newstation_builder_desc, parent, true);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1493 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1494 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1495
7991
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1496 /** Enum referring to the widgets of the signal window */
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1497 enum BuildSignalWidgets {
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1498 BSW_SEMAPHORE_NORM,
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1499 BSW_SEMAPHORE_ENTRY,
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1500 BSW_SEMAPHORE_EXIT,
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1501 BSW_SEMAPHORE_COMBO,
9796
8fd7b4a2b03f (svn r13938) -Codechange [YAPP]: Add the new signals to the build signal GUI. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9794
diff changeset
1502 BSW_SEMAPHORE_PBS,
8fd7b4a2b03f (svn r13938) -Codechange [YAPP]: Add the new signals to the build signal GUI. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9794
diff changeset
1503 BSW_SEMAPHORE_PBS_OWAY,
7991
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1504 BSW_ELECTRIC_NORM,
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1505 BSW_ELECTRIC_ENTRY,
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1506 BSW_ELECTRIC_EXIT,
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1507 BSW_ELECTRIC_COMBO,
9796
8fd7b4a2b03f (svn r13938) -Codechange [YAPP]: Add the new signals to the build signal GUI. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9794
diff changeset
1508 BSW_ELECTRIC_PBS,
8fd7b4a2b03f (svn r13938) -Codechange [YAPP]: Add the new signals to the build signal GUI. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9794
diff changeset
1509 BSW_ELECTRIC_PBS_OWAY,
7991
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1510 BSW_CONVERT,
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1511 BSW_DRAG_SIGNALS_DENSITY,
13153
c56e818d0685 (svn r17658) -Codechange: remove custom drawing of the signal density in the signal GUI
rubidium <rubidium@openttd.org>
parents: 13152
diff changeset
1512 BSW_DRAG_SIGNALS_DENSITY_LABEL,
7991
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1513 BSW_DRAG_SIGNALS_DENSITY_DECREASE,
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1514 BSW_DRAG_SIGNALS_DENSITY_INCREASE,
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1515 };
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1516
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1517 struct BuildSignalWindow : public PickerWindowBase {
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1518 private:
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1519 /**
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1520 * Draw dynamic a signal-sprite in a button in the signal GUI
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1521 * 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)
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1522 *
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1523 * @param widget_index index of this widget in the window
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1524 * @param image the sprite to draw
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1525 */
13154
596f54f80a52 (svn r17659) -Codechange: remove the last custom drawing from the signal GUI
rubidium <rubidium@openttd.org>
parents: 13153
diff changeset
1526 void DrawSignalSprite(byte widget_index, SpriteID image) const
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1527 {
13152
19482cfa7559 (svn r17657) -Fix [FS#3242]: some semaphore signals fell outside of the signal GUI. Now the signals are properly centered which should make that problem go away
rubidium <rubidium@openttd.org>
parents: 13079
diff changeset
1528 /* First get the right image, which is one later for 'green' signals. */
19482cfa7559 (svn r17657) -Fix [FS#3242]: some semaphore signals fell outside of the signal GUI. Now the signals are properly centered which should make that problem go away
rubidium <rubidium@openttd.org>
parents: 13079
diff changeset
1529 image += this->IsWidgetLowered(widget_index);
19482cfa7559 (svn r17657) -Fix [FS#3242]: some semaphore signals fell outside of the signal GUI. Now the signals are properly centered which should make that problem go away
rubidium <rubidium@openttd.org>
parents: 13079
diff changeset
1530
19482cfa7559 (svn r17657) -Fix [FS#3242]: some semaphore signals fell outside of the signal GUI. Now the signals are properly centered which should make that problem go away
rubidium <rubidium@openttd.org>
parents: 13079
diff changeset
1531 /* Next get the actual sprite so we can calculate the right offsets. */
19482cfa7559 (svn r17657) -Fix [FS#3242]: some semaphore signals fell outside of the signal GUI. Now the signals are properly centered which should make that problem go away
rubidium <rubidium@openttd.org>
parents: 13079
diff changeset
1532 const Sprite *sprite = GetSprite(image, ST_NORMAL);
19482cfa7559 (svn r17657) -Fix [FS#3242]: some semaphore signals fell outside of the signal GUI. Now the signals are properly centered which should make that problem go away
rubidium <rubidium@openttd.org>
parents: 13079
diff changeset
1533
19482cfa7559 (svn r17657) -Fix [FS#3242]: some semaphore signals fell outside of the signal GUI. Now the signals are properly centered which should make that problem go away
rubidium <rubidium@openttd.org>
parents: 13079
diff changeset
1534 /* For the x offset we want the sprite to be centered, so undo the offset
19482cfa7559 (svn r17657) -Fix [FS#3242]: some semaphore signals fell outside of the signal GUI. Now the signals are properly centered which should make that problem go away
rubidium <rubidium@openttd.org>
parents: 13079
diff changeset
1535 * for sprite drawing and add half of the sprite's width. For the y offset
19482cfa7559 (svn r17657) -Fix [FS#3242]: some semaphore signals fell outside of the signal GUI. Now the signals are properly centered which should make that problem go away
rubidium <rubidium@openttd.org>
parents: 13079
diff changeset
1536 * we want the sprite to be aligned on the bottom, so again we undo the
19482cfa7559 (svn r17657) -Fix [FS#3242]: some semaphore signals fell outside of the signal GUI. Now the signals are properly centered which should make that problem go away
rubidium <rubidium@openttd.org>
parents: 13079
diff changeset
1537 * offset for sprite drawing and assume it is the bottom of the sprite. */
19482cfa7559 (svn r17657) -Fix [FS#3242]: some semaphore signals fell outside of the signal GUI. Now the signals are properly centered which should make that problem go away
rubidium <rubidium@openttd.org>
parents: 13079
diff changeset
1538 int sprite_center_x_offset = sprite->x_offs + sprite->width / 2;
19482cfa7559 (svn r17657) -Fix [FS#3242]: some semaphore signals fell outside of the signal GUI. Now the signals are properly centered which should make that problem go away
rubidium <rubidium@openttd.org>
parents: 13079
diff changeset
1539 int sprite_bottom_y_offset = sprite->height + sprite->y_offs;
19482cfa7559 (svn r17657) -Fix [FS#3242]: some semaphore signals fell outside of the signal GUI. Now the signals are properly centered which should make that problem go away
rubidium <rubidium@openttd.org>
parents: 13079
diff changeset
1540
19482cfa7559 (svn r17657) -Fix [FS#3242]: some semaphore signals fell outside of the signal GUI. Now the signals are properly centered which should make that problem go away
rubidium <rubidium@openttd.org>
parents: 13079
diff changeset
1541 /* Next we want to know where on the window to draw. Calculate the center
19482cfa7559 (svn r17657) -Fix [FS#3242]: some semaphore signals fell outside of the signal GUI. Now the signals are properly centered which should make that problem go away
rubidium <rubidium@openttd.org>
parents: 13079
diff changeset
1542 * and the bottom of the area to draw. */
19482cfa7559 (svn r17657) -Fix [FS#3242]: some semaphore signals fell outside of the signal GUI. Now the signals are properly centered which should make that problem go away
rubidium <rubidium@openttd.org>
parents: 13079
diff changeset
1543 const NWidgetBase *widget = this->GetWidget<NWidgetBase>(widget_index);
19482cfa7559 (svn r17657) -Fix [FS#3242]: some semaphore signals fell outside of the signal GUI. Now the signals are properly centered which should make that problem go away
rubidium <rubidium@openttd.org>
parents: 13079
diff changeset
1544 int widget_center_x = widget->pos_x + widget->current_x / 2;
19482cfa7559 (svn r17657) -Fix [FS#3242]: some semaphore signals fell outside of the signal GUI. Now the signals are properly centered which should make that problem go away
rubidium <rubidium@openttd.org>
parents: 13079
diff changeset
1545 int widget_bottom_y = widget->pos_y + widget->current_y - 2;
19482cfa7559 (svn r17657) -Fix [FS#3242]: some semaphore signals fell outside of the signal GUI. Now the signals are properly centered which should make that problem go away
rubidium <rubidium@openttd.org>
parents: 13079
diff changeset
1546
19482cfa7559 (svn r17657) -Fix [FS#3242]: some semaphore signals fell outside of the signal GUI. Now the signals are properly centered which should make that problem go away
rubidium <rubidium@openttd.org>
parents: 13079
diff changeset
1547 /* Finally we draw the signal. */
19482cfa7559 (svn r17657) -Fix [FS#3242]: some semaphore signals fell outside of the signal GUI. Now the signals are properly centered which should make that problem go away
rubidium <rubidium@openttd.org>
parents: 13079
diff changeset
1548 DrawSprite(image, PAL_NONE,
19482cfa7559 (svn r17657) -Fix [FS#3242]: some semaphore signals fell outside of the signal GUI. Now the signals are properly centered which should make that problem go away
rubidium <rubidium@openttd.org>
parents: 13079
diff changeset
1549 widget_center_x - sprite_center_x_offset + this->IsWidgetLowered(widget_index),
19482cfa7559 (svn r17657) -Fix [FS#3242]: some semaphore signals fell outside of the signal GUI. Now the signals are properly centered which should make that problem go away
rubidium <rubidium@openttd.org>
parents: 13079
diff changeset
1550 widget_bottom_y - sprite_bottom_y_offset + this->IsWidgetLowered(widget_index));
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1551 }
7991
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1552
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1553 public:
12476
9ddac30cd724 (svn r16913) -Codechange: Signal, train depot, and waypoint windows switched to using nested widget tree.
alberth <alberth@openttd.org>
parents: 12475
diff changeset
1554 BuildSignalWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(parent)
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1555 {
12476
9ddac30cd724 (svn r16913) -Codechange: Signal, train depot, and waypoint windows switched to using nested widget tree.
alberth <alberth@openttd.org>
parents: 12475
diff changeset
1556 this->InitNested(desc, TRANSPORT_RAIL);
13153
c56e818d0685 (svn r17658) -Codechange: remove custom drawing of the signal density in the signal GUI
rubidium <rubidium@openttd.org>
parents: 13152
diff changeset
1557 this->OnInvalidateData();
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1558 };
7991
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1559
13153
c56e818d0685 (svn r17658) -Codechange: remove custom drawing of the signal density in the signal GUI
rubidium <rubidium@openttd.org>
parents: 13152
diff changeset
1560 virtual void SetStringParameters(int widget) const
c56e818d0685 (svn r17658) -Codechange: remove custom drawing of the signal density in the signal GUI
rubidium <rubidium@openttd.org>
parents: 13152
diff changeset
1561 {
c56e818d0685 (svn r17658) -Codechange: remove custom drawing of the signal density in the signal GUI
rubidium <rubidium@openttd.org>
parents: 13152
diff changeset
1562 switch (widget) {
c56e818d0685 (svn r17658) -Codechange: remove custom drawing of the signal density in the signal GUI
rubidium <rubidium@openttd.org>
parents: 13152
diff changeset
1563 case BSW_DRAG_SIGNALS_DENSITY_LABEL:
c56e818d0685 (svn r17658) -Codechange: remove custom drawing of the signal density in the signal GUI
rubidium <rubidium@openttd.org>
parents: 13152
diff changeset
1564 SetDParam(0, _settings_client.gui.drag_signals_density);
c56e818d0685 (svn r17658) -Codechange: remove custom drawing of the signal density in the signal GUI
rubidium <rubidium@openttd.org>
parents: 13152
diff changeset
1565 break;
c56e818d0685 (svn r17658) -Codechange: remove custom drawing of the signal density in the signal GUI
rubidium <rubidium@openttd.org>
parents: 13152
diff changeset
1566 }
c56e818d0685 (svn r17658) -Codechange: remove custom drawing of the signal density in the signal GUI
rubidium <rubidium@openttd.org>
parents: 13152
diff changeset
1567 }
c56e818d0685 (svn r17658) -Codechange: remove custom drawing of the signal density in the signal GUI
rubidium <rubidium@openttd.org>
parents: 13152
diff changeset
1568
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1569 virtual void OnPaint()
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1570 {
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1571 this->DrawWidgets();
13154
596f54f80a52 (svn r17659) -Codechange: remove the last custom drawing from the signal GUI
rubidium <rubidium@openttd.org>
parents: 13153
diff changeset
1572 }
7991
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1573
13154
596f54f80a52 (svn r17659) -Codechange: remove the last custom drawing from the signal GUI
rubidium <rubidium@openttd.org>
parents: 13153
diff changeset
1574 virtual void DrawWidget(const Rect &r, int widget) const
596f54f80a52 (svn r17659) -Codechange: remove the last custom drawing from the signal GUI
rubidium <rubidium@openttd.org>
parents: 13153
diff changeset
1575 {
596f54f80a52 (svn r17659) -Codechange: remove the last custom drawing from the signal GUI
rubidium <rubidium@openttd.org>
parents: 13153
diff changeset
1576 if (IsInsideMM(widget, BSW_SEMAPHORE_NORM, BSW_ELECTRIC_PBS_OWAY + 1)) {
596f54f80a52 (svn r17659) -Codechange: remove the last custom drawing from the signal GUI
rubidium <rubidium@openttd.org>
parents: 13153
diff changeset
1577 /* We need to do some custom sprite widget drawing for the signals. */
596f54f80a52 (svn r17659) -Codechange: remove the last custom drawing from the signal GUI
rubidium <rubidium@openttd.org>
parents: 13153
diff changeset
1578 const SpriteID _signal_lookup[] = {
596f54f80a52 (svn r17659) -Codechange: remove the last custom drawing from the signal GUI
rubidium <rubidium@openttd.org>
parents: 13153
diff changeset
1579 SPR_IMG_SIGNAL_SEMAPHORE_NORM, SPR_IMG_SIGNAL_SEMAPHORE_ENTRY, SPR_IMG_SIGNAL_SEMAPHORE_EXIT,
596f54f80a52 (svn r17659) -Codechange: remove the last custom drawing from the signal GUI
rubidium <rubidium@openttd.org>
parents: 13153
diff changeset
1580 SPR_IMG_SIGNAL_SEMAPHORE_COMBO, SPR_IMG_SIGNAL_SEMAPHORE_PBS, SPR_IMG_SIGNAL_SEMAPHORE_PBS_OWAY,
596f54f80a52 (svn r17659) -Codechange: remove the last custom drawing from the signal GUI
rubidium <rubidium@openttd.org>
parents: 13153
diff changeset
1581
596f54f80a52 (svn r17659) -Codechange: remove the last custom drawing from the signal GUI
rubidium <rubidium@openttd.org>
parents: 13153
diff changeset
1582 SPR_IMG_SIGNAL_ELECTRIC_NORM, SPR_IMG_SIGNAL_ELECTRIC_ENTRY, SPR_IMG_SIGNAL_ELECTRIC_EXIT,
596f54f80a52 (svn r17659) -Codechange: remove the last custom drawing from the signal GUI
rubidium <rubidium@openttd.org>
parents: 13153
diff changeset
1583 SPR_IMG_SIGNAL_ELECTRIC_COMBO, SPR_IMG_SIGNAL_ELECTRIC_PBS, SPR_IMG_SIGNAL_ELECTRIC_PBS_OWAY
596f54f80a52 (svn r17659) -Codechange: remove the last custom drawing from the signal GUI
rubidium <rubidium@openttd.org>
parents: 13153
diff changeset
1584 };
596f54f80a52 (svn r17659) -Codechange: remove the last custom drawing from the signal GUI
rubidium <rubidium@openttd.org>
parents: 13153
diff changeset
1585
596f54f80a52 (svn r17659) -Codechange: remove the last custom drawing from the signal GUI
rubidium <rubidium@openttd.org>
parents: 13153
diff changeset
1586 this->DrawSignalSprite(widget, _signal_lookup[widget - BSW_SEMAPHORE_NORM]);
596f54f80a52 (svn r17659) -Codechange: remove the last custom drawing from the signal GUI
rubidium <rubidium@openttd.org>
parents: 13153
diff changeset
1587 }
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1588 }
7991
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1589
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1590 virtual void OnClick(Point pt, int widget)
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1591 {
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1592 switch (widget) {
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1593 case BSW_SEMAPHORE_NORM:
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1594 case BSW_SEMAPHORE_ENTRY:
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1595 case BSW_SEMAPHORE_EXIT:
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1596 case BSW_SEMAPHORE_COMBO:
9796
8fd7b4a2b03f (svn r13938) -Codechange [YAPP]: Add the new signals to the build signal GUI. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9794
diff changeset
1597 case BSW_SEMAPHORE_PBS:
8fd7b4a2b03f (svn r13938) -Codechange [YAPP]: Add the new signals to the build signal GUI. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9794
diff changeset
1598 case BSW_SEMAPHORE_PBS_OWAY:
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1599 case BSW_ELECTRIC_NORM:
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1600 case BSW_ELECTRIC_ENTRY:
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1601 case BSW_ELECTRIC_EXIT:
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1602 case BSW_ELECTRIC_COMBO:
9796
8fd7b4a2b03f (svn r13938) -Codechange [YAPP]: Add the new signals to the build signal GUI. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9794
diff changeset
1603 case BSW_ELECTRIC_PBS:
8fd7b4a2b03f (svn r13938) -Codechange [YAPP]: Add the new signals to the build signal GUI. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9794
diff changeset
1604 case BSW_ELECTRIC_PBS_OWAY:
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1605 this->RaiseWidget((_cur_signal_variant == SIG_ELECTRIC ? BSW_ELECTRIC_NORM : BSW_SEMAPHORE_NORM) + _cur_signal_type);
7991
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1606
9796
8fd7b4a2b03f (svn r13938) -Codechange [YAPP]: Add the new signals to the build signal GUI. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9794
diff changeset
1607 _cur_signal_type = (SignalType)((uint)((widget - BSW_SEMAPHORE_NORM) % (SIGTYPE_LAST + 1)));
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1608 _cur_signal_variant = widget >= BSW_ELECTRIC_NORM ? SIG_ELECTRIC : SIG_SEMAPHORE;
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1609 break;
7991
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1610
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1611 case BSW_CONVERT:
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1612 _convert_signal_button = !_convert_signal_button;
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1613 break;
7991
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1614
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1615 case BSW_DRAG_SIGNALS_DENSITY_DECREASE:
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
1616 if (_settings_client.gui.drag_signals_density > 1) {
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
1617 _settings_client.gui.drag_signals_density--;
13034
6eb3f749890a (svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents: 13027
diff changeset
1618 SetWindowDirty(WC_GAME_OPTIONS, 0);
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1619 }
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1620 break;
7991
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1621
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1622 case BSW_DRAG_SIGNALS_DENSITY_INCREASE:
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
1623 if (_settings_client.gui.drag_signals_density < 20) {
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
1624 _settings_client.gui.drag_signals_density++;
13034
6eb3f749890a (svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents: 13027
diff changeset
1625 SetWindowDirty(WC_GAME_OPTIONS, 0);
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1626 }
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1627 break;
7991
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1628
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1629 default: break;
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1630 }
7991
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1631
13169
1f44cefc7825 (svn r17674) -Codechange: replace SetDirty + OnInvalidateData with InvalidateData (which does the same). Also call InvalidateData in a few cases where that was actually meant.
rubidium <rubidium@openttd.org>
parents: 13154
diff changeset
1632 this->InvalidateData();
13153
c56e818d0685 (svn r17658) -Codechange: remove custom drawing of the signal density in the signal GUI
rubidium <rubidium@openttd.org>
parents: 13152
diff changeset
1633 }
c56e818d0685 (svn r17658) -Codechange: remove custom drawing of the signal density in the signal GUI
rubidium <rubidium@openttd.org>
parents: 13152
diff changeset
1634
c56e818d0685 (svn r17658) -Codechange: remove custom drawing of the signal density in the signal GUI
rubidium <rubidium@openttd.org>
parents: 13152
diff changeset
1635 virtual void OnInvalidateData(int data = 0)
c56e818d0685 (svn r17658) -Codechange: remove custom drawing of the signal density in the signal GUI
rubidium <rubidium@openttd.org>
parents: 13152
diff changeset
1636 {
c56e818d0685 (svn r17658) -Codechange: remove custom drawing of the signal density in the signal GUI
rubidium <rubidium@openttd.org>
parents: 13152
diff changeset
1637 this->LowerWidget((_cur_signal_variant == SIG_ELECTRIC ? BSW_ELECTRIC_NORM : BSW_SEMAPHORE_NORM) + _cur_signal_type);
c56e818d0685 (svn r17658) -Codechange: remove custom drawing of the signal density in the signal GUI
rubidium <rubidium@openttd.org>
parents: 13152
diff changeset
1638
c56e818d0685 (svn r17658) -Codechange: remove custom drawing of the signal density in the signal GUI
rubidium <rubidium@openttd.org>
parents: 13152
diff changeset
1639 this->SetWidgetLoweredState(BSW_CONVERT, _convert_signal_button);
c56e818d0685 (svn r17658) -Codechange: remove custom drawing of the signal density in the signal GUI
rubidium <rubidium@openttd.org>
parents: 13152
diff changeset
1640
c56e818d0685 (svn r17658) -Codechange: remove custom drawing of the signal density in the signal GUI
rubidium <rubidium@openttd.org>
parents: 13152
diff changeset
1641 this->SetWidgetDisabledState(BSW_DRAG_SIGNALS_DENSITY_DECREASE, _settings_client.gui.drag_signals_density == 1);
c56e818d0685 (svn r17658) -Codechange: remove custom drawing of the signal density in the signal GUI
rubidium <rubidium@openttd.org>
parents: 13152
diff changeset
1642 this->SetWidgetDisabledState(BSW_DRAG_SIGNALS_DENSITY_INCREASE, _settings_client.gui.drag_signals_density == 20);
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1643 }
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1644 };
7991
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1645
12476
9ddac30cd724 (svn r16913) -Codechange: Signal, train depot, and waypoint windows switched to using nested widget tree.
alberth <alberth@openttd.org>
parents: 12475
diff changeset
1646 /** Nested widget definition of the build signal window */
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1647 static const NWidgetPart _nested_signal_builder_widgets[] = {
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1648 NWidget(NWID_HORIZONTAL),
13752
517d77f53919 (svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents: 13749
diff changeset
1649 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
517d77f53919 (svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents: 13749
diff changeset
1650 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_BUILD_SIGNAL_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1651 EndContainer(),
13154
596f54f80a52 (svn r17659) -Codechange: remove the last custom drawing from the signal GUI
rubidium <rubidium@openttd.org>
parents: 13153
diff changeset
1652 NWidget(NWID_VERTICAL, NC_EQUALSIZE),
596f54f80a52 (svn r17659) -Codechange: remove the last custom drawing from the signal GUI
rubidium <rubidium@openttd.org>
parents: 13153
diff changeset
1653 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1654 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BSW_SEMAPHORE_NORM), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_NORM_TOOLTIP), EndContainer(), SetFill(1, 1),
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1655 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BSW_SEMAPHORE_ENTRY), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TOOLTIP), EndContainer(), SetFill(1, 1),
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1656 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BSW_SEMAPHORE_EXIT), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TOOLTIP), EndContainer(), SetFill(1, 1),
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1657 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BSW_SEMAPHORE_COMBO), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TOOLTIP), EndContainer(), SetFill(1, 1),
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1658 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BSW_SEMAPHORE_PBS), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_PBS_TOOLTIP), EndContainer(), SetFill(1, 1),
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1659 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BSW_SEMAPHORE_PBS_OWAY), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_PBS_OWAY_TOOLTIP), EndContainer(), SetFill(1, 1),
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1660 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, BSW_CONVERT), SetDataTip(SPR_IMG_SIGNAL_CONVERT, STR_BUILD_SIGNAL_CONVERT_TOOLTIP), SetFill(1, 1),
13154
596f54f80a52 (svn r17659) -Codechange: remove the last custom drawing from the signal GUI
rubidium <rubidium@openttd.org>
parents: 13153
diff changeset
1661 EndContainer(),
596f54f80a52 (svn r17659) -Codechange: remove the last custom drawing from the signal GUI
rubidium <rubidium@openttd.org>
parents: 13153
diff changeset
1662 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1663 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BSW_ELECTRIC_NORM), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_NORM_TOOLTIP), EndContainer(), SetFill(1, 1),
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1664 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BSW_ELECTRIC_ENTRY), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TOOLTIP), EndContainer(), SetFill(1, 1),
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1665 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BSW_ELECTRIC_EXIT), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_EXIT_TOOLTIP), EndContainer(), SetFill(1, 1),
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1666 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BSW_ELECTRIC_COMBO), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_COMBO_TOOLTIP), EndContainer(), SetFill(1, 1),
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1667 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BSW_ELECTRIC_PBS), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_PBS_TOOLTIP), EndContainer(), SetFill(1, 1),
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1668 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BSW_ELECTRIC_PBS_OWAY), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_PBS_OWAY_TOOLTIP), EndContainer(), SetFill(1, 1),
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1669 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BSW_DRAG_SIGNALS_DENSITY), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_TOOLTIP), SetFill(1, 1),
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1670 NWidget(WWT_LABEL, COLOUR_DARK_GREEN, BSW_DRAG_SIGNALS_DENSITY_LABEL), SetDataTip(STR_ORANGE_INT, STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_TOOLTIP), SetFill(1, 1),
13154
596f54f80a52 (svn r17659) -Codechange: remove the last custom drawing from the signal GUI
rubidium <rubidium@openttd.org>
parents: 13153
diff changeset
1671 NWidget(NWID_HORIZONTAL), SetPIP(2, 0, 2),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1672 NWidget(NWID_SPACER), SetFill(1, 0),
13663
62985032eb6e (svn r18187) -Codechange: make the advanced face selection, custom currency, difficulty, news settings, signal, sign and vehicle details window RTL aware (use the arrow widget)
rubidium <rubidium@openttd.org>
parents: 13628
diff changeset
1673 NWidget(NWID_BUTTON_ARROW, COLOUR_GREY, BSW_DRAG_SIGNALS_DENSITY_DECREASE), SetMinimalSize(9, 12), SetDataTip(AWV_DECREASE, STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_DECREASE_TOOLTIP),
62985032eb6e (svn r18187) -Codechange: make the advanced face selection, custom currency, difficulty, news settings, signal, sign and vehicle details window RTL aware (use the arrow widget)
rubidium <rubidium@openttd.org>
parents: 13628
diff changeset
1674 NWidget(NWID_BUTTON_ARROW, COLOUR_GREY, BSW_DRAG_SIGNALS_DENSITY_INCREASE), SetMinimalSize(9, 12), SetDataTip(AWV_INCREASE, STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_INCREASE_TOOLTIP),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1675 NWidget(NWID_SPACER), SetFill(1, 0),
13154
596f54f80a52 (svn r17659) -Codechange: remove the last custom drawing from the signal GUI
rubidium <rubidium@openttd.org>
parents: 13153
diff changeset
1676 EndContainer(),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13687
diff changeset
1677 NWidget(NWID_SPACER), SetMinimalSize(0, 2), SetFill(1, 0),
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1678 EndContainer(),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1679 EndContainer(),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1680 EndContainer(),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1681 };
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1682
7991
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1683 /** Signal selection window description */
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
1684 static const WindowDesc _signal_builder_desc(
13798
6f820ae12bb3 (svn r18324) -Codechange: there's no need for a default size when the window isn't resizable
rubidium <rubidium@openttd.org>
parents: 13796
diff changeset
1685 WDP_AUTO, 0, 0,
7991
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1686 WC_BUILD_SIGNAL, WC_BUILD_TOOLBAR,
13749
fc3ab8256c95 (svn r18274) -Codechange: remove the unused WDF flags
rubidium <rubidium@openttd.org>
parents: 13716
diff changeset
1687 WDF_UNCLICK_BUTTONS | WDF_CONSTRUCTION,
13564
bae287664b02 (svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents: 13186
diff changeset
1688 _nested_signal_builder_widgets, lengthof(_nested_signal_builder_widgets)
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
1689 );
7991
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1690
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1691 /**
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1692 * Open the signal selection window
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1693 */
9338
9f0982110dda (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch <frosch@openttd.org>
parents: 9317
diff changeset
1694 static void ShowSignalBuilder(Window *parent)
7991
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1695 {
9338
9f0982110dda (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch <frosch@openttd.org>
parents: 9317
diff changeset
1696 new BuildSignalWindow(&_signal_builder_desc, parent);
7991
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1697 }
2b690afd01ca (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium <rubidium@openttd.org>
parents: 7955
diff changeset
1698
11501
e19ae1fe26c0 (svn r15862) -Codechange: New widgets for the road, rail and ship depot guis.
yexo <yexo@openttd.org>
parents: 11467
diff changeset
1699 /** Enum referring to the widgets of the build rail depot window */
e19ae1fe26c0 (svn r15862) -Codechange: New widgets for the road, rail and ship depot guis.
yexo <yexo@openttd.org>
parents: 11467
diff changeset
1700 enum BuildRailDepotWidgets {
e19ae1fe26c0 (svn r15862) -Codechange: New widgets for the road, rail and ship depot guis.
yexo <yexo@openttd.org>
parents: 11467
diff changeset
1701 BRDW_DEPOT_NE,
e19ae1fe26c0 (svn r15862) -Codechange: New widgets for the road, rail and ship depot guis.
yexo <yexo@openttd.org>
parents: 11467
diff changeset
1702 BRDW_DEPOT_SE,
e19ae1fe26c0 (svn r15862) -Codechange: New widgets for the road, rail and ship depot guis.
yexo <yexo@openttd.org>
parents: 11467
diff changeset
1703 BRDW_DEPOT_SW,
e19ae1fe26c0 (svn r15862) -Codechange: New widgets for the road, rail and ship depot guis.
yexo <yexo@openttd.org>
parents: 11467
diff changeset
1704 BRDW_DEPOT_NW,
e19ae1fe26c0 (svn r15862) -Codechange: New widgets for the road, rail and ship depot guis.
yexo <yexo@openttd.org>
parents: 11467
diff changeset
1705 };
e19ae1fe26c0 (svn r15862) -Codechange: New widgets for the road, rail and ship depot guis.
yexo <yexo@openttd.org>
parents: 11467
diff changeset
1706
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1707 struct BuildRailDepotWindow : public PickerWindowBase {
12476
9ddac30cd724 (svn r16913) -Codechange: Signal, train depot, and waypoint windows switched to using nested widget tree.
alberth <alberth@openttd.org>
parents: 12475
diff changeset
1708 BuildRailDepotWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(parent)
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1709 {
12476
9ddac30cd724 (svn r16913) -Codechange: Signal, train depot, and waypoint windows switched to using nested widget tree.
alberth <alberth@openttd.org>
parents: 12475
diff changeset
1710 this->InitNested(desc, TRANSPORT_RAIL);
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1711 this->LowerWidget(_build_depot_direction + BRDW_DEPOT_NE);
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1712 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1713
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1714 virtual void OnPaint()
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1715 {
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1716 this->DrawWidgets();
12815
2c2ff50fc161 (svn r17304) -Codechange: move (more) drawing code out of the rail depot picker's OnPaint.
rubidium <rubidium@openttd.org>
parents: 12789
diff changeset
1717 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1718
12815
2c2ff50fc161 (svn r17304) -Codechange: move (more) drawing code out of the rail depot picker's OnPaint.
rubidium <rubidium@openttd.org>
parents: 12789
diff changeset
1719 virtual void DrawWidget(const Rect &r, int widget) const
2c2ff50fc161 (svn r17304) -Codechange: move (more) drawing code out of the rail depot picker's OnPaint.
rubidium <rubidium@openttd.org>
parents: 12789
diff changeset
1720 {
2c2ff50fc161 (svn r17304) -Codechange: move (more) drawing code out of the rail depot picker's OnPaint.
rubidium <rubidium@openttd.org>
parents: 12789
diff changeset
1721 if (!IsInsideMM(widget, BRDW_DEPOT_NE, BRDW_DEPOT_NW + 1)) return;
2c2ff50fc161 (svn r17304) -Codechange: move (more) drawing code out of the rail depot picker's OnPaint.
rubidium <rubidium@openttd.org>
parents: 12789
diff changeset
1722
2c2ff50fc161 (svn r17304) -Codechange: move (more) drawing code out of the rail depot picker's OnPaint.
rubidium <rubidium@openttd.org>
parents: 12789
diff changeset
1723 DrawTrainDepotSprite(r.left - 1, r.top, widget - BRDW_DEPOT_NE + DIAGDIR_NE, _cur_railtype);
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1724 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1725
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1726 virtual void OnClick(Point pt, int widget)
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1727 {
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1728 switch (widget) {
7729
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
1729 case BRDW_DEPOT_NE:
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
1730 case BRDW_DEPOT_SE:
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
1731 case BRDW_DEPOT_SW:
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
1732 case BRDW_DEPOT_NW:
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1733 this->RaiseWidget(_build_depot_direction + BRDW_DEPOT_NE);
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1734 _build_depot_direction = (DiagDirection)(widget - BRDW_DEPOT_NE);
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1735 this->LowerWidget(_build_depot_direction + BRDW_DEPOT_NE);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1736 SndPlayFx(SND_15_BEEP);
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1737 this->SetDirty();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1738 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1739 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1740 }
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1741 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1742
12476
9ddac30cd724 (svn r16913) -Codechange: Signal, train depot, and waypoint windows switched to using nested widget tree.
alberth <alberth@openttd.org>
parents: 12475
diff changeset
1743 /** Nested widget definition of the build rail depot window */
11501
e19ae1fe26c0 (svn r15862) -Codechange: New widgets for the road, rail and ship depot guis.
yexo <yexo@openttd.org>
parents: 11467
diff changeset
1744 static const NWidgetPart _nested_build_depot_widgets[] = {
e19ae1fe26c0 (svn r15862) -Codechange: New widgets for the road, rail and ship depot guis.
yexo <yexo@openttd.org>
parents: 11467
diff changeset
1745 NWidget(NWID_HORIZONTAL),
13752
517d77f53919 (svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents: 13749
diff changeset
1746 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
517d77f53919 (svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents: 13749
diff changeset
1747 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_BUILD_DEPOT_TRAIN_ORIENTATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
11501
e19ae1fe26c0 (svn r15862) -Codechange: New widgets for the road, rail and ship depot guis.
yexo <yexo@openttd.org>
parents: 11467
diff changeset
1748 EndContainer(),
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
1749 NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
11501
e19ae1fe26c0 (svn r15862) -Codechange: New widgets for the road, rail and ship depot guis.
yexo <yexo@openttd.org>
parents: 11467
diff changeset
1750 NWidget(NWID_SPACER), SetMinimalSize(0, 3),
e19ae1fe26c0 (svn r15862) -Codechange: New widgets for the road, rail and ship depot guis.
yexo <yexo@openttd.org>
parents: 11467
diff changeset
1751 NWidget(NWID_HORIZONTAL_LTR),
13716
f262cbfc0af1 (svn r18241) -Codechange: make the rail depot 'buttons' centered in the window
rubidium <rubidium@openttd.org>
parents: 13705
diff changeset
1752 NWidget(NWID_SPACER), SetMinimalSize(3, 0), SetFill(1, 0),
11501
e19ae1fe26c0 (svn r15862) -Codechange: New widgets for the road, rail and ship depot guis.
yexo <yexo@openttd.org>
parents: 11467
diff changeset
1753 NWidget(NWID_VERTICAL),
12616
9b4919e3c2e9 (svn r17059) -Codechange: Rename a few strings to reflect their usage
yexo <yexo@openttd.org>
parents: 12578
diff changeset
1754 NWidget(WWT_PANEL, COLOUR_GREY, BRDW_DEPOT_NW), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP),
11501
e19ae1fe26c0 (svn r15862) -Codechange: New widgets for the road, rail and ship depot guis.
yexo <yexo@openttd.org>
parents: 11467
diff changeset
1755 EndContainer(),
e19ae1fe26c0 (svn r15862) -Codechange: New widgets for the road, rail and ship depot guis.
yexo <yexo@openttd.org>
parents: 11467
diff changeset
1756 NWidget(NWID_SPACER), SetMinimalSize(0, 2),
12616
9b4919e3c2e9 (svn r17059) -Codechange: Rename a few strings to reflect their usage
yexo <yexo@openttd.org>
parents: 12578
diff changeset
1757 NWidget(WWT_PANEL, COLOUR_GREY, BRDW_DEPOT_SW), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP),
11501
e19ae1fe26c0 (svn r15862) -Codechange: New widgets for the road, rail and ship depot guis.
yexo <yexo@openttd.org>
parents: 11467
diff changeset
1758 EndContainer(),
e19ae1fe26c0 (svn r15862) -Codechange: New widgets for the road, rail and ship depot guis.
yexo <yexo@openttd.org>
parents: 11467
diff changeset
1759 EndContainer(),
e19ae1fe26c0 (svn r15862) -Codechange: New widgets for the road, rail and ship depot guis.
yexo <yexo@openttd.org>
parents: 11467
diff changeset
1760 NWidget(NWID_SPACER), SetMinimalSize(2, 0),
e19ae1fe26c0 (svn r15862) -Codechange: New widgets for the road, rail and ship depot guis.
yexo <yexo@openttd.org>
parents: 11467
diff changeset
1761 NWidget(NWID_VERTICAL),
12616
9b4919e3c2e9 (svn r17059) -Codechange: Rename a few strings to reflect their usage
yexo <yexo@openttd.org>
parents: 12578
diff changeset
1762 NWidget(WWT_PANEL, COLOUR_GREY, BRDW_DEPOT_NE), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP),
11501
e19ae1fe26c0 (svn r15862) -Codechange: New widgets for the road, rail and ship depot guis.
yexo <yexo@openttd.org>
parents: 11467
diff changeset
1763 EndContainer(),
e19ae1fe26c0 (svn r15862) -Codechange: New widgets for the road, rail and ship depot guis.
yexo <yexo@openttd.org>
parents: 11467
diff changeset
1764 NWidget(NWID_SPACER), SetMinimalSize(0, 2),
12616
9b4919e3c2e9 (svn r17059) -Codechange: Rename a few strings to reflect their usage
yexo <yexo@openttd.org>
parents: 12578
diff changeset
1765 NWidget(WWT_PANEL, COLOUR_GREY, BRDW_DEPOT_SE), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP),
11501
e19ae1fe26c0 (svn r15862) -Codechange: New widgets for the road, rail and ship depot guis.
yexo <yexo@openttd.org>
parents: 11467
diff changeset
1766 EndContainer(),
e19ae1fe26c0 (svn r15862) -Codechange: New widgets for the road, rail and ship depot guis.
yexo <yexo@openttd.org>
parents: 11467
diff changeset
1767 EndContainer(),
13716
f262cbfc0af1 (svn r18241) -Codechange: make the rail depot 'buttons' centered in the window
rubidium <rubidium@openttd.org>
parents: 13705
diff changeset
1768 NWidget(NWID_SPACER), SetMinimalSize(3, 0), SetFill(1, 0),
11501
e19ae1fe26c0 (svn r15862) -Codechange: New widgets for the road, rail and ship depot guis.
yexo <yexo@openttd.org>
parents: 11467
diff changeset
1769 EndContainer(),
e19ae1fe26c0 (svn r15862) -Codechange: New widgets for the road, rail and ship depot guis.
yexo <yexo@openttd.org>
parents: 11467
diff changeset
1770 NWidget(NWID_SPACER), SetMinimalSize(0, 3),
e19ae1fe26c0 (svn r15862) -Codechange: New widgets for the road, rail and ship depot guis.
yexo <yexo@openttd.org>
parents: 11467
diff changeset
1771 EndContainer(),
e19ae1fe26c0 (svn r15862) -Codechange: New widgets for the road, rail and ship depot guis.
yexo <yexo@openttd.org>
parents: 11467
diff changeset
1772 };
e19ae1fe26c0 (svn r15862) -Codechange: New widgets for the road, rail and ship depot guis.
yexo <yexo@openttd.org>
parents: 11467
diff changeset
1773
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
1774 static const WindowDesc _build_depot_desc(
13798
6f820ae12bb3 (svn r18324) -Codechange: there's no need for a default size when the window isn't resizable
rubidium <rubidium@openttd.org>
parents: 13796
diff changeset
1775 WDP_AUTO, 0, 0,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1776 WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
13749
fc3ab8256c95 (svn r18274) -Codechange: remove the unused WDF flags
rubidium <rubidium@openttd.org>
parents: 13716
diff changeset
1777 WDF_CONSTRUCTION,
13564
bae287664b02 (svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents: 13186
diff changeset
1778 _nested_build_depot_widgets, lengthof(_nested_build_depot_widgets)
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
1779 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1780
9338
9f0982110dda (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch <frosch@openttd.org>
parents: 9317
diff changeset
1781 static void ShowBuildTrainDepotPicker(Window *parent)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1782 {
9338
9f0982110dda (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch <frosch@openttd.org>
parents: 9317
diff changeset
1783 new BuildRailDepotWindow(&_build_depot_desc, parent);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1784 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1785
11834
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
1786 /** Enum referring to the widgets of the build NewGRF rail waypoint window */
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
1787 enum BuildRailWaypointWidgets {
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
1788 BRWW_WAYPOINT_1,
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
1789 BRWW_WAYPOINT_2,
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
1790 BRWW_WAYPOINT_3,
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
1791 BRWW_WAYPOINT_4,
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
1792 BRWW_WAYPOINT_5,
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
1793 BRWW_SCROLL,
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
1794 };
862cb51fe984 (svn r16224) -Codechange: Move BuildRailStationWidgets and BuildRailWaypointWidgets enums out of their Window structs, extend horizontal scrollbar by 1 pixel.
alberth <alberth@openttd.org>
parents: 11765
diff changeset
1795
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1796 struct BuildRailWaypointWindow : PickerWindowBase {
12476
9ddac30cd724 (svn r16913) -Codechange: Signal, train depot, and waypoint windows switched to using nested widget tree.
alberth <alberth@openttd.org>
parents: 12475
diff changeset
1797 BuildRailWaypointWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(parent)
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1798 {
12476
9ddac30cd724 (svn r16913) -Codechange: Signal, train depot, and waypoint windows switched to using nested widget tree.
alberth <alberth@openttd.org>
parents: 12475
diff changeset
1799 this->InitNested(desc, TRANSPORT_RAIL);
12880
09381837656b (svn r17372) -Codechange: make the settings, rail and sign GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12815
diff changeset
1800 this->hscroll.SetCapacity(5);
09381837656b (svn r17372) -Codechange: make the settings, rail and sign GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12815
diff changeset
1801 this->hscroll.SetCount(_waypoint_count);
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1802 };
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1803
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1804 virtual void OnPaint()
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1805 {
12880
09381837656b (svn r17372) -Codechange: make the settings, rail and sign GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12815
diff changeset
1806 for (uint i = 0; i < this->hscroll.GetCapacity(); i++) {
09381837656b (svn r17372) -Codechange: make the settings, rail and sign GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12815
diff changeset
1807 this->SetWidgetLoweredState(i + BRWW_WAYPOINT_1, (this->hscroll.GetPosition() + i) == _cur_waypoint_type);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1808 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1809
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1810 this->DrawWidgets();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1811
12880
09381837656b (svn r17372) -Codechange: make the settings, rail and sign GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12815
diff changeset
1812 for (uint i = 0; i < this->hscroll.GetCapacity(); i++) {
09381837656b (svn r17372) -Codechange: make the settings, rail and sign GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12815
diff changeset
1813 if (this->hscroll.GetPosition() + i < this->hscroll.GetCount()) {
09381837656b (svn r17372) -Codechange: make the settings, rail and sign GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12815
diff changeset
1814 const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, this->hscroll.GetPosition() + i);
13624
c155f501b3a0 (svn r18148) -Fix: with the waypoint picker the wrong widget was 'grayed' with RTL and the y offset of the grayed area was incorrect for big fonts
rubidium <rubidium@openttd.org>
parents: 13564
diff changeset
1815 NWidgetBase *nw = this->GetWidget<NWidgetBase>(BRWW_WAYPOINT_1 + i);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1816
13624
c155f501b3a0 (svn r18148) -Fix: with the waypoint picker the wrong widget was 'grayed' with RTL and the y offset of the grayed area was incorrect for big fonts
rubidium <rubidium@openttd.org>
parents: 13564
diff changeset
1817 int bottom = nw->pos_y + nw->current_y;
c155f501b3a0 (svn r18148) -Fix: with the waypoint picker the wrong widget was 'grayed' with RTL and the y offset of the grayed area was incorrect for big fonts
rubidium <rubidium@openttd.org>
parents: 13564
diff changeset
1818 DrawWaypointSprite(nw->pos_x + TILE_PIXELS, bottom - TILE_PIXELS, this->hscroll.GetPosition() + i, _cur_railtype);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1819
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1820 if (statspec != NULL &&
13036
8e2a0e8fa275 (svn r17534) -Codechange: unify the naming of callback masks/flags
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
1821 HasBit(statspec->callback_mask, CBM_STATION_AVAIL) &&
9020
94bb527c979f (svn r12819) -Codechange: handle more NewGRFs in the same way as TTDP does it, i.e. testing the low bits for 0xFF or 0 instead of all bits.
rubidium <rubidium@openttd.org>
parents: 8973
diff changeset
1822 GB(GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE), 0, 8) == 0) {
13624
c155f501b3a0 (svn r18148) -Fix: with the waypoint picker the wrong widget was 'grayed' with RTL and the y offset of the grayed area was incorrect for big fonts
rubidium <rubidium@openttd.org>
parents: 13564
diff changeset
1823 GfxFillRect(nw->pos_x + 1, nw->pos_y + 1, nw->pos_x + nw->current_x - 2, bottom - 2, 0, FILLRECT_CHECKER);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1824 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1825 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1826 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1827 }
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1828
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1829 virtual void OnClick(Point pt, int widget)
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1830 {
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1831 switch (widget) {
7729
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
1832 case BRWW_WAYPOINT_1:
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
1833 case BRWW_WAYPOINT_2:
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
1834 case BRWW_WAYPOINT_3:
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
1835 case BRWW_WAYPOINT_4:
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
1836 case BRWW_WAYPOINT_5: {
12880
09381837656b (svn r17372) -Codechange: make the settings, rail and sign GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12815
diff changeset
1837 byte type = widget - BRWW_WAYPOINT_1 + this->hscroll.GetPosition();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1838
7729
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
1839 /* Check station availability callback */
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
1840 const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, type);
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
1841 if (statspec != NULL &&
13036
8e2a0e8fa275 (svn r17534) -Codechange: unify the naming of callback masks/flags
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
1842 HasBit(statspec->callback_mask, CBM_STATION_AVAIL) &&
9020
94bb527c979f (svn r12819) -Codechange: handle more NewGRFs in the same way as TTDP does it, i.e. testing the low bits for 0xFF or 0 instead of all bits.
rubidium <rubidium@openttd.org>
parents: 8973
diff changeset
1843 GB(GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE), 0, 8) == 0) return;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1844
7729
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
1845 _cur_waypoint_type = type;
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
1846 SndPlayFx(SND_15_BEEP);
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1847 this->SetDirty();
7729
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
1848 break;
0eeced3fd703 (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium <rubidium@openttd.org>
parents: 7521
diff changeset
1849 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1850 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1851 }
9276
5c0140f35dd7 (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx <glx@openttd.org>
parents: 9273
diff changeset
1852 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1853
12476
9ddac30cd724 (svn r16913) -Codechange: Signal, train depot, and waypoint windows switched to using nested widget tree.
alberth <alberth@openttd.org>
parents: 12475
diff changeset
1854 /** Nested widget definition for the build NewGRF rail waypoint window */
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1855 static const NWidgetPart _nested_build_waypoint_widgets[] = {
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1856 NWidget(NWID_HORIZONTAL),
13752
517d77f53919 (svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents: 13749
diff changeset
1857 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
517d77f53919 (svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents: 13749
diff changeset
1858 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_WAYPOINT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1859 EndContainer(),
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
1860 NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1861 NWidget(NWID_SPACER), SetMinimalSize(0, 3),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1862 NWidget(NWID_HORIZONTAL), SetPIP(3, 2, 3),
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12619
diff changeset
1863 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BRWW_WAYPOINT_1), SetMinimalSize(66, 60), SetDataTip(0x0, STR_WAYPOINT_GRAPHICS_TOOLTIP), EndContainer(),
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12619
diff changeset
1864 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BRWW_WAYPOINT_2), SetMinimalSize(66, 60), SetDataTip(0x0, STR_WAYPOINT_GRAPHICS_TOOLTIP), EndContainer(),
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12619
diff changeset
1865 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BRWW_WAYPOINT_3), SetMinimalSize(66, 60), SetDataTip(0x0, STR_WAYPOINT_GRAPHICS_TOOLTIP), EndContainer(),
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12619
diff changeset
1866 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BRWW_WAYPOINT_4), SetMinimalSize(66, 60), SetDataTip(0x0, STR_WAYPOINT_GRAPHICS_TOOLTIP), EndContainer(),
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12619
diff changeset
1867 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BRWW_WAYPOINT_5), SetMinimalSize(66, 60), SetDataTip(0x0, STR_WAYPOINT_GRAPHICS_TOOLTIP), EndContainer(),
11835
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1868 EndContainer(),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1869 NWidget(NWID_SPACER), SetMinimalSize(0, 3),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1870 NWidget(WWT_HSCROLLBAR, COLOUR_DARK_GREEN, BRWW_SCROLL),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1871 EndContainer(),
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1872 };
e89f5d641c93 (svn r16225) -Codechange: Added nested widgets to all rail_gui windows (except the build depot window).
alberth <alberth@openttd.org>
parents: 11834
diff changeset
1873
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
1874 static const WindowDesc _build_waypoint_desc(
13798
6f820ae12bb3 (svn r18324) -Codechange: there's no need for a default size when the window isn't resizable
rubidium <rubidium@openttd.org>
parents: 13796
diff changeset
1875 WDP_AUTO, 0, 0,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1876 WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
13749
fc3ab8256c95 (svn r18274) -Codechange: remove the unused WDF flags
rubidium <rubidium@openttd.org>
parents: 13716
diff changeset
1877 WDF_CONSTRUCTION,
13564
bae287664b02 (svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents: 13186
diff changeset
1878 _nested_build_waypoint_widgets, lengthof(_nested_build_waypoint_widgets)
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
1879 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1880
9338
9f0982110dda (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch <frosch@openttd.org>
parents: 9317
diff changeset
1881 static void ShowBuildWaypointPicker(Window *parent)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1882 {
9338
9f0982110dda (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch <frosch@openttd.org>
parents: 9317
diff changeset
1883 new BuildRailWaypointWindow(&_build_waypoint_desc, parent);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1884 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1885
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
1886 /**
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
1887 * Initialize rail building GUI settings
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
1888 */
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6207
diff changeset
1889 void InitializeRailGui()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1890 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1891 _build_depot_direction = DIAGDIR_NW;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1892 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1893
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
1894 /**
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
1895 * Re-initialize rail-build toolbar after toggling support for electric trains
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
1896 * @param disable Boolean whether electric trains are disabled (removed from the game)
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
1897 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1898 void ReinitGuiAfterToggleElrail(bool disable)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1899 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1900 extern RailType _last_built_railtype;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1901 if (disable && _last_built_railtype == RAILTYPE_ELECTRIC) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1902 _last_built_railtype = _cur_railtype = RAILTYPE_RAIL;
12329
923c27b30ed6 (svn r16749) -Codechange: Rail toolbar uses nested widget tree only.
alberth <alberth@openttd.org>
parents: 12087
diff changeset
1903 BuildRailToolbarWindow *w = dynamic_cast<BuildRailToolbarWindow *>(FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL));
923c27b30ed6 (svn r16749) -Codechange: Rail toolbar uses nested widget tree only.
alberth <alberth@openttd.org>
parents: 12087
diff changeset
1904 if (w != NULL) w->ModifyRailType(_cur_railtype);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1905 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1906 MarkWholeScreenDirty();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1907 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1908
9314
93a764ca7ec7 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 9303
diff changeset
1909 /** Set the initial (default) railtype to use */
8809
6f39a645401a (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz <smatz@openttd.org>
parents: 8808
diff changeset
1910 static void SetDefaultRailGui()
7064
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1911 {
11924
fccc9cea27a7 (svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents: 11835
diff changeset
1912 if (_local_company == COMPANY_SPECTATOR || !Company::IsValidID(_local_company)) return;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1913
7064
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1914 extern RailType _last_built_railtype;
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
1915 RailType rt = (RailType)_settings_client.gui.default_rail_type;
7064
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1916 if (rt >= RAILTYPE_END) {
12480
2bd521d1ddd7 (svn r16917) -Codechange: fix some GCC 4.5 'case X is not in enum Y' warnings
rubidium <rubidium@openttd.org>
parents: 12476
diff changeset
1917 if (rt == DEF_RAILTYPE_MOST_USED) {
7064
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1918 /* Find the most used rail type */
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1919 RailType count[RAILTYPE_END];
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1920 memset(count, 0, sizeof(count));
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1921 for (TileIndex t = 0; t < MapSize(); t++) {
12501
44606771f552 (svn r16938) -Codechange: introduce helper function to tell whether a tile is either a rail station or rail waypoint tile
rubidium <rubidium@openttd.org>
parents: 12500
diff changeset
1922 if (IsTileType(t, MP_RAILWAY) || IsLevelCrossingTile(t) || HasStationTileRail(t) ||
8088
5d7c61206209 (svn r11649) -Codechange: some code can be simplified thanks to changes in r11642
smatz <smatz@openttd.org>
parents: 8083
diff changeset
1923 (IsTileType(t, MP_TUNNELBRIDGE) && GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL)) {
7064
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1924 count[GetRailType(t)]++;
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1925 }
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1926 }
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1927
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1928 rt = RAILTYPE_RAIL;
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1929 for (RailType r = RAILTYPE_ELECTRIC; r < RAILTYPE_END; r++) {
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1930 if (count[r] >= count[rt]) rt = r;
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1931 }
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1932
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1933 /* No rail, just get the first available one */
12480
2bd521d1ddd7 (svn r16917) -Codechange: fix some GCC 4.5 'case X is not in enum Y' warnings
rubidium <rubidium@openttd.org>
parents: 12476
diff changeset
1934 if (count[rt] == 0) rt = DEF_RAILTYPE_FIRST;
7064
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1935 }
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1936 switch (rt) {
12480
2bd521d1ddd7 (svn r16917) -Codechange: fix some GCC 4.5 'case X is not in enum Y' warnings
rubidium <rubidium@openttd.org>
parents: 12476
diff changeset
1937 case DEF_RAILTYPE_FIRST:
7064
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1938 rt = RAILTYPE_RAIL;
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 9886
diff changeset
1939 while (rt < RAILTYPE_END && !HasRailtypeAvail(_local_company, rt)) rt++;
7064
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1940 break;
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1941
12480
2bd521d1ddd7 (svn r16917) -Codechange: fix some GCC 4.5 'case X is not in enum Y' warnings
rubidium <rubidium@openttd.org>
parents: 12476
diff changeset
1942 case DEF_RAILTYPE_LAST:
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 9886
diff changeset
1943 rt = GetBestRailtype(_local_company);
7064
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1944 break;
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1945
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1946 default:
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1947 break;
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1948 }
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1949 }
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1950
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1951 _last_built_railtype = _cur_railtype = rt;
12329
923c27b30ed6 (svn r16749) -Codechange: Rail toolbar uses nested widget tree only.
alberth <alberth@openttd.org>
parents: 12087
diff changeset
1952 BuildRailToolbarWindow *w = dynamic_cast<BuildRailToolbarWindow *>(FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL));
923c27b30ed6 (svn r16749) -Codechange: Rail toolbar uses nested widget tree only.
alberth <alberth@openttd.org>
parents: 12087
diff changeset
1953 if (w != NULL) w->ModifyRailType(_cur_railtype);
7064
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1954 }
a1b4950870eb (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium <rubidium@openttd.org>
parents: 6863
diff changeset
1955
8809
6f39a645401a (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz <smatz@openttd.org>
parents: 8808
diff changeset
1956 /**
6f39a645401a (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz <smatz@openttd.org>
parents: 8808
diff changeset
1957 * Updates the current signal variant used in the signal GUI
6f39a645401a (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz <smatz@openttd.org>
parents: 8808
diff changeset
1958 * to the one adequate to current year.
13079
090bac35e7e4 (svn r17579) -Fix: remove doxygen docs for removed parameters, or change @param to @tparam if necessary
rubidium <rubidium@openttd.org>
parents: 13072
diff changeset
1959 * @param p needed to be called when a setting changes
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10998
diff changeset
1960 * @return success, needed for settings
8809
6f39a645401a (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz <smatz@openttd.org>
parents: 8808
diff changeset
1961 */
13079
090bac35e7e4 (svn r17579) -Fix: remove doxygen docs for removed parameters, or change @param to @tparam if necessary
rubidium <rubidium@openttd.org>
parents: 13072
diff changeset
1962 bool ResetSignalVariant(int32 p = 0)
8809
6f39a645401a (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz <smatz@openttd.org>
parents: 8808
diff changeset
1963 {
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
1964 SignalVariant new_variant = (_cur_year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC);
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7773
diff changeset
1965
8809
6f39a645401a (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz <smatz@openttd.org>
parents: 8808
diff changeset
1966 if (new_variant != _cur_signal_variant) {
6f39a645401a (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz <smatz@openttd.org>
parents: 8808
diff changeset
1967 Window *w = FindWindowById(WC_BUILD_SIGNAL, 0);
6f39a645401a (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz <smatz@openttd.org>
parents: 8808
diff changeset
1968 if (w != NULL) {
9116
44beb31166aa (svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium <rubidium@openttd.org>
parents: 9115
diff changeset
1969 w->SetDirty();
8809
6f39a645401a (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz <smatz@openttd.org>
parents: 8808
diff changeset
1970 w->RaiseWidget((_cur_signal_variant == SIG_ELECTRIC ? BSW_ELECTRIC_NORM : BSW_SEMAPHORE_NORM) + _cur_signal_type);
6f39a645401a (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz <smatz@openttd.org>
parents: 8808
diff changeset
1971 }
6f39a645401a (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz <smatz@openttd.org>
parents: 8808
diff changeset
1972 _cur_signal_variant = new_variant;
6f39a645401a (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz <smatz@openttd.org>
parents: 8808
diff changeset
1973 }
8557
b78d027fd703 (svn r12135) -Codechange: Road and rail bridge selection windows were identical apart the caption. So remove one window definition and set manually the caption accordingly.
belugas <belugas@openttd.org>
parents: 8424
diff changeset
1974
10994
96a56d561b64 (svn r15334) -Codechange: reset setting to old value when the callback procedure returns false
smatz <smatz@openttd.org>
parents: 10960
diff changeset
1975 return true;
8809
6f39a645401a (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz <smatz@openttd.org>
parents: 8808
diff changeset
1976 }
6f39a645401a (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz <smatz@openttd.org>
parents: 8808
diff changeset
1977
6f39a645401a (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz <smatz@openttd.org>
parents: 8808
diff changeset
1978 /** Resets the rail GUI - sets default railtype to build
6f39a645401a (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz <smatz@openttd.org>
parents: 8808
diff changeset
1979 * and resets the signal GUI
6f39a645401a (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz <smatz@openttd.org>
parents: 8808
diff changeset
1980 */
6f39a645401a (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz <smatz@openttd.org>
parents: 8808
diff changeset
1981 void InitializeRailGUI()
6f39a645401a (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz <smatz@openttd.org>
parents: 8808
diff changeset
1982 {
6f39a645401a (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz <smatz@openttd.org>
parents: 8808
diff changeset
1983 SetDefaultRailGui();
6f39a645401a (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz <smatz@openttd.org>
parents: 8808
diff changeset
1984
6f39a645401a (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz <smatz@openttd.org>
parents: 8808
diff changeset
1985 _convert_signal_button = false;
9796
8fd7b4a2b03f (svn r13938) -Codechange [YAPP]: Add the new signals to the build signal GUI. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9794
diff changeset
1986 _cur_signal_type = _default_signal_type[_settings_client.gui.default_signal_type];
8809
6f39a645401a (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz <smatz@openttd.org>
parents: 8808
diff changeset
1987 ResetSignalVariant();
6f39a645401a (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz <smatz@openttd.org>
parents: 8808
diff changeset
1988 }