mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-10-31 15:20:10 +00:00
Enable picker tool for rail signals
This commit is contained in:
parent
bd378a2842
commit
428e1c364e
@ -2064,7 +2064,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline SignalType TypeForClick(uint id) const
|
static SignalType TypeForClick(uint id)
|
||||||
{
|
{
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case 0: return SIGTYPE_NORMAL;
|
case 0: return SIGTYPE_NORMAL;
|
||||||
@ -2081,6 +2081,23 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint ClickForType(SignalType type)
|
||||||
|
{
|
||||||
|
switch (type) {
|
||||||
|
case SIGTYPE_NORMAL: return 0;
|
||||||
|
case SIGTYPE_ENTRY: return 1;
|
||||||
|
case SIGTYPE_EXIT: return 2;
|
||||||
|
case SIGTYPE_COMBO: return 3;
|
||||||
|
case SIGTYPE_PROG: return 4;
|
||||||
|
case SIGTYPE_PBS: return 5;
|
||||||
|
case SIGTYPE_PBS_ONEWAY: return 6;
|
||||||
|
case SIGTYPE_NO_ENTRY: return 7;
|
||||||
|
default:
|
||||||
|
assert(!"Bad signal type");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void OnClick(Point pt, int widget, int click_count) override
|
void OnClick(Point pt, int widget, int click_count) override
|
||||||
{
|
{
|
||||||
switch (widget) {
|
switch (widget) {
|
||||||
@ -2886,3 +2903,49 @@ void ShowBuildRailStationPickerAndSelect(StationType station_type, const Station
|
|||||||
if (station_window != nullptr) station_window->SelectClassAndSpec(class_id, spec_id);
|
if (station_window != nullptr) station_window->SelectClassAndSpec(class_id, spec_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void OpenBuildSignalWindow(BuildRailToolbarWindow *w, SignalVariant variant, SignalType type, uint8 style)
|
||||||
|
{
|
||||||
|
if (!w->IsWidgetLowered(WID_RAT_BUILD_SIGNALS)) {
|
||||||
|
w->OnHotkey(WID_RAT_BUILD_SIGNALS);
|
||||||
|
}
|
||||||
|
|
||||||
|
BuildSignalWindow *signal_window = dynamic_cast<BuildSignalWindow *>(FindWindowById(WC_BUILD_SIGNAL, TRANSPORT_RAIL));
|
||||||
|
if (signal_window == nullptr) return;
|
||||||
|
|
||||||
|
signal_window->OnDropdownSelect(WID_BS_STYLE, style);
|
||||||
|
|
||||||
|
if (_settings_client.gui.signal_gui_mode == SIGNAL_GUI_PATH && _settings_game.vehicle.train_braking_model != TBM_REALISTIC && !IsPbsSignalNonExtended(type) && !IsNoEntrySignal(type)) {
|
||||||
|
signal_window->OnClick(Point(), WID_BS_TOGGLE_SIZE, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
signal_window->OnClick(Point(), ((variant == SIG_SEMAPHORE) ? WID_BS_SEMAPHORE_NORM : WID_BS_ELECTRIC_NORM) + BuildSignalWindow::ClickForType(type), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShowBuildRailToolbarWithPickTile(RailType railtype, TileIndex tile)
|
||||||
|
{
|
||||||
|
BuildRailToolbarWindow *w = static_cast<BuildRailToolbarWindow *>(ShowBuildRailToolbar(railtype));
|
||||||
|
if (w == nullptr) return;
|
||||||
|
|
||||||
|
if (IsPlainRailTile(tile) || IsRailTunnelBridgeTile(tile)) {
|
||||||
|
TrackBits trackbits = TrackdirBitsToTrackBits(GetTileTrackdirBits(tile, TRANSPORT_RAIL, 0));
|
||||||
|
if (trackbits & TRACK_BIT_VERT) { // N-S direction
|
||||||
|
trackbits = (_tile_fract_coords.x <= _tile_fract_coords.y) ? TRACK_BIT_RIGHT : TRACK_BIT_LEFT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (trackbits & TRACK_BIT_HORZ) { // E-W direction
|
||||||
|
trackbits = (_tile_fract_coords.x + _tile_fract_coords.y <= 15) ? TRACK_BIT_UPPER : TRACK_BIT_LOWER;
|
||||||
|
}
|
||||||
|
|
||||||
|
Track track = FindFirstTrack(trackbits);
|
||||||
|
if (track != INVALID_TRACK) {
|
||||||
|
if (IsTileType(tile, MP_RAILWAY) && HasTrack(tile, track) && HasSignalOnTrack(tile, track)) {
|
||||||
|
OpenBuildSignalWindow(w, GetSignalVariant(tile, track), GetSignalType(tile, track), GetSignalStyle(tile, track));
|
||||||
|
}
|
||||||
|
if (IsRailTunnelBridgeTile(tile) && IsTunnelBridgeWithSignalSimulation(tile) && HasTrack(GetTunnelBridgeTrackBits(tile), track)) {
|
||||||
|
OpenBuildSignalWindow(w, IsTunnelBridgeSemaphore(tile) ? SIG_SEMAPHORE : SIG_ELECTRIC,
|
||||||
|
IsTunnelBridgePBS(tile) ? SIGTYPE_PBS_ONEWAY : SIGTYPE_NORMAL, GetTunnelBridgeSignalStyle(tile));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "widgets/dropdown_type.h"
|
#include "widgets/dropdown_type.h"
|
||||||
|
|
||||||
struct Window *ShowBuildRailToolbar(RailType railtype);
|
struct Window *ShowBuildRailToolbar(RailType railtype);
|
||||||
|
void ShowBuildRailToolbarWithPickTile(RailType railtype, TileIndex tile);
|
||||||
void ShowBuildRailStationPickerAndSelect(StationType station_type, const StationSpec *spec);
|
void ShowBuildRailStationPickerAndSelect(StationType station_type, const StationSpec *spec);
|
||||||
void ReinitGuiAfterToggleElrail(bool disable);
|
void ReinitGuiAfterToggleElrail(bool disable);
|
||||||
void ResetSignalVariant(int32 = 0);
|
void ResetSignalVariant(int32 = 0);
|
||||||
|
@ -1140,7 +1140,7 @@ enum HelpMenuEntries {
|
|||||||
static void ShowBuildRailToolbarFromTile(TileIndex tile)
|
static void ShowBuildRailToolbarFromTile(TileIndex tile)
|
||||||
{
|
{
|
||||||
_last_built_railtype = GetRailType(tile);
|
_last_built_railtype = GetRailType(tile);
|
||||||
ShowBuildRailToolbar(_last_built_railtype);
|
ShowBuildRailToolbarWithPickTile(_last_built_railtype, tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ShowBuildRoadToolbarFromTile(TileIndex tile)
|
static void ShowBuildRoadToolbarFromTile(TileIndex tile)
|
||||||
|
Loading…
Reference in New Issue
Block a user