2009-08-21 22:21:05 +02:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
|
|
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2008-05-06 17:11:33 +02:00
|
|
|
/** @file road_gui.cpp GUI for building roads. */
|
2007-03-28 22:41:35 +02:00
|
|
|
|
2004-08-09 19:04:08 +02:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "gui.h"
|
2007-12-19 21:45:46 +01:00
|
|
|
#include "window_gui.h"
|
|
|
|
#include "station_gui.h"
|
2008-01-06 19:56:43 +01:00
|
|
|
#include "terraform_gui.h"
|
2008-01-09 10:45:45 +01:00
|
|
|
#include "viewport_func.h"
|
2007-12-21 22:50:46 +01:00
|
|
|
#include "command_func.h"
|
2007-05-21 23:58:31 +02:00
|
|
|
#include "road_cmd.h"
|
2009-01-31 21:16:06 +01:00
|
|
|
#include "station_func.h"
|
2007-12-25 12:26:07 +01:00
|
|
|
#include "window_func.h"
|
2007-12-27 14:35:39 +01:00
|
|
|
#include "vehicle_func.h"
|
2007-12-29 10:24:26 +01:00
|
|
|
#include "sound_func.h"
|
2008-09-30 22:51:04 +02:00
|
|
|
#include "company_func.h"
|
2008-04-18 12:16:51 +02:00
|
|
|
#include "tunnelbridge.h"
|
2010-03-17 21:19:55 +01:00
|
|
|
#include "tunnelbridge_map.h"
|
2008-05-07 15:10:15 +02:00
|
|
|
#include "tilehighlight_func.h"
|
2008-09-30 22:51:04 +02:00
|
|
|
#include "company_base.h"
|
2010-07-04 12:57:31 +02:00
|
|
|
#include "hotkeys.h"
|
2011-01-14 13:01:07 +01:00
|
|
|
#include "road_gui.h"
|
2014-09-22 10:01:25 +02:00
|
|
|
#include "zoom_func.h"
|
2024-03-31 18:31:47 +02:00
|
|
|
#include "dropdown_type.h"
|
|
|
|
#include "dropdown_func.h"
|
2019-04-06 08:46:15 +02:00
|
|
|
#include "engine_base.h"
|
2024-05-07 13:13:49 +02:00
|
|
|
#include "station_base.h"
|
2019-04-06 08:46:15 +02:00
|
|
|
#include "strings_func.h"
|
|
|
|
#include "core/geometry_func.hpp"
|
2021-10-29 00:56:07 +02:00
|
|
|
#include "station_cmd.h"
|
2021-10-31 19:39:09 +01:00
|
|
|
#include "road_cmd.h"
|
2021-10-30 01:31:46 +02:00
|
|
|
#include "tunnelbridge_cmd.h"
|
2022-11-06 16:01:27 +01:00
|
|
|
#include "newgrf_roadstop.h"
|
2024-05-07 13:13:48 +02:00
|
|
|
#include "picker_gui.h"
|
2023-04-13 13:56:00 +02:00
|
|
|
#include "timer/timer.h"
|
|
|
|
#include "timer/timer_game_calendar.h"
|
2004-12-08 16:46:13 +01:00
|
|
|
|
2011-12-15 23:22:55 +01:00
|
|
|
#include "widgets/road_widget.h"
|
|
|
|
|
2008-01-13 02:21:35 +01:00
|
|
|
#include "table/strings.h"
|
2004-08-09 19:04:08 +02:00
|
|
|
|
2014-04-23 22:13:33 +02:00
|
|
|
#include "safeguards.h"
|
|
|
|
|
2008-05-24 13:19:30 +02:00
|
|
|
static void ShowRVStationPicker(Window *parent, RoadStopType rs);
|
|
|
|
static void ShowRoadDepotPicker(Window *parent);
|
2004-08-09 19:04:08 +02:00
|
|
|
|
|
|
|
static bool _remove_button_clicked;
|
2007-11-18 14:55:23 +01:00
|
|
|
static bool _one_way_button_clicked;
|
2004-08-09 19:04:08 +02:00
|
|
|
|
2021-11-15 00:03:01 +01:00
|
|
|
static Axis _place_road_dir;
|
|
|
|
static bool _place_road_start_half_x;
|
|
|
|
static bool _place_road_start_half_y;
|
|
|
|
static bool _place_road_end_half;
|
2004-08-09 19:04:08 +02:00
|
|
|
|
2007-05-21 23:58:31 +02:00
|
|
|
static RoadType _cur_roadtype;
|
|
|
|
|
2007-01-10 19:56:51 +01:00
|
|
|
static DiagDirection _road_depot_orientation;
|
2022-11-06 16:01:27 +01:00
|
|
|
|
2024-05-07 13:13:48 +02:00
|
|
|
struct RoadStopPickerSelection {
|
|
|
|
RoadStopClassID sel_class; ///< Selected road stop class.
|
|
|
|
uint16_t sel_type; ///< Selected road stop type within the class.
|
|
|
|
DiagDirection orientation; ///< Selected orientation of the road stop.
|
2022-11-06 16:01:27 +01:00
|
|
|
};
|
2024-05-07 13:13:48 +02:00
|
|
|
static RoadStopPickerSelection _roadstop_gui;
|
|
|
|
|
|
|
|
static bool IsRoadStopEverAvailable(const RoadStopSpec *spec, StationType type)
|
|
|
|
{
|
|
|
|
if (spec == nullptr) return true;
|
|
|
|
|
|
|
|
if (HasBit(spec->flags, RSF_BUILD_MENU_ROAD_ONLY) && !RoadTypeIsRoad(_cur_roadtype)) return false;
|
|
|
|
if (HasBit(spec->flags, RSF_BUILD_MENU_TRAM_ONLY) && !RoadTypeIsTram(_cur_roadtype)) return false;
|
|
|
|
|
|
|
|
switch (spec->stop_type) {
|
|
|
|
case ROADSTOPTYPE_ALL: return true;
|
|
|
|
case ROADSTOPTYPE_PASSENGER: return type == STATION_BUS;
|
|
|
|
case ROADSTOPTYPE_FREIGHT: return type == STATION_TRUCK;
|
|
|
|
default: NOT_REACHED();
|
|
|
|
}
|
|
|
|
}
|
2022-11-06 16:01:27 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check whether a road stop type can be built.
|
|
|
|
* @return true if building is allowed.
|
|
|
|
*/
|
2024-05-07 13:13:48 +02:00
|
|
|
static bool IsRoadStopAvailable(const RoadStopSpec *spec, StationType type)
|
2022-11-06 16:01:27 +01:00
|
|
|
{
|
2024-05-07 13:13:48 +02:00
|
|
|
if (spec == nullptr) return true;
|
|
|
|
if (IsRoadStopEverAvailable(spec, type)) return true;
|
2022-11-06 16:01:27 +01:00
|
|
|
|
2024-05-07 13:13:48 +02:00
|
|
|
if (!HasBit(spec->callback_mask, CBM_ROAD_STOP_AVAIL)) return true;
|
2022-11-06 16:01:27 +01:00
|
|
|
|
2024-05-07 13:13:48 +02:00
|
|
|
uint16_t cb_res = GetRoadStopCallback(CBID_STATION_AVAILABILITY, 0, 0, spec, nullptr, INVALID_TILE, _cur_roadtype, type, 0);
|
2022-11-06 16:01:27 +01:00
|
|
|
if (cb_res == CALLBACK_FAILED) return true;
|
|
|
|
|
2024-05-07 13:13:48 +02:00
|
|
|
return Convert8bitBooleanCallback(spec->grf_prop.grffile, CBID_STATION_AVAILABILITY, cb_res);
|
2022-11-06 16:01:27 +01:00
|
|
|
}
|
2004-08-09 19:04:08 +02:00
|
|
|
|
2023-09-16 22:20:53 +02:00
|
|
|
void CcPlaySound_CONSTRUCTION_OTHER(Commands, const CommandCost &result, TileIndex tile)
|
2004-08-09 19:04:08 +02:00
|
|
|
{
|
2021-02-20 19:01:04 +01:00
|
|
|
if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile);
|
2004-08-09 19:04:08 +02:00
|
|
|
}
|
|
|
|
|
2007-10-22 21:11:50 +02:00
|
|
|
/**
|
2010-12-20 20:24:27 +01:00
|
|
|
* Callback to start placing a bridge.
|
|
|
|
* @param tile Start tile of the bridge.
|
2007-10-22 21:11:50 +02:00
|
|
|
*/
|
2010-12-20 20:24:27 +01:00
|
|
|
static void PlaceRoad_Bridge(TileIndex tile, Window *w)
|
2004-08-09 19:04:08 +02:00
|
|
|
{
|
2010-03-17 21:19:55 +01:00
|
|
|
if (IsBridgeTile(tile)) {
|
|
|
|
TileIndex other_tile = GetOtherTunnelBridgeEnd(tile);
|
|
|
|
Point pt = {0, 0};
|
2013-10-13 00:45:19 +02:00
|
|
|
w->OnPlaceMouseUp(VPM_X_OR_Y, DDSP_BUILD_BRIDGE, pt, other_tile, tile);
|
2010-03-17 21:19:55 +01:00
|
|
|
} else {
|
|
|
|
VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_BUILD_BRIDGE);
|
|
|
|
}
|
2004-08-09 19:04:08 +02:00
|
|
|
}
|
|
|
|
|
2011-01-14 13:01:07 +01:00
|
|
|
/**
|
|
|
|
* Callback executed after a build road tunnel command has been called.
|
|
|
|
*
|
2021-10-31 22:07:22 +01:00
|
|
|
* @param result Whether the build succeeded.
|
2011-01-14 13:01:07 +01:00
|
|
|
* @param start_tile Starting tile of the tunnel.
|
|
|
|
*/
|
2023-09-16 22:20:53 +02:00
|
|
|
void CcBuildRoadTunnel(Commands, const CommandCost &result, TileIndex start_tile)
|
2004-08-09 19:04:08 +02:00
|
|
|
{
|
2010-01-11 19:46:09 +01:00
|
|
|
if (result.Succeeded()) {
|
2021-02-20 19:01:04 +01:00
|
|
|
if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, start_tile);
|
2009-01-07 18:40:17 +01:00
|
|
|
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
|
2011-01-14 13:01:07 +01:00
|
|
|
|
|
|
|
DiagDirection start_direction = ReverseDiagDir(GetTunnelBridgeDirection(start_tile));
|
|
|
|
ConnectRoadToStructure(start_tile, start_direction);
|
|
|
|
|
|
|
|
TileIndex end_tile = GetOtherTunnelBridgeEnd(start_tile);
|
|
|
|
DiagDirection end_direction = ReverseDiagDir(GetTunnelBridgeDirection(end_tile));
|
|
|
|
ConnectRoadToStructure(end_tile, end_direction);
|
2004-08-09 19:04:08 +02:00
|
|
|
} else {
|
|
|
|
SetRedErrorSquare(_build_tunnel_endtile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-14 12:55:40 +01:00
|
|
|
/**
|
|
|
|
* If required, connects a new structure to an existing road or tram by building the missing roadbit.
|
|
|
|
* @param tile Tile containing the structure to connect.
|
|
|
|
* @param direction Direction to check.
|
|
|
|
*/
|
|
|
|
void ConnectRoadToStructure(TileIndex tile, DiagDirection direction)
|
2004-08-09 19:04:08 +02:00
|
|
|
{
|
2006-09-06 01:21:41 +02:00
|
|
|
tile += TileOffsByDiagDir(direction);
|
2008-04-04 20:41:16 +02:00
|
|
|
/* if there is a roadpiece just outside of the station entrance, build a connecting route */
|
2008-02-14 16:59:16 +01:00
|
|
|
if (IsNormalRoadTile(tile)) {
|
2019-04-06 08:46:15 +02:00
|
|
|
if (GetRoadBits(tile, GetRoadTramType(_cur_roadtype)) != ROAD_NONE) {
|
2021-11-15 00:03:01 +01:00
|
|
|
Command<CMD_BUILD_ROAD>::Post(tile, DiagDirToRoadBits(ReverseDiagDir(direction)), _cur_roadtype, DRD_NONE, 0);
|
2007-05-21 23:58:31 +02:00
|
|
|
}
|
2004-08-09 19:04:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-16 22:20:53 +02:00
|
|
|
void CcRoadDepot(Commands, const CommandCost &result, TileIndex tile, RoadType, DiagDirection dir)
|
2004-08-09 19:04:08 +02:00
|
|
|
{
|
2010-01-11 19:46:09 +01:00
|
|
|
if (result.Failed()) return;
|
|
|
|
|
2021-02-20 19:01:04 +01:00
|
|
|
if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile);
|
2010-01-11 19:46:09 +01:00
|
|
|
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
|
2011-01-14 12:55:40 +01:00
|
|
|
ConnectRoadToStructure(tile, dir);
|
2004-08-09 19:04:08 +02:00
|
|
|
}
|
|
|
|
|
2010-08-01 21:22:34 +02:00
|
|
|
/**
|
|
|
|
* Command callback for building road stops.
|
2021-11-28 22:43:38 +01:00
|
|
|
* @param result Result of the build road stop command.
|
2010-02-24 22:51:59 +01:00
|
|
|
* @param tile Start tile.
|
2021-11-28 22:43:38 +01:00
|
|
|
* @param width Width of the road stop.
|
|
|
|
* @param length Length of the road stop.
|
|
|
|
* @param is_drive_through False for normal stops, true for drive-through.
|
|
|
|
* @param dir Entrance direction (#DiagDirection) for normal stops. Converted to the axis for drive-through stops.
|
2022-11-06 16:01:27 +01:00
|
|
|
* @param spec_class Road stop spec class.
|
|
|
|
* @param spec_index Road stop spec index.
|
2010-02-24 22:45:23 +01:00
|
|
|
* @see CmdBuildRoadStop
|
|
|
|
*/
|
2023-09-16 22:20:53 +02:00
|
|
|
void CcRoadStop(Commands, const CommandCost &result, TileIndex tile, uint8_t width, uint8_t length, RoadStopType, bool is_drive_through,
|
2023-05-08 20:09:33 +02:00
|
|
|
DiagDirection dir, RoadType, RoadStopClassID spec_class, uint16_t spec_index, StationID, bool)
|
2010-02-24 22:45:23 +01:00
|
|
|
{
|
|
|
|
if (result.Failed()) return;
|
|
|
|
|
2021-02-20 19:01:04 +01:00
|
|
|
if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile);
|
2010-02-24 22:45:23 +01:00
|
|
|
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
|
2022-11-06 16:01:27 +01:00
|
|
|
|
|
|
|
bool connect_to_road = true;
|
|
|
|
if ((uint)spec_class < RoadStopClass::GetClassCount() && spec_index < RoadStopClass::Get(spec_class)->GetSpecCount()) {
|
|
|
|
const RoadStopSpec *roadstopspec = RoadStopClass::Get(spec_class)->GetSpec(spec_index);
|
|
|
|
if (roadstopspec != nullptr && HasBit(roadstopspec->flags, RSF_NO_AUTO_ROAD_CONNECTION)) connect_to_road = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (connect_to_road) {
|
|
|
|
TileArea roadstop_area(tile, width, length);
|
|
|
|
for (TileIndex cur_tile : roadstop_area) {
|
|
|
|
ConnectRoadToStructure(cur_tile, dir);
|
|
|
|
/* For a drive-through road stop build connecting road for other entrance. */
|
|
|
|
if (is_drive_through) ConnectRoadToStructure(cur_tile, ReverseDiagDir(dir));
|
|
|
|
}
|
2010-02-24 22:51:59 +01:00
|
|
|
}
|
2010-02-24 22:45:23 +01:00
|
|
|
}
|
|
|
|
|
2010-02-24 22:51:59 +01:00
|
|
|
/**
|
|
|
|
* Place a new road stop.
|
|
|
|
* @param start_tile First tile of the area.
|
|
|
|
* @param end_tile Last tile of the area.
|
2021-11-14 16:39:17 +01:00
|
|
|
* @param stop_type Type of stop (bus/truck).
|
|
|
|
* @param adjacent Allow stations directly adjacent to other stations.
|
|
|
|
* @param rt The roadtypes.
|
2021-10-03 21:13:32 +02:00
|
|
|
* @param err_msg Error message to show.
|
2010-02-24 22:51:59 +01:00
|
|
|
* @see CcRoadStop()
|
|
|
|
*/
|
2021-11-14 16:39:17 +01:00
|
|
|
static void PlaceRoadStop(TileIndex start_tile, TileIndex end_tile, RoadStopType stop_type, bool adjacent, RoadType rt, StringID err_msg)
|
2007-02-14 17:37:16 +01:00
|
|
|
{
|
2021-10-29 00:56:07 +02:00
|
|
|
TileArea ta(start_tile, end_tile);
|
2024-05-07 13:13:48 +02:00
|
|
|
DiagDirection ddir = _roadstop_gui.orientation;
|
2021-11-14 16:39:17 +01:00
|
|
|
bool drive_through = ddir >= DIAGDIR_END;
|
|
|
|
if (drive_through) ddir = static_cast<DiagDirection>(ddir - DIAGDIR_END); // Adjust picker result to actual direction.
|
2024-05-07 13:13:48 +02:00
|
|
|
RoadStopClassID spec_class = _roadstop_gui.sel_class;
|
|
|
|
uint16_t spec_index = _roadstop_gui.sel_type;
|
2010-02-24 22:45:23 +01:00
|
|
|
|
2021-10-29 00:56:07 +02:00
|
|
|
auto proc = [=](bool test, StationID to_join) -> bool {
|
|
|
|
if (test) {
|
2022-11-06 16:01:27 +01:00
|
|
|
return Command<CMD_BUILD_ROAD_STOP>::Do(CommandFlagsToDCFlags(GetCommandFlags<CMD_BUILD_ROAD_STOP>()), ta.tile, ta.w, ta.h, stop_type, drive_through,
|
|
|
|
ddir, rt, spec_class, spec_index, INVALID_STATION, adjacent).Succeeded();
|
2021-10-29 00:56:07 +02:00
|
|
|
} else {
|
2022-11-06 16:01:27 +01:00
|
|
|
return Command<CMD_BUILD_ROAD_STOP>::Post(err_msg, CcRoadStop, ta.tile, ta.w, ta.h, stop_type, drive_through,
|
|
|
|
ddir, rt, spec_class, spec_index, to_join, adjacent);
|
2021-10-29 00:56:07 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
ShowSelectStationIfNeeded(ta, proc);
|
2007-02-14 17:37:16 +01:00
|
|
|
}
|
|
|
|
|
2010-12-20 20:24:27 +01:00
|
|
|
/**
|
|
|
|
* Callback for placing a bus station.
|
|
|
|
* @param tile Position to place the station.
|
|
|
|
*/
|
2005-06-24 14:38:35 +02:00
|
|
|
static void PlaceRoad_BusStation(TileIndex tile)
|
2004-08-09 19:04:08 +02:00
|
|
|
{
|
2007-11-24 14:00:32 +01:00
|
|
|
if (_remove_button_clicked) {
|
2010-02-24 22:53:16 +01:00
|
|
|
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_REMOVE_BUSSTOP);
|
2007-02-14 17:37:16 +01:00
|
|
|
} else {
|
2024-05-07 13:13:48 +02:00
|
|
|
if (_roadstop_gui.orientation < DIAGDIR_END) { // Not a drive-through stop.
|
|
|
|
VpStartPlaceSizing(tile, (DiagDirToAxis(_roadstop_gui.orientation) == AXIS_X) ? VPM_X_LIMITED : VPM_Y_LIMITED, DDSP_BUILD_BUSSTOP);
|
2010-02-24 22:51:59 +01:00
|
|
|
} else {
|
|
|
|
VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_BUILD_BUSSTOP);
|
|
|
|
}
|
|
|
|
VpSetPlaceSizingLimit(_settings_game.station.station_spread);
|
2007-02-14 17:37:16 +01:00
|
|
|
}
|
2004-08-09 19:04:08 +02:00
|
|
|
}
|
|
|
|
|
2010-12-20 20:24:27 +01:00
|
|
|
/**
|
|
|
|
* Callback for placing a truck station.
|
|
|
|
* @param tile Position to place the station.
|
|
|
|
*/
|
2005-06-24 14:38:35 +02:00
|
|
|
static void PlaceRoad_TruckStation(TileIndex tile)
|
2004-08-09 19:04:08 +02:00
|
|
|
{
|
2007-11-24 14:00:32 +01:00
|
|
|
if (_remove_button_clicked) {
|
2010-02-24 22:53:16 +01:00
|
|
|
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_REMOVE_TRUCKSTOP);
|
2007-02-14 17:37:16 +01:00
|
|
|
} else {
|
2024-05-07 13:13:48 +02:00
|
|
|
if (_roadstop_gui.orientation < DIAGDIR_END) { // Not a drive-through stop.
|
|
|
|
VpStartPlaceSizing(tile, (DiagDirToAxis(_roadstop_gui.orientation) == AXIS_X) ? VPM_X_LIMITED : VPM_Y_LIMITED, DDSP_BUILD_TRUCKSTOP);
|
2010-02-24 22:51:59 +01:00
|
|
|
} else {
|
|
|
|
VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_BUILD_TRUCKSTOP);
|
|
|
|
}
|
|
|
|
VpSetPlaceSizingLimit(_settings_game.station.station_spread);
|
2007-02-14 17:37:16 +01:00
|
|
|
}
|
2004-08-09 19:04:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
typedef void OnButtonClick(Window *w);
|
|
|
|
|
2010-08-01 21:22:34 +02:00
|
|
|
/**
|
2013-01-08 23:46:42 +01:00
|
|
|
* Toggles state of the Remove button of Build road toolbar
|
2008-02-17 18:00:43 +01:00
|
|
|
* @param w window the button belongs to
|
|
|
|
*/
|
|
|
|
static void ToggleRoadButton_Remove(Window *w)
|
|
|
|
{
|
2011-12-16 19:52:15 +01:00
|
|
|
w->ToggleWidgetLoweredState(WID_ROT_REMOVE);
|
|
|
|
w->SetWidgetDirty(WID_ROT_REMOVE);
|
|
|
|
_remove_button_clicked = w->IsWidgetLowered(WID_ROT_REMOVE);
|
2008-02-17 18:00:43 +01:00
|
|
|
SetSelectionRed(_remove_button_clicked);
|
|
|
|
}
|
|
|
|
|
2010-08-01 21:22:34 +02:00
|
|
|
/**
|
|
|
|
* Updates the Remove button because of Ctrl state change
|
2008-02-17 18:00:43 +01:00
|
|
|
* @param w window the button belongs to
|
2013-01-08 23:46:42 +01:00
|
|
|
* @return true iff the remove button was changed
|
2008-02-17 18:00:43 +01:00
|
|
|
*/
|
|
|
|
static bool RoadToolbar_CtrlChanged(Window *w)
|
|
|
|
{
|
2011-12-16 19:52:15 +01:00
|
|
|
if (w->IsWidgetDisabled(WID_ROT_REMOVE)) return false;
|
2008-02-17 18:00:43 +01:00
|
|
|
|
|
|
|
/* allow ctrl to switch remove mode only for these widgets */
|
2023-12-29 20:11:59 +01:00
|
|
|
for (WidgetID i = WID_ROT_ROAD_X; i <= WID_ROT_AUTOROAD; i++) {
|
2008-02-17 18:00:43 +01:00
|
|
|
if (w->IsWidgetLowered(i)) {
|
|
|
|
ToggleRoadButton_Remove(w);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-12-20 20:20:38 +01:00
|
|
|
/** Road toolbar window handler. */
|
2008-05-18 23:34:35 +02:00
|
|
|
struct BuildRoadToolbarWindow : Window {
|
2019-04-06 08:46:15 +02:00
|
|
|
RoadType roadtype; ///< Road type to build.
|
2019-09-29 22:27:32 +02:00
|
|
|
const RoadTypeInfo *rti; ///< Information about current road type
|
2019-04-06 08:46:15 +02:00
|
|
|
int last_started_action; ///< Last started user action.
|
2010-12-20 20:23:07 +01:00
|
|
|
|
2013-05-26 21:23:42 +02:00
|
|
|
BuildRoadToolbarWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
|
2008-05-18 23:34:35 +02:00
|
|
|
{
|
2019-04-06 08:46:15 +02:00
|
|
|
this->Initialize(_cur_roadtype);
|
2013-05-26 21:23:42 +02:00
|
|
|
this->InitNested(window_number);
|
2019-04-06 08:46:15 +02:00
|
|
|
this->SetupRoadToolbar();
|
|
|
|
this->SetWidgetDisabledState(WID_ROT_REMOVE, true);
|
|
|
|
|
|
|
|
if (RoadTypeIsRoad(this->roadtype)) {
|
|
|
|
this->SetWidgetDisabledState(WID_ROT_ONE_WAY, true);
|
|
|
|
}
|
2008-05-18 23:34:35 +02:00
|
|
|
|
2010-09-28 23:58:06 +02:00
|
|
|
this->OnInvalidateData();
|
2023-09-17 16:24:29 +02:00
|
|
|
this->last_started_action = INVALID_WID_ROT;
|
2009-08-29 23:33:50 +02:00
|
|
|
|
2008-05-29 17:13:28 +02:00
|
|
|
if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
|
2007-10-14 22:24:42 +02:00
|
|
|
}
|
|
|
|
|
2023-10-13 13:59:15 +02:00
|
|
|
void Close([[maybe_unused]] int data = 0) override
|
2008-05-18 23:34:35 +02:00
|
|
|
{
|
2019-07-12 21:43:58 +02:00
|
|
|
if (_game_mode == GM_NORMAL && (this->IsWidgetLowered(WID_ROT_BUS_STATION) || this->IsWidgetLowered(WID_ROT_TRUCK_STATION))) SetViewportCatchmentStation(nullptr, true);
|
2021-05-17 15:46:38 +02:00
|
|
|
if (_settings_client.gui.link_terraform_toolbar) CloseWindowById(WC_SCEN_LAND_GEN, 0, false);
|
2021-05-15 23:12:25 +02:00
|
|
|
this->Window::Close();
|
2008-05-18 23:34:35 +02:00
|
|
|
}
|
|
|
|
|
2011-03-13 22:31:29 +01:00
|
|
|
/**
|
|
|
|
* Some data on this window has become invalid.
|
|
|
|
* @param data Information about the changed data.
|
|
|
|
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
|
|
|
|
*/
|
2023-09-16 22:20:53 +02:00
|
|
|
void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
|
2010-09-28 23:58:06 +02:00
|
|
|
{
|
2011-03-13 22:31:29 +01:00
|
|
|
if (!gui_scope) return;
|
2021-01-07 23:06:23 +01:00
|
|
|
RoadTramType rtt = GetRoadTramType(this->roadtype);
|
2015-02-22 16:26:27 +01:00
|
|
|
|
2021-01-07 23:06:23 +01:00
|
|
|
bool can_build = CanBuildVehicleInfrastructure(VEH_ROAD, rtt);
|
Change: always allow to click on the toolbar icons for road/rail/dock/airport
This change allows a user to see what is available and what will become
available before it is available, instead of only disabling the button
with no further explanation. It also always allows building roads and
canals, even if no vehicles are available for road / water.
For rail/road/tram, a dropdown with available types is shown. If
none are available, it reads "None". If the type is not yet available,
it is greyed out.
For dock/airport, this always open the toolbar, but building airports,
docks, and depots buttons are disabled till vehicles are available
for those.
Road is the only exception, with the primary road always being
available. Here too, stations and depots are disabled till vehicles
become available. It does mean you can now always build roads to
for example help towns grow.
2021-01-07 22:28:08 +01:00
|
|
|
this->SetWidgetsDisabledState(!can_build,
|
|
|
|
WID_ROT_DEPOT,
|
|
|
|
WID_ROT_BUS_STATION,
|
2023-09-16 21:56:09 +02:00
|
|
|
WID_ROT_TRUCK_STATION);
|
Change: always allow to click on the toolbar icons for road/rail/dock/airport
This change allows a user to see what is available and what will become
available before it is available, instead of only disabling the button
with no further explanation. It also always allows building roads and
canals, even if no vehicles are available for road / water.
For rail/road/tram, a dropdown with available types is shown. If
none are available, it reads "None". If the type is not yet available,
it is greyed out.
For dock/airport, this always open the toolbar, but building airports,
docks, and depots buttons are disabled till vehicles are available
for those.
Road is the only exception, with the primary road always being
available. Here too, stations and depots are disabled till vehicles
become available. It does mean you can now always build roads to
for example help towns grow.
2021-01-07 22:28:08 +01:00
|
|
|
if (!can_build) {
|
2021-05-17 15:46:38 +02:00
|
|
|
CloseWindowById(WC_BUS_STATION, TRANSPORT_ROAD);
|
|
|
|
CloseWindowById(WC_TRUCK_STATION, TRANSPORT_ROAD);
|
|
|
|
CloseWindowById(WC_BUILD_DEPOT, TRANSPORT_ROAD);
|
2021-01-08 19:48:39 +01:00
|
|
|
}
|
2021-01-07 23:06:23 +01:00
|
|
|
|
2021-01-08 19:48:39 +01:00
|
|
|
if (_game_mode != GM_EDITOR) {
|
|
|
|
if (!can_build) {
|
|
|
|
/* Show in the tooltip why this button is disabled. */
|
|
|
|
this->GetWidget<NWidgetCore>(WID_ROT_DEPOT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
|
|
|
|
this->GetWidget<NWidgetCore>(WID_ROT_BUS_STATION)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
|
|
|
|
this->GetWidget<NWidgetCore>(WID_ROT_TRUCK_STATION)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
|
|
|
|
} else {
|
|
|
|
this->GetWidget<NWidgetCore>(WID_ROT_DEPOT)->SetToolTip(rtt == RTT_ROAD ? STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_VEHICLE_DEPOT : STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAM_VEHICLE_DEPOT);
|
|
|
|
this->GetWidget<NWidgetCore>(WID_ROT_BUS_STATION)->SetToolTip(rtt == RTT_ROAD ? STR_ROAD_TOOLBAR_TOOLTIP_BUILD_BUS_STATION : STR_ROAD_TOOLBAR_TOOLTIP_BUILD_PASSENGER_TRAM_STATION);
|
|
|
|
this->GetWidget<NWidgetCore>(WID_ROT_TRUCK_STATION)->SetToolTip(rtt == RTT_ROAD ? STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRUCK_LOADING_BAY : STR_ROAD_TOOLBAR_TOOLTIP_BUILD_CARGO_TRAM_STATION);
|
|
|
|
}
|
Change: always allow to click on the toolbar icons for road/rail/dock/airport
This change allows a user to see what is available and what will become
available before it is available, instead of only disabling the button
with no further explanation. It also always allows building roads and
canals, even if no vehicles are available for road / water.
For rail/road/tram, a dropdown with available types is shown. If
none are available, it reads "None". If the type is not yet available,
it is greyed out.
For dock/airport, this always open the toolbar, but building airports,
docks, and depots buttons are disabled till vehicles are available
for those.
Road is the only exception, with the primary road always being
available. Here too, stations and depots are disabled till vehicles
become available. It does mean you can now always build roads to
for example help towns grow.
2021-01-07 22:28:08 +01:00
|
|
|
}
|
2010-09-28 23:58:06 +02:00
|
|
|
}
|
|
|
|
|
2019-04-06 08:46:15 +02:00
|
|
|
void Initialize(RoadType roadtype)
|
|
|
|
{
|
|
|
|
assert(roadtype < ROADTYPE_END);
|
|
|
|
this->roadtype = roadtype;
|
|
|
|
this->rti = GetRoadTypeInfo(this->roadtype);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Configures the road toolbar for roadtype given
|
|
|
|
* @param roadtype the roadtype to display
|
|
|
|
*/
|
|
|
|
void SetupRoadToolbar()
|
|
|
|
{
|
|
|
|
this->GetWidget<NWidgetCore>(WID_ROT_ROAD_X)->widget_data = rti->gui_sprites.build_x_road;
|
|
|
|
this->GetWidget<NWidgetCore>(WID_ROT_ROAD_Y)->widget_data = rti->gui_sprites.build_y_road;
|
|
|
|
this->GetWidget<NWidgetCore>(WID_ROT_AUTOROAD)->widget_data = rti->gui_sprites.auto_road;
|
|
|
|
if (_game_mode != GM_EDITOR) {
|
|
|
|
this->GetWidget<NWidgetCore>(WID_ROT_DEPOT)->widget_data = rti->gui_sprites.build_depot;
|
|
|
|
}
|
|
|
|
this->GetWidget<NWidgetCore>(WID_ROT_CONVERT_ROAD)->widget_data = rti->gui_sprites.convert_road;
|
|
|
|
this->GetWidget<NWidgetCore>(WID_ROT_BUILD_TUNNEL)->widget_data = rti->gui_sprites.build_tunnel;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Switch to another road type.
|
|
|
|
* @param roadtype New road type.
|
|
|
|
*/
|
|
|
|
void ModifyRoadType(RoadType roadtype)
|
|
|
|
{
|
|
|
|
this->Initialize(roadtype);
|
|
|
|
this->SetupRoadToolbar();
|
|
|
|
this->ReInit();
|
|
|
|
}
|
|
|
|
|
2023-12-29 20:11:59 +01:00
|
|
|
void SetStringParameters(WidgetID widget) const override
|
2019-04-06 08:46:15 +02:00
|
|
|
{
|
|
|
|
if (widget == WID_ROT_CAPTION) {
|
|
|
|
if (this->rti->max_speed > 0) {
|
|
|
|
SetDParam(0, STR_TOOLBAR_RAILTYPE_VELOCITY);
|
|
|
|
SetDParam(1, this->rti->strings.toolbar_caption);
|
2023-04-08 18:26:13 +02:00
|
|
|
SetDParam(2, PackVelocity(this->rti->max_speed / 2, VEH_ROAD));
|
2019-04-06 08:46:15 +02:00
|
|
|
} else {
|
|
|
|
SetDParam(0, this->rti->strings.toolbar_caption);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-18 23:34:35 +02:00
|
|
|
/**
|
|
|
|
* Update the remove button lowered state of the road toolbar
|
|
|
|
*
|
2008-09-30 22:39:50 +02:00
|
|
|
* @param clicked_widget The widget which the client clicked just now
|
2008-05-18 23:34:35 +02:00
|
|
|
*/
|
|
|
|
void UpdateOptionWidgetStatus(RoadToolbarWidgets clicked_widget)
|
|
|
|
{
|
|
|
|
/* The remove and the one way button state is driven
|
2013-01-08 23:46:42 +01:00
|
|
|
* by the other buttons so they don't act on themselves.
|
2008-05-18 23:34:35 +02:00
|
|
|
* Both are only valid if they are able to apply as options. */
|
|
|
|
switch (clicked_widget) {
|
2011-12-16 19:52:15 +01:00
|
|
|
case WID_ROT_REMOVE:
|
2019-04-06 08:46:15 +02:00
|
|
|
if (RoadTypeIsRoad(this->roadtype)) {
|
|
|
|
this->RaiseWidget(WID_ROT_ONE_WAY);
|
|
|
|
this->SetWidgetDirty(WID_ROT_ONE_WAY);
|
|
|
|
}
|
|
|
|
|
2008-05-18 23:34:35 +02:00
|
|
|
break;
|
|
|
|
|
2011-12-16 19:52:15 +01:00
|
|
|
case WID_ROT_ONE_WAY:
|
|
|
|
this->RaiseWidget(WID_ROT_REMOVE);
|
|
|
|
this->SetWidgetDirty(WID_ROT_REMOVE);
|
2008-05-18 23:34:35 +02:00
|
|
|
break;
|
|
|
|
|
2011-12-16 19:52:15 +01:00
|
|
|
case WID_ROT_BUS_STATION:
|
|
|
|
case WID_ROT_TRUCK_STATION:
|
2019-04-06 08:46:15 +02:00
|
|
|
if (RoadTypeIsRoad(this->roadtype)) this->DisableWidget(WID_ROT_ONE_WAY);
|
2011-12-16 19:52:15 +01:00
|
|
|
this->SetWidgetDisabledState(WID_ROT_REMOVE, !this->IsWidgetLowered(clicked_widget));
|
2008-05-18 23:34:35 +02:00
|
|
|
break;
|
|
|
|
|
2011-12-16 19:52:15 +01:00
|
|
|
case WID_ROT_ROAD_X:
|
|
|
|
case WID_ROT_ROAD_Y:
|
|
|
|
case WID_ROT_AUTOROAD:
|
2019-04-06 08:46:15 +02:00
|
|
|
this->SetWidgetDisabledState(WID_ROT_REMOVE, !this->IsWidgetLowered(clicked_widget));
|
|
|
|
if (RoadTypeIsRoad(this->roadtype)) {
|
|
|
|
this->SetWidgetDisabledState(WID_ROT_ONE_WAY, !this->IsWidgetLowered(clicked_widget));
|
|
|
|
}
|
2008-05-18 23:34:35 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* When any other buttons than road/station, raise and
|
|
|
|
* disable the removal button */
|
2019-04-06 08:46:15 +02:00
|
|
|
this->SetWidgetDisabledState(WID_ROT_REMOVE, true);
|
|
|
|
this->SetWidgetLoweredState(WID_ROT_REMOVE, false);
|
|
|
|
|
|
|
|
if (RoadTypeIsRoad(this->roadtype)) {
|
|
|
|
this->SetWidgetDisabledState(WID_ROT_ONE_WAY, true);
|
|
|
|
this->SetWidgetLoweredState(WID_ROT_ONE_WAY, false);
|
|
|
|
}
|
|
|
|
|
2008-05-18 23:34:35 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-29 20:11:59 +01:00
|
|
|
void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
|
2008-05-18 23:34:35 +02:00
|
|
|
{
|
2010-12-20 20:20:38 +01:00
|
|
|
_remove_button_clicked = false;
|
|
|
|
_one_way_button_clicked = false;
|
|
|
|
switch (widget) {
|
2011-12-16 19:52:15 +01:00
|
|
|
case WID_ROT_ROAD_X:
|
2019-04-06 08:46:15 +02:00
|
|
|
HandlePlacePushButton(this, WID_ROT_ROAD_X, this->rti->cursor.road_nwse, HT_RECT);
|
2010-12-20 20:23:07 +01:00
|
|
|
this->last_started_action = widget;
|
2010-12-20 20:20:38 +01:00
|
|
|
break;
|
|
|
|
|
2011-12-16 19:52:15 +01:00
|
|
|
case WID_ROT_ROAD_Y:
|
2019-04-06 08:46:15 +02:00
|
|
|
HandlePlacePushButton(this, WID_ROT_ROAD_Y, this->rti->cursor.road_swne, HT_RECT);
|
2010-12-20 20:23:07 +01:00
|
|
|
this->last_started_action = widget;
|
2010-12-20 20:20:38 +01:00
|
|
|
break;
|
|
|
|
|
2011-12-16 19:52:15 +01:00
|
|
|
case WID_ROT_AUTOROAD:
|
2019-04-06 08:46:15 +02:00
|
|
|
HandlePlacePushButton(this, WID_ROT_AUTOROAD, this->rti->cursor.autoroad, HT_RECT);
|
2010-12-20 20:23:07 +01:00
|
|
|
this->last_started_action = widget;
|
2010-12-20 20:20:38 +01:00
|
|
|
break;
|
|
|
|
|
2011-12-16 19:52:15 +01:00
|
|
|
case WID_ROT_DEMOLISH:
|
|
|
|
HandlePlacePushButton(this, WID_ROT_DEMOLISH, ANIMCURSOR_DEMOLISH, HT_RECT | HT_DIAGONAL);
|
2010-12-20 20:23:07 +01:00
|
|
|
this->last_started_action = widget;
|
2010-12-20 20:20:38 +01:00
|
|
|
break;
|
|
|
|
|
2011-12-16 19:52:15 +01:00
|
|
|
case WID_ROT_DEPOT:
|
2019-04-06 08:46:15 +02:00
|
|
|
if (HandlePlacePushButton(this, WID_ROT_DEPOT, this->rti->cursor.depot, HT_RECT)) {
|
2010-12-20 20:23:07 +01:00
|
|
|
ShowRoadDepotPicker(this);
|
|
|
|
this->last_started_action = widget;
|
|
|
|
}
|
2010-12-20 20:20:38 +01:00
|
|
|
break;
|
|
|
|
|
2011-12-16 19:52:15 +01:00
|
|
|
case WID_ROT_BUS_STATION:
|
|
|
|
if (HandlePlacePushButton(this, WID_ROT_BUS_STATION, SPR_CURSOR_BUS_STATION, HT_RECT)) {
|
2010-12-20 20:23:07 +01:00
|
|
|
ShowRVStationPicker(this, ROADSTOP_BUS);
|
|
|
|
this->last_started_action = widget;
|
|
|
|
}
|
2010-12-20 20:20:38 +01:00
|
|
|
break;
|
|
|
|
|
2011-12-16 19:52:15 +01:00
|
|
|
case WID_ROT_TRUCK_STATION:
|
|
|
|
if (HandlePlacePushButton(this, WID_ROT_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, HT_RECT)) {
|
2010-12-20 20:23:07 +01:00
|
|
|
ShowRVStationPicker(this, ROADSTOP_TRUCK);
|
|
|
|
this->last_started_action = widget;
|
|
|
|
}
|
2010-12-20 20:20:38 +01:00
|
|
|
break;
|
|
|
|
|
2011-12-16 19:52:15 +01:00
|
|
|
case WID_ROT_ONE_WAY:
|
|
|
|
if (this->IsWidgetDisabled(WID_ROT_ONE_WAY)) return;
|
2010-12-20 20:21:50 +01:00
|
|
|
this->SetDirty();
|
2011-12-16 19:52:15 +01:00
|
|
|
this->ToggleWidgetLoweredState(WID_ROT_ONE_WAY);
|
2010-12-20 20:21:50 +01:00
|
|
|
SetSelectionRed(false);
|
2010-12-20 20:20:38 +01:00
|
|
|
break;
|
|
|
|
|
2011-12-16 19:52:15 +01:00
|
|
|
case WID_ROT_BUILD_BRIDGE:
|
|
|
|
HandlePlacePushButton(this, WID_ROT_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, HT_RECT);
|
2010-12-20 20:23:07 +01:00
|
|
|
this->last_started_action = widget;
|
2010-12-20 20:20:38 +01:00
|
|
|
break;
|
|
|
|
|
2011-12-16 19:52:15 +01:00
|
|
|
case WID_ROT_BUILD_TUNNEL:
|
2019-04-06 08:46:15 +02:00
|
|
|
HandlePlacePushButton(this, WID_ROT_BUILD_TUNNEL, this->rti->cursor.tunnel, HT_SPECIAL);
|
2010-12-20 20:23:07 +01:00
|
|
|
this->last_started_action = widget;
|
2010-12-20 20:20:38 +01:00
|
|
|
break;
|
|
|
|
|
2011-12-16 19:52:15 +01:00
|
|
|
case WID_ROT_REMOVE:
|
|
|
|
if (this->IsWidgetDisabled(WID_ROT_REMOVE)) return;
|
2010-12-20 20:21:50 +01:00
|
|
|
|
2021-05-17 15:46:38 +02:00
|
|
|
CloseWindowById(WC_SELECT_STATION, 0);
|
2010-12-20 20:21:50 +01:00
|
|
|
ToggleRoadButton_Remove(this);
|
2012-12-23 22:09:09 +01:00
|
|
|
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
2010-12-20 20:20:38 +01:00
|
|
|
break;
|
|
|
|
|
2019-04-06 08:46:15 +02:00
|
|
|
case WID_ROT_CONVERT_ROAD:
|
|
|
|
HandlePlacePushButton(this, WID_ROT_CONVERT_ROAD, this->rti->cursor.convert_road, HT_RECT);
|
|
|
|
this->last_started_action = widget;
|
|
|
|
break;
|
|
|
|
|
2010-12-20 20:20:38 +01:00
|
|
|
default: NOT_REACHED();
|
2008-05-18 23:34:35 +02:00
|
|
|
}
|
|
|
|
this->UpdateOptionWidgetStatus((RoadToolbarWidgets)widget);
|
|
|
|
if (_ctrl_pressed) RoadToolbar_CtrlChanged(this);
|
|
|
|
}
|
|
|
|
|
2019-03-04 08:49:37 +01:00
|
|
|
EventState OnHotkey(int hotkey) override
|
2008-05-18 23:34:35 +02:00
|
|
|
{
|
2009-04-26 12:21:50 +02:00
|
|
|
MarkTileDirtyByTile(TileVirtXY(_thd.pos.x, _thd.pos.y)); // redraw tile selection
|
2013-06-15 17:30:44 +02:00
|
|
|
return Window::OnHotkey(hotkey);
|
2008-05-18 23:34:35 +02:00
|
|
|
}
|
|
|
|
|
2023-09-16 22:20:53 +02:00
|
|
|
void OnPlaceObject([[maybe_unused]] Point pt, TileIndex tile) override
|
2008-05-18 23:34:35 +02:00
|
|
|
{
|
2011-12-16 19:52:15 +01:00
|
|
|
_remove_button_clicked = this->IsWidgetLowered(WID_ROT_REMOVE);
|
2019-04-06 08:46:15 +02:00
|
|
|
_one_way_button_clicked = RoadTypeIsRoad(this->roadtype) ? this->IsWidgetLowered(WID_ROT_ONE_WAY) : false;
|
2010-12-20 20:23:07 +01:00
|
|
|
switch (this->last_started_action) {
|
2011-12-16 19:52:15 +01:00
|
|
|
case WID_ROT_ROAD_X:
|
2021-11-15 00:03:01 +01:00
|
|
|
_place_road_dir = AXIS_X;
|
|
|
|
_place_road_start_half_x = _tile_fract_coords.x >= 8;
|
2010-12-20 20:24:27 +01:00
|
|
|
VpStartPlaceSizing(tile, VPM_FIX_Y, DDSP_PLACE_ROAD_X_DIR);
|
2010-12-20 20:23:07 +01:00
|
|
|
break;
|
|
|
|
|
2011-12-16 19:52:15 +01:00
|
|
|
case WID_ROT_ROAD_Y:
|
2021-11-15 00:03:01 +01:00
|
|
|
_place_road_dir = AXIS_Y;
|
|
|
|
_place_road_start_half_y = _tile_fract_coords.y >= 8;
|
2010-12-20 20:24:27 +01:00
|
|
|
VpStartPlaceSizing(tile, VPM_FIX_X, DDSP_PLACE_ROAD_Y_DIR);
|
2010-12-20 20:23:07 +01:00
|
|
|
break;
|
|
|
|
|
2011-12-16 19:52:15 +01:00
|
|
|
case WID_ROT_AUTOROAD:
|
2021-11-15 00:03:01 +01:00
|
|
|
_place_road_dir = INVALID_AXIS;
|
|
|
|
_place_road_start_half_x = _tile_fract_coords.x >= 8;
|
|
|
|
_place_road_start_half_y = _tile_fract_coords.y >= 8;
|
2010-12-20 20:24:27 +01:00
|
|
|
VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_PLACE_AUTOROAD);
|
2010-12-20 20:23:07 +01:00
|
|
|
break;
|
|
|
|
|
2011-12-16 19:52:15 +01:00
|
|
|
case WID_ROT_DEMOLISH:
|
2010-12-20 20:23:07 +01:00
|
|
|
PlaceProc_DemolishArea(tile);
|
|
|
|
break;
|
|
|
|
|
2011-12-16 19:52:15 +01:00
|
|
|
case WID_ROT_DEPOT:
|
2021-10-31 19:39:09 +01:00
|
|
|
Command<CMD_BUILD_ROAD_DEPOT>::Post(this->rti->strings.err_depot, CcRoadDepot,
|
2021-11-14 16:39:17 +01:00
|
|
|
tile, _cur_roadtype, _road_depot_orientation);
|
2010-12-20 20:23:07 +01:00
|
|
|
break;
|
|
|
|
|
2011-12-16 19:52:15 +01:00
|
|
|
case WID_ROT_BUS_STATION:
|
2010-12-20 20:23:07 +01:00
|
|
|
PlaceRoad_BusStation(tile);
|
|
|
|
break;
|
|
|
|
|
2011-12-16 19:52:15 +01:00
|
|
|
case WID_ROT_TRUCK_STATION:
|
2010-12-20 20:23:07 +01:00
|
|
|
PlaceRoad_TruckStation(tile);
|
|
|
|
break;
|
|
|
|
|
2011-12-16 19:52:15 +01:00
|
|
|
case WID_ROT_BUILD_BRIDGE:
|
2010-12-20 20:24:27 +01:00
|
|
|
PlaceRoad_Bridge(tile, this);
|
2010-12-20 20:23:07 +01:00
|
|
|
break;
|
|
|
|
|
2011-12-16 19:52:15 +01:00
|
|
|
case WID_ROT_BUILD_TUNNEL:
|
2021-10-31 19:39:09 +01:00
|
|
|
Command<CMD_BUILD_TUNNEL>::Post(STR_ERROR_CAN_T_BUILD_TUNNEL_HERE, CcBuildRoadTunnel,
|
2021-11-15 00:03:01 +01:00
|
|
|
tile, TRANSPORT_ROAD, _cur_roadtype);
|
2010-12-20 20:23:07 +01:00
|
|
|
break;
|
|
|
|
|
2019-04-06 08:46:15 +02:00
|
|
|
case WID_ROT_CONVERT_ROAD:
|
|
|
|
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CONVERT_ROAD);
|
|
|
|
break;
|
|
|
|
|
2010-12-20 20:23:07 +01:00
|
|
|
default: NOT_REACHED();
|
|
|
|
}
|
2008-05-18 23:34:35 +02:00
|
|
|
}
|
|
|
|
|
2019-03-04 08:49:37 +01:00
|
|
|
void OnPlaceObjectAbort() override
|
2008-05-18 23:34:35 +02:00
|
|
|
{
|
2019-04-29 20:09:11 +02:00
|
|
|
if (_game_mode != GM_EDITOR && (this->IsWidgetLowered(WID_ROT_BUS_STATION) || this->IsWidgetLowered(WID_ROT_TRUCK_STATION))) SetViewportCatchmentStation(nullptr, true);
|
2019-03-30 17:58:40 +01:00
|
|
|
|
2008-05-18 23:34:35 +02:00
|
|
|
this->RaiseButtons();
|
2019-04-06 08:46:15 +02:00
|
|
|
this->SetWidgetDisabledState(WID_ROT_REMOVE, true);
|
2011-12-16 19:52:15 +01:00
|
|
|
this->SetWidgetDirty(WID_ROT_REMOVE);
|
2019-04-06 08:46:15 +02:00
|
|
|
|
|
|
|
if (RoadTypeIsRoad(this->roadtype)) {
|
|
|
|
this->SetWidgetDisabledState(WID_ROT_ONE_WAY, true);
|
|
|
|
this->SetWidgetDirty(WID_ROT_ONE_WAY);
|
|
|
|
}
|
2008-05-18 23:34:35 +02:00
|
|
|
|
2021-05-17 15:46:38 +02:00
|
|
|
CloseWindowById(WC_BUS_STATION, TRANSPORT_ROAD);
|
|
|
|
CloseWindowById(WC_TRUCK_STATION, TRANSPORT_ROAD);
|
|
|
|
CloseWindowById(WC_BUILD_DEPOT, TRANSPORT_ROAD);
|
|
|
|
CloseWindowById(WC_SELECT_STATION, 0);
|
|
|
|
CloseWindowByClass(WC_BUILD_BRIDGE);
|
2008-05-18 23:34:35 +02:00
|
|
|
}
|
|
|
|
|
2023-09-16 22:20:53 +02:00
|
|
|
void OnPlaceDrag(ViewportPlaceMethod select_method, [[maybe_unused]] ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt) override
|
2008-05-18 23:34:35 +02:00
|
|
|
{
|
|
|
|
/* Here we update the end tile flags
|
|
|
|
* of the road placement actions.
|
|
|
|
* At first we reset the end halfroad
|
|
|
|
* bits and if needed we set them again. */
|
|
|
|
switch (select_proc) {
|
|
|
|
case DDSP_PLACE_ROAD_X_DIR:
|
2021-11-15 00:03:01 +01:00
|
|
|
_place_road_end_half = pt.x & 8;
|
2008-05-18 23:34:35 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DDSP_PLACE_ROAD_Y_DIR:
|
2021-11-15 00:03:01 +01:00
|
|
|
_place_road_end_half = pt.y & 8;
|
2008-05-18 23:34:35 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DDSP_PLACE_AUTOROAD:
|
|
|
|
/* For autoroad we need to update the
|
|
|
|
* direction of the road */
|
|
|
|
if (_thd.size.x > _thd.size.y || (_thd.size.x == _thd.size.y &&
|
|
|
|
( (_tile_fract_coords.x < _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) < 16) ||
|
|
|
|
(_tile_fract_coords.x > _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) > 16) ))) {
|
|
|
|
/* Set dir = X */
|
2021-11-15 00:03:01 +01:00
|
|
|
_place_road_dir = AXIS_X;
|
|
|
|
_place_road_end_half = pt.x & 8;
|
2008-05-18 23:34:35 +02:00
|
|
|
} else {
|
|
|
|
/* Set dir = Y */
|
2021-11-15 00:03:01 +01:00
|
|
|
_place_road_dir = AXIS_Y;
|
|
|
|
_place_road_end_half = pt.y & 8;
|
2007-10-22 21:11:50 +02:00
|
|
|
}
|
2007-05-23 14:45:56 +02:00
|
|
|
|
2008-05-18 23:34:35 +02:00
|
|
|
break;
|
2007-05-23 14:45:56 +02:00
|
|
|
|
2008-05-18 23:34:35 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-04-04 20:41:16 +02:00
|
|
|
|
2008-05-18 23:34:35 +02:00
|
|
|
VpSelectTilesWithMethod(pt.x, pt.y, select_method);
|
|
|
|
}
|
|
|
|
|
2023-09-16 22:20:53 +02:00
|
|
|
void OnPlaceMouseUp([[maybe_unused]] ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt, TileIndex start_tile, TileIndex end_tile) override
|
2008-05-18 23:34:35 +02:00
|
|
|
{
|
|
|
|
if (pt.x != -1) {
|
|
|
|
switch (select_proc) {
|
|
|
|
default: NOT_REACHED();
|
|
|
|
case DDSP_BUILD_BRIDGE:
|
2009-01-07 18:40:17 +01:00
|
|
|
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
|
2019-04-06 08:46:15 +02:00
|
|
|
ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_ROAD, _cur_roadtype);
|
2008-04-04 20:41:16 +02:00
|
|
|
break;
|
|
|
|
|
2008-05-18 23:34:35 +02:00
|
|
|
case DDSP_DEMOLISH_AREA:
|
|
|
|
GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
|
2007-05-23 14:45:56 +02:00
|
|
|
break;
|
2004-08-09 19:04:08 +02:00
|
|
|
|
2008-05-18 23:34:35 +02:00
|
|
|
case DDSP_PLACE_ROAD_X_DIR:
|
|
|
|
case DDSP_PLACE_ROAD_Y_DIR:
|
2021-11-15 00:03:01 +01:00
|
|
|
case DDSP_PLACE_AUTOROAD: {
|
2022-03-20 12:05:31 +01:00
|
|
|
bool start_half = _place_road_dir == AXIS_Y ? _place_road_start_half_y : _place_road_start_half_x;
|
2008-05-18 23:34:35 +02:00
|
|
|
|
2021-10-31 19:39:09 +01:00
|
|
|
if (_remove_button_clicked) {
|
|
|
|
Command<CMD_REMOVE_LONG_ROAD>::Post(this->rti->strings.err_remove_road, CcPlaySound_CONSTRUCTION_OTHER,
|
2022-05-12 02:52:38 +02:00
|
|
|
end_tile, start_tile, _cur_roadtype, _place_road_dir, start_half, _place_road_end_half);
|
2021-10-31 19:39:09 +01:00
|
|
|
} else {
|
|
|
|
Command<CMD_BUILD_LONG_ROAD>::Post(this->rti->strings.err_build_road, CcPlaySound_CONSTRUCTION_OTHER,
|
2022-05-12 02:52:38 +02:00
|
|
|
end_tile, start_tile, _cur_roadtype, _place_road_dir, _one_way_button_clicked ? DRD_NORTHBOUND : DRD_NONE, start_half, _place_road_end_half, false);
|
2021-10-31 19:39:09 +01:00
|
|
|
}
|
2008-05-18 23:34:35 +02:00
|
|
|
break;
|
2021-11-15 00:03:01 +01:00
|
|
|
}
|
2010-02-24 22:51:59 +01:00
|
|
|
|
|
|
|
case DDSP_BUILD_BUSSTOP:
|
2018-06-06 14:08:22 +02:00
|
|
|
case DDSP_REMOVE_BUSSTOP:
|
2024-05-07 13:13:48 +02:00
|
|
|
if (this->IsWidgetLowered(WID_ROT_BUS_STATION) && GetIfClassHasNewStopsByType(RoadStopClass::Get(_roadstop_gui.sel_class), ROADSTOP_BUS, _cur_roadtype)) {
|
2018-06-06 14:08:22 +02:00
|
|
|
if (_remove_button_clicked) {
|
|
|
|
TileArea ta(start_tile, end_tile);
|
2021-11-14 16:39:17 +01:00
|
|
|
Command<CMD_REMOVE_ROAD_STOP>::Post(this->rti->strings.err_remove_station[ROADSTOP_BUS], CcPlaySound_CONSTRUCTION_OTHER, ta.tile, ta.w, ta.h, ROADSTOP_BUS, _ctrl_pressed);
|
2018-06-06 14:08:22 +02:00
|
|
|
} else {
|
2021-11-14 16:39:17 +01:00
|
|
|
PlaceRoadStop(start_tile, end_tile, ROADSTOP_BUS, _ctrl_pressed, _cur_roadtype, this->rti->strings.err_build_station[ROADSTOP_BUS]);
|
2018-06-06 14:08:22 +02:00
|
|
|
}
|
|
|
|
}
|
2010-02-24 22:51:59 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DDSP_BUILD_TRUCKSTOP:
|
2018-06-06 14:08:22 +02:00
|
|
|
case DDSP_REMOVE_TRUCKSTOP:
|
2024-05-07 13:13:48 +02:00
|
|
|
if (this->IsWidgetLowered(WID_ROT_TRUCK_STATION) && GetIfClassHasNewStopsByType(RoadStopClass::Get(_roadstop_gui.sel_class), ROADSTOP_TRUCK, _cur_roadtype)) {
|
2018-06-06 14:08:22 +02:00
|
|
|
if (_remove_button_clicked) {
|
|
|
|
TileArea ta(start_tile, end_tile);
|
2021-11-14 16:39:17 +01:00
|
|
|
Command<CMD_REMOVE_ROAD_STOP>::Post(this->rti->strings.err_remove_station[ROADSTOP_TRUCK], CcPlaySound_CONSTRUCTION_OTHER, ta.tile, ta.w, ta.h, ROADSTOP_TRUCK, _ctrl_pressed);
|
2018-06-06 14:08:22 +02:00
|
|
|
} else {
|
2021-11-14 16:39:17 +01:00
|
|
|
PlaceRoadStop(start_tile, end_tile, ROADSTOP_TRUCK, _ctrl_pressed, _cur_roadtype, this->rti->strings.err_build_station[ROADSTOP_TRUCK]);
|
2018-06-06 14:08:22 +02:00
|
|
|
}
|
|
|
|
}
|
2010-02-24 22:51:59 +01:00
|
|
|
break;
|
2019-04-06 08:46:15 +02:00
|
|
|
|
|
|
|
case DDSP_CONVERT_ROAD:
|
2021-11-15 00:03:01 +01:00
|
|
|
Command<CMD_CONVERT_ROAD>::Post(rti->strings.err_convert_road, CcPlaySound_CONSTRUCTION_OTHER, end_tile, start_tile, _cur_roadtype);
|
2019-04-06 08:46:15 +02:00
|
|
|
break;
|
2008-04-04 20:41:16 +02:00
|
|
|
}
|
2008-05-18 23:34:35 +02:00
|
|
|
}
|
|
|
|
}
|
2005-11-09 08:25:55 +01:00
|
|
|
|
2023-09-16 22:20:53 +02:00
|
|
|
void OnPlacePresize([[maybe_unused]] Point pt, TileIndex tile) override
|
2008-05-18 23:34:35 +02:00
|
|
|
{
|
2021-11-15 00:03:01 +01:00
|
|
|
Command<CMD_BUILD_TUNNEL>::Do(DC_AUTO, tile, TRANSPORT_ROAD, _cur_roadtype);
|
2008-05-18 23:34:35 +02:00
|
|
|
VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile);
|
|
|
|
}
|
2008-02-17 18:00:43 +01:00
|
|
|
|
2019-03-04 08:49:37 +01:00
|
|
|
EventState OnCTRLStateChange() override
|
2008-05-18 23:34:35 +02:00
|
|
|
{
|
|
|
|
if (RoadToolbar_CtrlChanged(this)) return ES_HANDLED;
|
|
|
|
return ES_NOT_HANDLED;
|
2004-08-09 19:04:08 +02:00
|
|
|
}
|
2010-07-04 12:57:31 +02:00
|
|
|
|
2023-06-05 19:12:30 +02:00
|
|
|
/**
|
|
|
|
* Handler for global hotkeys of the BuildRoadToolbarWindow.
|
|
|
|
* @param hotkey Hotkey
|
|
|
|
* @param last_build Last build road type
|
|
|
|
* @return ES_HANDLED if hotkey was accepted.
|
|
|
|
*/
|
|
|
|
static EventState RoadTramToolbarGlobalHotkeys(int hotkey, RoadType last_build, RoadTramType rtt)
|
|
|
|
{
|
2024-01-03 22:33:38 +01:00
|
|
|
Window *w = nullptr;
|
2023-06-05 19:12:30 +02:00
|
|
|
switch (_game_mode) {
|
|
|
|
case GM_NORMAL:
|
|
|
|
w = ShowBuildRoadToolbar(last_build);
|
|
|
|
break;
|
2010-07-04 12:57:31 +02:00
|
|
|
|
2023-06-05 19:12:30 +02:00
|
|
|
case GM_EDITOR:
|
|
|
|
if ((GetRoadTypes(true) & ((rtt == RTT_ROAD) ? ~_roadtypes_type : _roadtypes_type)) == ROADTYPES_NONE) return ES_NOT_HANDLED;
|
|
|
|
w = ShowBuildRoadScenToolbar(last_build);
|
|
|
|
break;
|
2020-03-23 18:28:55 +01:00
|
|
|
|
2023-06-05 19:12:30 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2013-06-15 17:31:22 +02:00
|
|
|
|
2023-06-05 19:12:30 +02:00
|
|
|
if (w == nullptr) return ES_NOT_HANDLED;
|
|
|
|
return w->OnHotkey(hotkey);
|
|
|
|
}
|
2013-06-15 17:31:22 +02:00
|
|
|
|
2023-06-05 19:12:30 +02:00
|
|
|
static EventState RoadToolbarGlobalHotkeys(int hotkey)
|
|
|
|
{
|
|
|
|
extern RoadType _last_built_roadtype;
|
|
|
|
return RoadTramToolbarGlobalHotkeys(hotkey, _last_built_roadtype, RTT_ROAD);
|
|
|
|
}
|
2013-06-15 17:31:22 +02:00
|
|
|
|
2023-06-05 19:12:30 +02:00
|
|
|
static EventState TramToolbarGlobalHotkeys(int hotkey)
|
|
|
|
{
|
|
|
|
extern RoadType _last_built_tramtype;
|
|
|
|
return RoadTramToolbarGlobalHotkeys(hotkey, _last_built_tramtype, RTT_TRAM);
|
|
|
|
}
|
2010-07-04 12:57:31 +02:00
|
|
|
|
2023-06-05 19:12:30 +02:00
|
|
|
static inline HotkeyList road_hotkeys{"roadtoolbar", {
|
|
|
|
Hotkey('1', "build_x", WID_ROT_ROAD_X),
|
|
|
|
Hotkey('2', "build_y", WID_ROT_ROAD_Y),
|
|
|
|
Hotkey('3', "autoroad", WID_ROT_AUTOROAD),
|
|
|
|
Hotkey('4', "demolish", WID_ROT_DEMOLISH),
|
|
|
|
Hotkey('5', "depot", WID_ROT_DEPOT),
|
|
|
|
Hotkey('6', "bus_station", WID_ROT_BUS_STATION),
|
|
|
|
Hotkey('7', "truck_station", WID_ROT_TRUCK_STATION),
|
|
|
|
Hotkey('8', "oneway", WID_ROT_ONE_WAY),
|
|
|
|
Hotkey('B', "bridge", WID_ROT_BUILD_BRIDGE),
|
|
|
|
Hotkey('T', "tunnel", WID_ROT_BUILD_TUNNEL),
|
|
|
|
Hotkey('R', "remove", WID_ROT_REMOVE),
|
|
|
|
Hotkey('C', "convert", WID_ROT_CONVERT_ROAD),
|
|
|
|
}, RoadToolbarGlobalHotkeys};
|
|
|
|
|
|
|
|
static inline HotkeyList tram_hotkeys{"tramtoolbar", {
|
|
|
|
Hotkey('1', "build_x", WID_ROT_ROAD_X),
|
|
|
|
Hotkey('2', "build_y", WID_ROT_ROAD_Y),
|
|
|
|
Hotkey('3', "autoroad", WID_ROT_AUTOROAD),
|
|
|
|
Hotkey('4', "demolish", WID_ROT_DEMOLISH),
|
|
|
|
Hotkey('5', "depot", WID_ROT_DEPOT),
|
|
|
|
Hotkey('6', "bus_station", WID_ROT_BUS_STATION),
|
|
|
|
Hotkey('7', "truck_station", WID_ROT_TRUCK_STATION),
|
|
|
|
Hotkey('B', "bridge", WID_ROT_BUILD_BRIDGE),
|
|
|
|
Hotkey('T', "tunnel", WID_ROT_BUILD_TUNNEL),
|
|
|
|
Hotkey('R', "remove", WID_ROT_REMOVE),
|
|
|
|
Hotkey('C', "convert", WID_ROT_CONVERT_ROAD),
|
|
|
|
}, TramToolbarGlobalHotkeys};
|
|
|
|
};
|
2004-08-09 19:04:08 +02:00
|
|
|
|
2024-01-15 23:49:24 +01:00
|
|
|
static constexpr NWidgetPart _nested_build_road_widgets[] = {
|
2009-03-26 19:55:42 +01:00
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-11-24 19:05:55 +01:00
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
|
2023-06-13 20:00:26 +02:00
|
|
|
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_ROT_CAPTION), SetDataTip(STR_JUST_STRING2, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), SetTextStyle(TC_WHITE),
|
2009-11-24 19:05:55 +01:00
|
|
|
NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
|
2009-03-26 19:55:42 +01:00
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2011-12-16 19:52:15 +01:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_X),
|
2009-11-22 19:26:01 +01:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_X_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
|
2011-12-16 19:52:15 +01:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_Y),
|
2009-11-22 19:26:01 +01:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_Y_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
|
2011-12-16 19:52:15 +01:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_AUTOROAD),
|
2009-11-22 19:26:01 +01:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTOROAD, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_AUTOROAD),
|
2011-12-16 19:52:15 +01:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEMOLISH),
|
2009-11-22 19:26:01 +01:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
|
2011-12-16 19:52:15 +01:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEPOT),
|
2009-11-22 19:26:01 +01:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_DEPOT, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_VEHICLE_DEPOT),
|
2011-12-16 19:52:15 +01:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUS_STATION),
|
2009-11-22 19:26:01 +01:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_BUS_STATION, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_BUS_STATION),
|
2011-12-16 19:52:15 +01:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_TRUCK_STATION),
|
2009-11-22 19:26:01 +01:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRUCK_BAY, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRUCK_LOADING_BAY),
|
|
|
|
NWidget(WWT_PANEL, COLOUR_DARK_GREEN, -1), SetMinimalSize(0, 22), SetFill(1, 1), EndContainer(),
|
2011-12-16 19:52:15 +01:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ONE_WAY),
|
2009-11-22 19:26:01 +01:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_ONE_WAY, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_ONE_WAY_ROAD),
|
2011-12-16 19:52:15 +01:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_BRIDGE),
|
2009-11-22 19:26:01 +01:00
|
|
|
SetFill(0, 1), SetMinimalSize(43, 22), SetDataTip(SPR_IMG_BRIDGE, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_BRIDGE),
|
2011-12-16 19:52:15 +01:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_TUNNEL),
|
2009-11-22 19:26:01 +01:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_TUNNEL, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_TUNNEL),
|
2011-12-16 19:52:15 +01:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_REMOVE),
|
2009-11-22 19:26:01 +01:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR_ROAD),
|
2019-04-06 08:46:15 +02:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_CONVERT_ROAD),
|
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_CONVERT_ROAD, STR_ROAD_TOOLBAR_TOOLTIP_CONVERT_ROAD),
|
2009-03-26 19:55:42 +01:00
|
|
|
EndContainer(),
|
|
|
|
};
|
|
|
|
|
2024-01-17 04:17:02 +01:00
|
|
|
static WindowDesc _build_road_desc(
|
2013-05-26 21:25:01 +02:00
|
|
|
WDP_ALIGN_TOOLBAR, "toolbar_road", 0, 0,
|
2007-02-01 16:49:12 +01:00
|
|
|
WC_BUILD_TOOLBAR, WC_NONE,
|
2009-11-24 18:28:29 +01:00
|
|
|
WDF_CONSTRUCTION,
|
2023-09-03 22:54:13 +02:00
|
|
|
std::begin(_nested_build_road_widgets), std::end(_nested_build_road_widgets),
|
2019-04-06 08:46:15 +02:00
|
|
|
&BuildRoadToolbarWindow::road_hotkeys
|
2009-03-15 16:12:06 +01:00
|
|
|
);
|
2004-08-09 19:04:08 +02:00
|
|
|
|
2024-01-15 23:49:24 +01:00
|
|
|
static constexpr NWidgetPart _nested_build_tramway_widgets[] = {
|
2009-03-26 19:55:42 +01:00
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-11-24 19:05:55 +01:00
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
|
2023-10-16 19:49:44 +02:00
|
|
|
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_ROT_CAPTION), SetDataTip(STR_JUST_STRING2, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), SetTextStyle(TC_WHITE),
|
2009-11-24 19:05:55 +01:00
|
|
|
NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
|
2009-03-26 19:55:42 +01:00
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2011-12-16 19:52:15 +01:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_X),
|
2009-11-22 19:26:01 +01:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRAMWAY_X_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_SECTION),
|
2011-12-16 19:52:15 +01:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_Y),
|
2009-11-22 19:26:01 +01:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRAMWAY_Y_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_SECTION),
|
2011-12-16 19:52:15 +01:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_AUTOROAD),
|
2009-11-22 19:26:01 +01:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTOTRAM, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_AUTOTRAM),
|
2011-12-16 19:52:15 +01:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEMOLISH),
|
2009-11-22 19:26:01 +01:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
|
2011-12-16 19:52:15 +01:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEPOT),
|
2009-11-22 19:26:01 +01:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_DEPOT, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAM_VEHICLE_DEPOT),
|
2011-12-16 19:52:15 +01:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUS_STATION),
|
2009-11-22 19:26:01 +01:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_BUS_STATION, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_PASSENGER_TRAM_STATION),
|
2011-12-16 19:52:15 +01:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_TRUCK_STATION),
|
2009-11-22 19:26:01 +01:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRUCK_BAY, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_CARGO_TRAM_STATION),
|
|
|
|
NWidget(WWT_PANEL, COLOUR_DARK_GREEN, -1), SetMinimalSize(0, 22), SetFill(1, 1), EndContainer(),
|
2011-12-16 19:52:15 +01:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_BRIDGE),
|
2009-11-22 19:26:01 +01:00
|
|
|
SetFill(0, 1), SetMinimalSize(43, 22), SetDataTip(SPR_IMG_BRIDGE, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_BRIDGE),
|
2011-12-16 19:52:15 +01:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_TUNNEL),
|
2009-11-22 19:26:01 +01:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_TUNNEL, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_TUNNEL),
|
2011-12-16 19:52:15 +01:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_REMOVE),
|
2009-11-22 19:26:01 +01:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS),
|
2019-04-06 08:46:15 +02:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_CONVERT_ROAD),
|
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_CONVERT_ROAD, STR_ROAD_TOOLBAR_TOOLTIP_CONVERT_TRAM),
|
2009-03-26 19:55:42 +01:00
|
|
|
EndContainer(),
|
|
|
|
};
|
|
|
|
|
2024-01-17 04:17:02 +01:00
|
|
|
static WindowDesc _build_tramway_desc(
|
2013-05-26 21:25:01 +02:00
|
|
|
WDP_ALIGN_TOOLBAR, "toolbar_tramway", 0, 0,
|
2007-05-26 00:07:40 +02:00
|
|
|
WC_BUILD_TOOLBAR, WC_NONE,
|
2009-11-24 18:28:29 +01:00
|
|
|
WDF_CONSTRUCTION,
|
2023-09-03 22:54:13 +02:00
|
|
|
std::begin(_nested_build_tramway_widgets), std::end(_nested_build_tramway_widgets),
|
2019-04-06 08:46:15 +02:00
|
|
|
&BuildRoadToolbarWindow::tram_hotkeys
|
2009-03-15 16:12:06 +01:00
|
|
|
);
|
2007-05-26 00:07:40 +02:00
|
|
|
|
2010-07-04 12:57:31 +02:00
|
|
|
/**
|
|
|
|
* Open the build road toolbar window
|
|
|
|
*
|
|
|
|
* If the terraform toolbar is linked to the toolbar, that window is also opened.
|
|
|
|
*
|
2019-04-10 23:07:06 +02:00
|
|
|
* @return newly opened road toolbar, or nullptr if the toolbar could not be opened.
|
2010-07-04 12:57:31 +02:00
|
|
|
*/
|
|
|
|
Window *ShowBuildRoadToolbar(RoadType roadtype)
|
2004-08-09 19:04:08 +02:00
|
|
|
{
|
2019-04-10 23:07:06 +02:00
|
|
|
if (!Company::IsValidID(_local_company)) return nullptr;
|
2019-04-06 08:46:15 +02:00
|
|
|
if (!ValParamRoadType(roadtype)) return nullptr;
|
2006-10-31 22:15:56 +01:00
|
|
|
|
2021-05-17 15:46:38 +02:00
|
|
|
CloseWindowByClass(WC_BUILD_TOOLBAR);
|
2019-04-06 08:46:15 +02:00
|
|
|
_cur_roadtype = roadtype;
|
|
|
|
|
|
|
|
return AllocateWindowDescFront<BuildRoadToolbarWindow>(RoadTypeIsRoad(_cur_roadtype) ? &_build_road_desc : &_build_tramway_desc, TRANSPORT_ROAD);
|
2010-07-04 12:57:31 +02:00
|
|
|
}
|
|
|
|
|
2024-01-15 23:49:24 +01:00
|
|
|
static constexpr NWidgetPart _nested_build_road_scen_widgets[] = {
|
2009-03-26 19:55:42 +01:00
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-11-24 19:05:55 +01:00
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
|
2023-10-16 19:49:44 +02:00
|
|
|
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_ROT_CAPTION), SetDataTip(STR_JUST_STRING2, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), SetTextStyle(TC_WHITE),
|
2009-11-24 19:05:55 +01:00
|
|
|
NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
|
2009-03-26 19:55:42 +01:00
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2011-12-16 19:52:15 +01:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_X),
|
2009-11-22 19:26:01 +01:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_X_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
|
2011-12-16 19:52:15 +01:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_Y),
|
2009-11-22 19:26:01 +01:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_Y_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
|
2011-12-16 19:52:15 +01:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_AUTOROAD),
|
2009-11-22 19:26:01 +01:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTOROAD, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_AUTOROAD),
|
2011-12-16 19:52:15 +01:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEMOLISH),
|
2009-11-22 19:26:01 +01:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
|
|
|
|
NWidget(WWT_PANEL, COLOUR_DARK_GREEN, -1), SetMinimalSize(0, 22), SetFill(1, 1), EndContainer(),
|
2011-12-16 19:52:15 +01:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ONE_WAY),
|
2009-11-22 19:26:01 +01:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_ONE_WAY, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_ONE_WAY_ROAD),
|
2011-12-16 19:52:15 +01:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_BRIDGE),
|
2009-11-22 19:26:01 +01:00
|
|
|
SetFill(0, 1), SetMinimalSize(43, 22), SetDataTip(SPR_IMG_BRIDGE, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_BRIDGE),
|
2011-12-16 19:52:15 +01:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_TUNNEL),
|
2009-11-22 19:26:01 +01:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_TUNNEL, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_TUNNEL),
|
2011-12-16 19:52:15 +01:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_REMOVE),
|
2009-11-22 19:26:01 +01:00
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR_ROAD),
|
2019-04-06 08:46:15 +02:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_CONVERT_ROAD),
|
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_CONVERT_ROAD, STR_ROAD_TOOLBAR_TOOLTIP_CONVERT_ROAD),
|
2009-03-26 19:55:42 +01:00
|
|
|
EndContainer(),
|
|
|
|
};
|
|
|
|
|
2024-01-17 04:17:02 +01:00
|
|
|
static WindowDesc _build_road_scen_desc(
|
2013-05-26 21:25:01 +02:00
|
|
|
WDP_AUTO, "toolbar_road_scen", 0, 0,
|
2008-06-25 19:30:16 +02:00
|
|
|
WC_SCEN_BUILD_TOOLBAR, WC_NONE,
|
2009-11-24 18:28:29 +01:00
|
|
|
WDF_CONSTRUCTION,
|
2023-09-03 22:54:13 +02:00
|
|
|
std::begin(_nested_build_road_scen_widgets), std::end(_nested_build_road_scen_widgets),
|
2019-04-06 08:46:15 +02:00
|
|
|
&BuildRoadToolbarWindow::road_hotkeys
|
|
|
|
);
|
|
|
|
|
2024-01-15 23:49:24 +01:00
|
|
|
static constexpr NWidgetPart _nested_build_tramway_scen_widgets[] = {
|
2019-04-06 08:46:15 +02:00
|
|
|
NWidget(NWID_HORIZONTAL),
|
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
|
2023-10-16 19:49:44 +02:00
|
|
|
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_ROT_CAPTION), SetDataTip(STR_JUST_STRING2, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), SetTextStyle(TC_WHITE),
|
2019-04-06 08:46:15 +02:00
|
|
|
NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
|
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_X),
|
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRAMWAY_X_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_SECTION),
|
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_Y),
|
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRAMWAY_Y_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_SECTION),
|
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_AUTOROAD),
|
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTOTRAM, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_AUTOTRAM),
|
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEMOLISH),
|
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
|
|
|
|
NWidget(WWT_PANEL, COLOUR_DARK_GREEN, -1), SetMinimalSize(0, 22), SetFill(1, 1), EndContainer(),
|
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_BRIDGE),
|
|
|
|
SetFill(0, 1), SetMinimalSize(43, 22), SetDataTip(SPR_IMG_BRIDGE, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_BRIDGE),
|
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_TUNNEL),
|
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_TUNNEL, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_TUNNEL),
|
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_REMOVE),
|
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS),
|
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_CONVERT_ROAD),
|
|
|
|
SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_CONVERT_ROAD, STR_ROAD_TOOLBAR_TOOLTIP_CONVERT_TRAM),
|
|
|
|
EndContainer(),
|
|
|
|
};
|
|
|
|
|
2024-01-17 04:17:02 +01:00
|
|
|
static WindowDesc _build_tramway_scen_desc(
|
2019-04-06 08:46:15 +02:00
|
|
|
WDP_AUTO, "toolbar_tram_scen", 0, 0,
|
|
|
|
WC_SCEN_BUILD_TOOLBAR, WC_NONE,
|
|
|
|
WDF_CONSTRUCTION,
|
2023-09-03 22:54:13 +02:00
|
|
|
std::begin(_nested_build_tramway_scen_widgets), std::end(_nested_build_tramway_scen_widgets),
|
2019-04-06 08:46:15 +02:00
|
|
|
&BuildRoadToolbarWindow::tram_hotkeys
|
2009-03-15 16:12:06 +01:00
|
|
|
);
|
2004-08-09 19:04:08 +02:00
|
|
|
|
2011-05-01 21:51:52 +02:00
|
|
|
/**
|
|
|
|
* Show the road building toolbar in the scenario editor.
|
2019-04-10 23:07:06 +02:00
|
|
|
* @return The just opened toolbar, or \c nullptr if the toolbar was already open.
|
2011-05-01 21:51:52 +02:00
|
|
|
*/
|
2019-04-06 08:46:15 +02:00
|
|
|
Window *ShowBuildRoadScenToolbar(RoadType roadtype)
|
2004-08-09 19:04:08 +02:00
|
|
|
{
|
2021-05-17 15:46:38 +02:00
|
|
|
CloseWindowById(WC_SCEN_BUILD_TOOLBAR, TRANSPORT_ROAD);
|
2019-04-06 08:46:15 +02:00
|
|
|
_cur_roadtype = roadtype;
|
|
|
|
|
|
|
|
return AllocateWindowDescFront<BuildRoadToolbarWindow>(RoadTypeIsRoad(_cur_roadtype) ? &_build_road_scen_desc : &_build_tramway_scen_desc, TRANSPORT_ROAD);
|
2010-07-04 12:57:31 +02:00
|
|
|
}
|
|
|
|
|
2008-05-17 19:37:44 +02:00
|
|
|
struct BuildRoadDepotWindow : public PickerWindowBase {
|
2013-05-26 21:23:42 +02:00
|
|
|
BuildRoadDepotWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
|
2008-05-17 19:37:44 +02:00
|
|
|
{
|
2013-05-26 21:23:42 +02:00
|
|
|
this->CreateNestedTree();
|
2009-08-29 23:33:50 +02:00
|
|
|
|
2024-01-16 22:01:28 +01:00
|
|
|
this->LowerWidget(WID_BROD_DEPOT_NE + _road_depot_orientation);
|
2019-04-06 08:46:15 +02:00
|
|
|
if (RoadTypeIsTram(_cur_roadtype)) {
|
2011-12-16 19:52:15 +01:00
|
|
|
this->GetWidget<NWidgetCore>(WID_BROD_CAPTION)->widget_data = STR_BUILD_DEPOT_TRAM_ORIENTATION_CAPTION;
|
2023-12-29 20:11:59 +01:00
|
|
|
for (WidgetID i = WID_BROD_DEPOT_NE; i <= WID_BROD_DEPOT_NW; i++) {
|
|
|
|
this->GetWidget<NWidgetCore>(i)->tool_tip = STR_BUILD_DEPOT_TRAM_ORIENTATION_SELECT_TOOLTIP;
|
|
|
|
}
|
2008-05-17 19:37:44 +02:00
|
|
|
}
|
2009-08-29 23:33:50 +02:00
|
|
|
|
2013-05-26 21:23:42 +02:00
|
|
|
this->FinishInitNested(TRANSPORT_ROAD);
|
2008-05-17 19:37:44 +02:00
|
|
|
}
|
2008-04-04 20:41:16 +02:00
|
|
|
|
2024-04-09 09:34:45 +02:00
|
|
|
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
|
2014-09-22 10:01:25 +02:00
|
|
|
{
|
|
|
|
if (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return;
|
|
|
|
|
2024-04-09 09:34:45 +02:00
|
|
|
size.width = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal();
|
|
|
|
size.height = ScaleGUITrad(48) + WidgetDimensions::scaled.fullbevel.Vertical();
|
2014-09-22 10:01:25 +02:00
|
|
|
}
|
|
|
|
|
2023-12-29 20:11:59 +01:00
|
|
|
void DrawWidget(const Rect &r, WidgetID widget) const override
|
2009-08-29 23:33:50 +02:00
|
|
|
{
|
2011-12-16 19:52:15 +01:00
|
|
|
if (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return;
|
2008-04-04 20:41:16 +02:00
|
|
|
|
2022-10-17 20:25:33 +02:00
|
|
|
DrawPixelInfo tmp_dpi;
|
2023-12-20 01:15:33 +01:00
|
|
|
Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
|
|
|
|
if (FillDrawPixelInfo(&tmp_dpi, ir)) {
|
2023-01-26 19:21:36 +01:00
|
|
|
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
|
2023-12-20 01:15:33 +01:00
|
|
|
int x = (ir.Width() - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
|
|
|
|
int y = (ir.Height() + ScaleSpriteTrad(48)) / 2 - ScaleSpriteTrad(31);
|
2022-10-17 20:25:33 +02:00
|
|
|
DrawRoadDepotSprite(x, y, (DiagDirection)(widget - WID_BROD_DEPOT_NE + DIAGDIR_NE), _cur_roadtype);
|
|
|
|
}
|
2008-05-17 19:37:44 +02:00
|
|
|
}
|
2008-04-04 20:41:16 +02:00
|
|
|
|
2023-12-29 20:11:59 +01:00
|
|
|
void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
|
2008-05-17 19:37:44 +02:00
|
|
|
{
|
|
|
|
switch (widget) {
|
2011-12-16 19:52:15 +01:00
|
|
|
case WID_BROD_DEPOT_NW:
|
|
|
|
case WID_BROD_DEPOT_NE:
|
|
|
|
case WID_BROD_DEPOT_SW:
|
|
|
|
case WID_BROD_DEPOT_SE:
|
2024-01-16 22:01:28 +01:00
|
|
|
this->RaiseWidget(WID_BROD_DEPOT_NE + _road_depot_orientation);
|
2011-12-16 19:52:15 +01:00
|
|
|
_road_depot_orientation = (DiagDirection)(widget - WID_BROD_DEPOT_NE);
|
2024-01-16 22:01:28 +01:00
|
|
|
this->LowerWidget(WID_BROD_DEPOT_NE + _road_depot_orientation);
|
2012-12-23 22:09:09 +01:00
|
|
|
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
2008-05-17 19:37:44 +02:00
|
|
|
this->SetDirty();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2004-08-09 19:04:08 +02:00
|
|
|
}
|
2008-05-17 19:37:44 +02:00
|
|
|
};
|
2004-08-09 19:04:08 +02:00
|
|
|
|
2024-01-15 23:49:24 +01:00
|
|
|
static constexpr NWidgetPart _nested_build_road_depot_widgets[] = {
|
2009-03-26 22:12:14 +01:00
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-11-24 19:05:55 +01:00
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
|
2011-12-16 19:52:15 +01:00
|
|
|
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BROD_CAPTION), SetDataTip(STR_BUILD_DEPOT_ROAD_ORIENTATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
2009-03-26 22:12:14 +01:00
|
|
|
EndContainer(),
|
2009-11-24 22:13:36 +01:00
|
|
|
NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
|
2023-10-31 20:25:12 +01:00
|
|
|
NWidget(NWID_HORIZONTAL_LTR), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1), SetPadding(WidgetDimensions::unscaled.picker),
|
|
|
|
NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0),
|
2024-05-05 13:38:00 +02:00
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROD_DEPOT_NW), SetFill(0, 0), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP),
|
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROD_DEPOT_SW), SetFill(0, 0), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP),
|
2023-10-31 20:25:12 +01:00
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0),
|
2024-05-05 13:38:00 +02:00
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROD_DEPOT_NE), SetFill(0, 0), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP),
|
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROD_DEPOT_SE), SetFill(0, 0), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP),
|
2009-03-26 22:12:14 +01:00
|
|
|
EndContainer(),
|
|
|
|
EndContainer(),
|
|
|
|
EndContainer(),
|
|
|
|
};
|
|
|
|
|
2024-01-17 04:17:02 +01:00
|
|
|
static WindowDesc _build_road_depot_desc(
|
2019-04-10 23:07:06 +02:00
|
|
|
WDP_AUTO, nullptr, 0, 0,
|
2006-11-10 20:24:14 +01:00
|
|
|
WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
|
2009-11-24 18:28:29 +01:00
|
|
|
WDF_CONSTRUCTION,
|
2023-09-03 22:54:13 +02:00
|
|
|
std::begin(_nested_build_road_depot_widgets), std::end(_nested_build_road_depot_widgets)
|
2009-03-15 16:12:06 +01:00
|
|
|
);
|
2007-05-26 00:07:40 +02:00
|
|
|
|
2008-05-24 13:19:30 +02:00
|
|
|
static void ShowRoadDepotPicker(Window *parent)
|
2004-08-09 19:04:08 +02:00
|
|
|
{
|
2008-05-24 13:19:30 +02:00
|
|
|
new BuildRoadDepotWindow(&_build_road_depot_desc, parent);
|
2008-05-17 19:37:44 +02:00
|
|
|
}
|
|
|
|
|
2024-05-07 13:13:48 +02:00
|
|
|
template <RoadStopType roadstoptype>
|
|
|
|
class RoadStopPickerCallbacks : public PickerCallbacksNewGRFClass<RoadStopClass> {
|
|
|
|
public:
|
2024-05-07 13:13:49 +02:00
|
|
|
RoadStopPickerCallbacks(const std::string &ini_group) : PickerCallbacksNewGRFClass<RoadStopClass>(ini_group) {}
|
|
|
|
|
2024-05-07 13:13:48 +02:00
|
|
|
StringID GetClassTooltip() const override;
|
|
|
|
StringID GetTypeTooltip() const override;
|
2022-11-06 16:01:27 +01:00
|
|
|
|
2024-05-07 13:13:48 +02:00
|
|
|
bool IsActive() const override
|
|
|
|
{
|
|
|
|
for (const auto &cls : RoadStopClass::Classes()) {
|
|
|
|
if (IsWaypointClass(cls)) continue;
|
|
|
|
for (const auto *spec : cls.Specs()) {
|
|
|
|
if (spec == nullptr) continue;
|
|
|
|
if (roadstoptype == ROADSTOP_TRUCK && spec->stop_type != ROADSTOPTYPE_FREIGHT && spec->stop_type != ROADSTOPTYPE_ALL) continue;
|
|
|
|
if (roadstoptype == ROADSTOP_BUS && spec->stop_type != ROADSTOPTYPE_PASSENGER && spec->stop_type != ROADSTOPTYPE_ALL) continue;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool IsClassChoice(const RoadStopClass &cls)
|
|
|
|
{
|
|
|
|
return !IsWaypointClass(cls) && GetIfClassHasNewStopsByType(&cls, roadstoptype, _cur_roadtype);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool HasClassChoice() const override
|
|
|
|
{
|
|
|
|
return std::count_if(std::begin(RoadStopClass::Classes()), std::end(RoadStopClass::Classes()), IsClassChoice);
|
|
|
|
}
|
2022-11-06 16:01:27 +01:00
|
|
|
|
2024-05-07 13:13:48 +02:00
|
|
|
int GetSelectedClass() const override { return _roadstop_gui.sel_class; }
|
|
|
|
void SetSelectedClass(int id) const override { _roadstop_gui.sel_class = this->GetClassIndex(id); }
|
2022-11-06 16:01:27 +01:00
|
|
|
|
2024-05-07 13:13:48 +02:00
|
|
|
StringID GetClassName(int id) const override
|
|
|
|
{
|
|
|
|
const auto *rsc = this->GetClass(id);
|
|
|
|
if (!IsClassChoice(*rsc)) return INVALID_STRING_ID;
|
|
|
|
return rsc->name;
|
|
|
|
}
|
2022-11-06 16:01:27 +01:00
|
|
|
|
2024-05-07 13:13:48 +02:00
|
|
|
int GetSelectedType() const override { return _roadstop_gui.sel_type; }
|
|
|
|
void SetSelectedType(int id) const override { _roadstop_gui.sel_type = id; }
|
|
|
|
|
|
|
|
StringID GetTypeName(int cls_id, int id) const override
|
|
|
|
{
|
|
|
|
const auto *spec = this->GetSpec(cls_id, id);
|
|
|
|
if (!IsRoadStopEverAvailable(spec, roadstoptype == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK)) return INVALID_STRING_ID;
|
|
|
|
return (spec == nullptr) ? STR_STATION_CLASS_DFLT_ROADSTOP : spec->name;
|
|
|
|
}
|
2022-11-06 16:01:27 +01:00
|
|
|
|
2024-05-07 13:13:48 +02:00
|
|
|
bool IsTypeAvailable(int cls_id, int id) const override
|
2008-05-17 19:37:44 +02:00
|
|
|
{
|
2024-05-07 13:13:48 +02:00
|
|
|
const auto *spec = this->GetSpec(cls_id, id);
|
|
|
|
return IsRoadStopAvailable(spec, roadstoptype == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DrawType(int x, int y, int cls_id, int id) const override
|
|
|
|
{
|
|
|
|
const auto *spec = this->GetSpec(cls_id, id);
|
|
|
|
if (spec == nullptr) {
|
|
|
|
StationPickerDrawSprite(x, y, roadstoptype == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK, INVALID_RAILTYPE, _cur_roadtype, _roadstop_gui.orientation);
|
|
|
|
} else {
|
|
|
|
DiagDirection orientation = _roadstop_gui.orientation;
|
|
|
|
if (orientation < DIAGDIR_END && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) orientation = DIAGDIR_END;
|
|
|
|
DrawRoadStopTile(x, y, _cur_roadtype, spec, roadstoptype == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK, (uint8_t)orientation);
|
2022-11-06 16:01:27 +01:00
|
|
|
}
|
|
|
|
}
|
2024-05-07 13:13:49 +02:00
|
|
|
|
|
|
|
void FillUsedItems(std::set<PickerItem> &items) override
|
|
|
|
{
|
|
|
|
for (const Station *st : Station::Iterate()) {
|
|
|
|
if (st->owner != _local_company) continue;
|
|
|
|
if (roadstoptype == ROADSTOP_TRUCK && !(st->facilities & FACIL_TRUCK_STOP)) continue;
|
|
|
|
if (roadstoptype == ROADSTOP_BUS && !(st->facilities & FACIL_BUS_STOP)) continue;
|
|
|
|
items.insert({0, 0, ROADSTOP_CLASS_DFLT, 0}); // We would need to scan the map to find out if default is used.
|
|
|
|
for (const auto &sm : st->roadstop_speclist) {
|
|
|
|
if (sm.spec == nullptr) continue;
|
|
|
|
if (roadstoptype == ROADSTOP_TRUCK && sm.spec->stop_type != ROADSTOPTYPE_FREIGHT && sm.spec->stop_type != ROADSTOPTYPE_ALL) continue;
|
|
|
|
if (roadstoptype == ROADSTOP_BUS && sm.spec->stop_type != ROADSTOPTYPE_PASSENGER && sm.spec->stop_type != ROADSTOPTYPE_ALL) continue;
|
|
|
|
items.insert({sm.grfid, sm.localidx, sm.spec->class_index, sm.spec->index});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-05-07 13:13:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
template <> StringID RoadStopPickerCallbacks<ROADSTOP_BUS>::GetClassTooltip() const { return STR_PICKER_ROADSTOP_BUS_CLASS_TOOLTIP; }
|
|
|
|
template <> StringID RoadStopPickerCallbacks<ROADSTOP_BUS>::GetTypeTooltip() const { return STR_PICKER_ROADSTOP_BUS_TYPE_TOOLTIP; }
|
|
|
|
|
|
|
|
template <> StringID RoadStopPickerCallbacks<ROADSTOP_TRUCK>::GetClassTooltip() const { return STR_PICKER_ROADSTOP_TRUCK_CLASS_TOOLTIP; }
|
|
|
|
template <> StringID RoadStopPickerCallbacks<ROADSTOP_TRUCK>::GetTypeTooltip() const { return STR_PICKER_ROADSTOP_TRUCK_TYPE_TOOLTIP; }
|
|
|
|
|
2024-05-07 13:13:49 +02:00
|
|
|
static RoadStopPickerCallbacks<ROADSTOP_BUS> _bus_callback_instance("fav_passenger_roadstops");
|
|
|
|
static RoadStopPickerCallbacks<ROADSTOP_TRUCK> _truck_callback_instance("fav_freight_roadstops");
|
2024-05-07 13:13:48 +02:00
|
|
|
|
|
|
|
static PickerCallbacks &GetRoadStopPickerCallbacks(RoadStopType rs)
|
|
|
|
{
|
|
|
|
return rs == ROADSTOP_BUS ? static_cast<PickerCallbacks &>(_bus_callback_instance) : static_cast<PickerCallbacks &>(_truck_callback_instance);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct BuildRoadStationWindow : public PickerWindow {
|
|
|
|
private:
|
|
|
|
uint coverage_height; ///< Height of the coverage texts.
|
2022-11-06 16:01:27 +01:00
|
|
|
|
|
|
|
void CheckOrientationValid()
|
|
|
|
{
|
2024-05-07 13:13:48 +02:00
|
|
|
const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui.sel_class)->GetSpec(_roadstop_gui.sel_type);
|
2024-02-14 18:23:17 +01:00
|
|
|
|
|
|
|
/* Raise and lower to ensure the correct widget is lowered after changing displayed orientation plane. */
|
2024-02-23 21:02:59 +01:00
|
|
|
if (RoadTypeIsRoad(_cur_roadtype)) {
|
2024-05-07 13:13:48 +02:00
|
|
|
this->RaiseWidget(WID_BROS_STATION_NE + _roadstop_gui.orientation);
|
2024-02-23 21:02:59 +01:00
|
|
|
this->GetWidget<NWidgetStacked>(WID_BROS_AVAILABLE_ORIENTATIONS)->SetDisplayedPlane((spec != nullptr && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) ? 1 : 0);
|
2024-05-07 13:13:48 +02:00
|
|
|
this->LowerWidget(WID_BROS_STATION_NE + _roadstop_gui.orientation);
|
2024-02-23 21:02:59 +01:00
|
|
|
}
|
2024-02-14 18:23:17 +01:00
|
|
|
|
2024-05-07 13:13:48 +02:00
|
|
|
if (_roadstop_gui.orientation >= DIAGDIR_END) return;
|
2024-02-14 18:23:17 +01:00
|
|
|
|
2022-11-06 16:01:27 +01:00
|
|
|
if (spec != nullptr && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) {
|
2024-05-07 13:13:48 +02:00
|
|
|
this->RaiseWidget(WID_BROS_STATION_NE + _roadstop_gui.orientation);
|
|
|
|
_roadstop_gui.orientation = DIAGDIR_END;
|
|
|
|
this->LowerWidget(WID_BROS_STATION_NE + _roadstop_gui.orientation);
|
2022-11-06 16:01:27 +01:00
|
|
|
this->SetDirty();
|
|
|
|
CloseWindowById(WC_SELECT_STATION, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2024-05-07 13:13:48 +02:00
|
|
|
BuildRoadStationWindow(WindowDesc *desc, Window *parent, RoadStopType rs) : PickerWindow(desc, parent, TRANSPORT_ROAD, GetRoadStopPickerCallbacks(rs))
|
2022-11-06 16:01:27 +01:00
|
|
|
{
|
2023-11-21 20:04:24 +01:00
|
|
|
this->coverage_height = 2 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
|
2022-11-06 16:01:27 +01:00
|
|
|
|
2008-05-17 19:37:44 +02:00
|
|
|
/* Trams don't have non-drivethrough stations */
|
2024-05-07 13:13:48 +02:00
|
|
|
if (RoadTypeIsTram(_cur_roadtype) && _roadstop_gui.orientation < DIAGDIR_END) {
|
|
|
|
_roadstop_gui.orientation = DIAGDIR_END;
|
2008-05-17 19:37:44 +02:00
|
|
|
}
|
2024-05-07 13:13:48 +02:00
|
|
|
this->ConstructWindow();
|
|
|
|
|
2019-04-06 08:46:15 +02:00
|
|
|
const RoadTypeInfo *rti = GetRoadTypeInfo(_cur_roadtype);
|
|
|
|
this->GetWidget<NWidgetCore>(WID_BROS_CAPTION)->widget_data = rti->strings.picker_title[rs];
|
2008-05-17 19:37:44 +02:00
|
|
|
|
2023-12-29 20:11:59 +01:00
|
|
|
for (WidgetID i = RoadTypeIsTram(_cur_roadtype) ? WID_BROS_STATION_X : WID_BROS_STATION_NE; i < WID_BROS_LT_OFF; i++) {
|
2019-04-06 08:46:15 +02:00
|
|
|
this->GetWidget<NWidgetCore>(i)->tool_tip = rti->strings.picker_tooltip[rs];
|
2017-01-15 15:27:54 +01:00
|
|
|
}
|
2008-05-17 19:37:44 +02:00
|
|
|
|
2024-05-07 13:13:48 +02:00
|
|
|
this->LowerWidget(WID_BROS_STATION_NE + _roadstop_gui.orientation);
|
2024-01-16 22:01:28 +01:00
|
|
|
this->LowerWidget(WID_BROS_LT_OFF + _settings_client.gui.station_show_coverage);
|
2009-08-30 00:24:29 +02:00
|
|
|
|
|
|
|
this->window_class = (rs == ROADSTOP_BUS) ? WC_BUS_STATION : WC_TRUCK_STATION;
|
2008-05-17 19:37:44 +02:00
|
|
|
}
|
2004-08-09 19:04:08 +02:00
|
|
|
|
2023-10-13 13:59:15 +02:00
|
|
|
void Close([[maybe_unused]] int data = 0) override
|
2009-01-08 17:35:45 +01:00
|
|
|
{
|
2021-05-17 15:46:38 +02:00
|
|
|
CloseWindowById(WC_SELECT_STATION, 0);
|
2024-05-07 13:13:48 +02:00
|
|
|
this->PickerWindow::Close();
|
2022-11-06 16:01:27 +01:00
|
|
|
}
|
|
|
|
|
2023-09-16 22:20:53 +02:00
|
|
|
void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
|
2022-11-06 16:01:27 +01:00
|
|
|
{
|
2024-05-07 13:13:48 +02:00
|
|
|
this->PickerWindow::OnInvalidateData(data, gui_scope);
|
2022-11-06 16:01:27 +01:00
|
|
|
|
2024-05-07 13:13:48 +02:00
|
|
|
if (gui_scope) {
|
|
|
|
this->CheckOrientationValid();
|
2023-09-16 23:25:17 +02:00
|
|
|
}
|
2022-11-06 16:01:27 +01:00
|
|
|
}
|
|
|
|
|
2019-03-04 08:49:37 +01:00
|
|
|
void OnPaint() override
|
2008-05-17 19:37:44 +02:00
|
|
|
{
|
|
|
|
this->DrawWidgets();
|
2008-04-04 20:41:16 +02:00
|
|
|
|
2013-01-28 23:21:29 +01:00
|
|
|
int rad = _settings_game.station.modified_catchment ? ((this->window_class == WC_BUS_STATION) ? CA_BUS : CA_TRUCK) : CA_UNMODIFIED;
|
2009-01-04 12:11:11 +01:00
|
|
|
if (_settings_client.gui.station_show_coverage) {
|
2008-05-17 19:37:44 +02:00
|
|
|
SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
|
|
|
|
} else {
|
|
|
|
SetTileSelectSize(1, 1);
|
|
|
|
}
|
2008-04-04 20:41:16 +02:00
|
|
|
|
2022-11-06 16:01:27 +01:00
|
|
|
if (this->IsShaded()) return;
|
|
|
|
|
2009-08-30 00:24:29 +02:00
|
|
|
/* 'Accepts' and 'Supplies' texts. */
|
2009-07-11 00:03:09 +02:00
|
|
|
StationCoverageType sct = (this->window_class == WC_BUS_STATION) ? SCT_PASSENGERS_ONLY : SCT_NON_PASSENGERS_ONLY;
|
2021-05-04 13:35:27 +02:00
|
|
|
Rect r = this->GetWidget<NWidgetBase>(WID_BROS_ACCEPTANCE)->GetCurrentRect();
|
2023-10-31 21:22:05 +01:00
|
|
|
int top = r.top;
|
2022-09-23 10:36:22 +02:00
|
|
|
top = DrawStationCoverageAreaText(r.left, r.right, top, sct, rad, false) + WidgetDimensions::scaled.vsep_normal;
|
2023-10-31 21:22:05 +01:00
|
|
|
top = DrawStationCoverageAreaText(r.left, r.right, top, sct, rad, true);
|
2013-06-11 20:36:26 +02:00
|
|
|
/* Resize background if the window is too small.
|
|
|
|
* Never make the window smaller to avoid oscillating if the size change affects the acceptance.
|
|
|
|
* (This is the case, if making the window bigger moves the mouse into the window.) */
|
2021-05-04 13:35:27 +02:00
|
|
|
if (top > r.bottom) {
|
2022-11-06 16:01:27 +01:00
|
|
|
this->coverage_height += top - r.bottom;
|
|
|
|
this->ReInit();
|
2008-05-17 19:37:44 +02:00
|
|
|
}
|
|
|
|
}
|
2008-04-04 20:41:16 +02:00
|
|
|
|
2024-04-09 09:34:45 +02:00
|
|
|
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
|
2014-09-22 10:01:25 +02:00
|
|
|
{
|
2022-11-06 16:01:27 +01:00
|
|
|
switch (widget) {
|
|
|
|
case WID_BROS_STATION_NE:
|
|
|
|
case WID_BROS_STATION_SE:
|
|
|
|
case WID_BROS_STATION_SW:
|
|
|
|
case WID_BROS_STATION_NW:
|
|
|
|
case WID_BROS_STATION_X:
|
|
|
|
case WID_BROS_STATION_Y:
|
2024-05-07 13:13:48 +02:00
|
|
|
size.width = ScaleGUITrad(PREVIEW_WIDTH) + WidgetDimensions::scaled.fullbevel.Horizontal();
|
|
|
|
size.height = ScaleGUITrad(PREVIEW_HEIGHT) + WidgetDimensions::scaled.fullbevel.Vertical();
|
2022-11-06 16:01:27 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WID_BROS_ACCEPTANCE:
|
2024-04-09 09:34:45 +02:00
|
|
|
size.height = this->coverage_height;
|
2022-11-06 16:01:27 +01:00
|
|
|
break;
|
2024-05-07 13:13:48 +02:00
|
|
|
|
|
|
|
default:
|
|
|
|
this->PickerWindow::UpdateWidgetSize(widget, size, padding, fill, resize);
|
|
|
|
break;
|
2022-11-06 16:01:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Simply to have a easier way to get the StationType for bus, truck and trams from the WindowClass.
|
|
|
|
*/
|
2023-11-09 20:20:41 +01:00
|
|
|
StationType GetRoadStationTypeByWindowClass(WindowClass window_class) const
|
|
|
|
{
|
2022-11-06 16:01:27 +01:00
|
|
|
switch (window_class) {
|
|
|
|
case WC_BUS_STATION: return STATION_BUS;
|
|
|
|
case WC_TRUCK_STATION: return STATION_TRUCK;
|
|
|
|
default: NOT_REACHED();
|
|
|
|
}
|
2014-09-22 10:01:25 +02:00
|
|
|
}
|
|
|
|
|
2023-12-29 20:11:59 +01:00
|
|
|
void DrawWidget(const Rect &r, WidgetID widget) const override
|
2009-08-30 00:24:29 +02:00
|
|
|
{
|
2023-12-30 19:24:26 +01:00
|
|
|
switch (widget) {
|
2022-11-06 16:01:27 +01:00
|
|
|
case WID_BROS_STATION_NE:
|
|
|
|
case WID_BROS_STATION_SE:
|
|
|
|
case WID_BROS_STATION_SW:
|
|
|
|
case WID_BROS_STATION_NW:
|
|
|
|
case WID_BROS_STATION_X:
|
|
|
|
case WID_BROS_STATION_Y: {
|
|
|
|
StationType st = GetRoadStationTypeByWindowClass(this->window_class);
|
2024-05-07 13:13:48 +02:00
|
|
|
const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui.sel_class)->GetSpec(_roadstop_gui.sel_type);
|
2022-11-06 16:01:27 +01:00
|
|
|
DrawPixelInfo tmp_dpi;
|
2023-12-20 01:15:33 +01:00
|
|
|
Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
|
|
|
|
if (FillDrawPixelInfo(&tmp_dpi, ir)) {
|
2022-11-06 16:01:27 +01:00
|
|
|
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
|
2024-05-07 13:13:48 +02:00
|
|
|
int x = (ir.Width() - ScaleSpriteTrad(PREVIEW_WIDTH)) / 2 + ScaleSpriteTrad(PREVIEW_LEFT);
|
|
|
|
int y = (ir.Height() + ScaleSpriteTrad(PREVIEW_HEIGHT)) / 2 - ScaleSpriteTrad(PREVIEW_BOTTOM);
|
2024-02-14 18:23:17 +01:00
|
|
|
if (spec == nullptr) {
|
2022-11-06 16:01:27 +01:00
|
|
|
StationPickerDrawSprite(x, y, st, INVALID_RAILTYPE, _cur_roadtype, widget - WID_BROS_STATION_NE);
|
|
|
|
} else {
|
|
|
|
DrawRoadStopTile(x, y, _cur_roadtype, spec, st, widget - WID_BROS_STATION_NE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2009-08-30 00:24:29 +02:00
|
|
|
|
2024-05-07 13:13:48 +02:00
|
|
|
default:
|
|
|
|
this->PickerWindow::DrawWidget(r, widget);
|
2022-11-06 16:01:27 +01:00
|
|
|
break;
|
2022-10-17 20:25:33 +02:00
|
|
|
}
|
2009-08-30 00:24:29 +02:00
|
|
|
}
|
|
|
|
|
2023-12-29 20:11:59 +01:00
|
|
|
void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
|
2008-05-17 19:37:44 +02:00
|
|
|
{
|
2023-12-30 19:24:26 +01:00
|
|
|
switch (widget) {
|
2011-12-16 19:52:15 +01:00
|
|
|
case WID_BROS_STATION_NE:
|
|
|
|
case WID_BROS_STATION_SE:
|
|
|
|
case WID_BROS_STATION_SW:
|
|
|
|
case WID_BROS_STATION_NW:
|
|
|
|
case WID_BROS_STATION_X:
|
|
|
|
case WID_BROS_STATION_Y:
|
2022-11-06 16:01:27 +01:00
|
|
|
if (widget < WID_BROS_STATION_X) {
|
2024-05-07 13:13:48 +02:00
|
|
|
const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui.sel_class)->GetSpec(_roadstop_gui.sel_type);
|
2022-11-06 16:01:27 +01:00
|
|
|
if (spec != nullptr && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) return;
|
|
|
|
}
|
2024-05-07 13:13:48 +02:00
|
|
|
this->RaiseWidget(WID_BROS_STATION_NE + _roadstop_gui.orientation);
|
|
|
|
_roadstop_gui.orientation = (DiagDirection)(widget - WID_BROS_STATION_NE);
|
|
|
|
this->LowerWidget(WID_BROS_STATION_NE + _roadstop_gui.orientation);
|
2012-12-23 22:09:09 +01:00
|
|
|
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
2008-05-17 19:37:44 +02:00
|
|
|
this->SetDirty();
|
2021-05-17 15:46:38 +02:00
|
|
|
CloseWindowById(WC_SELECT_STATION, 0);
|
2008-05-17 19:37:44 +02:00
|
|
|
break;
|
|
|
|
|
2011-12-16 19:52:15 +01:00
|
|
|
case WID_BROS_LT_OFF:
|
|
|
|
case WID_BROS_LT_ON:
|
|
|
|
this->RaiseWidget(_settings_client.gui.station_show_coverage + WID_BROS_LT_OFF);
|
|
|
|
_settings_client.gui.station_show_coverage = (widget != WID_BROS_LT_OFF);
|
|
|
|
this->LowerWidget(_settings_client.gui.station_show_coverage + WID_BROS_LT_OFF);
|
2012-12-23 22:09:09 +01:00
|
|
|
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
2008-05-17 19:37:44 +02:00
|
|
|
this->SetDirty();
|
2020-07-27 18:37:47 +02:00
|
|
|
SetViewportCatchmentStation(nullptr, true);
|
2008-05-17 19:37:44 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2024-05-07 13:13:48 +02:00
|
|
|
this->PickerWindow::OnClick(pt, widget, click_count);
|
2008-05-17 19:37:44 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-04-04 20:41:16 +02:00
|
|
|
|
2023-09-16 22:20:53 +02:00
|
|
|
void OnRealtimeTick([[maybe_unused]] uint delta_ms) override
|
2008-05-17 19:37:44 +02:00
|
|
|
{
|
|
|
|
CheckRedrawStationCoverage(this);
|
2004-09-10 21:02:27 +02:00
|
|
|
}
|
2022-11-06 16:01:27 +01:00
|
|
|
|
2024-02-06 00:14:21 +01:00
|
|
|
static inline HotkeyList road_hotkeys{"buildroadstop", {
|
2024-05-07 13:13:48 +02:00
|
|
|
Hotkey('F', "focus_filter_box", PCWHK_FOCUS_FILTER_BOX),
|
2024-02-06 00:14:21 +01:00
|
|
|
}};
|
|
|
|
|
|
|
|
static inline HotkeyList tram_hotkeys{"buildtramstop", {
|
2024-05-07 13:13:48 +02:00
|
|
|
Hotkey('F', "focus_filter_box", PCWHK_FOCUS_FILTER_BOX),
|
2023-06-05 19:12:30 +02:00
|
|
|
}};
|
2022-11-06 16:01:27 +01:00
|
|
|
};
|
|
|
|
|
2009-05-03 15:53:34 +02:00
|
|
|
/** Widget definition of the build road station window */
|
2024-01-15 23:49:24 +01:00
|
|
|
static constexpr NWidgetPart _nested_road_station_picker_widgets[] = {
|
2009-05-03 15:55:22 +02:00
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-11-24 19:05:55 +01:00
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
|
2011-12-16 19:52:15 +01:00
|
|
|
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BROS_CAPTION),
|
2022-11-06 16:01:27 +01:00
|
|
|
NWidget(WWT_SHADEBOX, COLOUR_DARK_GREEN),
|
2024-05-07 13:13:48 +02:00
|
|
|
NWidget(WWT_DEFSIZEBOX, COLOUR_DARK_GREEN),
|
2009-05-03 15:55:22 +02:00
|
|
|
EndContainer(),
|
2023-10-31 21:22:05 +01:00
|
|
|
NWidget(NWID_HORIZONTAL),
|
2024-05-07 13:13:48 +02:00
|
|
|
NWidget(NWID_VERTICAL),
|
|
|
|
NWidgetFunction(MakePickerClassWidgets),
|
|
|
|
NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
|
|
|
|
NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_picker, 0), SetPadding(WidgetDimensions::unscaled.picker),
|
|
|
|
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BROS_AVAILABLE_ORIENTATIONS),
|
|
|
|
/* 6-orientation plane. */
|
|
|
|
NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0),
|
|
|
|
NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1),
|
|
|
|
NWidget(NWID_HORIZONTAL_LTR), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
|
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_NW), SetFill(0, 0), EndContainer(),
|
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_NE), SetFill(0, 0), EndContainer(),
|
2023-10-31 21:22:05 +01:00
|
|
|
EndContainer(),
|
2024-05-07 13:13:48 +02:00
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_X), SetFill(0, 0), EndContainer(),
|
2023-10-31 21:22:05 +01:00
|
|
|
EndContainer(),
|
2024-05-07 13:13:48 +02:00
|
|
|
NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1),
|
|
|
|
NWidget(NWID_HORIZONTAL_LTR), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
|
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_SW), SetFill(0, 0), EndContainer(),
|
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_SE), SetFill(0, 0), EndContainer(),
|
2023-10-31 21:22:05 +01:00
|
|
|
EndContainer(),
|
2024-05-07 13:13:48 +02:00
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_Y), SetFill(0, 0), EndContainer(),
|
2023-10-31 21:22:05 +01:00
|
|
|
EndContainer(),
|
|
|
|
EndContainer(),
|
2024-05-07 13:13:48 +02:00
|
|
|
/* 2-orientation plane. */
|
|
|
|
NWidget(NWID_VERTICAL), SetPIPRatio(0, 0, 1),
|
|
|
|
NWidget(NWID_HORIZONTAL_LTR), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1),
|
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_X), SetFill(0, 0), EndContainer(),
|
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_Y), SetFill(0, 0), EndContainer(),
|
2022-11-06 16:01:27 +01:00
|
|
|
EndContainer(),
|
|
|
|
EndContainer(),
|
|
|
|
EndContainer(),
|
2024-05-07 13:13:48 +02:00
|
|
|
NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0),
|
|
|
|
NWidget(NWID_HORIZONTAL), SetPIPRatio(1, 0, 1),
|
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_OFF), SetMinimalSize(60, 12),
|
|
|
|
SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
|
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_ON), SetMinimalSize(60, 12),
|
|
|
|
SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
|
|
|
|
EndContainer(),
|
|
|
|
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_BROS_ACCEPTANCE), SetFill(1, 1), SetResize(1, 0), SetMinimalTextLines(2, 0),
|
2022-10-09 18:42:47 +02:00
|
|
|
EndContainer(),
|
2022-11-06 16:01:27 +01:00
|
|
|
EndContainer(),
|
2017-01-15 15:27:54 +01:00
|
|
|
EndContainer(),
|
2024-05-07 13:13:48 +02:00
|
|
|
NWidgetFunction(MakePickerTypeWidgets),
|
2017-01-15 15:27:54 +01:00
|
|
|
EndContainer(),
|
|
|
|
};
|
|
|
|
|
2024-01-17 04:17:02 +01:00
|
|
|
static WindowDesc _road_station_picker_desc(
|
2023-07-12 22:07:31 +02:00
|
|
|
WDP_AUTO, "build_station_road", 0, 0,
|
2017-01-15 15:27:54 +01:00
|
|
|
WC_BUS_STATION, WC_BUILD_TOOLBAR,
|
|
|
|
WDF_CONSTRUCTION,
|
2024-02-06 00:14:21 +01:00
|
|
|
std::begin(_nested_road_station_picker_widgets), std::end(_nested_road_station_picker_widgets),
|
|
|
|
&BuildRoadStationWindow::road_hotkeys
|
2017-01-15 15:27:54 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
/** Widget definition of the build tram station window */
|
2024-01-15 23:49:24 +01:00
|
|
|
static constexpr NWidgetPart _nested_tram_station_picker_widgets[] = {
|
2017-01-15 15:27:54 +01:00
|
|
|
NWidget(NWID_HORIZONTAL),
|
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
|
|
|
|
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BROS_CAPTION),
|
2022-11-06 16:01:27 +01:00
|
|
|
NWidget(WWT_SHADEBOX, COLOUR_DARK_GREEN),
|
2024-05-07 13:13:48 +02:00
|
|
|
NWidget(WWT_DEFSIZEBOX, COLOUR_DARK_GREEN),
|
2017-01-15 15:27:54 +01:00
|
|
|
EndContainer(),
|
2023-10-31 21:22:05 +01:00
|
|
|
NWidget(NWID_HORIZONTAL),
|
2024-05-07 13:13:48 +02:00
|
|
|
NWidget(NWID_VERTICAL),
|
|
|
|
NWidgetFunction(MakePickerClassWidgets),
|
|
|
|
NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
|
|
|
|
NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_picker, 0), SetPadding(WidgetDimensions::unscaled.picker),
|
|
|
|
NWidget(NWID_HORIZONTAL_LTR), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1),
|
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_X), SetFill(0, 0), EndContainer(),
|
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_Y), SetFill(0, 0), EndContainer(),
|
2022-11-06 16:01:27 +01:00
|
|
|
EndContainer(),
|
2024-05-07 13:13:48 +02:00
|
|
|
NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0),
|
|
|
|
NWidget(NWID_HORIZONTAL), SetPIPRatio(1, 0, 1),
|
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_OFF), SetMinimalSize(60, 12),
|
|
|
|
SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
|
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_ON), SetMinimalSize(60, 12),
|
|
|
|
SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
|
2022-11-06 16:01:27 +01:00
|
|
|
EndContainer(),
|
2024-05-07 13:13:48 +02:00
|
|
|
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_BROS_ACCEPTANCE), SetFill(1, 1), SetResize(1, 0), SetMinimalTextLines(2, 0),
|
2022-10-09 18:42:47 +02:00
|
|
|
EndContainer(),
|
2022-11-06 16:01:27 +01:00
|
|
|
EndContainer(),
|
2009-05-03 15:55:22 +02:00
|
|
|
EndContainer(),
|
2024-05-07 13:13:48 +02:00
|
|
|
NWidgetFunction(MakePickerTypeWidgets),
|
2009-05-03 15:55:22 +02:00
|
|
|
EndContainer(),
|
|
|
|
};
|
|
|
|
|
2024-01-17 04:17:02 +01:00
|
|
|
static WindowDesc _tram_station_picker_desc(
|
2023-07-12 22:07:31 +02:00
|
|
|
WDP_AUTO, "build_station_tram", 0, 0,
|
2006-11-10 20:24:14 +01:00
|
|
|
WC_BUS_STATION, WC_BUILD_TOOLBAR,
|
2009-11-24 18:28:29 +01:00
|
|
|
WDF_CONSTRUCTION,
|
2024-02-06 00:14:21 +01:00
|
|
|
std::begin(_nested_tram_station_picker_widgets), std::end(_nested_tram_station_picker_widgets),
|
|
|
|
&BuildRoadStationWindow::tram_hotkeys
|
2009-03-15 16:12:06 +01:00
|
|
|
);
|
2004-08-09 19:04:08 +02:00
|
|
|
|
2008-05-24 13:19:30 +02:00
|
|
|
static void ShowRVStationPicker(Window *parent, RoadStopType rs)
|
2004-08-09 19:04:08 +02:00
|
|
|
{
|
2019-04-06 08:46:15 +02:00
|
|
|
new BuildRoadStationWindow(RoadTypeIsRoad(_cur_roadtype) ? &_road_station_picker_desc : &_tram_station_picker_desc, parent, rs);
|
2004-08-09 19:04:08 +02:00
|
|
|
}
|
|
|
|
|
2007-03-07 12:47:46 +01:00
|
|
|
void InitializeRoadGui()
|
2004-08-09 19:04:08 +02:00
|
|
|
{
|
2007-01-10 19:56:51 +01:00
|
|
|
_road_depot_orientation = DIAGDIR_NW;
|
2024-05-07 13:13:48 +02:00
|
|
|
_roadstop_gui.orientation = DIAGDIR_NW;
|
2004-08-09 19:04:08 +02:00
|
|
|
}
|
2019-04-06 08:46:15 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* I really don't know why rail_gui.cpp has this too, shouldn't be included in the other one?
|
|
|
|
*/
|
|
|
|
void InitializeRoadGUI()
|
|
|
|
{
|
|
|
|
BuildRoadToolbarWindow *w = dynamic_cast<BuildRoadToolbarWindow *>(FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_ROAD));
|
|
|
|
if (w != nullptr) w->ModifyRoadType(_cur_roadtype);
|
|
|
|
}
|
|
|
|
|
|
|
|
DropDownList GetRoadTypeDropDownList(RoadTramTypes rtts, bool for_replacement, bool all_option)
|
|
|
|
{
|
|
|
|
RoadTypes used_roadtypes;
|
|
|
|
RoadTypes avail_roadtypes;
|
|
|
|
|
|
|
|
const Company *c = Company::Get(_local_company);
|
|
|
|
|
|
|
|
/* Find the used roadtypes. */
|
|
|
|
if (for_replacement) {
|
|
|
|
avail_roadtypes = GetCompanyRoadTypes(c->index, false);
|
|
|
|
used_roadtypes = GetRoadTypes(false);
|
|
|
|
} else {
|
|
|
|
avail_roadtypes = c->avail_roadtypes;
|
|
|
|
used_roadtypes = GetRoadTypes(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Filter listed road types */
|
|
|
|
if (!HasBit(rtts, RTT_ROAD)) used_roadtypes &= _roadtypes_type;
|
|
|
|
if (!HasBit(rtts, RTT_TRAM)) used_roadtypes &= ~_roadtypes_type;
|
|
|
|
|
|
|
|
DropDownList list;
|
|
|
|
|
|
|
|
if (all_option) {
|
2024-03-31 18:31:47 +02:00
|
|
|
list.push_back(MakeDropDownListStringItem(STR_REPLACE_ALL_ROADTYPE, INVALID_ROADTYPE));
|
2019-04-06 08:46:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Dimension d = { 0, 0 };
|
|
|
|
/* Get largest icon size, to ensure text is aligned on each menu item. */
|
|
|
|
if (!for_replacement) {
|
2021-04-28 22:50:23 +02:00
|
|
|
for (const auto &rt : _sorted_roadtypes) {
|
2019-04-06 08:46:15 +02:00
|
|
|
if (!HasBit(used_roadtypes, rt)) continue;
|
|
|
|
const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
|
|
|
|
d = maxdim(d, GetSpriteSize(rti->gui_sprites.build_x_road));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-28 22:50:23 +02:00
|
|
|
for (const auto &rt : _sorted_roadtypes) {
|
2019-04-06 08:46:15 +02:00
|
|
|
/* If it's not used ever, don't show it to the user. */
|
|
|
|
if (!HasBit(used_roadtypes, rt)) continue;
|
|
|
|
|
|
|
|
const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
|
|
|
|
|
2023-06-23 10:30:13 +02:00
|
|
|
SetDParam(0, rti->strings.menu_text);
|
2023-08-15 10:34:36 +02:00
|
|
|
SetDParam(1, rti->max_speed / 2);
|
2019-04-06 08:46:15 +02:00
|
|
|
if (for_replacement) {
|
2024-03-31 18:31:47 +02:00
|
|
|
list.push_back(MakeDropDownListStringItem(rti->strings.replace_text, rt, !HasBit(avail_roadtypes, rt)));
|
2019-04-06 08:46:15 +02:00
|
|
|
} else {
|
|
|
|
StringID str = rti->max_speed > 0 ? STR_TOOLBAR_RAILTYPE_VELOCITY : STR_JUST_STRING;
|
2024-03-31 18:31:47 +02:00
|
|
|
list.push_back(MakeDropDownListIconItem(d, rti->gui_sprites.build_x_road, PAL_NONE, str, rt, !HasBit(avail_roadtypes, rt)));
|
2019-04-06 08:46:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-20 20:09:58 +02:00
|
|
|
if (list.empty()) {
|
2019-04-06 08:46:15 +02:00
|
|
|
/* Empty dropdowns are not allowed */
|
2024-03-31 18:31:47 +02:00
|
|
|
list.push_back(MakeDropDownListStringItem(STR_NONE, INVALID_ROADTYPE, true));
|
2019-04-06 08:46:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
DropDownList GetScenRoadTypeDropDownList(RoadTramTypes rtts)
|
|
|
|
{
|
|
|
|
RoadTypes avail_roadtypes = GetRoadTypes(false);
|
2023-04-24 17:56:01 +02:00
|
|
|
avail_roadtypes = AddDateIntroducedRoadTypes(avail_roadtypes, TimerGameCalendar::date);
|
2019-04-06 08:46:15 +02:00
|
|
|
RoadTypes used_roadtypes = GetRoadTypes(true);
|
|
|
|
|
|
|
|
/* Filter listed road types */
|
|
|
|
if (!HasBit(rtts, RTT_ROAD)) used_roadtypes &= _roadtypes_type;
|
|
|
|
if (!HasBit(rtts, RTT_TRAM)) used_roadtypes &= ~_roadtypes_type;
|
|
|
|
|
|
|
|
DropDownList list;
|
|
|
|
|
|
|
|
/* If it's not used ever, don't show it to the user. */
|
|
|
|
Dimension d = { 0, 0 };
|
2021-04-28 22:50:23 +02:00
|
|
|
for (const auto &rt : _sorted_roadtypes) {
|
2019-04-06 08:46:15 +02:00
|
|
|
if (!HasBit(used_roadtypes, rt)) continue;
|
|
|
|
const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
|
|
|
|
d = maxdim(d, GetSpriteSize(rti->gui_sprites.build_x_road));
|
|
|
|
}
|
2021-04-28 22:50:23 +02:00
|
|
|
for (const auto &rt : _sorted_roadtypes) {
|
2019-04-06 08:46:15 +02:00
|
|
|
if (!HasBit(used_roadtypes, rt)) continue;
|
|
|
|
|
|
|
|
const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
|
|
|
|
|
2023-06-23 10:30:13 +02:00
|
|
|
SetDParam(0, rti->strings.menu_text);
|
2023-08-15 10:34:36 +02:00
|
|
|
SetDParam(1, rti->max_speed / 2);
|
2019-04-06 08:46:15 +02:00
|
|
|
StringID str = rti->max_speed > 0 ? STR_TOOLBAR_RAILTYPE_VELOCITY : STR_JUST_STRING;
|
2024-03-31 18:31:47 +02:00
|
|
|
list.push_back(MakeDropDownListIconItem(d, rti->gui_sprites.build_x_road, PAL_NONE, str, rt, !HasBit(avail_roadtypes, rt)));
|
2019-04-06 08:46:15 +02:00
|
|
|
}
|
|
|
|
|
2023-10-20 20:09:58 +02:00
|
|
|
if (list.empty()) {
|
2019-04-06 08:46:15 +02:00
|
|
|
/* Empty dropdowns are not allowed */
|
2024-03-31 18:31:47 +02:00
|
|
|
list.push_back(MakeDropDownListStringItem(STR_NONE, -1, true));
|
2019-04-06 08:46:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|