src/rail_gui.cpp
author Tero Marttila <terom@fixme.fi>
Fri, 19 Dec 2008 02:13:39 +0200
changeset 10440 0a91ea45b0e8
parent 10208 72c00af5c95d
permissions -rw-r--r--
adjust the random land gen a bit to work with mini-maps
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
6117
6507b2a7e71d (svn r8853) -Cleanup: doxygen changes. Correct forgotten c files to cpp files with the @file tag as well as a few general comments style
belugas
parents: 6106
diff changeset
     3
/** @file rail_gui.cpp File for dealing with rail construction user interface */
2274
2c99425c1086 (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2186
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
9772
eeb3d3284895 (svn r13909) -Codechange: use the same type before CmdBuildRailStation as it used in the command itself (Alberth)
rubidium
parents: 9771
diff changeset
     6
#include "direction_type.h"
1891
862800791170 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1884
diff changeset
     7
#include "openttd.h"
8119
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 8116
diff changeset
     8
#include "tile_cmd.h"
6453
226bcddeba32 (svn r9609) -Codechange: Move some function prototypes out of functions.h and into landscape.h, and add a few where they didn't exist.
maedhros
parents: 6247
diff changeset
     9
#include "landscape.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    10
#include "gui.h"
8107
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
    11
#include "window_gui.h"
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
    12
#include "station_gui.h"
8205
2bde724f1b5d (svn r11768) -Codechange: move some terraform related gui stuff from main_gui.cpp to terraform_gui.cpp (and introduce terraform_gui.h). Based on a patch by Roujin.
rubidium
parents: 8157
diff changeset
    13
#include "terraform_gui.h"
8224
c5a64d87cc54 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8205
diff changeset
    14
#include "viewport_func.h"
c5a64d87cc54 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8205
diff changeset
    15
#include "gfx_func.h"
8116
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8114
diff changeset
    16
#include "command_func.h"
8785
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents: 8616
diff changeset
    17
#include "town_type.h"
1542
62a03537ad0b (svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents: 1363
diff changeset
    18
#include "waypoint.h"
1738
dfa8f078450a (svn r2242) -Fix: [ 1193414 ] Fix for waypoint GUI, scrolling and button-actions (Hackykid)
Darkvater
parents: 1656
diff changeset
    19
#include "debug.h"
2159
f6284cf5fab0 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2049
diff changeset
    20
#include "variables.h"
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
    21
#include "newgrf_callbacks.h"
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
    22
#include "newgrf_station.h"
5116
3c0c3da214ca (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 5105
diff changeset
    23
#include "train.h"
8114
dd6d21dc99c1 (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8108
diff changeset
    24
#include "strings_func.h"
8131
160939e24ed3 (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents: 8128
diff changeset
    25
#include "functions.h"
160939e24ed3 (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents: 8128
diff changeset
    26
#include "window_func.h"
8140
0d0d8c94f84b (svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents: 8139
diff changeset
    27
#include "date_func.h"
8157
1505def01945 (svn r11719) -Codechange: split sound.h in a header with types and one with functions.
rubidium
parents: 8144
diff changeset
    28
#include "sound_func.h"
10208
72c00af5c95d (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium
parents: 10207
diff changeset
    29
#include "company_func.h"
8270
e7c342f6b14c (svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents: 8264
diff changeset
    30
#include "settings_type.h"
8295
70fa977c9c65 (svn r11859) -Codechange: Update newgrf station class dropdown to use new method of generating list.
peter1138
parents: 8284
diff changeset
    31
#include "widgets/dropdown_type.h"
8284
ebdc5ba08874 (svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents: 8270
diff changeset
    32
#include "widgets/dropdown_func.h"
8973
749e572f9378 (svn r12765) -Codechange: move some stuff out of variables.h that required including other headers in variables.h.
rubidium
parents: 8846
diff changeset
    33
#include "tunnelbridge.h"
9127
14f21c5954ee (svn r12987) -Codechange: split viewport and tile selection.
rubidium
parents: 9116
diff changeset
    34
#include "tilehighlight_func.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    35
7064
81d35e1f3e37 (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
parents: 6863
diff changeset
    36
#include "bridge_map.h"
81d35e1f3e37 (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
parents: 6863
diff changeset
    37
#include "rail_map.h"
81d35e1f3e37 (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
parents: 6863
diff changeset
    38
#include "road_map.h"
81d35e1f3e37 (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
parents: 6863
diff changeset
    39
#include "station_map.h"
81d35e1f3e37 (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
parents: 6863
diff changeset
    40
#include "tunnel_map.h"
8083
ad22eade501f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents: 8032
diff changeset
    41
#include "tunnelbridge_map.h"
ad22eade501f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents: 8032
diff changeset
    42
8264
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    43
#include "table/sprites.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    44
#include "table/strings.h"
7064
81d35e1f3e37 (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
parents: 6863
diff changeset
    45
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
    46
static RailType _cur_railtype;               ///< Rail type of the current build-rail toolbar.
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
    47
static bool _remove_button_clicked;          ///< Flag whether 'remove' toggle-button is currently enabled
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
    48
static DiagDirection _build_depot_direction; ///< Currently selected depot direction
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
    49
static byte _waypoint_count = 1;             ///< Number of waypoint types
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
    50
static byte _cur_waypoint_type;              ///< Currently selected waypoint type
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
    51
static bool _convert_signal_button;          ///< convert signal button in the signal GUI pressed
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
    52
static SignalVariant _cur_signal_variant;    ///< set the signal variant (for signal GUI)
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
    53
static SignalType _cur_signal_type;          ///< set the signal type (for signal GUI)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    54
9793
359d2460833b (svn r13935) -Codechange [YAPP]: PBS signals can now be built with the normal signal tools. (michi_cc)
rubidium
parents: 9772
diff changeset
    55
/* Map _patches.default_signal_type to the corresponding signal type */
359d2460833b (svn r13935) -Codechange [YAPP]: PBS signals can now be built with the normal signal tools. (michi_cc)
rubidium
parents: 9772
diff changeset
    56
static const SignalType _default_signal_type[] = {SIGTYPE_NORMAL, SIGTYPE_PBS, SIGTYPE_PBS_ONEWAY};
359d2460833b (svn r13935) -Codechange [YAPP]: PBS signals can now be built with the normal signal tools. (michi_cc)
rubidium
parents: 9772
diff changeset
    57
9772
eeb3d3284895 (svn r13909) -Codechange: use the same type before CmdBuildRailStation as it used in the command itself (Alberth)
rubidium
parents: 9771
diff changeset
    58
struct RailStationGUISettings {
eeb3d3284895 (svn r13909) -Codechange: use the same type before CmdBuildRailStation as it used in the command itself (Alberth)
rubidium
parents: 9771
diff changeset
    59
	Axis orientation;                 ///< Currently selected rail station orientation
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
    60
	byte numtracks;                   ///< Currently selected number of tracks in station (if not \c dragdrop )
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
    61
	byte platlength;                  ///< Currently selected platform length of station (if not \c dragdrop )
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
    62
	bool dragdrop;                    ///< Use drag & drop to place a station
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
    63
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
    64
	bool newstations;                 ///< Are custom station definitions available?
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
    65
	StationClassIDByte station_class; ///< Currently selected custom station class (if newstations is \c true )
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
    66
	byte station_type;                ///< Station type within the currently selected custom station class (if newstations is \c true )
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
    67
	byte station_count;               ///< Number of custom stations (if newstations is \c true )
9772
eeb3d3284895 (svn r13909) -Codechange: use the same type before CmdBuildRailStation as it used in the command itself (Alberth)
rubidium
parents: 9771
diff changeset
    68
};
eeb3d3284895 (svn r13909) -Codechange: use the same type before CmdBuildRailStation as it used in the command itself (Alberth)
rubidium
parents: 9771
diff changeset
    69
static RailStationGUISettings _railstation; ///< Settings of the station builder GUI
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    71
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    72
static void HandleStationPlacement(TileIndex start, TileIndex end);
9338
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
    73
static void ShowBuildTrainDepotPicker(Window *parent);
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
    74
static void ShowBuildWaypointPicker(Window *parent);
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
    75
static void ShowStationBuilder(Window *parent);
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
    76
static void ShowSignalBuilder(Window *parent);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    77
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    78
void CcPlaySound1E(bool success, TileIndex tile, uint32 p1, uint32 p2)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    79
{
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 514
diff changeset
    80
	if (success) SndPlayTileFx(SND_20_SPLAT_2, tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    81
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    82
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    83
static void GenericPlaceRail(TileIndex tile, int cmd)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    84
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    85
	DoCommandP(tile, _cur_railtype, cmd, CcPlaySound1E,
8586
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
    86
		_remove_button_clicked ?
7521
0da1e91510e4 (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7341
diff changeset
    87
		CMD_REMOVE_SINGLE_RAIL | CMD_MSG(STR_1012_CAN_T_REMOVE_RAILROAD_TRACK) | CMD_NO_WATER :
0da1e91510e4 (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7341
diff changeset
    88
		CMD_BUILD_SINGLE_RAIL | CMD_MSG(STR_1011_CAN_T_BUILD_RAILROAD_TRACK) | CMD_NO_WATER
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
    89
	);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    92
static void PlaceRail_N(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
	int cmd = _tile_fract_coords.x > _tile_fract_coords.y ? 4 : 5;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
	GenericPlaceRail(tile, cmd);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
    98
static void PlaceRail_NE(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
{
6670
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
   100
	VpStartPlaceSizing(tile, VPM_FIX_Y, DDSP_PLACE_RAIL_NE);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   101
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   102
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   103
static void PlaceRail_E(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   104
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   105
	int cmd = _tile_fract_coords.x + _tile_fract_coords.y <= 15 ? 2 : 3;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   106
	GenericPlaceRail(tile, cmd);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   107
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   108
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   109
static void PlaceRail_NW(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   110
{
6670
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
   111
	VpStartPlaceSizing(tile, VPM_FIX_X, DDSP_PLACE_RAIL_NW);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   112
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   113
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   114
static void PlaceRail_AutoRail(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   115
{
6670
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
   116
	VpStartPlaceSizing(tile, VPM_RAILDIRS, DDSP_PLACE_AUTORAIL);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   117
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   118
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   119
/**
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   120
 * Try to add an additional rail-track at the entrance of a depot
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   121
 * @param tile  Tile to use for adding the rail-track
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   122
 * @param extra Track to add
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   123
 * @see CcRailDepot()
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   124
 */
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   125
static void PlaceExtraDepotRail(TileIndex tile, uint16 extra)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   126
{
3792
67c865c9315c (svn r4788) - Codechange: RAILTYPE_{NORMAL,ELECTRIC,...} and RAIL_TYPE_{NORMAL,SIGNAL,...} have nearly the same name, rename RAIL_TYPE_* to RAIL_TILE_* of extra clarity
rubidium
parents: 3782
diff changeset
   127
	if (GetRailTileType(tile) != RAIL_TILE_NORMAL) return;
3269
62fb247bf94b (svn r3981) More work for the rail accessing functions and enums
tron
parents: 3157
diff changeset
   128
	if ((GetTrackBits(tile) & GB(extra, 8, 8)) == 0) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   129
7521
0da1e91510e4 (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7341
diff changeset
   130
	DoCommandP(tile, _cur_railtype, extra & 0xFF, NULL, CMD_BUILD_SINGLE_RAIL | CMD_NO_WATER);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   131
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   132
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   133
/** Additional pieces of track to add at the entrance of a depot. */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   134
static const uint16 _place_depot_extra[12] = {
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   135
	0x0604, 0x2102, 0x1202, 0x0505,  // First additional track for directions 0..3
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   136
	0x2400, 0x2801, 0x1800, 0x1401,  // Second additional track
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   137
	0x2203, 0x0904, 0x0A05, 0x1103,  // Third additional track
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   138
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   139
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   140
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   141
void CcRailDepot(bool success, TileIndex tile, uint32 p1, uint32 p2)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   142
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   143
	if (success) {
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   144
		DiagDirection dir = (DiagDirection)p2;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   145
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 514
diff changeset
   146
		SndPlayTileFx(SND_20_SPLAT_2, tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   147
		ResetObjectToPlace();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   148
4559
aa0c13e39840 (svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents: 4547
diff changeset
   149
		tile += TileOffsByDiagDir(dir);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   150
1035
812f837ee03f (svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts
tron
parents: 980
diff changeset
   151
		if (IsTileType(tile, MP_RAILWAY)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   152
			PlaceExtraDepotRail(tile, _place_depot_extra[dir]);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   153
			PlaceExtraDepotRail(tile, _place_depot_extra[dir + 4]);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   154
			PlaceExtraDepotRail(tile, _place_depot_extra[dir + 8]);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   155
		}
201
c40d343115f8 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents: 179
diff changeset
   156
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   157
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   158
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   159
static void PlaceRail_Depot(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   160
{
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   161
	DoCommandP(tile, _cur_railtype, _build_depot_direction, CcRailDepot,
7521
0da1e91510e4 (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7341
diff changeset
   162
		CMD_BUILD_TRAIN_DEPOT | CMD_NO_WATER | CMD_MSG(STR_100E_CAN_T_BUILD_TRAIN_DEPOT));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   163
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   164
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   165
static void PlaceRail_Waypoint(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   166
{
8587
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   167
	if (_remove_button_clicked) {
7949
730724a67d80 (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
parents: 7928
diff changeset
   168
		DoCommandP(tile, 0, 0, CcPlaySound1E, CMD_REMOVE_TRAIN_WAYPOINT | CMD_MSG(STR_CANT_REMOVE_TRAIN_WAYPOINT));
730724a67d80 (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
parents: 7928
diff changeset
   169
	} else {
2625
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents: 2619
diff changeset
   170
		DoCommandP(tile, _cur_waypoint_type, 0, CcPlaySound1E, CMD_BUILD_TRAIN_WAYPOINT | CMD_MSG(STR_CANT_BUILD_TRAIN_WAYPOINT));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   171
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   172
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   173
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   174
void CcStation(bool success, TileIndex tile, uint32 p1, uint32 p2)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   175
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   176
	if (success) {
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 514
diff changeset
   177
		SndPlayTileFx(SND_20_SPLAT_2, tile);
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
   178
		/* Only close the station builder window if the default station is chosen. */
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
   179
		if (_railstation.station_class == STAT_CLASS_DFLT && _railstation.station_type == 0) ResetObjectToPlace();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   180
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   181
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   182
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   183
static void PlaceRail_Station(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   184
{
7955
64310868e7aa (svn r11511) -Revert parts of r11505: forgot that CTRL might be used for other features, like adjacent stations or signals.
rubidium
parents: 7949
diff changeset
   185
	if (_remove_button_clicked) {
8587
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   186
		VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_REMOVE_STATION);
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   187
		VpSetPlaceSizingLimit(-1);
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3921
diff changeset
   188
	} else if (_railstation.dragdrop) {
6670
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
   189
		VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_BUILD_STATION);
9413
7042a8ec3fa8 (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
parents: 9354
diff changeset
   190
		VpSetPlaceSizingLimit(_settings_game.station.station_spread);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   191
	} else {
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
   192
		DoCommandP(tile,
6674
5d77615aeaf2 (svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros
parents: 6670
diff changeset
   193
				_railstation.orientation | (_railstation.numtracks << 8) | (_railstation.platlength << 16) | (_ctrl_pressed << 24),
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
   194
				_cur_railtype | (_railstation.station_class << 8) | (_railstation.station_type << 16), CcStation,
7521
0da1e91510e4 (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7341
diff changeset
   195
				CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   196
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   197
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   198
7991
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
   199
/**
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
   200
 * Build a new signal or edit/remove a present signal, use CmdBuildSingleSignal() or CmdRemoveSingleSignal() in rail_cmd.cpp
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
   201
 *
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
   202
 * @param tile The tile where the signal will build or edit
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
   203
 */
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   204
static void GenericPlaceSignals(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   205
{
8616
fd862a55c47f (svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch
parents: 8587
diff changeset
   206
	TrackBits trackbits = TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_RAIL, 0));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   207
6846
175bf19b9def (svn r10086) -Codechange: Use more sensible types and functions in GenericPlaceSignals.
maedhros
parents: 6683
diff changeset
   208
	if (trackbits & TRACK_BIT_VERT) { // N-S direction
175bf19b9def (svn r10086) -Codechange: Use more sensible types and functions in GenericPlaceSignals.
maedhros
parents: 6683
diff changeset
   209
		trackbits = (_tile_fract_coords.x <= _tile_fract_coords.y) ? TRACK_BIT_RIGHT : TRACK_BIT_LEFT;
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   210
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   211
6846
175bf19b9def (svn r10086) -Codechange: Use more sensible types and functions in GenericPlaceSignals.
maedhros
parents: 6683
diff changeset
   212
	if (trackbits & TRACK_BIT_HORZ) { // E-W direction
175bf19b9def (svn r10086) -Codechange: Use more sensible types and functions in GenericPlaceSignals.
maedhros
parents: 6683
diff changeset
   213
		trackbits = (_tile_fract_coords.x + _tile_fract_coords.y <= 15) ? TRACK_BIT_UPPER : TRACK_BIT_LOWER;
175bf19b9def (svn r10086) -Codechange: Use more sensible types and functions in GenericPlaceSignals.
maedhros
parents: 6683
diff changeset
   214
	}
175bf19b9def (svn r10086) -Codechange: Use more sensible types and functions in GenericPlaceSignals.
maedhros
parents: 6683
diff changeset
   215
6863
746e9481a436 (svn r10103) -Fix (r10086): TrackBitsToTrack doesn't cope well with TRACK_BIT_NONE (e.g. non-rail tiles), so use FindFirstTrack instead.
maedhros
parents: 6846
diff changeset
   216
	Track track = FindFirstTrack(trackbits);
6846
175bf19b9def (svn r10086) -Codechange: Use more sensible types and functions in GenericPlaceSignals.
maedhros
parents: 6683
diff changeset
   217
7955
64310868e7aa (svn r11511) -Revert parts of r11505: forgot that CTRL might be used for other features, like adjacent stations or signals.
rubidium
parents: 7949
diff changeset
   218
	if (_remove_button_clicked) {
7949
730724a67d80 (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
parents: 7928
diff changeset
   219
		DoCommandP(tile, track, 0, CcPlaySound1E,
730724a67d80 (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
parents: 7928
diff changeset
   220
			CMD_REMOVE_SIGNALS | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM));
730724a67d80 (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
parents: 7928
diff changeset
   221
	} else {
8808
6296dfa53f81 (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz
parents: 8785
diff changeset
   222
		const Window *w = FindWindowById(WC_BUILD_SIGNAL, 0);
7991
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
   223
9793
359d2460833b (svn r13935) -Codechange [YAPP]: PBS signals can now be built with the normal signal tools. (michi_cc)
rubidium
parents: 9772
diff changeset
   224
		/* Map _patches.cycle_signal_types to the lower and upper allowed signal type. */
359d2460833b (svn r13935) -Codechange [YAPP]: PBS signals can now be built with the normal signal tools. (michi_cc)
rubidium
parents: 9772
diff changeset
   225
		static const uint cycle_bounds[] = {SIGTYPE_NORMAL | (SIGTYPE_LAST_NOPBS << 3), SIGTYPE_PBS | (SIGTYPE_LAST << 3), SIGTYPE_NORMAL | (SIGTYPE_LAST << 3)};
359d2460833b (svn r13935) -Codechange [YAPP]: PBS signals can now be built with the normal signal tools. (michi_cc)
rubidium
parents: 9772
diff changeset
   226
7991
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
   227
		/* various bitstuffed elements for CmdBuildSingleSignal() */
6846
175bf19b9def (svn r10086) -Codechange: Use more sensible types and functions in GenericPlaceSignals.
maedhros
parents: 6683
diff changeset
   228
		uint32 p1 = track;
8808
6296dfa53f81 (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz
parents: 8785
diff changeset
   229
6296dfa53f81 (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz
parents: 8785
diff changeset
   230
		if (w != NULL) {
6296dfa53f81 (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz
parents: 8785
diff changeset
   231
			/* signal GUI is used */
6296dfa53f81 (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz
parents: 8785
diff changeset
   232
			SB(p1, 3, 1, _ctrl_pressed);
6296dfa53f81 (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz
parents: 8785
diff changeset
   233
			SB(p1, 4, 1, _cur_signal_variant);
9793
359d2460833b (svn r13935) -Codechange [YAPP]: PBS signals can now be built with the normal signal tools. (michi_cc)
rubidium
parents: 9772
diff changeset
   234
			SB(p1, 5, 3, _cur_signal_type);
359d2460833b (svn r13935) -Codechange [YAPP]: PBS signals can now be built with the normal signal tools. (michi_cc)
rubidium
parents: 9772
diff changeset
   235
			SB(p1, 8, 1, _convert_signal_button);
359d2460833b (svn r13935) -Codechange [YAPP]: PBS signals can now be built with the normal signal tools. (michi_cc)
rubidium
parents: 9772
diff changeset
   236
			SB(p1, 9, 6, cycle_bounds[_settings_client.gui.cycle_signal_types]);
8808
6296dfa53f81 (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz
parents: 8785
diff changeset
   237
		} else {
6296dfa53f81 (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz
parents: 8785
diff changeset
   238
			SB(p1, 3, 1, _ctrl_pressed);
9413
7042a8ec3fa8 (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
parents: 9354
diff changeset
   239
			SB(p1, 4, 1, (_cur_year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC));
9793
359d2460833b (svn r13935) -Codechange [YAPP]: PBS signals can now be built with the normal signal tools. (michi_cc)
rubidium
parents: 9772
diff changeset
   240
			SB(p1, 5, 3, _default_signal_type[_settings_client.gui.default_signal_type]);
359d2460833b (svn r13935) -Codechange [YAPP]: PBS signals can now be built with the normal signal tools. (michi_cc)
rubidium
parents: 9772
diff changeset
   241
			SB(p1, 8, 1, 0);
359d2460833b (svn r13935) -Codechange [YAPP]: PBS signals can now be built with the normal signal tools. (michi_cc)
rubidium
parents: 9772
diff changeset
   242
			SB(p1, 9, 6, cycle_bounds[_settings_client.gui.cycle_signal_types]);
8808
6296dfa53f81 (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz
parents: 8785
diff changeset
   243
		}
5731
c68613da5c4d (svn r8274) -Codechange (r8151): Move the automatic semaphore/signal checks inside the CMD_ functions where they are supposed to be. Achieve this by adding a seperate bit to p1/p2 to hold the CTRL-modifier. While here, use proper types, and 'unify' the parameter bit-meanings. 0 - ctrl-pressed, 1 - signal/semaphore, 2-4 - trackbits, 5 - remove (internal), 24-31 - drag density.
Darkvater
parents: 5696
diff changeset
   244
7991
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
   245
		DoCommandP(tile, p1, 0, CcPlaySound1E, CMD_BUILD_SIGNALS |
8808
6296dfa53f81 (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz
parents: 8785
diff changeset
   246
			CMD_MSG((w != NULL && _convert_signal_button) ? STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE : STR_1010_CAN_T_BUILD_SIGNALS_HERE));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   247
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   248
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   249
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   250
static void PlaceRail_Bridge(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   251
{
6670
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
   252
	VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_BUILD_BRIDGE);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   253
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   254
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   255
/** Command callback for building a tunnel */
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   256
void CcBuildRailTunnel(bool success, TileIndex tile, uint32 p1, uint32 p2)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   257
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   258
	if (success) {
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 514
diff changeset
   259
		SndPlayTileFx(SND_20_SPLAT_2, tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   260
		ResetObjectToPlace();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   261
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   262
		SetRedErrorSquare(_build_tunnel_endtile);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   263
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   264
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   265
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   266
static void PlaceRail_Tunnel(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   267
{
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 541
diff changeset
   268
	DoCommandP(tile, _cur_railtype, 0, CcBuildRailTunnel,
7521
0da1e91510e4 (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7341
diff changeset
   269
		CMD_BUILD_TUNNEL | CMD_MSG(STR_5016_CAN_T_BUILD_TUNNEL_HERE));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   270
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   271
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   272
static void PlaceRail_ConvertRail(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   273
{
6670
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
   274
	VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CONVERT_RAIL);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   275
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   276
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   277
static void PlaceRail_AutoSignals(TileIndex tile)
58
b9fdcc9b5c90 (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents: 0
diff changeset
   278
{
6670
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
   279
	VpStartPlaceSizing(tile, VPM_SIGNALDIRS, DDSP_BUILD_SIGNALS);
58
b9fdcc9b5c90 (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents: 0
diff changeset
   280
}
b9fdcc9b5c90 (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents: 0
diff changeset
   281
5147
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5116
diff changeset
   282
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5116
diff changeset
   283
/** Enum referring to the widgets of the build rail toolbar */
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   284
enum RailToolbarWidgets {
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   285
	RTW_CLOSEBOX = 0,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   286
	RTW_CAPTION,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   287
	RTW_STICKY,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   288
	RTW_SPACER,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   289
	RTW_BUILD_NS,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   290
	RTW_BUILD_X,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   291
	RTW_BUILD_EW,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   292
	RTW_BUILD_Y,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   293
	RTW_AUTORAIL,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   294
	RTW_DEMOLISH,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   295
	RTW_BUILD_DEPOT,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   296
	RTW_BUILD_WAYPOINT,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   297
	RTW_BUILD_STATION,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   298
	RTW_BUILD_SIGNALS,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   299
	RTW_BUILD_BRIDGE,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   300
	RTW_BUILD_TUNNEL,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   301
	RTW_REMOVE,
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   302
	RTW_CONVERT_RAIL,
5147
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5116
diff changeset
   303
};
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5116
diff changeset
   304
8586
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   305
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   306
/** Toggles state of the Remove button of Build rail toolbar
8586
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   307
 * @param w window the button belongs to
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   308
 */
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   309
static void ToggleRailButton_Remove(Window *w)
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   310
{
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   311
	w->ToggleWidgetLoweredState(RTW_REMOVE);
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   312
	w->InvalidateWidget(RTW_REMOVE);
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   313
	_remove_button_clicked = w->IsWidgetLowered(RTW_REMOVE);
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   314
	SetSelectionRed(_remove_button_clicked);
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   315
}
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   316
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   317
/** Updates the Remove button because of Ctrl state change
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   318
 * @param w window the button belongs to
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   319
 * @return true iff the remove buton was changed
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   320
 */
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   321
static bool RailToolbar_CtrlChanged(Window *w)
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   322
{
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   323
	if (w->IsWidgetDisabled(RTW_REMOVE)) return false;
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   324
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   325
	/* allow ctrl to switch remove mode only for these widgets */
8587
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   326
	for (uint i = RTW_BUILD_NS; i <= RTW_BUILD_STATION; i++) {
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   327
		if ((i <= RTW_AUTORAIL || i >= RTW_BUILD_WAYPOINT) && w->IsWidgetLowered(i)) {
8586
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   328
			ToggleRailButton_Remove(w);
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   329
			return true;
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   330
		}
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   331
	}
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   332
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   333
	return false;
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   334
}
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   335
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   336
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   337
/**
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   338
 * The "rail N"-button click proc of the build-rail toolbar.
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   339
 * @param w Build-rail toolbar window
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   340
 * @see BuildRailToolbWndProc()
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   341
 */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   342
static void BuildRailClick_N(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   343
{
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7824
diff changeset
   344
	HandlePlacePushButton(w, RTW_BUILD_NS, GetRailTypeInfo(_cur_railtype)->cursor.rail_ns, VHM_RECT, PlaceRail_N);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   345
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   346
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   347
/**
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   348
 * The "rail NE"-button click proc of the build-rail toolbar.
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   349
 * @param w Build-rail toolbar window
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   350
 * @see BuildRailToolbWndProc()
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   351
 */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   352
static void BuildRailClick_NE(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   353
{
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7824
diff changeset
   354
	HandlePlacePushButton(w, RTW_BUILD_X, GetRailTypeInfo(_cur_railtype)->cursor.rail_swne, VHM_RECT, PlaceRail_NE);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   355
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   356
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   357
/**
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   358
 * The "rail E"-button click proc of the build-rail toolbar.
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   359
 * @param w Build-rail toolbar window
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   360
 * @see BuildRailToolbWndProc()
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   361
 */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   362
static void BuildRailClick_E(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   363
{
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7824
diff changeset
   364
	HandlePlacePushButton(w, RTW_BUILD_EW, GetRailTypeInfo(_cur_railtype)->cursor.rail_ew, VHM_RECT, PlaceRail_E);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   365
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   366
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   367
/**
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   368
 * The "rail NW"-button click proc of the build-rail toolbar.
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   369
 * @param w Build-rail toolbar window
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   370
 * @see BuildRailToolbWndProc()
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   371
 */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   372
static void BuildRailClick_NW(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   373
{
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7824
diff changeset
   374
	HandlePlacePushButton(w, RTW_BUILD_Y, GetRailTypeInfo(_cur_railtype)->cursor.rail_nwse, VHM_RECT, PlaceRail_NW);
606
da90c837064c (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
   375
}
da90c837064c (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
   376
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   377
/**
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   378
 * The "auto-rail"-button click proc of the build-rail toolbar.
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   379
 * @param w Build-rail toolbar window
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   380
 * @see BuildRailToolbWndProc()
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   381
 */
606
da90c837064c (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
   382
static void BuildRailClick_AutoRail(Window *w)
da90c837064c (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
   383
{
5147
866030c20f0a (svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents: 5116
diff changeset
   384
	HandlePlacePushButton(w, RTW_AUTORAIL, GetRailTypeInfo(_cur_railtype)->cursor.autorail, VHM_RAIL, PlaceRail_AutoRail);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   385
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   386
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   387
/**
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   388
 * The "demolish"-button click proc of the build-rail toolbar.
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   389
 * @param w Build-rail toolbar window
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   390
 * @see BuildRailToolbWndProc()
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   391
 */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   392
static void BuildRailClick_Demolish(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   393
{
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7824
diff changeset
   394
	HandlePlacePushButton(w, RTW_DEMOLISH, ANIMCURSOR_DEMOLISH, VHM_RECT, PlaceProc_DemolishArea);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   395
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   396
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   397
/**
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   398
 * The "build depot"-button click proc of the build-rail toolbar.
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   399
 * @param w Build-rail toolbar window
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   400
 * @see BuildRailToolbWndProc()
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   401
 */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   402
static void BuildRailClick_Depot(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   403
{
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7824
diff changeset
   404
	if (HandlePlacePushButton(w, RTW_BUILD_DEPOT, GetRailTypeInfo(_cur_railtype)->cursor.depot, VHM_RECT, PlaceRail_Depot)) {
9338
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
   405
		ShowBuildTrainDepotPicker(w);
2514
859692ffa65a (svn r3040) Don't deduce the cursor sprites when building rails from magic numbers, but fetch them from the central rail info array.
tron
parents: 2274
diff changeset
   406
	}
606
da90c837064c (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
   407
}
da90c837064c (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
   408
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   409
/**
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   410
 * The "build waypoint"-button click proc of the build-rail toolbar.
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   411
 * If there are newGRF waypoints, also open a window to pick the waypoint type.
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   412
 * @param w Build-rail toolbar window
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   413
 * @see BuildRailToolbWndProc()
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   414
 */
606
da90c837064c (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
   415
static void BuildRailClick_Waypoint(Window *w)
da90c837064c (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
   416
{
2625
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents: 2619
diff changeset
   417
	_waypoint_count = GetNumCustomStations(STAT_CLASS_WAYP);
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7824
diff changeset
   418
	if (HandlePlacePushButton(w, RTW_BUILD_WAYPOINT, SPR_CURSOR_WAYPOINT, VHM_RECT, PlaceRail_Waypoint) &&
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   419
			_waypoint_count > 1) {
9338
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
   420
		ShowBuildWaypointPicker(w);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   421
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   422
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   423
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   424
/**
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   425
 * The "build station"-button click proc of the build-rail toolbar.
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   426
 * @param w Build-rail toolbar window
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   427
 * @see BuildRailToolbWndProc()
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   428
 */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   429
static void BuildRailClick_Station(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   430
{
9338
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
   431
	if (HandlePlacePushButton(w, RTW_BUILD_STATION, SPR_CURSOR_RAIL_STATION, VHM_RECT, PlaceRail_Station)) ShowStationBuilder(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   432
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   433
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   434
/**
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   435
 * The "build signal"-button click proc of the build-rail toolbar.
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   436
 * Start ShowSignalBuilder() and/or HandleAutoSignalPlacement().
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   437
 * @param w Build-rail toolbar window
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   438
 * @see BuildRailToolbWndProc()
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   439
 */
58
b9fdcc9b5c90 (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents: 0
diff changeset
   440
static void BuildRailClick_AutoSignals(Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   441
{
9413
7042a8ec3fa8 (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
parents: 9354
diff changeset
   442
	if (_settings_client.gui.enable_signal_gui != _ctrl_pressed) {
9338
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
   443
		if (HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals)) ShowSignalBuilder(w);
7991
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
   444
	} else {
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
   445
		HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals);
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
   446
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   447
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   448
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   449
/**
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   450
 * The "build bridge"-button click proc of the build-rail toolbar.
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   451
 * @param w Build-rail toolbar window
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   452
 * @see BuildRailToolbWndProc()
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   453
 */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   454
static void BuildRailClick_Bridge(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   455
{
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7824
diff changeset
   456
	HandlePlacePushButton(w, RTW_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, VHM_RECT, PlaceRail_Bridge);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   457
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   458
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   459
/**
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   460
 * The "build tunnel"-button click proc of the build-rail toolbar.
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   461
 * @param w Build-rail toolbar window
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   462
 * @see BuildRailToolbWndProc()
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   463
 */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   464
static void BuildRailClick_Tunnel(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   465
{
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7824
diff changeset
   466
	HandlePlacePushButton(w, RTW_BUILD_TUNNEL, GetRailTypeInfo(_cur_railtype)->cursor.tunnel, VHM_SPECIAL, PlaceRail_Tunnel);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   467
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   468
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   469
/**
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   470
 * The "remove"-button click proc of the build-rail toolbar.
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   471
 * @param w Build-rail toolbar window
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   472
 * @see BuildRailToolbWndProc()
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   473
 */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   474
static void BuildRailClick_Remove(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   475
{
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7991
diff changeset
   476
	if (w->IsWidgetDisabled(RTW_REMOVE)) return;
8586
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   477
	ToggleRailButton_Remove(w);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 514
diff changeset
   478
	SndPlayFx(SND_15_BEEP);
8587
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   479
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   480
	/* handle station builder */
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   481
	if (w->IsWidgetLowered(RTW_BUILD_STATION)) {
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   482
		if (_remove_button_clicked) {
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   483
			/* starting drag & drop remove */
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   484
			if (!_railstation.dragdrop) {
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   485
				SetTileSelectSize(1, 1);
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   486
			} else {
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   487
				VpSetPlaceSizingLimit(-1);
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   488
			}
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   489
		} else {
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   490
			/* starting station build mode */
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   491
			if (!_railstation.dragdrop) {
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   492
				int x = _railstation.numtracks;
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   493
				int y = _railstation.platlength;
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   494
				if (_railstation.orientation == 0) Swap(x, y);
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   495
				SetTileSelectSize(x, y);
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   496
			} else {
9413
7042a8ec3fa8 (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
parents: 9354
diff changeset
   497
				VpSetPlaceSizingLimit(_settings_game.station.station_spread);
8587
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   498
			}
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   499
		}
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   500
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   501
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   502
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   503
/**
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   504
 * The "convert-rail"-button click proc of the build-rail toolbar.
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   505
 * Switches to 'convert-rail' mode
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   506
 * @param w Build-rail toolbar window
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   507
 * @see BuildRailToolbWndProc()
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   508
 */
606
da90c837064c (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 568
diff changeset
   509
static void BuildRailClick_Convert(Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   510
{
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7824
diff changeset
   511
	HandlePlacePushButton(w, RTW_CONVERT_RAIL, GetRailTypeInfo(_cur_railtype)->cursor.convert, VHM_RECT, PlaceRail_ConvertRail);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   512
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   513
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   514
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   515
static void DoRailroadTrack(int mode)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   516
{
1980
6c5917cfcb78 (svn r2486) Turn TILE_FROM_XY into an inline function and rename it to TileVirtXY
tron
parents: 1977
diff changeset
   517
	DoCommandP(TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), _cur_railtype | (mode << 4), NULL,
8586
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   518
		_remove_button_clicked ?
7521
0da1e91510e4 (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7341
diff changeset
   519
		CMD_REMOVE_RAILROAD_TRACK | CMD_NO_WATER | CMD_MSG(STR_1012_CAN_T_REMOVE_RAILROAD_TRACK) :
0da1e91510e4 (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7341
diff changeset
   520
		CMD_BUILD_RAILROAD_TRACK  | CMD_NO_WATER | CMD_MSG(STR_1011_CAN_T_BUILD_RAILROAD_TRACK)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   521
	);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   522
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   523
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6207
diff changeset
   524
static void HandleAutodirPlacement()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   525
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   526
	TileHighlightData *thd = &_thd;
1227
1d940a5e02d2 (svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents: 1209
diff changeset
   527
	int trackstat = thd->drawstyle & 0xF; // 0..5
201
c40d343115f8 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents: 179
diff changeset
   528
1070
bd31ed783fd3 (svn r1571) Feature: Visually enhanced autorail placing
dominik
parents: 1035
diff changeset
   529
	if (thd->drawstyle & HT_RAIL) { // one tile case
1980
6c5917cfcb78 (svn r2486) Turn TILE_FROM_XY into an inline function and rename it to TileVirtXY
tron
parents: 1977
diff changeset
   530
		GenericPlaceRail(TileVirtXY(thd->selend.x, thd->selend.y), trackstat);
1227
1d940a5e02d2 (svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents: 1209
diff changeset
   531
		return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   532
	}
1227
1d940a5e02d2 (svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents: 1209
diff changeset
   533
1d940a5e02d2 (svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents: 1209
diff changeset
   534
	DoRailroadTrack(trackstat);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   535
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   536
7991
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
   537
/**
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
   538
 * Build new signals or remove signals or (if only one tile marked) edit a signal.
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
   539
 *
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
   540
 * If one tile marked abort and use GenericPlaceSignals()
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
   541
 * else use CmdBuildSingleSignal() or CmdRemoveSingleSignal() in rail_cmd.cpp to build many signals
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
   542
 */
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6207
diff changeset
   543
static void HandleAutoSignalPlacement()
58
b9fdcc9b5c90 (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents: 0
diff changeset
   544
{
b9fdcc9b5c90 (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents: 0
diff changeset
   545
	TileHighlightData *thd = &_thd;
5735
9f3729784816 (svn r8279) -Regression (r8274): Removing signals could fail under certain circumstances (not the proper bits of p1/p2 were set to trackbits). Moved trackbits back to bits 0..2, ctrl to 3, semaphore to 4. Also lower the decision of the ctrl-override of signal/semaphore from the GUI into the cmd function since we are passing the ctrl-bit anyways. Bug(s) found by Frostregen; thanks
Darkvater
parents: 5731
diff changeset
   546
	uint32 p2 = GB(thd->drawstyle, 0, 3); // 0..5
201
c40d343115f8 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents: 179
diff changeset
   547
1123
9c8b944a2737 (svn r1624) -Fix: [1106930] BugFix: placing signals with 2x1 drags is treated as placing a single signal thus providing an easy fix for a nasty problem.
darkvater
parents: 1116
diff changeset
   548
	if (thd->drawstyle == HT_RECT) { // one tile case
1980
6c5917cfcb78 (svn r2486) Turn TILE_FROM_XY into an inline function and rename it to TileVirtXY
tron
parents: 1977
diff changeset
   549
		GenericPlaceSignals(TileVirtXY(thd->selend.x, thd->selend.y));
1123
9c8b944a2737 (svn r1624) -Fix: [1106930] BugFix: placing signals with 2x1 drags is treated as placing a single signal thus providing an easy fix for a nasty problem.
darkvater
parents: 1116
diff changeset
   550
		return;
9c8b944a2737 (svn r1624) -Fix: [1106930] BugFix: placing signals with 2x1 drags is treated as placing a single signal thus providing an easy fix for a nasty problem.
darkvater
parents: 1116
diff changeset
   551
	}
58
b9fdcc9b5c90 (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents: 0
diff changeset
   552
8808
6296dfa53f81 (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz
parents: 8785
diff changeset
   553
	const Window *w = FindWindowById(WC_BUILD_SIGNAL, 0);
6296dfa53f81 (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz
parents: 8785
diff changeset
   554
6296dfa53f81 (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz
parents: 8785
diff changeset
   555
	if (w != NULL) {
6296dfa53f81 (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz
parents: 8785
diff changeset
   556
		/* signal GUI is used */
6296dfa53f81 (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz
parents: 8785
diff changeset
   557
		SB(p2,  3, 1, 0);
6296dfa53f81 (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz
parents: 8785
diff changeset
   558
		SB(p2,  4, 1, _cur_signal_variant);
6296dfa53f81 (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz
parents: 8785
diff changeset
   559
		SB(p2,  6, 1, _ctrl_pressed);
9794
dd4a7638d2d6 (svn r13936) -Codechange [YAPP]: Enable the auto-signal tool to build PBS signals and honor the default signal type. (michi_cc)
rubidium
parents: 9793
diff changeset
   560
		SB(p2,  7, 3, _cur_signal_type);
9413
7042a8ec3fa8 (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
parents: 9354
diff changeset
   561
		SB(p2, 24, 8, _settings_client.gui.drag_signals_density);
8808
6296dfa53f81 (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz
parents: 8785
diff changeset
   562
	} else {
6296dfa53f81 (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz
parents: 8785
diff changeset
   563
		SB(p2,  3, 1, 0);
9413
7042a8ec3fa8 (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
parents: 9354
diff changeset
   564
		SB(p2,  4, 1, (_cur_year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC));
8808
6296dfa53f81 (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz
parents: 8785
diff changeset
   565
		SB(p2,  6, 1, _ctrl_pressed);
9794
dd4a7638d2d6 (svn r13936) -Codechange [YAPP]: Enable the auto-signal tool to build PBS signals and honor the default signal type. (michi_cc)
rubidium
parents: 9793
diff changeset
   566
		SB(p2,  7, 3, _default_signal_type[_settings_client.gui.default_signal_type]);
9413
7042a8ec3fa8 (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
parents: 9354
diff changeset
   567
		SB(p2, 24, 8, _settings_client.gui.drag_signals_density);
8808
6296dfa53f81 (svn r12549) -Fix [FS#1900](r11547): respect type of selected signal when building more signals using the GUI
smatz
parents: 8785
diff changeset
   568
	}
5688
c4ba40106d5d (svn r8151) -Feature: Automatically build semaphores before a configurable date, which can be set by each network player seperately.
maedhros
parents: 5682
diff changeset
   569
9413
7042a8ec3fa8 (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
parents: 9354
diff changeset
   570
	/* _settings_client.gui.drag_signals_density is given as a parameter such that each user
5731
c68613da5c4d (svn r8274) -Codechange (r8151): Move the automatic semaphore/signal checks inside the CMD_ functions where they are supposed to be. Achieve this by adding a seperate bit to p1/p2 to hold the CTRL-modifier. While here, use proper types, and 'unify' the parameter bit-meanings. 0 - ctrl-pressed, 1 - signal/semaphore, 2-4 - trackbits, 5 - remove (internal), 24-31 - drag density.
Darkvater
parents: 5696
diff changeset
   571
	 * in a network game can specify his/her own signal density */
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   572
	DoCommandP(
5731
c68613da5c4d (svn r8274) -Codechange (r8151): Move the automatic semaphore/signal checks inside the CMD_ functions where they are supposed to be. Achieve this by adding a seperate bit to p1/p2 to hold the CTRL-modifier. While here, use proper types, and 'unify' the parameter bit-meanings. 0 - ctrl-pressed, 1 - signal/semaphore, 2-4 - trackbits, 5 - remove (internal), 24-31 - drag density.
Darkvater
parents: 5696
diff changeset
   573
		TileVirtXY(thd->selstart.x, thd->selstart.y),
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   574
		TileVirtXY(thd->selend.x, thd->selend.y),
5731
c68613da5c4d (svn r8274) -Codechange (r8151): Move the automatic semaphore/signal checks inside the CMD_ functions where they are supposed to be. Achieve this by adding a seperate bit to p1/p2 to hold the CTRL-modifier. While here, use proper types, and 'unify' the parameter bit-meanings. 0 - ctrl-pressed, 1 - signal/semaphore, 2-4 - trackbits, 5 - remove (internal), 24-31 - drag density.
Darkvater
parents: 5696
diff changeset
   575
		p2,
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   576
		CcPlaySound1E,
7955
64310868e7aa (svn r11511) -Revert parts of r11505: forgot that CTRL might be used for other features, like adjacent stations or signals.
rubidium
parents: 7949
diff changeset
   577
		_remove_button_clicked ?
7521
0da1e91510e4 (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7341
diff changeset
   578
			CMD_REMOVE_SIGNAL_TRACK | CMD_NO_WATER | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM) :
0da1e91510e4 (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7341
diff changeset
   579
			CMD_BUILD_SIGNAL_TRACK  | CMD_NO_WATER | CMD_MSG(STR_1010_CAN_T_BUILD_SIGNALS_HERE)
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   580
	);
58
b9fdcc9b5c90 (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents: 0
diff changeset
   581
}
b9fdcc9b5c90 (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents: 0
diff changeset
   582
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   583
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   584
typedef void OnButtonClick(Window *w);
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   585
9771
9b1bcac0f84b (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium
parents: 9762
diff changeset
   586
/** Data associated with a push button in the build rail toolbar window */
9b1bcac0f84b (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium
parents: 9762
diff changeset
   587
struct RailBuildingGUIButtonData {
9b1bcac0f84b (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium
parents: 9762
diff changeset
   588
	uint16 keycode;            ///< Keycode associated with the button
9b1bcac0f84b (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium
parents: 9762
diff changeset
   589
	OnButtonClick *click_proc; ///< Procedure to call when button is clicked
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   590
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   591
9771
9b1bcac0f84b (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium
parents: 9762
diff changeset
   592
/**
9b1bcac0f84b (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium
parents: 9762
diff changeset
   593
 * GUI rail-building button data constants.
9b1bcac0f84b (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium
parents: 9762
diff changeset
   594
 * Offsets match widget order, starting at RTW_BUILD_NS
9b1bcac0f84b (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium
parents: 9762
diff changeset
   595
 */
9b1bcac0f84b (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium
parents: 9762
diff changeset
   596
static const RailBuildingGUIButtonData _rail_build_button_data[] = {
9b1bcac0f84b (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium
parents: 9762
diff changeset
   597
	{'1', BuildRailClick_N          },
9b1bcac0f84b (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium
parents: 9762
diff changeset
   598
	{'2', BuildRailClick_NE         },
9b1bcac0f84b (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium
parents: 9762
diff changeset
   599
	{'3', BuildRailClick_E          },
9b1bcac0f84b (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium
parents: 9762
diff changeset
   600
	{'4', BuildRailClick_NW         },
9b1bcac0f84b (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium
parents: 9762
diff changeset
   601
	{'5', BuildRailClick_AutoRail   },
9b1bcac0f84b (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium
parents: 9762
diff changeset
   602
	{'6', BuildRailClick_Demolish   },
9b1bcac0f84b (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium
parents: 9762
diff changeset
   603
	{'7', BuildRailClick_Depot      },
9b1bcac0f84b (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium
parents: 9762
diff changeset
   604
	{'8', BuildRailClick_Waypoint   },
9b1bcac0f84b (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium
parents: 9762
diff changeset
   605
	{'9', BuildRailClick_Station    },
9b1bcac0f84b (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium
parents: 9762
diff changeset
   606
	{'S', BuildRailClick_AutoSignals},
9b1bcac0f84b (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium
parents: 9762
diff changeset
   607
	{'B', BuildRailClick_Bridge     },
9b1bcac0f84b (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium
parents: 9762
diff changeset
   608
	{'T', BuildRailClick_Tunnel     },
9b1bcac0f84b (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium
parents: 9762
diff changeset
   609
	{'R', BuildRailClick_Remove     },
9b1bcac0f84b (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium
parents: 9762
diff changeset
   610
	{'C', BuildRailClick_Convert    }
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   611
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   612
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   613
/**
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   614
 * Based on the widget clicked, update the status of the 'remove' button.
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   615
 * @param w              Rail toolbar window
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   616
 * @param clicked_widget Widget clicked in the toolbar
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   617
 */
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   618
struct BuildRailToolbarWindow : Window {
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   619
	BuildRailToolbarWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   620
	{
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   621
		this->DisableWidget(RTW_REMOVE);
4709
a81ab800c25b (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4634
diff changeset
   622
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   623
		this->FindWindowPlacementAndResize(desc);
9413
7042a8ec3fa8 (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
parents: 9354
diff changeset
   624
		if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   625
	}
4731
c5b97171c5ae (svn r6643) -Fix(r6631): Adjust proper disabled and lowered states of removal button on railtoolbar
belugas
parents: 4727
diff changeset
   626
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   627
	~BuildRailToolbarWindow()
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   628
	{
9413
7042a8ec3fa8 (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
parents: 9354
diff changeset
   629
		if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   630
	}
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   631
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   632
	void UpdateRemoveWidgetStatus(int clicked_widget)
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   633
	{
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   634
		switch (clicked_widget) {
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   635
			case RTW_REMOVE:
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   636
				/* If it is the removal button that has been clicked, do nothing,
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   637
				* as it is up to the other buttons to drive removal status */
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   638
				return;
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   639
				break;
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   640
			case RTW_BUILD_NS:
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   641
			case RTW_BUILD_X:
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   642
			case RTW_BUILD_EW:
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   643
			case RTW_BUILD_Y:
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   644
			case RTW_AUTORAIL:
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   645
			case RTW_BUILD_WAYPOINT:
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   646
			case RTW_BUILD_STATION:
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   647
			case RTW_BUILD_SIGNALS:
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   648
				/* Removal button is enabled only if the rail/signal/waypoint/station
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   649
				* button is still lowered.  Once raised, it has to be disabled */
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   650
				this->SetWidgetDisabledState(RTW_REMOVE, !this->IsWidgetLowered(clicked_widget));
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   651
				break;
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   652
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   653
			default:
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   654
				/* When any other buttons than rail/signal/waypoint/station, raise and
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   655
				* disable the removal button */
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   656
				this->DisableWidget(RTW_REMOVE);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   657
				this->RaiseWidget(RTW_REMOVE);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   658
				break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   659
		}
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   660
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   661
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   662
	virtual void OnPaint()
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   663
	{
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   664
		this->DrawWidgets();
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   665
	}
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   666
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   667
	virtual void OnClick(Point pt, int widget)
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   668
	{
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   669
		if (widget >= RTW_BUILD_NS) {
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   670
			_remove_button_clicked = false;
9771
9b1bcac0f84b (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium
parents: 9762
diff changeset
   671
			_rail_build_button_data[widget - RTW_BUILD_NS].click_proc(this);
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   672
		}
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   673
		this->UpdateRemoveWidgetStatus(widget);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   674
		if (_ctrl_pressed) RailToolbar_CtrlChanged(this);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   675
	}
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   676
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   677
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   678
	{
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   679
		EventState state = ES_NOT_HANDLED;
9771
9b1bcac0f84b (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium
parents: 9762
diff changeset
   680
		for (uint8 i = 0; i != lengthof(_rail_build_button_data); i++) {
9b1bcac0f84b (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium
parents: 9762
diff changeset
   681
			if (keycode == _rail_build_button_data[i].keycode) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   682
				_remove_button_clicked = false;
9771
9b1bcac0f84b (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium
parents: 9762
diff changeset
   683
				_rail_build_button_data[i].click_proc(this);
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   684
				this->UpdateRemoveWidgetStatus(i + RTW_BUILD_NS);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   685
				if (_ctrl_pressed) RailToolbar_CtrlChanged(this);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   686
				state = ES_HANDLED;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   687
				break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   688
			}
756
b76998029c12 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents: 679
diff changeset
   689
		}
b76998029c12 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents: 679
diff changeset
   690
		MarkTileDirty(_thd.pos.x, _thd.pos.y); // redraw tile selection
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   691
		return state;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   692
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   693
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   694
	virtual void OnPlaceObject(Point pt, TileIndex tile)
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   695
	{
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   696
		_place_proc(tile);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   697
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   698
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   699
	virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   700
	{
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   701
		/* no dragging if you have pressed the convert button */
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   702
		if (FindWindowById(WC_BUILD_SIGNAL, 0) != NULL && _convert_signal_button && this->IsWidgetLowered(RTW_BUILD_SIGNALS)) return;
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   703
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   704
		VpSelectTilesWithMethod(pt.x, pt.y, select_method);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   705
	}
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   706
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   707
	virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   708
	{
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   709
		if (pt.x != -1) {
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   710
			switch (select_proc) {
9293
96e818608056 (svn r13160) -Codechange: prepare GUIPlaceProcDragXY for the removal of WindowEvent.
rubidium
parents: 9277
diff changeset
   711
				default: NOT_REACHED();
6670
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
   712
				case DDSP_BUILD_BRIDGE:
6669
bb48a810a509 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 6596
diff changeset
   713
					ResetObjectToPlace();
8557
d5fb341fc220 (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
parents: 8424
diff changeset
   714
					ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_RAIL, _cur_railtype);
6669
bb48a810a509 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 6596
diff changeset
   715
					break;
1632
10c391e108b7 (svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents: 1542
diff changeset
   716
7949
730724a67d80 (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
parents: 7928
diff changeset
   717
				case DDSP_PLACE_AUTORAIL:
6669
bb48a810a509 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 6596
diff changeset
   718
					HandleAutodirPlacement();
7949
730724a67d80 (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
parents: 7928
diff changeset
   719
					break;
6596
f200c4895149 (svn r9810) -Feature: Add drag and drop removal of station tiles (Wolf01)
peter1138
parents: 6453
diff changeset
   720
6670
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
   721
				case DDSP_BUILD_SIGNALS:
6669
bb48a810a509 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 6596
diff changeset
   722
					HandleAutoSignalPlacement();
bb48a810a509 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 6596
diff changeset
   723
					break;
bb48a810a509 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 6596
diff changeset
   724
6670
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
   725
				case DDSP_DEMOLISH_AREA:
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   726
					GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
6669
bb48a810a509 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 6596
diff changeset
   727
					break;
bb48a810a509 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 6596
diff changeset
   728
6670
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
   729
				case DDSP_CONVERT_RAIL:
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
   730
					DoCommandP(end_tile, start_tile, _cur_railtype, CcPlaySound10, CMD_CONVERT_RAIL | CMD_MSG(STR_CANT_CONVERT_RAIL));
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
   731
					break;
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
   732
8587
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   733
				case DDSP_REMOVE_STATION:
6670
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
   734
				case DDSP_BUILD_STATION:
8587
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   735
					if (_remove_button_clicked) {
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   736
						DoCommandP(end_tile, start_tile, 0, CcPlaySound1E, CMD_REMOVE_FROM_RAILROAD_STATION | CMD_MSG(STR_CANT_REMOVE_PART_OF_STATION));
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   737
						break;
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   738
					}
6669
bb48a810a509 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 6596
diff changeset
   739
					HandleStationPlacement(start_tile, end_tile);
bb48a810a509 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 6596
diff changeset
   740
					break;
bb48a810a509 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 6596
diff changeset
   741
6670
f0300bf50643 (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 6669
diff changeset
   742
				case DDSP_PLACE_RAIL_NE:
7949
730724a67d80 (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
parents: 7928
diff changeset
   743
				case DDSP_PLACE_RAIL_NW:
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   744
					DoRailroadTrack(select_proc == DDSP_PLACE_RAIL_NE ? TRACK_X : TRACK_Y);
7949
730724a67d80 (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
parents: 7928
diff changeset
   745
					break;
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3921
diff changeset
   746
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   747
		}
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   748
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   749
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   750
	virtual void OnPlaceObjectAbort()
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   751
	{
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   752
		this->RaiseButtons();
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   753
		this->DisableWidget(RTW_REMOVE);
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   754
		this->InvalidateWidget(RTW_REMOVE);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   755
9238
e2f586d12318 (svn r13104) -Codechange: make ResetObjectToPlace safe to be called recursively via the OnPlaceObjectAbort callback and use this knowledge to simplify closing some windows.
rubidium
parents: 9161
diff changeset
   756
		delete FindWindowById(WC_BUILD_SIGNAL, 0);
e2f586d12318 (svn r13104) -Codechange: make ResetObjectToPlace safe to be called recursively via the OnPlaceObjectAbort callback and use this knowledge to simplify closing some windows.
rubidium
parents: 9161
diff changeset
   757
		delete FindWindowById(WC_BUILD_STATION, 0);
e2f586d12318 (svn r13104) -Codechange: make ResetObjectToPlace safe to be called recursively via the OnPlaceObjectAbort callback and use this knowledge to simplify closing some windows.
rubidium
parents: 9161
diff changeset
   758
		delete FindWindowById(WC_BUILD_DEPOT, 0);
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   759
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   760
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   761
	virtual void OnPlacePresize(Point pt, TileIndex tile)
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   762
	{
3491
35d747bb5e82 (svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents: 3269
diff changeset
   763
		DoCommand(tile, 0, 0, DC_AUTO, CMD_BUILD_TUNNEL);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
   764
		VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile);
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   765
	}
8586
cb0e7e00f1d2 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8573
diff changeset
   766
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   767
	virtual EventState OnCTRLStateChange()
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   768
	{
8587
70a3c4f44c2f (svn r12168) -Fix: behave a bit better when 'R' is pressed during rail station dragging
smatz
parents: 8586
diff changeset
   769
		/* do not toggle Remove button by Ctrl when placing station */
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   770
		if (!this->IsWidgetLowered(RTW_BUILD_STATION) && RailToolbar_CtrlChanged(this)) return ES_HANDLED;
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   771
		return ES_NOT_HANDLED;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   772
	}
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   773
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   774
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   775
/** Widget definition for the rail toolbar */
2274
2c99425c1086 (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2186
diff changeset
   776
static const Widget _build_rail_widgets[] = {
9762
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
   777
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_DARK_GREEN,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},                   // RTW_CLOSEBOX
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
   778
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_DARK_GREEN,    11,   337,     0,    13, STR_100A_RAILROAD_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},         // RTW_CAPTION
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
   779
{  WWT_STICKYBOX,   RESIZE_NONE,  COLOUR_DARK_GREEN,   338,   349,     0,    13, 0x0,                            STR_STICKY_BUTTON},                       // RTW_STICKY
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 855
diff changeset
   780
9762
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
   781
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_DARK_GREEN,   110,   113,    14,    35, 0x0,                            STR_NULL},                                // RTW_SPACER
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4171
diff changeset
   782
9762
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
   783
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,     0,    21,    14,    35, SPR_IMG_RAIL_NS,                STR_1018_BUILD_RAILROAD_TRACK},           // RTW_BUILD_NS
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
   784
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,    22,    43,    14,    35, SPR_IMG_RAIL_NE,                STR_1018_BUILD_RAILROAD_TRACK},           // RTW_BUILD_X
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
   785
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,    44,    65,    14,    35, SPR_IMG_RAIL_EW,                STR_1018_BUILD_RAILROAD_TRACK},           // RTW_BUILD_EW
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
   786
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,    66,    87,    14,    35, SPR_IMG_RAIL_NW,                STR_1018_BUILD_RAILROAD_TRACK},           // RTW_BUILD_Y
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
   787
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,    88,   109,    14,    35, SPR_IMG_AUTORAIL,               STR_BUILD_AUTORAIL_TIP},                  // RTW_AUTORAIL
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   788
9762
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
   789
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,   114,   135,    14,    35, SPR_IMG_DYNAMITE,               STR_018D_DEMOLISH_BUILDINGS_ETC},         // RTW_DEMOLISH
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
   790
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,   136,   157,    14,    35, SPR_IMG_DEPOT_RAIL,             STR_1019_BUILD_TRAIN_DEPOT_FOR_BUILDING}, // RTW_BUILD_DEPOT
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
   791
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,   158,   179,    14,    35, SPR_IMG_WAYPOINT,               STR_CONVERT_RAIL_TO_WAYPOINT_TIP},        // RTW_BUILD_WAYPOINT
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
   792
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
   793
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,   180,   221,    14,    35, SPR_IMG_RAIL_STATION,           STR_101A_BUILD_RAILROAD_STATION},         // RTW_BUILD_STATION
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
   794
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,   222,   243,    14,    35, SPR_IMG_RAIL_SIGNALS,           STR_101B_BUILD_RAILROAD_SIGNALS},         // RTW_BUILD_SIGNALS
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
   795
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,   244,   285,    14,    35, SPR_IMG_BRIDGE,                 STR_101C_BUILD_RAILROAD_BRIDGE},          // RTW_BUILD_BRIDGE
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
   796
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,   286,   305,    14,    35, SPR_IMG_TUNNEL_RAIL,            STR_101D_BUILD_RAILROAD_TUNNEL},          // RTW_BUILD_TUNNEL
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
   797
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,   306,   327,    14,    35, SPR_IMG_REMOVE,                 STR_101E_TOGGLE_BUILD_REMOVE_FOR},        // RTW_REMOVE
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
   798
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,   328,   349,    14,    35, SPR_IMG_CONVERT_RAIL,           STR_CONVERT_RAIL_TIP},                    // RTW_CONVERT_RAIL
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4171
diff changeset
   799
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 159
diff changeset
   800
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   801
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   802
2274
2c99425c1086 (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2186
diff changeset
   803
static const WindowDesc _build_rail_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7272
diff changeset
   804
	WDP_ALIGN_TBR, 22, 350, 36, 350, 36,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5860
diff changeset
   805
	WC_BUILD_TOOLBAR, WC_NONE,
756
b76998029c12 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents: 679
diff changeset
   806
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
2274
2c99425c1086 (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2186
diff changeset
   807
	_build_rail_widgets,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   808
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   809
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 855
diff changeset
   810
2274
2c99425c1086 (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2186
diff changeset
   811
/** Configures the rail toolbar for railtype given
2c99425c1086 (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2186
diff changeset
   812
 * @param railtype the railtype to display
2c99425c1086 (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2186
diff changeset
   813
 * @param w the window to modify
2c99425c1086 (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2186
diff changeset
   814
 */
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   815
static void SetupRailToolbar(RailType railtype, Window *w)
2274
2c99425c1086 (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2186
diff changeset
   816
{
2c99425c1086 (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2186
diff changeset
   817
	const RailtypeInfo *rti = GetRailTypeInfo(railtype);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   818
2274
2c99425c1086 (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2186
diff changeset
   819
	assert(railtype < RAILTYPE_END);
4547
d37c2d172ad4 (svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents: 4429
diff changeset
   820
	w->widget[RTW_CAPTION].data = rti->strings.toolbar_caption;
d37c2d172ad4 (svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents: 4429
diff changeset
   821
	w->widget[RTW_BUILD_NS].data = rti->gui_sprites.build_ns_rail;
d37c2d172ad4 (svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents: 4429
diff changeset
   822
	w->widget[RTW_BUILD_X].data = rti->gui_sprites.build_x_rail;
d37c2d172ad4 (svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents: 4429
diff changeset
   823
	w->widget[RTW_BUILD_EW].data = rti->gui_sprites.build_ew_rail;
d37c2d172ad4 (svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents: 4429
diff changeset
   824
	w->widget[RTW_BUILD_Y].data = rti->gui_sprites.build_y_rail;
d37c2d172ad4 (svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents: 4429
diff changeset
   825
	w->widget[RTW_AUTORAIL].data = rti->gui_sprites.auto_rail;
d37c2d172ad4 (svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents: 4429
diff changeset
   826
	w->widget[RTW_BUILD_DEPOT].data = rti->gui_sprites.build_depot;
d37c2d172ad4 (svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents: 4429
diff changeset
   827
	w->widget[RTW_CONVERT_RAIL].data = rti->gui_sprites.convert_rail;
d37c2d172ad4 (svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents: 4429
diff changeset
   828
	w->widget[RTW_BUILD_TUNNEL].data = rti->gui_sprites.build_tunnel;
2274
2c99425c1086 (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2186
diff changeset
   829
}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   830
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   831
/**
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   832
 * Open the build rail toolbar window for a specific rail type.
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   833
 * The window may be opened in the 'normal' way by clicking at the rail icon in
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   834
 * the main toolbar, or by means of selecting one of the functions of the
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   835
 * toolbar. In the latter case, the corresponding widget is also selected.
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   836
 *
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   837
 * If the terraform toolbar is linked to the toolbar, that window is also opened.
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   838
 *
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   839
 * @param railtype Rail type to open the window for
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   840
 * @param button   Widget clicked (\c -1 means no button clicked)
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   841
 */
2520
8a52362c4ada (svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents: 2514
diff changeset
   842
void ShowBuildRailToolbar(RailType railtype, int button)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   843
{
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   844
	BuildRailToolbarWindow *w;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   845
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 9886
diff changeset
   846
	if (!IsValidCompanyID(_current_company)) return;
4816
e555e273cf08 (svn r6740) -Fix: if a rail is not available, don't show toolbar even with hotkey 'A'
Darkvater
parents: 4747
diff changeset
   847
	if (!ValParamRailtype(railtype)) return;
946
2468063f35a4 (svn r1435) Fix: [ 1094092 ] Toolbars accessible via keyboard in spectator mode
dominik
parents: 926
diff changeset
   848
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   849
	// don't recreate the window if we're clicking on a button and the window exists.
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   850
	if (button < 0 || !(w = dynamic_cast<BuildRailToolbarWindow*>(FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL)))) {
9080
34bc7cbbb79a (svn r12939) -Codechange: do not use the window proc to determine whether a toolbar is a rail toolbar, but use the window number.
rubidium
parents: 9020
diff changeset
   851
		DeleteWindowByClass(WC_BUILD_TOOLBAR);
2520
8a52362c4ada (svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents: 2514
diff changeset
   852
		_cur_railtype = railtype;
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   853
		w = AllocateWindowDescFront<BuildRailToolbarWindow>(&_build_rail_desc, TRANSPORT_RAIL);
2520
8a52362c4ada (svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents: 2514
diff changeset
   854
		SetupRailToolbar(railtype, w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   855
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   856
288
72ca19a694dd (svn r294) -Fix: autorail always builds rail, instead of occasional rail removal (on pressing hotkey after pressing 'bulldozer')
darkvater
parents: 201
diff changeset
   857
	_remove_button_clicked = false;
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
   858
	if (w != NULL && button >= RTW_CLOSEBOX) {
9771
9b1bcac0f84b (svn r13908) -Codechange: merge two tables into a single one (Alberth)
rubidium
parents: 9762
diff changeset
   859
		_rail_build_button_data[button].click_proc(w);
9303
6b6b52069079 (svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents: 9293
diff changeset
   860
		w->UpdateRemoveWidgetStatus(button + RTW_BUILD_NS);
4747
b6d0ac6a2316 (svn r6659) -Fix r6619: Fix widget state setting of the rail toolbar when using global hotkeys.
glx
parents: 4738
diff changeset
   861
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   862
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   863
449
2856e9ce0754 (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   864
/* TODO: For custom stations, respect their allowed platforms/lengths bitmasks!
2856e9ce0754 (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   865
 * --pasky */
2856e9ce0754 (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   866
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1914
diff changeset
   867
static void HandleStationPlacement(TileIndex start, TileIndex end)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   868
{
926
a6d140a6a4de (svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents: 909
diff changeset
   869
	uint sx = TileX(start);
a6d140a6a4de (svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents: 909
diff changeset
   870
	uint sy = TileY(start);
a6d140a6a4de (svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents: 909
diff changeset
   871
	uint ex = TileX(end);
a6d140a6a4de (svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents: 909
diff changeset
   872
	uint ey = TileY(end);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   873
	uint w,h;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   874
6106
2898cd9417fd (svn r8841) -Fix
tron
parents: 5893
diff changeset
   875
	if (sx > ex) Swap(sx, ex);
2898cd9417fd (svn r8841) -Fix
tron
parents: 5893
diff changeset
   876
	if (sy > ey) Swap(sy, ey);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   877
	w = ex - sx + 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   878
	h = ey - sy + 1;
9772
eeb3d3284895 (svn r13909) -Codechange: use the same type before CmdBuildRailStation as it used in the command itself (Alberth)
rubidium
parents: 9771
diff changeset
   879
	if (_railstation.orientation == AXIS_X) Swap(w, h);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   880
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
   881
	DoCommandP(TileXY(sx, sy),
6674
5d77615aeaf2 (svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros
parents: 6670
diff changeset
   882
			_railstation.orientation | (w << 8) | (h << 16) | (_ctrl_pressed << 24),
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
   883
			_cur_railtype | (_railstation.station_class << 8) | (_railstation.station_type << 16), CcStation,
7521
0da1e91510e4 (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7341
diff changeset
   884
			CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   885
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   886
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   887
struct BuildRailStationWindow : public PickerWindowBase {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   888
private:
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   889
	/** Enum referring to the widgets of the rail stations window */
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   890
	enum BuildRailStationWidgets {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   891
		BRSW_CLOSEBOX = 0,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   892
		BRSW_CAPTION,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   893
		BRSW_BACKGROUND,
5049
43340069c983 (svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents: 5005
diff changeset
   894
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   895
		BRSW_PLATFORM_DIR_X,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   896
		BRSW_PLATFORM_DIR_Y,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   897
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   898
		BRSW_PLATFORM_NUM_BEGIN = BRSW_PLATFORM_DIR_Y,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   899
		BRSW_PLATFORM_NUM_1,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   900
		BRSW_PLATFORM_NUM_2,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   901
		BRSW_PLATFORM_NUM_3,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   902
		BRSW_PLATFORM_NUM_4,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   903
		BRSW_PLATFORM_NUM_5,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   904
		BRSW_PLATFORM_NUM_6,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   905
		BRSW_PLATFORM_NUM_7,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   906
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   907
		BRSW_PLATFORM_LEN_BEGIN = BRSW_PLATFORM_NUM_7,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   908
		BRSW_PLATFORM_LEN_1,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   909
		BRSW_PLATFORM_LEN_2,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   910
		BRSW_PLATFORM_LEN_3,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   911
		BRSW_PLATFORM_LEN_4,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   912
		BRSW_PLATFORM_LEN_5,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   913
		BRSW_PLATFORM_LEN_6,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   914
		BRSW_PLATFORM_LEN_7,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   915
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   916
		BRSW_PLATFORM_DRAG_N_DROP,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   917
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   918
		BRSW_HIGHLIGHT_OFF,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   919
		BRSW_HIGHLIGHT_ON,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   920
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   921
		BRSW_NEWST_DROPDOWN,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   922
		BRSW_NEWST_LIST,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   923
		BRSW_NEWST_SCROLL
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   924
	};
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   925
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   926
	/**
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   927
	 * Verify whether the currently selected station size is allowed after selecting a new station class/type.
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   928
	 * If not, change the station size variables ( _railstation.numtracks and _railstation.platlength ).
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   929
	 * @param statspec Specification of the new station class/type
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   930
	 */
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   931
	void CheckSelectedSize(const StationSpec *statspec)
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   932
	{
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   933
		if (statspec == NULL || _railstation.dragdrop) return;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   934
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   935
		/* If current number of tracks is not allowed, make it as big as possible (which is always less than currently selected) */
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   936
		if (HasBit(statspec->disallowed_platforms, _railstation.numtracks - 1)) {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   937
			this->RaiseWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   938
			_railstation.numtracks = 1;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   939
			while (HasBit(statspec->disallowed_platforms, _railstation.numtracks - 1)) {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   940
				_railstation.numtracks++;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   941
			}
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   942
			this->LowerWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
5049
43340069c983 (svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents: 5005
diff changeset
   943
		}
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   944
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   945
		if (HasBit(statspec->disallowed_lengths, _railstation.platlength - 1)) {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   946
			this->RaiseWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   947
			_railstation.platlength = 1;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   948
			while (HasBit(statspec->disallowed_lengths, _railstation.platlength - 1)) {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   949
				_railstation.platlength++;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   950
			}
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   951
			this->LowerWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   952
		}
5049
43340069c983 (svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents: 5005
diff changeset
   953
	}
43340069c983 (svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents: 5005
diff changeset
   954
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   955
	/** Build a dropdown list of available station classes */
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   956
	static DropDownList *BuildStationClassDropDown()
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   957
	{
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   958
		DropDownList *list = new DropDownList();
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   959
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   960
		for (uint i = 0; i < GetNumStationClasses(); i++) {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   961
			if (i == STAT_CLASS_WAYP) continue;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   962
			list->push_back(new DropDownListStringItem(GetStationClassName((StationClassID)i), i, false));
5049
43340069c983 (svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents: 5005
diff changeset
   963
		}
43340069c983 (svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents: 5005
diff changeset
   964
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   965
		return list;
8295
70fa977c9c65 (svn r11859) -Codechange: Update newgrf station class dropdown to use new method of generating list.
peter1138
parents: 8284
diff changeset
   966
	}
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   967
/**
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   968
 * Window event handler of station build window.
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   969
 * @param w Staion build window
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   970
 * @param e Window event to handle
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
   971
 */
8295
70fa977c9c65 (svn r11859) -Codechange: Update newgrf station class dropdown to use new method of generating list.
peter1138
parents: 8284
diff changeset
   972
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   973
public:
9338
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
   974
	BuildRailStationWindow(const WindowDesc *desc, Window *parent, bool newstation) : PickerWindowBase(desc, parent)
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   975
	{
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   976
		this->LowerWidget(_railstation.orientation + BRSW_PLATFORM_DIR_X);
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   977
		if (_railstation.dragdrop) {
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   978
			this->LowerWidget(BRSW_PLATFORM_DRAG_N_DROP);
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   979
		} else {
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   980
			this->LowerWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   981
			this->LowerWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   982
		}
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   983
		this->SetWidgetLoweredState(BRSW_HIGHLIGHT_OFF, !_station_show_coverage);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   984
		this->SetWidgetLoweredState(BRSW_HIGHLIGHT_ON, _station_show_coverage);
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   985
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   986
		this->FindWindowPlacementAndResize(desc);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   987
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   988
		_railstation.newstations = newstation;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   989
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   990
		if (newstation) {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   991
			_railstation.station_count = GetNumCustomStations(_railstation.station_class);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   992
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   993
			this->vscroll.count = _railstation.station_count;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   994
			this->vscroll.cap   = 5;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   995
			this->vscroll.pos   = Clamp(_railstation.station_type - 2, 0, this->vscroll.count - this->vscroll.cap);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   996
		}
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   997
	}
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   998
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
   999
	virtual void OnPaint()
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1000
	{
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1001
		bool newstations = _railstation.newstations;
3921
bf161a808b51 (svn r5048) - NewStations: Set up clipping areas to draw the station preview graphics in. This prevents larger station graphics from overflowing onto the list.
peter1138
parents: 3900
diff changeset
  1002
		DrawPixelInfo tmp_dpi, *old_dpi;
5514
0f1c3a0aa66e (svn r7812) -Fix: rail station build window was not correctly updated after station_spread change
glx
parents: 5475
diff changeset
  1003
		const StationSpec *statspec = newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1004
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1005
		if (_railstation.dragdrop) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1006
			SetTileSelectSize(1, 1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1007
		} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1008
			int x = _railstation.numtracks;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1009
			int y = _railstation.platlength;
9772
eeb3d3284895 (svn r13909) -Codechange: use the same type before CmdBuildRailStation as it used in the command itself (Alberth)
rubidium
parents: 9771
diff changeset
  1010
			if (_railstation.orientation == AXIS_X) Swap(x, y);
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2725
diff changeset
  1011
			if (!_remove_button_clicked)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1012
				SetTileSelectSize(x, y);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1013
		}
201
c40d343115f8 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents: 179
diff changeset
  1014
9413
7042a8ec3fa8 (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
parents: 9354
diff changeset
  1015
		int rad = (_settings_game.station.modified_catchment) ? CA_TRAIN : CA_UNMODIFIED;
568
b0d0df062880 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 543
diff changeset
  1016
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1017
		if (_station_show_coverage)
568
b0d0df062880 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 543
diff changeset
  1018
			SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1019
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
  1020
		for (uint bits = 0; bits < 7; bits++) {
9413
7042a8ec3fa8 (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
parents: 9354
diff changeset
  1021
			bool disable = bits >= _settings_game.station.station_spread;
5514
0f1c3a0aa66e (svn r7812) -Fix: rail station build window was not correctly updated after station_spread change
glx
parents: 5475
diff changeset
  1022
			if (statspec == NULL) {
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1023
				this->SetWidgetDisabledState(bits + BRSW_PLATFORM_NUM_1, disable);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1024
				this->SetWidgetDisabledState(bits + BRSW_PLATFORM_LEN_1, disable);
5514
0f1c3a0aa66e (svn r7812) -Fix: rail station build window was not correctly updated after station_spread change
glx
parents: 5475
diff changeset
  1025
			} else {
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1026
				this->SetWidgetDisabledState(bits + BRSW_PLATFORM_NUM_1, HasBit(statspec->disallowed_platforms, bits) || disable);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1027
				this->SetWidgetDisabledState(bits + BRSW_PLATFORM_LEN_1, HasBit(statspec->disallowed_lengths,   bits) || disable);
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1028
			}
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1029
		}
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1030
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1031
		SetDParam(0, GetStationClassName(_railstation.station_class));
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1032
		this->DrawWidgets();
201
c40d343115f8 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents: 179
diff changeset
  1033
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
  1034
		int y_offset = newstations ? 90 : 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1035
3921
bf161a808b51 (svn r5048) - NewStations: Set up clipping areas to draw the station preview graphics in. This prevents larger station graphics from overflowing onto the list.
peter1138
parents: 3900
diff changeset
  1036
		/* Set up a clipping area for the '/' station preview */
4429
b4eb6d97996f (svn r6184) Remove the unused (because it was NULL in all callers) second parameter of FillDrawPixelInfo() and simplify some expressions
tron
parents: 4344
diff changeset
  1037
		if (FillDrawPixelInfo(&tmp_dpi, 7, 26 + y_offset, 66, 48)) {
3921
bf161a808b51 (svn r5048) - NewStations: Set up clipping areas to draw the station preview graphics in. This prevents larger station graphics from overflowing onto the list.
peter1138
parents: 3900
diff changeset
  1038
			old_dpi = _cur_dpi;
bf161a808b51 (svn r5048) - NewStations: Set up clipping areas to draw the station preview graphics in. This prevents larger station graphics from overflowing onto the list.
peter1138
parents: 3900
diff changeset
  1039
			_cur_dpi = &tmp_dpi;
bf161a808b51 (svn r5048) - NewStations: Set up clipping areas to draw the station preview graphics in. This prevents larger station graphics from overflowing onto the list.
peter1138
parents: 3900
diff changeset
  1040
			if (!DrawStationTile(32, 16, _cur_railtype, AXIS_X, _railstation.station_class, _railstation.station_type)) {
7272
d47fc9e22d1c (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7266
diff changeset
  1041
				StationPickerDrawSprite(32, 16, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 2);
3921
bf161a808b51 (svn r5048) - NewStations: Set up clipping areas to draw the station preview graphics in. This prevents larger station graphics from overflowing onto the list.
peter1138
parents: 3900
diff changeset
  1042
			}
bf161a808b51 (svn r5048) - NewStations: Set up clipping areas to draw the station preview graphics in. This prevents larger station graphics from overflowing onto the list.
peter1138
parents: 3900
diff changeset
  1043
			_cur_dpi = old_dpi;
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1044
		}
3921
bf161a808b51 (svn r5048) - NewStations: Set up clipping areas to draw the station preview graphics in. This prevents larger station graphics from overflowing onto the list.
peter1138
parents: 3900
diff changeset
  1045
bf161a808b51 (svn r5048) - NewStations: Set up clipping areas to draw the station preview graphics in. This prevents larger station graphics from overflowing onto the list.
peter1138
parents: 3900
diff changeset
  1046
		/* Set up a clipping area for the '\' station preview */
4429
b4eb6d97996f (svn r6184) Remove the unused (because it was NULL in all callers) second parameter of FillDrawPixelInfo() and simplify some expressions
tron
parents: 4344
diff changeset
  1047
		if (FillDrawPixelInfo(&tmp_dpi, 75, 26 + y_offset, 66, 48)) {
3921
bf161a808b51 (svn r5048) - NewStations: Set up clipping areas to draw the station preview graphics in. This prevents larger station graphics from overflowing onto the list.
peter1138
parents: 3900
diff changeset
  1048
			old_dpi = _cur_dpi;
bf161a808b51 (svn r5048) - NewStations: Set up clipping areas to draw the station preview graphics in. This prevents larger station graphics from overflowing onto the list.
peter1138
parents: 3900
diff changeset
  1049
			_cur_dpi = &tmp_dpi;
bf161a808b51 (svn r5048) - NewStations: Set up clipping areas to draw the station preview graphics in. This prevents larger station graphics from overflowing onto the list.
peter1138
parents: 3900
diff changeset
  1050
			if (!DrawStationTile(32, 16, _cur_railtype, AXIS_Y, _railstation.station_class, _railstation.station_type)) {
7272
d47fc9e22d1c (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7266
diff changeset
  1051
				StationPickerDrawSprite(32, 16, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 3);
3921
bf161a808b51 (svn r5048) - NewStations: Set up clipping areas to draw the station preview graphics in. This prevents larger station graphics from overflowing onto the list.
peter1138
parents: 3900
diff changeset
  1052
			}
bf161a808b51 (svn r5048) - NewStations: Set up clipping areas to draw the station preview graphics in. This prevents larger station graphics from overflowing onto the list.
peter1138
parents: 3900
diff changeset
  1053
			_cur_dpi = old_dpi;
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1054
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1055
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7773
diff changeset
  1056
		DrawStringCentered(74, 15 + y_offset, STR_3002_ORIENTATION, TC_FROMSTRING);
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7773
diff changeset
  1057
		DrawStringCentered(74, 76 + y_offset, STR_3003_NUMBER_OF_TRACKS, TC_FROMSTRING);
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7773
diff changeset
  1058
		DrawStringCentered(74, 101 + y_offset, STR_3004_PLATFORM_LENGTH, TC_FROMSTRING);
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7773
diff changeset
  1059
		DrawStringCentered(74, 141 + y_offset, STR_3066_COVERAGE_AREA_HIGHLIGHT, TC_FROMSTRING);
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1060
8846
1b90782b2c4e (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 8829
diff changeset
  1061
		int text_end = DrawStationCoverageAreaText(2, 166 + y_offset, SCT_ALL, rad, false);
1b90782b2c4e (svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents: 8829
diff changeset
  1062
		text_end = DrawStationCoverageAreaText(2, text_end + 4, SCT_ALL, rad, true) + 4;
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1063
		if (text_end != this->widget[BRSW_BACKGROUND].bottom) {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1064
			this->SetDirty();
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1065
			ResizeWindowForWidget(this, BRSW_BACKGROUND, 0, text_end - this->widget[BRSW_BACKGROUND].bottom);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1066
			this->SetDirty();
8423
0c0f0370620b (svn r11993) -Fix: Resize station/roadstop/dock/airport construction windows if cargo acceptance list is too long.
peter1138
parents: 8346
diff changeset
  1067
		}
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1068
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1069
		if (newstations) {
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1070
			uint y = 35;
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1071
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1072
			for (uint16 i = this->vscroll.pos; i < _railstation.station_count && i < (uint)(this->vscroll.pos + this->vscroll.cap); i++) {
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1073
				const StationSpec *statspec = GetCustomStationSpec(_railstation.station_class, i);
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1074
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1075
				if (statspec != NULL && statspec->name != 0) {
9020
8174bbda9abe (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
parents: 8973
diff changeset
  1076
					if (HasBit(statspec->callbackmask, CBM_STATION_AVAIL) && GB(GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE), 0, 8) == 0) {
9607
5a5728fb702a (svn r13649) -Codechange: Split the GfxFillRect() special flags from 'color' into their own parameter.
frosch
parents: 9435
diff changeset
  1077
						GfxFillRect(8, y - 2, 127, y + 10, 0, FILLRECT_CHECKER);
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1078
					}
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1079
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7773
diff changeset
  1080
					DrawStringTruncated(9, y, statspec->name, i == _railstation.station_type ? TC_WHITE : TC_BLACK, 118);
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1081
				} else {
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7773
diff changeset
  1082
					DrawStringTruncated(9, y, STR_STAT_CLASS_DFLT, i == _railstation.station_type ? TC_WHITE : TC_BLACK, 118);
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1083
				}
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1084
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1085
				y += 14;
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1086
			}
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1087
		}
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1088
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1089
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1090
	virtual void OnClick(Point pt, int widget)
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1091
	{
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1092
		switch (widget) {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1093
			case BRSW_PLATFORM_DIR_X:
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1094
			case BRSW_PLATFORM_DIR_Y:
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1095
				this->RaiseWidget(_railstation.orientation + BRSW_PLATFORM_DIR_X);
9772
eeb3d3284895 (svn r13909) -Codechange: use the same type before CmdBuildRailStation as it used in the command itself (Alberth)
rubidium
parents: 9771
diff changeset
  1096
				_railstation.orientation = (Axis)(widget - BRSW_PLATFORM_DIR_X);
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1097
				this->LowerWidget(_railstation.orientation + BRSW_PLATFORM_DIR_X);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1098
				SndPlayFx(SND_15_BEEP);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1099
				this->SetDirty();
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1100
				break;
6207
a04057330c4d (svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents: 6117
diff changeset
  1101
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1102
			case BRSW_PLATFORM_NUM_1:
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1103
			case BRSW_PLATFORM_NUM_2:
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1104
			case BRSW_PLATFORM_NUM_3:
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1105
			case BRSW_PLATFORM_NUM_4:
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1106
			case BRSW_PLATFORM_NUM_5:
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1107
			case BRSW_PLATFORM_NUM_6:
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1108
			case BRSW_PLATFORM_NUM_7: {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1109
				this->RaiseWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1110
				this->RaiseWidget(BRSW_PLATFORM_DRAG_N_DROP);
6207
a04057330c4d (svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents: 6117
diff changeset
  1111
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1112
				_railstation.numtracks = widget - BRSW_PLATFORM_NUM_BEGIN;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1113
				_railstation.dragdrop = false;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1114
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1115
				const StationSpec *statspec = _railstation.newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1116
				if (statspec != NULL && HasBit(statspec->disallowed_lengths, _railstation.platlength - 1)) {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1117
					/* The previously selected number of platforms in invalid */
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1118
					for (uint i = 0; i < 7; i++) {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1119
						if (!HasBit(statspec->disallowed_lengths, i)) {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1120
							this->RaiseWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1121
							_railstation.platlength = i + 1;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1122
							break;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1123
						}
6207
a04057330c4d (svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents: 6117
diff changeset
  1124
					}
a04057330c4d (svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents: 6117
diff changeset
  1125
				}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1126
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1127
				this->LowerWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1128
				this->LowerWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1129
				SndPlayFx(SND_15_BEEP);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1130
				this->SetDirty();
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1131
				break;
6207
a04057330c4d (svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents: 6117
diff changeset
  1132
			}
a04057330c4d (svn r8999) -Fix [FS#450]: do not select a disabled platform length/number of track count when going out of drag-drop mode.
rubidium
parents: 6117
diff changeset
  1133
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1134
			case BRSW_PLATFORM_LEN_1:
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1135
			case BRSW_PLATFORM_LEN_2:
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1136
			case BRSW_PLATFORM_LEN_3:
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1137
			case BRSW_PLATFORM_LEN_4:
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1138
			case BRSW_PLATFORM_LEN_5:
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1139
			case BRSW_PLATFORM_LEN_6:
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1140
			case BRSW_PLATFORM_LEN_7: {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1141
				this->RaiseWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1142
				this->RaiseWidget(BRSW_PLATFORM_DRAG_N_DROP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1143
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1144
				_railstation.platlength = widget - BRSW_PLATFORM_LEN_BEGIN;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1145
				_railstation.dragdrop = false;
7773
6a97c5cba126 (svn r11322) -Codechange: select an allowed station size when drag&drop is disabled. Patch by Wolf01.
rubidium
parents: 7729
diff changeset
  1146
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1147
				const StationSpec *statspec = _railstation.newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1148
				if (statspec != NULL && HasBit(statspec->disallowed_platforms, _railstation.numtracks - 1)) {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1149
					/* The previously selected number of tracks in invalid */
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1150
					for (uint i = 0; i < 7; i++) {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1151
						if (!HasBit(statspec->disallowed_platforms, i)) {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1152
							this->RaiseWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1153
							_railstation.numtracks = i + 1;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1154
							break;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1155
						}
7773
6a97c5cba126 (svn r11322) -Codechange: select an allowed station size when drag&drop is disabled. Patch by Wolf01.
rubidium
parents: 7729
diff changeset
  1156
					}
6a97c5cba126 (svn r11322) -Codechange: select an allowed station size when drag&drop is disabled. Patch by Wolf01.
rubidium
parents: 7729
diff changeset
  1157
				}
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1158
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1159
				this->LowerWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1160
				this->LowerWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1161
				SndPlayFx(SND_15_BEEP);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1162
				this->SetDirty();
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1163
				break;
7773
6a97c5cba126 (svn r11322) -Codechange: select an allowed station size when drag&drop is disabled. Patch by Wolf01.
rubidium
parents: 7729
diff changeset
  1164
			}
6a97c5cba126 (svn r11322) -Codechange: select an allowed station size when drag&drop is disabled. Patch by Wolf01.
rubidium
parents: 7729
diff changeset
  1165
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1166
			case BRSW_PLATFORM_DRAG_N_DROP: {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1167
				_railstation.dragdrop ^= true;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1168
				this->ToggleWidgetLoweredState(BRSW_PLATFORM_DRAG_N_DROP);
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1169
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1170
				/* get the first allowed length/number of platforms */
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1171
				const StationSpec *statspec = _railstation.newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1172
				if (statspec != NULL && HasBit(statspec->disallowed_lengths, _railstation.platlength - 1)) {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1173
					for (uint i = 0; i < 7; i++) {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1174
						if (!HasBit(statspec->disallowed_lengths, i)) {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1175
							this->RaiseWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1176
							_railstation.platlength = i + 1;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1177
							break;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1178
						}
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1179
					}
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1180
				}
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1181
				if (statspec != NULL && HasBit(statspec->disallowed_platforms, _railstation.numtracks - 1)) {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1182
					for (uint i = 0; i < 7; i++) {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1183
						if (!HasBit(statspec->disallowed_platforms, i)) {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1184
							this->RaiseWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1185
							_railstation.numtracks = i + 1;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1186
							break;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1187
						}
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1188
					}
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1189
				}
5049
43340069c983 (svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents: 5005
diff changeset
  1190
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1191
				this->SetWidgetLoweredState(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN, !_railstation.dragdrop);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1192
				this->SetWidgetLoweredState(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN, !_railstation.dragdrop);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1193
				SndPlayFx(SND_15_BEEP);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1194
				this->SetDirty();
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1195
			} break;
5049
43340069c983 (svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents: 5005
diff changeset
  1196
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1197
			case BRSW_HIGHLIGHT_OFF:
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1198
			case BRSW_HIGHLIGHT_ON:
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1199
				_station_show_coverage = (widget != BRSW_HIGHLIGHT_OFF);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1200
				this->SetWidgetLoweredState(BRSW_HIGHLIGHT_OFF, !_station_show_coverage);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1201
				this->SetWidgetLoweredState(BRSW_HIGHLIGHT_ON, _station_show_coverage);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1202
				SndPlayFx(SND_15_BEEP);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1203
				this->SetDirty();
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1204
				break;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1205
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1206
			case BRSW_NEWST_DROPDOWN:
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1207
				ShowDropDownList(this, BuildStationClassDropDown(), _railstation.station_class, BRSW_NEWST_DROPDOWN);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1208
				break;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1209
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1210
			case BRSW_NEWST_LIST: {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1211
				const StationSpec *statspec;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1212
				int y = (pt.y - 32) / 14;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1213
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1214
				if (y >= this->vscroll.cap) return;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1215
				y += this->vscroll.pos;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1216
				if (y >= _railstation.station_count) return;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1217
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1218
				/* Check station availability callback */
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1219
				statspec = GetCustomStationSpec(_railstation.station_class, y);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1220
				if (statspec != NULL &&
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1221
					HasBit(statspec->callbackmask, CBM_STATION_AVAIL) &&
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1222
					GB(GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE), 0, 8) == 0) return;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1223
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1224
				_railstation.station_type = y;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1225
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1226
				this->CheckSelectedSize(statspec);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1227
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1228
				SndPlayFx(SND_15_BEEP);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1229
				this->SetDirty();
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1230
				break;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1231
			}
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1232
		}
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1233
	}
201
c40d343115f8 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents: 179
diff changeset
  1234
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1235
	virtual void OnDropdownSelect(int widget, int index)
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1236
	{
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1237
		if (_railstation.station_class != index) {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1238
			_railstation.station_class = (StationClassID)index;
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1239
			_railstation.station_type  = 0;
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1240
			_railstation.station_count = GetNumCustomStations(_railstation.station_class);
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1241
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1242
			this->CheckSelectedSize(GetCustomStationSpec(_railstation.station_class, _railstation.station_type));
5049
43340069c983 (svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
peter1138
parents: 5005
diff changeset
  1243
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1244
			this->vscroll.count = _railstation.station_count;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1245
			this->vscroll.pos   = _railstation.station_type;
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1246
		}
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1247
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1248
		SndPlayFx(SND_15_BEEP);
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1249
		this->SetDirty();
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1250
	}
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1251
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1252
	virtual void OnTick()
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1253
	{
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1254
		CheckRedrawStationCoverage(this);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1255
	}
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1256
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1257
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
  1258
/** Widget definition of the standard build rail station window */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1259
static const Widget _station_builder_widgets[] = {
9762
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1260
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_DARK_GREEN,   0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},               // BRSW_CLOSEBOX
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1261
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_DARK_GREEN,  11,   147,     0,    13, STR_3000_RAIL_STATION_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS},     // BRSW_CAPTION
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1262
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_DARK_GREEN,   0,   147,    14,   199, 0x0,                             STR_NULL},                            // BRSW_BACKGROUND
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1263
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,         7,    72,    26,    73, 0x0,                             STR_304E_SELECT_RAILROAD_STATION},    // BRSW_PLATFORM_DIR_X
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1264
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,        75,   140,    26,    73, 0x0,                             STR_304E_SELECT_RAILROAD_STATION},    // BRSW_PLATFORM_DIR_Y
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1265
9762
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1266
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        22,    36,    87,    98, STR_00CB_1,                      STR_304F_SELECT_NUMBER_OF_PLATFORMS}, // BRSW_PLATFORM_NUM_1
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1267
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        37,    51,    87,    98, STR_00CC_2,                      STR_304F_SELECT_NUMBER_OF_PLATFORMS}, // BRSW_PLATFORM_NUM_2
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1268
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        52,    66,    87,    98, STR_00CD_3,                      STR_304F_SELECT_NUMBER_OF_PLATFORMS}, // BRSW_PLATFORM_NUM_3
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1269
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        67,    81,    87,    98, STR_00CE_4,                      STR_304F_SELECT_NUMBER_OF_PLATFORMS}, // BRSW_PLATFORM_NUM_4
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1270
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        82,    96,    87,    98, STR_00CF_5,                      STR_304F_SELECT_NUMBER_OF_PLATFORMS}, // BRSW_PLATFORM_NUM_5
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1271
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        97,   111,    87,    98, STR_6,                           STR_304F_SELECT_NUMBER_OF_PLATFORMS}, // BRSW_PLATFORM_NUM_6
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1272
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,       112,   126,    87,    98, STR_7,                           STR_304F_SELECT_NUMBER_OF_PLATFORMS}, // BRSW_PLATFORM_NUM_7
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1273
9762
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1274
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        22,    36,   112,   123, STR_00CB_1,                      STR_3050_SELECT_LENGTH_OF_RAILROAD},  // BRSW_PLATFORM_LEN_1
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1275
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        37,    51,   112,   123, STR_00CC_2,                      STR_3050_SELECT_LENGTH_OF_RAILROAD},  // BRSW_PLATFORM_LEN_2
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1276
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        52,    66,   112,   123, STR_00CD_3,                      STR_3050_SELECT_LENGTH_OF_RAILROAD},  // BRSW_PLATFORM_LEN_3
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1277
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        67,    81,   112,   123, STR_00CE_4,                      STR_3050_SELECT_LENGTH_OF_RAILROAD},  // BRSW_PLATFORM_LEN_4
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1278
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        82,    96,   112,   123, STR_00CF_5,                      STR_3050_SELECT_LENGTH_OF_RAILROAD},  // BRSW_PLATFORM_LEN_5
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1279
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        97,   111,   112,   123, STR_6,                           STR_3050_SELECT_LENGTH_OF_RAILROAD},  // BRSW_PLATFORM_LEN_6
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1280
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,       112,   126,   112,   123, STR_7,                           STR_3050_SELECT_LENGTH_OF_RAILROAD},  // BRSW_PLATFORM_LEN_7
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1281
9762
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1282
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        37,   111,   126,   137, STR_DRAG_DROP,                   STR_STATION_DRAG_DROP},               // BRSW_PLATFORM_DRAG_N_DROP
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1283
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        14,    73,   152,   163, STR_02DB_OFF,                    STR_3065_DON_T_HIGHLIGHT_COVERAGE},   // BRSW_HIGHLIGHT_OFF
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1284
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        74,   133,   152,   163, STR_02DA_ON,                     STR_3064_HIGHLIGHT_COVERAGE_AREA},    // BRSW_HIGHLIGHT_ON
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 159
diff changeset
  1285
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1286
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1287
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
  1288
/** Widget definition of the build NewGRF rail station window */
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1289
static const Widget _newstation_builder_widgets[] = {
9762
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1290
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_DARK_GREEN,   0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},               // BRSW_CLOSEBOX
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1291
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_DARK_GREEN,  11,   147,     0,    13, STR_3000_RAIL_STATION_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS},     // BRSW_CAPTION
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1292
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_DARK_GREEN,   0,   147,    14,   289, 0x0,                             STR_NULL},                            // BRSW_BACKGROUND
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1293
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,         7,    72,   116,   163, 0x0,                             STR_304E_SELECT_RAILROAD_STATION},    // BRSW_PLATFORM_DIR_X
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1294
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,        75,   140,   116,   163, 0x0,                             STR_304E_SELECT_RAILROAD_STATION},    // BRSW_PLATFORM_DIR_Y
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1295
9762
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1296
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        22,    36,   177,   188, STR_00CB_1,                      STR_304F_SELECT_NUMBER_OF_PLATFORMS}, // BRSW_PLATFORM_NUM_1
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1297
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        37,    51,   177,   188, STR_00CC_2,                      STR_304F_SELECT_NUMBER_OF_PLATFORMS}, // BRSW_PLATFORM_NUM_2
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1298
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        52,    66,   177,   188, STR_00CD_3,                      STR_304F_SELECT_NUMBER_OF_PLATFORMS}, // BRSW_PLATFORM_NUM_3
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1299
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        67,    81,   177,   188, STR_00CE_4,                      STR_304F_SELECT_NUMBER_OF_PLATFORMS}, // BRSW_PLATFORM_NUM_4
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1300
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        82,    96,   177,   188, STR_00CF_5,                      STR_304F_SELECT_NUMBER_OF_PLATFORMS}, // BRSW_PLATFORM_NUM_5
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1301
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        97,   111,   177,   188, STR_6,                           STR_304F_SELECT_NUMBER_OF_PLATFORMS}, // BRSW_PLATFORM_NUM_6
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1302
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,       112,   126,   177,   188, STR_7,                           STR_304F_SELECT_NUMBER_OF_PLATFORMS}, // BRSW_PLATFORM_NUM_7
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1303
9762
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1304
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        22,    36,   202,   213, STR_00CB_1,                      STR_3050_SELECT_LENGTH_OF_RAILROAD},  // BRSW_PLATFORM_LEN_1
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1305
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        37,    51,   202,   213, STR_00CC_2,                      STR_3050_SELECT_LENGTH_OF_RAILROAD},  // BRSW_PLATFORM_LEN_2
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1306
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        52,    66,   202,   213, STR_00CD_3,                      STR_3050_SELECT_LENGTH_OF_RAILROAD},  // BRSW_PLATFORM_LEN_3
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1307
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        67,    81,   202,   213, STR_00CE_4,                      STR_3050_SELECT_LENGTH_OF_RAILROAD},  // BRSW_PLATFORM_LEN_4
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1308
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        82,    96,   202,   213, STR_00CF_5,                      STR_3050_SELECT_LENGTH_OF_RAILROAD},  // BRSW_PLATFORM_LEN_5
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1309
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        97,   111,   202,   213, STR_6,                           STR_3050_SELECT_LENGTH_OF_RAILROAD},  // BRSW_PLATFORM_LEN_6
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1310
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,       112,   126,   202,   213, STR_7,                           STR_3050_SELECT_LENGTH_OF_RAILROAD},  // BRSW_PLATFORM_LEN_7
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1311
9762
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1312
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        37,   111,   216,   227, STR_DRAG_DROP,                   STR_STATION_DRAG_DROP},               // BRSW_PLATFORM_DRAG_N_DROP
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1313
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        14,    73,   242,   253, STR_02DB_OFF,                    STR_3065_DON_T_HIGHLIGHT_COVERAGE},   // BRSW_HIGHLIGHT_OFF
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1314
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,        74,   133,   242,   253, STR_02DA_ON,                     STR_3064_HIGHLIGHT_COVERAGE_AREA},    // BRSW_HIGHLIGHT_ON
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1315
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1316
/* newstations gui additions */
9762
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1317
{ WWT_DROPDOWNIN,   RESIZE_NONE,  COLOUR_GREY,         7,   140,    17,    28, STR_02BD,                        STR_SELECT_STATION_CLASS_TIP},        // BRSW_NEWST_DROPDOWN
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1318
{     WWT_MATRIX,   RESIZE_NONE,  COLOUR_GREY,         7,   128,    32,   102, 0x501,                           STR_SELECT_STATION_TYPE_TIP},         // BRSW_NEWST_LIST
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1319
{  WWT_SCROLLBAR,   RESIZE_NONE,  COLOUR_GREY,       129,   140,    32,   102, 0x0,                             STR_0190_SCROLL_BAR_SCROLLS_LIST},    // BRSW_NEWST_SCROLL
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1320
{   WIDGETS_END},
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1321
};
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1322
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
  1323
/** High level window description of the default station-build window */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1324
static const WindowDesc _station_builder_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7272
diff changeset
  1325
	WDP_AUTO, WDP_AUTO, 148, 200, 148, 200,
5070
7f5b13b7e728 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 5049
diff changeset
  1326
	WC_BUILD_STATION, WC_BUILD_TOOLBAR,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1327
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1328
	_station_builder_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1329
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1330
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
  1331
/** High level window description of the newGRF station-build window */
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1332
static const WindowDesc _newstation_builder_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7272
diff changeset
  1333
	WDP_AUTO, WDP_AUTO, 148, 290, 148, 290,
5070
7f5b13b7e728 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 5049
diff changeset
  1334
	WC_BUILD_STATION, WC_BUILD_TOOLBAR,
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1335
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1336
	_newstation_builder_widgets,
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1337
};
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1338
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
  1339
/** Open station build window */
9338
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
  1340
static void ShowStationBuilder(Window *parent)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1341
{
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1342
	if (GetNumStationClasses() <= 2 && GetNumCustomStations(STAT_CLASS_DFLT) == 1) {
9338
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
  1343
		new BuildRailStationWindow(&_station_builder_desc, parent, false);
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1344
	} else {
9338
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
  1345
		new BuildRailStationWindow(&_newstation_builder_desc, parent, true);
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1346
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1347
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1348
7991
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1349
/** Enum referring to the widgets of the signal window */
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1350
enum BuildSignalWidgets {
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1351
	BSW_CLOSEBOX = 0,
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1352
	BSW_CAPTION,
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1353
	BSW_SEMAPHORE_NORM,
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1354
	BSW_SEMAPHORE_ENTRY,
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1355
	BSW_SEMAPHORE_EXIT,
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1356
	BSW_SEMAPHORE_COMBO,
9796
4d1358696a92 (svn r13938) -Codechange [YAPP]: Add the new signals to the build signal GUI. (michi_cc)
rubidium
parents: 9794
diff changeset
  1357
	BSW_SEMAPHORE_PBS,
4d1358696a92 (svn r13938) -Codechange [YAPP]: Add the new signals to the build signal GUI. (michi_cc)
rubidium
parents: 9794
diff changeset
  1358
	BSW_SEMAPHORE_PBS_OWAY,
7991
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1359
	BSW_ELECTRIC_NORM,
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1360
	BSW_ELECTRIC_ENTRY,
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1361
	BSW_ELECTRIC_EXIT,
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1362
	BSW_ELECTRIC_COMBO,
9796
4d1358696a92 (svn r13938) -Codechange [YAPP]: Add the new signals to the build signal GUI. (michi_cc)
rubidium
parents: 9794
diff changeset
  1363
	BSW_ELECTRIC_PBS,
4d1358696a92 (svn r13938) -Codechange [YAPP]: Add the new signals to the build signal GUI. (michi_cc)
rubidium
parents: 9794
diff changeset
  1364
	BSW_ELECTRIC_PBS_OWAY,
7991
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1365
	BSW_CONVERT,
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1366
	BSW_DRAG_SIGNALS_DENSITY,
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1367
	BSW_DRAG_SIGNALS_DENSITY_DECREASE,
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1368
	BSW_DRAG_SIGNALS_DENSITY_INCREASE,
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1369
};
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1370
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1371
struct BuildSignalWindow : public PickerWindowBase {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1372
private:
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1373
	/**
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1374
	 * Draw dynamic a signal-sprite in a button in the signal GUI
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1375
	 * 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)
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1376
	 *
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1377
	 * @param widget_index index of this widget in the window
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1378
	 * @param image        the sprite to draw
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1379
	 * @param xrel         the relativ x value of the sprite in the grf
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1380
	 * @param xsize        the width of the sprite
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1381
	 */
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1382
	void DrawSignalSprite(byte widget_index, SpriteID image, int8 xrel, uint8 xsize)
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1383
	{
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1384
		DrawSprite(image + this->IsWidgetLowered(widget_index), PAL_NONE,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1385
				this->widget[widget_index].left + (this->widget[widget_index].right - this->widget[widget_index].left) / 2 - xrel - xsize / 2 +
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1386
				this->IsWidgetLowered(widget_index), this->widget[widget_index].bottom - 3 + this->IsWidgetLowered(widget_index));
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1387
	}
7991
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1388
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1389
public:
9338
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
  1390
	BuildSignalWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1391
	{
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1392
		this->FindWindowPlacementAndResize(desc);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1393
	};
7991
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1394
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1395
	virtual void OnPaint()
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1396
	{
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1397
		this->LowerWidget((_cur_signal_variant == SIG_ELECTRIC ? BSW_ELECTRIC_NORM : BSW_SEMAPHORE_NORM) + _cur_signal_type);
7991
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1398
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1399
		this->SetWidgetLoweredState(BSW_CONVERT, _convert_signal_button);
7991
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1400
9413
7042a8ec3fa8 (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
parents: 9354
diff changeset
  1401
		this->SetWidgetDisabledState(BSW_DRAG_SIGNALS_DENSITY_DECREASE, _settings_client.gui.drag_signals_density == 1);
7042a8ec3fa8 (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
parents: 9354
diff changeset
  1402
		this->SetWidgetDisabledState(BSW_DRAG_SIGNALS_DENSITY_INCREASE, _settings_client.gui.drag_signals_density == 20);
7991
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1403
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1404
		this->DrawWidgets();
7991
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1405
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1406
		/* The 'hardcoded' off sets are needed because they are reused sprites. */
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1407
		this->DrawSignalSprite(BSW_SEMAPHORE_NORM,  SPR_IMG_SIGNAL_SEMAPHORE_NORM,   0, 12); // xsize of sprite + 1 ==  9
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1408
		this->DrawSignalSprite(BSW_SEMAPHORE_ENTRY, SPR_IMG_SIGNAL_SEMAPHORE_ENTRY, -1, 13); // xsize of sprite + 1 == 10
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1409
		this->DrawSignalSprite(BSW_SEMAPHORE_EXIT,  SPR_IMG_SIGNAL_SEMAPHORE_EXIT,   0, 12); // xsize of sprite + 1 ==  9
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1410
		this->DrawSignalSprite(BSW_SEMAPHORE_COMBO, SPR_IMG_SIGNAL_SEMAPHORE_COMBO,  0, 12); // xsize of sprite + 1 ==  9
9796
4d1358696a92 (svn r13938) -Codechange [YAPP]: Add the new signals to the build signal GUI. (michi_cc)
rubidium
parents: 9794
diff changeset
  1411
		this->DrawSignalSprite(BSW_SEMAPHORE_PBS,   SPR_IMG_SIGNAL_SEMAPHORE_PBS,    0, 12); // xsize of sprite + 1 ==  9
9886
0aba4fa1e667 (svn r14034) -Cleanup (r13938) [FS#2210]: Typo in YAPP constant. (Eddi)
peter1138
parents: 9885
diff changeset
  1412
		this->DrawSignalSprite(BSW_SEMAPHORE_PBS_OWAY, SPR_IMG_SIGNAL_SEMAPHORE_PBS_OWAY, -1, 13); // xsize of sprite + 1 == 10
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1413
		this->DrawSignalSprite(BSW_ELECTRIC_NORM,   SPR_IMG_SIGNAL_ELECTRIC_NORM,   -1,  4);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1414
		this->DrawSignalSprite(BSW_ELECTRIC_ENTRY,  SPR_IMG_SIGNAL_ELECTRIC_ENTRY,  -2,  6);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1415
		this->DrawSignalSprite(BSW_ELECTRIC_EXIT,   SPR_IMG_SIGNAL_ELECTRIC_EXIT,   -2,  6);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1416
		this->DrawSignalSprite(BSW_ELECTRIC_COMBO,  SPR_IMG_SIGNAL_ELECTRIC_COMBO,  -2,  6);
9796
4d1358696a92 (svn r13938) -Codechange [YAPP]: Add the new signals to the build signal GUI. (michi_cc)
rubidium
parents: 9794
diff changeset
  1417
		this->DrawSignalSprite(BSW_ELECTRIC_PBS,    SPR_IMG_SIGNAL_ELECTRIC_PBS,    -1,  4);
9886
0aba4fa1e667 (svn r14034) -Cleanup (r13938) [FS#2210]: Typo in YAPP constant. (Eddi)
peter1138
parents: 9885
diff changeset
  1418
		this->DrawSignalSprite(BSW_ELECTRIC_PBS_OWAY,SPR_IMG_SIGNAL_ELECTRIC_PBS_OWAY,-2,  6);
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1419
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1420
		/* Draw dragging signal density value in the BSW_DRAG_SIGNALS_DENSITY widget */
9413
7042a8ec3fa8 (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
parents: 9354
diff changeset
  1421
		SetDParam(0, _settings_client.gui.drag_signals_density);
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1422
		DrawStringCentered(this->widget[BSW_DRAG_SIGNALS_DENSITY].left + (this->widget[BSW_DRAG_SIGNALS_DENSITY].right -
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1423
				this->widget[BSW_DRAG_SIGNALS_DENSITY].left) / 2 + 1,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1424
				this->widget[BSW_DRAG_SIGNALS_DENSITY].top + 2, STR_JUST_INT, TC_ORANGE);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1425
	}
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1426
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1427
	virtual void OnClick(Point pt, int widget)
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1428
	{
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1429
		switch (widget) {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1430
			case BSW_SEMAPHORE_NORM:
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1431
			case BSW_SEMAPHORE_ENTRY:
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1432
			case BSW_SEMAPHORE_EXIT:
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1433
			case BSW_SEMAPHORE_COMBO:
9796
4d1358696a92 (svn r13938) -Codechange [YAPP]: Add the new signals to the build signal GUI. (michi_cc)
rubidium
parents: 9794
diff changeset
  1434
			case BSW_SEMAPHORE_PBS:
4d1358696a92 (svn r13938) -Codechange [YAPP]: Add the new signals to the build signal GUI. (michi_cc)
rubidium
parents: 9794
diff changeset
  1435
			case BSW_SEMAPHORE_PBS_OWAY:
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1436
			case BSW_ELECTRIC_NORM:
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1437
			case BSW_ELECTRIC_ENTRY:
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1438
			case BSW_ELECTRIC_EXIT:
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1439
			case BSW_ELECTRIC_COMBO:
9796
4d1358696a92 (svn r13938) -Codechange [YAPP]: Add the new signals to the build signal GUI. (michi_cc)
rubidium
parents: 9794
diff changeset
  1440
			case BSW_ELECTRIC_PBS:
4d1358696a92 (svn r13938) -Codechange [YAPP]: Add the new signals to the build signal GUI. (michi_cc)
rubidium
parents: 9794
diff changeset
  1441
			case BSW_ELECTRIC_PBS_OWAY:
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1442
				this->RaiseWidget((_cur_signal_variant == SIG_ELECTRIC ? BSW_ELECTRIC_NORM : BSW_SEMAPHORE_NORM) + _cur_signal_type);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1443
9796
4d1358696a92 (svn r13938) -Codechange [YAPP]: Add the new signals to the build signal GUI. (michi_cc)
rubidium
parents: 9794
diff changeset
  1444
				_cur_signal_type = (SignalType)((uint)((widget - BSW_SEMAPHORE_NORM) % (SIGTYPE_LAST + 1)));
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1445
				_cur_signal_variant = widget >= BSW_ELECTRIC_NORM ? SIG_ELECTRIC : SIG_SEMAPHORE;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1446
				break;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1447
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1448
			case BSW_CONVERT:
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1449
				_convert_signal_button = !_convert_signal_button;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1450
				break;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1451
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1452
			case BSW_DRAG_SIGNALS_DENSITY_DECREASE:
9413
7042a8ec3fa8 (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
parents: 9354
diff changeset
  1453
				if (_settings_client.gui.drag_signals_density > 1) {
7042a8ec3fa8 (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
parents: 9354
diff changeset
  1454
					_settings_client.gui.drag_signals_density--;
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1455
					SetWindowDirty(FindWindowById(WC_GAME_OPTIONS, 0));
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1456
				}
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1457
				break;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1458
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1459
			case BSW_DRAG_SIGNALS_DENSITY_INCREASE:
9413
7042a8ec3fa8 (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
parents: 9354
diff changeset
  1460
				if (_settings_client.gui.drag_signals_density < 20) {
7042a8ec3fa8 (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
parents: 9354
diff changeset
  1461
					_settings_client.gui.drag_signals_density++;
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1462
					SetWindowDirty(FindWindowById(WC_GAME_OPTIONS, 0));
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1463
				}
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1464
				break;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1465
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1466
			default: break;
7991
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1467
		}
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1468
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1469
		this->SetDirty();
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1470
	}
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1471
};
7991
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1472
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1473
/** Widget definition of the build signal window */
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1474
static const Widget _signal_builder_widgets[] = {
9762
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1475
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_DARK_GREEN,   0,  10,   0,  13, STR_00C5,               STR_018B_CLOSE_WINDOW},                 // BSW_CLOSEBOX
9885
fc1907d1c650 (svn r14033) -Fix (r13938) [FS#2209]: Wrong offset in signal GUI. (Eddi)
peter1138
parents: 9796
diff changeset
  1476
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_DARK_GREEN,  11, 153,   0,  13, STR_SIGNAL_SELECTION,   STR_018C_WINDOW_TITLE_DRAG_THIS},       // BSW_CAPTION
7991
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1477
9762
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1478
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_DARK_GREEN,   0,  21,  14,  40, STR_NULL,               STR_BUILD_SIGNAL_SEMAPHORE_NORM_TIP},   // BSW_SEMAPHORE_NORM
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1479
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_DARK_GREEN,  22,  43,  14,  40, STR_NULL,               STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TIP},  // BSW_SEMAPHORE_ENTRY
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1480
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_DARK_GREEN,  44,  65,  14,  40, STR_NULL,               STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TIP},   // BSW_SEMAPHORE_EXIT
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1481
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_DARK_GREEN,  66,  87,  14,  40, STR_NULL,               STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TIP},  // BSW_SEMAPHORE_COMBO
9796
4d1358696a92 (svn r13938) -Codechange [YAPP]: Add the new signals to the build signal GUI. (michi_cc)
rubidium
parents: 9794
diff changeset
  1482
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_DARK_GREEN,  88, 109,  14,  40, STR_NULL,               STR_BUILD_SIGNAL_SEMAPHORE_PBS_TIP},    // BSW_SEMAPHORE_PBS
9885
fc1907d1c650 (svn r14033) -Fix (r13938) [FS#2209]: Wrong offset in signal GUI. (Eddi)
peter1138
parents: 9796
diff changeset
  1483
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_DARK_GREEN, 110, 131,  14,  40, STR_NULL,               STR_BUILD_SIGNAL_SEMAPHORE_PBS_OWAY_TIP},// BSW_SEMAPHORE_PBS_OWAY
7991
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1484
9762
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1485
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_DARK_GREEN,   0,  21,  41,  67, STR_NULL,               STR_BUILD_SIGNAL_ELECTRIC_NORM_TIP},    // BSW_ELECTRIC_NORM
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1486
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_DARK_GREEN,  22,  43,  41,  67, STR_NULL,               STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TIP},   // BSW_ELECTRIC_ENTRY
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1487
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_DARK_GREEN,  44,  65,  41,  67, STR_NULL,               STR_BUILD_SIGNAL_ELECTRIC_EXIT_TIP},    // BSW_ELECTRIC_EXIT
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1488
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_DARK_GREEN,  66,  87,  41,  67, STR_NULL,               STR_BUILD_SIGNAL_ELECTRIC_COMBO_TIP},   // BSW_ELECTRIC_COMBO
9796
4d1358696a92 (svn r13938) -Codechange [YAPP]: Add the new signals to the build signal GUI. (michi_cc)
rubidium
parents: 9794
diff changeset
  1489
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_DARK_GREEN,  88, 109,  41,  67, STR_NULL,               STR_BUILD_SIGNAL_ELECTRIC_PBS_TIP},     // BSW_ELECTRIC_PBS
9885
fc1907d1c650 (svn r14033) -Fix (r13938) [FS#2209]: Wrong offset in signal GUI. (Eddi)
peter1138
parents: 9796
diff changeset
  1490
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_DARK_GREEN, 110, 131,  41,  67, STR_NULL,               STR_BUILD_SIGNAL_ELECTRIC_PBS_OWAY_TIP},// BSW_ELECTRIC_PBS_OWAY
9762
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1491
9885
fc1907d1c650 (svn r14033) -Fix (r13938) [FS#2209]: Wrong offset in signal GUI. (Eddi)
peter1138
parents: 9796
diff changeset
  1492
{     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN, 132, 153,  14,  40, SPR_IMG_SIGNAL_CONVERT, STR_SIGNAL_CONVERT_TIP},                // BSW_CONVERT
fc1907d1c650 (svn r14033) -Fix (r13938) [FS#2209]: Wrong offset in signal GUI. (Eddi)
peter1138
parents: 9796
diff changeset
  1493
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_DARK_GREEN, 132, 153,  41,  67, STR_NULL,               STR_DRAG_SIGNALS_DENSITY_TIP},          // BSW_DRAG_SIGNALS_DENSITY
fc1907d1c650 (svn r14033) -Fix (r13938) [FS#2209]: Wrong offset in signal GUI. (Eddi)
peter1138
parents: 9796
diff changeset
  1494
{ WWT_PUSHIMGBTN,   RESIZE_NONE,  COLOUR_GREY,       134, 142,  54,  65, SPR_ARROW_LEFT,         STR_DRAG_SIGNALS_DENSITY_DECREASE_TIP}, // BSW_DRAG_SIGNALS_DENSITY_DECREASE
fc1907d1c650 (svn r14033) -Fix (r13938) [FS#2209]: Wrong offset in signal GUI. (Eddi)
peter1138
parents: 9796
diff changeset
  1495
{ WWT_PUSHIMGBTN,   RESIZE_NONE,  COLOUR_GREY,       143, 151,  54,  65, SPR_ARROW_RIGHT,        STR_DRAG_SIGNALS_DENSITY_INCREASE_TIP}, // BSW_DRAG_SIGNALS_DENSITY_INCREASE
7991
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1496
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1497
{   WIDGETS_END},
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1498
};
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1499
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1500
/** Signal selection window description */
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1501
static const WindowDesc _signal_builder_desc = {
9885
fc1907d1c650 (svn r14033) -Fix (r13938) [FS#2209]: Wrong offset in signal GUI. (Eddi)
peter1138
parents: 9796
diff changeset
  1502
	WDP_AUTO, WDP_AUTO, 154, 68, 154, 68,
7991
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1503
	WC_BUILD_SIGNAL, WC_BUILD_TOOLBAR,
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1504
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1505
	_signal_builder_widgets,
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1506
};
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1507
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1508
/**
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1509
 * Open the signal selection window
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1510
 */
9338
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
  1511
static void ShowSignalBuilder(Window *parent)
7991
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1512
{
9338
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
  1513
	new BuildSignalWindow(&_signal_builder_desc, parent);
7991
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1514
}
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7955
diff changeset
  1515
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1516
struct BuildRailDepotWindow : public PickerWindowBase {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1517
private:
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1518
	/** Enum referring to the widgets of the build rail depot window */
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1519
	enum BuildRailDepotWidgets {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1520
		BRDW_CLOSEBOX = 0,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1521
		BRDW_CAPTION,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1522
		BRDW_BACKGROUND,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1523
		BRDW_DEPOT_NE,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1524
		BRDW_DEPOT_SE,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1525
		BRDW_DEPOT_SW,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1526
		BRDW_DEPOT_NW,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1527
	};
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
  1528
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1529
public:
9338
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
  1530
	BuildRailDepotWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1531
	{
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1532
		this->LowerWidget(_build_depot_direction + BRDW_DEPOT_NE);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1533
		this->FindWindowPlacementAndResize(desc);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1534
	}
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
  1535
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1536
	virtual void OnPaint()
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1537
	{
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1538
		this->DrawWidgets();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1539
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
  1540
		DrawTrainDepotSprite(70, 17, DIAGDIR_NE, _cur_railtype);
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
  1541
		DrawTrainDepotSprite(70, 69, DIAGDIR_SE, _cur_railtype);
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
  1542
		DrawTrainDepotSprite( 2, 69, DIAGDIR_SW, _cur_railtype);
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
  1543
		DrawTrainDepotSprite( 2, 17, DIAGDIR_NW, _cur_railtype);
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1544
	}
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1545
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1546
	virtual void OnClick(Point pt, int widget)
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1547
	{
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1548
		switch (widget) {
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
  1549
			case BRDW_DEPOT_NE:
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
  1550
			case BRDW_DEPOT_SE:
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
  1551
			case BRDW_DEPOT_SW:
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
  1552
			case BRDW_DEPOT_NW:
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1553
				this->RaiseWidget(_build_depot_direction + BRDW_DEPOT_NE);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1554
				_build_depot_direction = (DiagDirection)(widget - BRDW_DEPOT_NE);
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1555
				this->LowerWidget(_build_depot_direction + BRDW_DEPOT_NE);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1556
				SndPlayFx(SND_15_BEEP);
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1557
				this->SetDirty();
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1558
				break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1559
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1560
	}
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1561
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1562
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
  1563
/** Widget definition of the build rail depot window */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1564
static const Widget _build_depot_widgets[] = {
9762
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1565
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_DARK_GREEN,   0,    10,     0,    13, STR_00C5,                         STR_018B_CLOSE_WINDOW},                     // BRDW_CLOSEBOX
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1566
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_DARK_GREEN,  11,   139,     0,    13, STR_1014_TRAIN_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS},           // BRDW_CAPTION
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1567
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_DARK_GREEN,   0,   139,    14,   121, 0x0,                              STR_NULL},                                  // BRDW_BACKGROUND
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1568
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,        71,   136,    17,    66, 0x0,                              STR_1020_SELECT_RAILROAD_DEPOT_ORIENTATIO}, // BRDW_DEPOT_NE
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1569
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,        71,   136,    69,   118, 0x0,                              STR_1020_SELECT_RAILROAD_DEPOT_ORIENTATIO}, // BRDW_DEPOT_SE
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1570
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,         3,    68,    69,   118, 0x0,                              STR_1020_SELECT_RAILROAD_DEPOT_ORIENTATIO}, // BRDW_DEPOT_SW
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1571
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,         3,    68,    17,    66, 0x0,                              STR_1020_SELECT_RAILROAD_DEPOT_ORIENTATIO}, // BRDW_DEPOT_NW
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 159
diff changeset
  1572
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1573
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1574
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1575
static const WindowDesc _build_depot_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7272
diff changeset
  1576
	WDP_AUTO, WDP_AUTO, 140, 122, 140, 122,
5070
7f5b13b7e728 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 5049
diff changeset
  1577
	WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1578
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1579
	_build_depot_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1580
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1581
9338
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
  1582
static void ShowBuildTrainDepotPicker(Window *parent)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1583
{
9338
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
  1584
	new BuildRailDepotWindow(&_build_depot_desc, parent);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1585
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1586
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1587
struct BuildRailWaypointWindow : PickerWindowBase {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1588
private:
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1589
	/** Enum referring to the widgets of the build NewGRF rail waypoint window */
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1590
	enum BuildRailWaypointWidgets {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1591
		BRWW_CLOSEBOX = 0,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1592
		BRWW_CAPTION,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1593
		BRWW_BACKGROUND,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1594
		BRWW_WAYPOINT_1,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1595
		BRWW_WAYPOINT_2,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1596
		BRWW_WAYPOINT_3,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1597
		BRWW_WAYPOINT_4,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1598
		BRWW_WAYPOINT_5,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1599
		BRWW_SCROLL,
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1600
	};
393
e1128b94f3fb (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents: 389
diff changeset
  1601
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1602
public:
9338
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
  1603
	BuildRailWaypointWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1604
	{
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1605
		this->hscroll.cap = 5;
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1606
		this->hscroll.count = _waypoint_count;
9277
dc4132fe3f8e (svn r13143) -Fix (r13142): the Build Waypoint window wasn't resized when it was opened
smatz
parents: 9276
diff changeset
  1607
		this->FindWindowPlacementAndResize(desc);
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1608
	};
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1609
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1610
	virtual void OnPaint()
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1611
	{
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1612
		uint i;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1613
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1614
		for (i = 0; i < this->hscroll.cap; i++) {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1615
			this->SetWidgetLoweredState(i + BRWW_WAYPOINT_1, (this->hscroll.pos + i) == _cur_waypoint_type);
4853
f66ef6209e9d (svn r6779) -Fix r6631: waypoint selector now correctly shows the current selected waypoint type (thx Maedhros)
glx
parents: 4848
diff changeset
  1616
		}
f66ef6209e9d (svn r6779) -Fix r6631: waypoint selector now correctly shows the current selected waypoint type (thx Maedhros)
glx
parents: 4848
diff changeset
  1617
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1618
		this->DrawWidgets();
393
e1128b94f3fb (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents: 389
diff changeset
  1619
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1620
		for (i = 0; i < this->hscroll.cap; i++) {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1621
			if (this->hscroll.pos + i < this->hscroll.count) {
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1622
				const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, this->hscroll.pos + i);
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1623
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1624
				DrawWaypointSprite(2 + i * 68, 25, this->hscroll.pos + i, _cur_railtype);
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1625
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1626
				if (statspec != NULL &&
7928
63e18de69e50 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 7922
diff changeset
  1627
						HasBit(statspec->callbackmask, CBM_STATION_AVAIL) &&
9020
8174bbda9abe (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
parents: 8973
diff changeset
  1628
						GB(GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE), 0, 8) == 0) {
9607
5a5728fb702a (svn r13649) -Codechange: Split the GfxFillRect() special flags from 'color' into their own parameter.
frosch
parents: 9435
diff changeset
  1629
					GfxFillRect(4 + i * 68, 18, 67 + i * 68, 75, 0, FILLRECT_CHECKER);
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1630
				}
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2635
diff changeset
  1631
			}
2627
7a29af37b416 (svn r3169) Little bit of coding style fixing, and change from value to lengthof()
peter1138
parents: 2625
diff changeset
  1632
		}
1738
dfa8f078450a (svn r2242) -Fix: [ 1193414 ] Fix for waypoint GUI, scrolling and button-actions (Hackykid)
Darkvater
parents: 1656
diff changeset
  1633
	}
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1634
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1635
	virtual void OnClick(Point pt, int widget)
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1636
	{
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1637
		switch (widget) {
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
  1638
			case BRWW_WAYPOINT_1:
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
  1639
			case BRWW_WAYPOINT_2:
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
  1640
			case BRWW_WAYPOINT_3:
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
  1641
			case BRWW_WAYPOINT_4:
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
  1642
			case BRWW_WAYPOINT_5: {
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1643
				byte type = widget - BRWW_WAYPOINT_1 + this->hscroll.pos;
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1644
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
  1645
				/* Check station availability callback */
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
  1646
				const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, type);
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
  1647
				if (statspec != NULL &&
7928
63e18de69e50 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 7922
diff changeset
  1648
						HasBit(statspec->callbackmask, CBM_STATION_AVAIL) &&
9020
8174bbda9abe (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
parents: 8973
diff changeset
  1649
						GB(GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE), 0, 8) == 0) return;
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1650
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
  1651
				_cur_waypoint_type = type;
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
  1652
				SndPlayFx(SND_15_BEEP);
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1653
				this->SetDirty();
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
  1654
				break;
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
  1655
			}
3776
1545763bfc75 (svn r4768) - Newstations: Add newstation selector GUI. The additions are only active if a newstation set is loaded, otherwise it will look the same.
peter1138
parents: 3567
diff changeset
  1656
		}
393
e1128b94f3fb (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents: 389
diff changeset
  1657
	}
9276
332c61c7c95a (svn r13142) -Codechange: make classes of the Build[RailDepot|RailStation|RailWaypoint|Signal]Window
glx
parents: 9273
diff changeset
  1658
};
393
e1128b94f3fb (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents: 389
diff changeset
  1659
7729
04c9f8150a5e (svn r11264) -Codechange: replace a lot of magic numbers with enums for the rail and road GUIs. Patch by skidd13.
rubidium
parents: 7521
diff changeset
  1660
/** Widget definition for the build NewGRF rail waypoint window */
395
788a9bba0889 (svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents: 393
diff changeset
  1661
static const Widget _build_waypoint_widgets[] = {
9762
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1662
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_DARK_GREEN,     0,    10,     0,    13, STR_00C5,     STR_018B_CLOSE_WINDOW},            // BRWW_CLOSEBOX
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1663
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_DARK_GREEN,    11,   343,     0,    13, STR_WAYPOINT, STR_018C_WINDOW_TITLE_DRAG_THIS},  // BRWW_CAPTION
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1664
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_DARK_GREEN,     0,   343,    14,    91, 0x0,          STR_NULL},                         // BRWW_BACKGROUND
393
e1128b94f3fb (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents: 389
diff changeset
  1665
9762
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1666
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_DARK_GREEN,     3,    68,    17,    76, 0x0,          STR_WAYPOINT_GRAPHICS_TIP},        // BRWW_WAYPOINT_1
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1667
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_DARK_GREEN,    71,   136,    17,    76, 0x0,          STR_WAYPOINT_GRAPHICS_TIP},        // BRWW_WAYPOINT_2
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1668
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_DARK_GREEN,   139,   204,    17,    76, 0x0,          STR_WAYPOINT_GRAPHICS_TIP},        // BRWW_WAYPOINT_3
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1669
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_DARK_GREEN,   207,   272,    17,    76, 0x0,          STR_WAYPOINT_GRAPHICS_TIP},        // BRWW_WAYPOINT_4
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1670
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_DARK_GREEN,   275,   340,    17,    76, 0x0,          STR_WAYPOINT_GRAPHICS_TIP},        // BRWW_WAYPOINT_5
393
e1128b94f3fb (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents: 389
diff changeset
  1671
9762
5e591b9665a2 (svn r13898) -Codechange: Replace remaining numbers with Colours enum on players, roads and rails guis
belugas
parents: 9652
diff changeset
  1672
{ WWT_HSCROLLBAR,   RESIZE_NONE,  COLOUR_DARK_GREEN,     1,   343,     80,    91, 0x0,          STR_HSCROLL_BAR_SCROLLS_LIST},     // BRWW_SCROLL
417
6a7b22f86424 (svn r614) [newgrf] Some minor code fixes
dominik
parents: 415
diff changeset
  1673
{    WIDGETS_END},
393
e1128b94f3fb (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents: 389
diff changeset
  1674
};
e1128b94f3fb (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents: 389
diff changeset
  1675
395
788a9bba0889 (svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents: 393
diff changeset
  1676
static const WindowDesc _build_waypoint_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7272
diff changeset
  1677
	WDP_AUTO, WDP_AUTO, 344, 92, 344, 92,
5070
7f5b13b7e728 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 5049
diff changeset
  1678
	WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
393
e1128b94f3fb (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents: 389
diff changeset
  1679
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
395
788a9bba0889 (svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents: 393
diff changeset
  1680
	_build_waypoint_widgets,
393
e1128b94f3fb (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents: 389
diff changeset
  1681
};
e1128b94f3fb (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents: 389
diff changeset
  1682
9338
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
  1683
static void ShowBuildWaypointPicker(Window *parent)
393
e1128b94f3fb (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents: 389
diff changeset
  1684
{
9338
3d6f9ddd431d (svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents: 9317
diff changeset
  1685
	new BuildRailWaypointWindow(&_build_waypoint_desc, parent);
393
e1128b94f3fb (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents: 389
diff changeset
  1686
}
e1128b94f3fb (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents: 389
diff changeset
  1687
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
  1688
/**
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
  1689
 * Initialize rail building GUI settings
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
  1690
 */
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6207
diff changeset
  1691
void InitializeRailGui()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1692
{
3157
3f35e2d9c8e3 (svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents: 3132
diff changeset
  1693
	_build_depot_direction = DIAGDIR_NW;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1694
	_railstation.numtracks = 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1695
	_railstation.platlength = 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1696
	_railstation.dragdrop = true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1697
}
5116
3c0c3da214ca (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 5105
diff changeset
  1698
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
  1699
/**
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
  1700
 * Re-initialize rail-build toolbar after toggling support for electric trains
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
  1701
 * @param disable Boolean whether electric trains are disabled (removed from the game)
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
  1702
 */
5116
3c0c3da214ca (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 5105
diff changeset
  1703
void ReinitGuiAfterToggleElrail(bool disable)
3c0c3da214ca (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 5105
diff changeset
  1704
{
3c0c3da214ca (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 5105
diff changeset
  1705
	extern RailType _last_built_railtype;
3c0c3da214ca (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 5105
diff changeset
  1706
	if (disable && _last_built_railtype == RAILTYPE_ELECTRIC) {
3c0c3da214ca (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 5105
diff changeset
  1707
		Window *w;
3c0c3da214ca (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 5105
diff changeset
  1708
		_last_built_railtype = _cur_railtype = RAILTYPE_RAIL;
9080
34bc7cbbb79a (svn r12939) -Codechange: do not use the window proc to determine whether a toolbar is a rail toolbar, but use the window number.
rubidium
parents: 9020
diff changeset
  1709
		w = FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL);
34bc7cbbb79a (svn r12939) -Codechange: do not use the window proc to determine whether a toolbar is a rail toolbar, but use the window number.
rubidium
parents: 9020
diff changeset
  1710
		if (w != NULL) {
5116
3c0c3da214ca (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 5105
diff changeset
  1711
			SetupRailToolbar(_cur_railtype, w);
9116
f2491d3c321b (svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents: 9115
diff changeset
  1712
			w->SetDirty();
5116
3c0c3da214ca (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 5105
diff changeset
  1713
		}
3c0c3da214ca (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 5105
diff changeset
  1714
	}
3c0c3da214ca (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 5105
diff changeset
  1715
	MarkWholeScreenDirty();
3c0c3da214ca (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 5105
diff changeset
  1716
}
3c0c3da214ca (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 5105
diff changeset
  1717
9314
9ba6a9620a69 (svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents: 9303
diff changeset
  1718
/** Set the initial (default) railtype to use */
8809
e0d09d74e805 (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 8808
diff changeset
  1719
static void SetDefaultRailGui()
7064
81d35e1f3e37 (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
parents: 6863
diff changeset
  1720
{
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 9886
diff changeset
  1721
	if (_local_company == COMPANY_SPECTATOR || !IsValidCompanyID(_local_company)) return;
5116
3c0c3da214ca (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 5105
diff changeset
  1722
7064
81d35e1f3e37 (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
parents: 6863
diff changeset
  1723
	extern RailType _last_built_railtype;
9413
7042a8ec3fa8 (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
parents: 9354
diff changeset
  1724
	RailType rt = (RailType)_settings_client.gui.default_rail_type;
7064
81d35e1f3e37 (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
parents: 6863
diff changeset
  1725
	if (rt >= RAILTYPE_END) {
81d35e1f3e37 (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
parents: 6863
diff changeset
  1726
		if (rt == RAILTYPE_END + 2) {
81d35e1f3e37 (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
parents: 6863
diff changeset
  1727
			/* Find the most used rail type */
81d35e1f3e37 (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
parents: 6863
diff changeset
  1728
			RailType count[RAILTYPE_END];
81d35e1f3e37 (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
parents: 6863
diff changeset
  1729
			memset(count, 0, sizeof(count));
81d35e1f3e37 (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
parents: 6863
diff changeset
  1730
			for (TileIndex t = 0; t < MapSize(); t++) {
8088
92fca5b09665 (svn r11649) -Codechange: some code can be simplified thanks to changes in r11642
smatz
parents: 8083
diff changeset
  1731
				if (IsTileType(t, MP_RAILWAY) || IsLevelCrossingTile(t) || IsRailwayStationTile(t) ||
92fca5b09665 (svn r11649) -Codechange: some code can be simplified thanks to changes in r11642
smatz
parents: 8083
diff changeset
  1732
						(IsTileType(t, MP_TUNNELBRIDGE) && GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL)) {
7064
81d35e1f3e37 (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
parents: 6863
diff changeset
  1733
					count[GetRailType(t)]++;
81d35e1f3e37 (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
parents: 6863
diff changeset
  1734
				}
81d35e1f3e37 (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
parents: 6863
diff changeset
  1735
			}
81d35e1f3e37 (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
parents: 6863
diff changeset
  1736
81d35e1f3e37 (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
parents: 6863
diff changeset
  1737
			rt = RAILTYPE_RAIL;
81d35e1f3e37 (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
parents: 6863
diff changeset
  1738
			for (RailType r = RAILTYPE_ELECTRIC; r < RAILTYPE_END; r++) {
81d35e1f3e37 (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
parents: 6863
diff changeset
  1739
				if (count[r] >= count[rt]) rt = r;
81d35e1f3e37 (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
parents: 6863
diff changeset
  1740
			}
81d35e1f3e37 (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
parents: 6863
diff changeset
  1741
81d35e1f3e37 (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
parents: 6863
diff changeset
  1742
			/* No rail, just get the first available one */
81d35e1f3e37 (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
parents: 6863
diff changeset
  1743
			if (count[rt] == 0) rt = RAILTYPE_END;
81d35e1f3e37 (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
parents: 6863
diff changeset
  1744
		}
81d35e1f3e37 (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
parents: 6863
diff changeset
  1745
		switch (rt) {
81d35e1f3e37 (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
parents: 6863
diff changeset
  1746
			case RAILTYPE_END + 0:
81d35e1f3e37 (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
parents: 6863
diff changeset
  1747
				rt = RAILTYPE_RAIL;
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 9886
diff changeset
  1748
				while (rt < RAILTYPE_END && !HasRailtypeAvail(_local_company, rt)) rt++;
7064
81d35e1f3e37 (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
parents: 6863
diff changeset
  1749
				break;
81d35e1f3e37 (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
parents: 6863
diff changeset
  1750
81d35e1f3e37 (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
parents: 6863
diff changeset
  1751
			case RAILTYPE_END + 1:
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 9886
diff changeset
  1752
				rt = GetBestRailtype(_local_company);
7064
81d35e1f3e37 (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
parents: 6863
diff changeset
  1753
				break;
81d35e1f3e37 (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
parents: 6863
diff changeset
  1754
81d35e1f3e37 (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
parents: 6863
diff changeset
  1755
			default:
81d35e1f3e37 (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
parents: 6863
diff changeset
  1756
				break;
81d35e1f3e37 (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
parents: 6863
diff changeset
  1757
		}
81d35e1f3e37 (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
parents: 6863
diff changeset
  1758
	}
81d35e1f3e37 (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
parents: 6863
diff changeset
  1759
81d35e1f3e37 (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
parents: 6863
diff changeset
  1760
	_last_built_railtype = _cur_railtype = rt;
9080
34bc7cbbb79a (svn r12939) -Codechange: do not use the window proc to determine whether a toolbar is a rail toolbar, but use the window number.
rubidium
parents: 9020
diff changeset
  1761
	Window *w = FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL);
34bc7cbbb79a (svn r12939) -Codechange: do not use the window proc to determine whether a toolbar is a rail toolbar, but use the window number.
rubidium
parents: 9020
diff changeset
  1762
	if (w != NULL) {
7064
81d35e1f3e37 (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
parents: 6863
diff changeset
  1763
		SetupRailToolbar(_cur_railtype, w);
9116
f2491d3c321b (svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents: 9115
diff changeset
  1764
		w->SetDirty();
7064
81d35e1f3e37 (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
parents: 6863
diff changeset
  1765
	}
81d35e1f3e37 (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
parents: 6863
diff changeset
  1766
}
81d35e1f3e37 (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
parents: 6863
diff changeset
  1767
8809
e0d09d74e805 (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 8808
diff changeset
  1768
/**
e0d09d74e805 (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 8808
diff changeset
  1769
 * Updates the current signal variant used in the signal GUI
e0d09d74e805 (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 8808
diff changeset
  1770
 * to the one adequate to current year.
e0d09d74e805 (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 8808
diff changeset
  1771
 * @param 0 needed to be called when a patch setting changes
e0d09d74e805 (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 8808
diff changeset
  1772
 * @return success, needed for patch settings
e0d09d74e805 (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 8808
diff changeset
  1773
 */
e0d09d74e805 (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 8808
diff changeset
  1774
int32 ResetSignalVariant(int32 = 0)
e0d09d74e805 (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 8808
diff changeset
  1775
{
9413
7042a8ec3fa8 (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
parents: 9354
diff changeset
  1776
	SignalVariant new_variant = (_cur_year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7773
diff changeset
  1777
8809
e0d09d74e805 (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 8808
diff changeset
  1778
	if (new_variant != _cur_signal_variant) {
e0d09d74e805 (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 8808
diff changeset
  1779
		Window *w = FindWindowById(WC_BUILD_SIGNAL, 0);
e0d09d74e805 (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 8808
diff changeset
  1780
		if (w != NULL) {
9116
f2491d3c321b (svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents: 9115
diff changeset
  1781
			w->SetDirty();
8809
e0d09d74e805 (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 8808
diff changeset
  1782
			w->RaiseWidget((_cur_signal_variant == SIG_ELECTRIC ? BSW_ELECTRIC_NORM : BSW_SEMAPHORE_NORM) + _cur_signal_type);
e0d09d74e805 (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 8808
diff changeset
  1783
		}
e0d09d74e805 (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 8808
diff changeset
  1784
		_cur_signal_variant = new_variant;
e0d09d74e805 (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 8808
diff changeset
  1785
	}
8557
d5fb341fc220 (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
parents: 8424
diff changeset
  1786
8809
e0d09d74e805 (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 8808
diff changeset
  1787
	return 0;
e0d09d74e805 (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 8808
diff changeset
  1788
}
e0d09d74e805 (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 8808
diff changeset
  1789
e0d09d74e805 (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 8808
diff changeset
  1790
/** Resets the rail GUI - sets default railtype to build
e0d09d74e805 (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 8808
diff changeset
  1791
 * and resets the signal GUI
e0d09d74e805 (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 8808
diff changeset
  1792
 */
e0d09d74e805 (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 8808
diff changeset
  1793
void InitializeRailGUI()
e0d09d74e805 (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 8808
diff changeset
  1794
{
e0d09d74e805 (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 8808
diff changeset
  1795
	SetDefaultRailGui();
e0d09d74e805 (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 8808
diff changeset
  1796
e0d09d74e805 (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 8808
diff changeset
  1797
	_convert_signal_button = false;
9796
4d1358696a92 (svn r13938) -Codechange [YAPP]: Add the new signals to the build signal GUI. (michi_cc)
rubidium
parents: 9794
diff changeset
  1798
	_cur_signal_type = _default_signal_type[_settings_client.gui.default_signal_type];
8809
e0d09d74e805 (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 8808
diff changeset
  1799
	ResetSignalVariant();
e0d09d74e805 (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz
parents: 8808
diff changeset
  1800
}