Merge branch '1.11' into blueprints

This commit is contained in:
Pavel Stupnikov
2021-05-26 00:46:18 +03:00
1249 changed files with 63306 additions and 74123 deletions

View File

@@ -32,6 +32,10 @@
#include "vehicle_func.h"
#include "zoom_func.h"
#include "rail_gui.h"
#include "querystring_gui.h"
#include "sortlist_type.h"
#include "stringfilter_type.h"
#include "string_func.h"
#include "station_map.h"
#include "tunnelbridge_map.h"
@@ -82,7 +86,7 @@ RailStationGUISettings _railstation; ///< Settings of the station builder GUI
static void HandleStationPlacement(TileIndex start, TileIndex end);
static void ShowBuildTrainDepotPicker(Window *parent);
static void ShowBuildWaypointPicker(Window *parent);
static void ShowStationBuilder(Window *parent);
static Window *ShowStationBuilder(Window *parent);
static void ShowSignalBuilder(Window *parent);
/**
@@ -99,21 +103,21 @@ static bool IsStationAvailable(const StationSpec *statspec)
return Convert8bitBooleanCallback(statspec->grf_prop.grffile, CBID_STATION_AVAILABILITY, cb_res);
}
void CcPlaySound_SPLAT_RAIL(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
void CcPlaySound_CONSTRUCTION_RAIL(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
{
if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_20_SPLAT_RAIL, tile);
if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_20_CONSTRUCTION_RAIL, tile);
}
static CommandContainer GenericPlaceRailCmd(TileIndex tile, Track track)
static CommandContainer GenericPlaceRailCmd(TileIndex tile, uint32 cmd)
{
CommandContainer ret = {
tile, // tile
_cur_railtype, // p1
track, // p2
tile, // tile
_cur_railtype, // p1
cmd | ((uint32)_settings_client.gui.auto_remove_signals << 3), // p2
_remove_button_clicked ?
CMD_REMOVE_SINGLE_RAIL | CMD_MSG(STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK) :
CMD_BUILD_SINGLE_RAIL | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK), // cmd
CcPlaySound_SPLAT_RAIL, // callback
CcPlaySound_CONSTRUCTION_RAIL, // callback
"" // text
};
@@ -129,10 +133,11 @@ static CommandContainer GenericPlaceRailCmd(TileIndex tile, Track track)
*/
static void PlaceExtraDepotRail(TileIndex tile, DiagDirection dir, Track track)
{
if (GetRailTileType(tile) != RAIL_TILE_NORMAL) return;
if (GetRailTileType(tile) == RAIL_TILE_DEPOT) return;
if (GetRailTileType(tile) == RAIL_TILE_SIGNALS && !_settings_client.gui.auto_remove_signals) return;
if ((GetTrackBits(tile) & DiagdirReachesTracks(dir)) == 0) return;
DoCommandP(tile, _cur_railtype, track, CMD_BUILD_SINGLE_RAIL);
DoCommandP(tile, _cur_railtype, track | (_settings_client.gui.auto_remove_signals << 3), CMD_BUILD_SINGLE_RAIL);
}
/** Additional pieces of track to add at the entrance of a depot. */
@@ -155,7 +160,7 @@ void CcRailDepot(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2
DiagDirection dir = (DiagDirection)p2;
if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_SPLAT_RAIL, tile);
if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_CONSTRUCTION_RAIL, tile);
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
tile += TileOffsByDiagDir(dir);
@@ -174,7 +179,7 @@ void CcRailDepot(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2
static void PlaceRail_Waypoint(TileIndex tile)
{
if (_remove_button_clicked) {
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_REMOVE_STATION);
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_BUILD_STATION);
return;
}
@@ -194,7 +199,7 @@ void CcStation(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2,
{
if (result.Failed()) return;
if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_SPLAT_RAIL, tile);
if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_CONSTRUCTION_RAIL, tile);
/* Only close the station builder window if the default station and non persistent building is chosen. */
if (_railstation.station_class == STAT_CLASS_DFLT && _railstation.station_type == 0 && !_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
}
@@ -206,13 +211,13 @@ void CcStation(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2,
static void PlaceRail_Station(TileIndex tile)
{
if (_remove_button_clicked) {
VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_REMOVE_STATION);
VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_BUILD_STATION);
VpSetPlaceSizingLimit(-1);
} else if (_settings_client.gui.station_dragdrop) {
VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_BUILD_STATION);
VpSetPlaceSizingLimit(_settings_game.station.station_spread);
} else {
if (_settings_client.gui.cm_use_improved_station_join) {
if (citymania::UseImprovedStationJoin()) {
citymania::PlaceRail_Station(tile);
return;
}
@@ -248,7 +253,7 @@ static void GenericPlaceSignals(TileIndex tile)
Track track = FindFirstTrack(trackbits);
if (_remove_button_clicked) {
DoCommandP(tile, track, 0, CMD_REMOVE_SIGNALS | CMD_MSG(STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM), CcPlaySound_SPLAT_RAIL);
DoCommandP(tile, track, 0, CMD_REMOVE_SIGNALS | CMD_MSG(STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM), CcPlaySound_CONSTRUCTION_RAIL);
} else {
const Window *w = FindWindowById(WC_BUILD_SIGNAL, 0);
@@ -275,7 +280,7 @@ static void GenericPlaceSignals(TileIndex tile)
DoCommandP(tile, p1, 0, CMD_BUILD_SIGNALS |
CMD_MSG((w != nullptr && _convert_signal_button) ? STR_ERROR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE : STR_ERROR_CAN_T_BUILD_SIGNALS_HERE),
CcPlaySound_SPLAT_RAIL);
CcPlaySound_CONSTRUCTION_RAIL);
}
}
@@ -299,7 +304,7 @@ static void PlaceRail_Bridge(TileIndex tile, Window *w)
void CcBuildRailTunnel(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
{
if (result.Succeeded()) {
if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_SPLAT_RAIL, tile);
if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_CONSTRUCTION_RAIL, tile);
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
StoreRailPlacementEndpoints(tile, _build_tunnel_endtile, TileX(tile) == TileX(_build_tunnel_endtile) ? TRACK_Y : TRACK_X, false);
} else {
@@ -380,11 +385,11 @@ static CommandContainer DoRailroadTrackCmd(TileIndex start_tile, TileIndex end_t
CommandContainer ret = {
start_tile, // tile
end_tile, // p1
(uint32)(_cur_railtype | (track << 6)), // p2
((uint32)_cur_railtype | ((uint32)track << 6) | ((uint32)_settings_client.gui.auto_remove_signals << 11)), // p2
_remove_button_clicked ?
CMD_REMOVE_RAILROAD_TRACK | CMD_MSG(STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK) :
CMD_BUILD_RAILROAD_TRACK | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK), // cmd
CcPlaySound_SPLAT_RAIL, // callback
CcPlaySound_CONSTRUCTION_RAIL, // callback
"" // text
};
@@ -459,25 +464,7 @@ static void HandleAutoSignalPlacement()
_remove_button_clicked ?
CMD_REMOVE_SIGNAL_TRACK | CMD_MSG(STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM) :
CMD_BUILD_SIGNAL_TRACK | CMD_MSG(STR_ERROR_CAN_T_BUILD_SIGNALS_HERE),
CcPlaySound_SPLAT_RAIL);
}
// FIXME duplicate from road_gui.cpp
static DiagDirection TileFractCoordsToDiagDir() {
bool diag = (_tile_fract_coords.x + _tile_fract_coords.y) < 16;
if (_tile_fract_coords.x < _tile_fract_coords.y) {
return diag ? DIAGDIR_NE : DIAGDIR_SE;
}
return diag ? DIAGDIR_NW : DIAGDIR_SW;
}
// FIXME duplicate from road_gui.cpp
static DiagDirection RoadBitsToDiagDir(RoadBits bits) {
if (bits < ROAD_SE) {
return bits == ROAD_NW ? DIAGDIR_NW : DIAGDIR_SW;
}
return bits == ROAD_SE ? DIAGDIR_SE : DIAGDIR_NE;
CcPlaySound_CONSTRUCTION_RAIL);
}
RoadBits FindRailsToConnect(TileIndex tile) {
@@ -630,27 +617,27 @@ struct BuildRailToolbarWindow : Window {
switch (widget) {
case WID_RAT_BUILD_NS:
HandlePlacePushButton(this, WID_RAT_BUILD_NS, GetRailTypeInfo(_cur_railtype)->cursor.rail_ns, HT_LINE | HT_DIR_VL);
HandlePlacePushButton(this, WID_RAT_BUILD_NS, GetRailTypeInfo(_cur_railtype)->cursor.rail_ns, HT_LINE | HT_DIR_VL, DDSP_PLACE_RAIL);
this->last_user_action = widget;
break;
case WID_RAT_BUILD_X:
HandlePlacePushButton(this, WID_RAT_BUILD_X, GetRailTypeInfo(_cur_railtype)->cursor.rail_swne, HT_LINE | HT_DIR_X);
HandlePlacePushButton(this, WID_RAT_BUILD_X, GetRailTypeInfo(_cur_railtype)->cursor.rail_swne, HT_LINE | HT_DIR_X, DDSP_PLACE_RAIL);
this->last_user_action = widget;
break;
case WID_RAT_BUILD_EW:
HandlePlacePushButton(this, WID_RAT_BUILD_EW, GetRailTypeInfo(_cur_railtype)->cursor.rail_ew, HT_LINE | HT_DIR_HL);
HandlePlacePushButton(this, WID_RAT_BUILD_EW, GetRailTypeInfo(_cur_railtype)->cursor.rail_ew, HT_LINE | HT_DIR_HL, DDSP_PLACE_RAIL);
this->last_user_action = widget;
break;
case WID_RAT_BUILD_Y:
HandlePlacePushButton(this, WID_RAT_BUILD_Y, GetRailTypeInfo(_cur_railtype)->cursor.rail_nwse, HT_LINE | HT_DIR_Y);
HandlePlacePushButton(this, WID_RAT_BUILD_Y, GetRailTypeInfo(_cur_railtype)->cursor.rail_nwse, HT_LINE | HT_DIR_Y, DDSP_PLACE_RAIL);
this->last_user_action = widget;
break;
case WID_RAT_AUTORAIL:
HandlePlacePushButton(this, WID_RAT_AUTORAIL, GetRailTypeInfo(_cur_railtype)->cursor.autorail, HT_RAIL);
HandlePlacePushButton(this, WID_RAT_AUTORAIL, GetRailTypeInfo(_cur_railtype)->cursor.autorail, HT_RAIL, DDSP_PLACE_RAIL);
this->last_user_action = widget;
break;
@@ -677,7 +664,7 @@ struct BuildRailToolbarWindow : Window {
do_open = !was_open;
}
/* close/open the tool */
if (was_open != do_open) HandlePlacePushButton(this, WID_RAT_POLYRAIL, GetRailTypeInfo(railtype)->cursor.autorail, HT_RAIL | HT_POLY);
if (was_open != do_open) HandlePlacePushButton(this, WID_RAT_POLYRAIL, GetRailTypeInfo(railtype)->cursor.autorail, HT_RAIL | HT_POLY, DDSP_PLACE_RAIL);
/* set snapping mode */
if (do_open) SetRailSnapMode(do_snap ? RSM_SNAP_TO_RAIL : RSM_NO_SNAP);
@@ -687,12 +674,12 @@ struct BuildRailToolbarWindow : Window {
}
case WID_RAT_DEMOLISH:
HandlePlacePushButton(this, WID_RAT_DEMOLISH, ANIMCURSOR_DEMOLISH, HT_RECT | HT_DIAGONAL);
HandlePlacePushButton(this, WID_RAT_DEMOLISH, ANIMCURSOR_DEMOLISH, HT_RECT | HT_DIAGONAL, CM_DDSP_DEMOLISH);
this->last_user_action = widget;
break;
case WID_RAT_BUILD_DEPOT:
if (HandlePlacePushButton(this, WID_RAT_BUILD_DEPOT, GetRailTypeInfo(_cur_railtype)->cursor.depot, HT_RECT | (HighLightStyle)_build_depot_direction)) {
if (HandlePlacePushButton(this, WID_RAT_BUILD_DEPOT, GetRailTypeInfo(_cur_railtype)->cursor.depot, HT_RECT | (HighLightStyle)_build_depot_direction, CM_DDSP_BUILD_RAIL_DEPOT)) {
citymania::ResetRotateAutodetection();
ShowBuildTrainDepotPicker(this);
this->last_user_action = widget;
@@ -702,7 +689,7 @@ struct BuildRailToolbarWindow : Window {
case WID_RAT_BUILD_WAYPOINT:
this->last_user_action = widget;
_waypoint_count = StationClass::Get(STAT_CLASS_WAYP)->GetSpecCount();
if (HandlePlacePushButton(this, WID_RAT_BUILD_WAYPOINT, SPR_CURSOR_WAYPOINT, HT_RECT) && _waypoint_count > 1) {
if (HandlePlacePushButton(this, WID_RAT_BUILD_WAYPOINT, SPR_CURSOR_WAYPOINT, HT_RECT, CM_DDSP_BUILD_WAYPOINT) && _waypoint_count > 1) {
ShowBuildWaypointPicker(this);
}
break;
@@ -716,12 +703,12 @@ struct BuildRailToolbarWindow : Window {
if (was_open) ResetObjectToPlace();
if (!was_open || dragdrop != _settings_client.gui.station_dragdrop) {
_settings_client.gui.station_dragdrop = dragdrop;
if (HandlePlacePushButton(this, WID_RAT_BUILD_STATION, SPR_CURSOR_RAIL_STATION, HT_RECT))
if (HandlePlacePushButton(this, WID_RAT_BUILD_STATION, SPR_CURSOR_RAIL_STATION, HT_RECT, DDSP_BUILD_STATION))
ShowStationBuilder(this);
}
this->last_user_action = WID_RAT_BUILD_STATION;
} else { /* button */
if (HandlePlacePushButton(this, WID_RAT_BUILD_STATION, SPR_CURSOR_RAIL_STATION, HT_RECT)) {
if (HandlePlacePushButton(this, WID_RAT_BUILD_STATION, SPR_CURSOR_RAIL_STATION, HT_RECT, DDSP_BUILD_STATION)) {
ShowStationBuilder(this);
this->last_user_action = WID_RAT_BUILD_STATION;
}
@@ -731,7 +718,7 @@ struct BuildRailToolbarWindow : Window {
case WID_RAT_BUILD_SIGNALS: {
this->last_user_action = widget;
bool started = HandlePlacePushButton(this, WID_RAT_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, HT_RECT);
bool started = HandlePlacePushButton(this, WID_RAT_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, HT_RECT, DDSP_BUILD_SIGNALS);
if (started && _settings_client.gui.enable_signal_gui != citymania::_fn_mod) {
ShowSignalBuilder(this);
}
@@ -739,27 +726,26 @@ struct BuildRailToolbarWindow : Window {
}
case WID_RAT_BUILD_BRIDGE:
HandlePlacePushButton(this, WID_RAT_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, HT_RECT);
HandlePlacePushButton(this, WID_RAT_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, HT_RECT, CM_DDSP_BUILD_RAIL_BRIDGE);
this->last_user_action = widget;
break;
case WID_RAT_BUILD_TUNNEL:
HandlePlacePushButton(this, WID_RAT_BUILD_TUNNEL, GetRailTypeInfo(_cur_railtype)->cursor.tunnel, HT_SPECIAL);
HandlePlacePushButton(this, WID_RAT_BUILD_TUNNEL, GetRailTypeInfo(_cur_railtype)->cursor.tunnel, HT_SPECIAL, CM_DDSP_BUILD_RAIL_TUNNEL);
this->last_user_action = widget;
break;
case CM_WID_RAT_BLUEPRINT:
HandlePlacePushButton(this, CM_WID_RAT_BLUEPRINT, SPR_CURSOR_RAIL_STATION, HT_RECT);
HandlePlacePushButton(this, CM_WID_RAT_BLUEPRINT, SPR_CURSOR_RAIL_STATION, HT_RECT, CM_DDSP_RAIL_BLUEPRINT);
this->last_user_action = widget;
break;
case WID_RAT_REMOVE:
_remove_button_clicked = citymania::RailToolbar_RemoveModChanged(this, _cm_invert_remove, _remove_button_clicked, true);
// BuildRailClick_Remove(this);
BuildRailClick_Remove(this);
break;
case WID_RAT_CONVERT_RAIL:
HandlePlacePushButton(this, WID_RAT_CONVERT_RAIL, GetRailTypeInfo(_cur_railtype)->cursor.convert, HT_RECT | HT_DIAGONAL);
HandlePlacePushButton(this, WID_RAT_CONVERT_RAIL, GetRailTypeInfo(_cur_railtype)->cursor.convert, HT_RECT | HT_DIAGONAL, DDSP_CONVERT_RAIL);
this->last_user_action = widget;
break;
@@ -836,7 +822,7 @@ struct BuildRailToolbarWindow : Window {
case WID_RAT_BUILD_DEPOT:
ddir = _build_depot_direction;
if (ddir == DIAGDIR_NW + 1) {
if (ddir == citymania::DEPOTDIR_AUTO) {
assert(_thd.cm.type == citymania::ObjectHighlight::Type::RAIL_DEPOT);
ddir = _thd.cm.ddir;
}
@@ -915,7 +901,7 @@ struct BuildRailToolbarWindow : Window {
break;
case DDSP_CONVERT_RAIL:
DoCommandP(end_tile, start_tile, _cur_railtype | (citymania::_fn_mod ? 1 << 6 : 0), CMD_CONVERT_RAIL | CMD_MSG(STR_ERROR_CAN_T_CONVERT_RAIL), CcPlaySound_SPLAT_RAIL);
DoCommandP(end_tile, start_tile, _cur_railtype | (citymania::_fn_mod ? 1 << 6 : 0), CMD_CONVERT_RAIL | CMD_MSG(STR_ERROR_CAN_T_CONVERT_RAIL), CcPlaySound_CONSTRUCTION_RAIL);
break;
case DDSP_REMOVE_STATION:
@@ -923,27 +909,27 @@ struct BuildRailToolbarWindow : Window {
if (this->IsWidgetLowered(WID_RAT_BUILD_STATION)) {
/* Station */
if (_remove_button_clicked) {
DoCommandP(end_tile, start_tile, citymania::_fn_mod ? 0 : 1, CMD_REMOVE_FROM_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_REMOVE_PART_OF_STATION), CcPlaySound_SPLAT_RAIL);
DoCommandP(end_tile, start_tile, citymania::_fn_mod ? 0 : 1, CMD_REMOVE_FROM_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_REMOVE_PART_OF_STATION), CcPlaySound_CONSTRUCTION_RAIL);
} else {
HandleStationPlacement(start_tile, end_tile);
}
} else {
/* Waypoint */
if (_remove_button_clicked) {
DoCommandP(end_tile, start_tile, citymania::_fn_mod ? 0 : 1, CMD_REMOVE_FROM_RAIL_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_REMOVE_TRAIN_WAYPOINT), CcPlaySound_SPLAT_RAIL);
DoCommandP(end_tile, start_tile, citymania::_fn_mod ? 0 : 1, CMD_REMOVE_FROM_RAIL_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_REMOVE_TRAIN_WAYPOINT), CcPlaySound_CONSTRUCTION_RAIL);
} else {
TileArea ta(start_tile, end_tile);
uint32 p1 = _cur_railtype | (select_method == VPM_X_LIMITED ? AXIS_X : AXIS_Y) << 6 | ta.w << 8 | ta.h << 16 | citymania::_fn_mod << 24;
uint32 p2 = STAT_CLASS_WAYP | _cur_waypoint_type << 8 | INVALID_STATION << 16;
CommandContainer cmdcont = { ta.tile, p1, p2, CMD_BUILD_RAIL_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_BUILD_TRAIN_WAYPOINT), CcPlaySound_SPLAT_RAIL, "" };
CommandContainer cmdcont = { ta.tile, p1, p2, CMD_BUILD_RAIL_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_BUILD_TRAIN_WAYPOINT), CcPlaySound_CONSTRUCTION_RAIL, "" };
ShowSelectWaypointIfNeeded(cmdcont, ta);
}
}
break;
case CM_DDSP_BLUEPRINT_AREA:
SetObjectToPlace(SPR_CURSOR_RAIL_STATION, PAL_NONE, CM_HT_BLUEPRINT_PLACE, this->window_class, this->window_number);
SetObjectToPlace(SPR_CURSOR_RAIL_STATION, PAL_NONE, CM_HT_BLUEPRINT_PLACE, this->window_class, this->window_number, CM_DDSP_BLUEPRINT_AREA);
citymania::BlueprintCopyArea(start_tile, end_tile);
this->last_user_action = CM_WID_RAT_BLUEPRINT_PLACE;
break;
@@ -996,7 +982,7 @@ struct BuildRailToolbarWindow : Window {
*/
static EventState RailToolbarGlobalHotkeys(int hotkey)
{
if (_game_mode != GM_NORMAL || !CanBuildVehicleInfrastructure(VEH_TRAIN)) return ES_NOT_HANDLED;
if (_game_mode != GM_NORMAL) return ES_NOT_HANDLED;
extern RailType _last_built_railtype;
Window *w = ShowBuildRailToolbar(_last_built_railtype);
if (w == nullptr) return ES_NOT_HANDLED;
@@ -1110,7 +1096,7 @@ Window *ShowBuildRailToolbar(RailType railtype)
static void HandleStationPlacement(TileIndex start, TileIndex end)
{
if (_settings_client.gui.cm_use_improved_station_join) {
if (citymania::UseImprovedStationJoin()) {
citymania::HandleStationPlacement(start, end);
return;
}
@@ -1128,20 +1114,49 @@ static void HandleStationPlacement(TileIndex start, TileIndex end)
ShowSelectStationIfNeeded(cmdcont, ta);
}
/** Enum referring to the Hotkeys in the build rail station window */
enum BuildRalStationHotkeys {
BRASHK_FOCUS_FILTER_BOX, ///< Focus the edit box for editing the filter string
CM_BRASHK_ROTATE, ///< Rotate station (switch orientation)
};
struct BuildRailStationWindow : public PickerWindowBase {
/* CityMania code start */
public:
enum class Hotkey : int {
ROTATE,
};
/* CityMania code end */
private:
uint line_height; ///< Height of a single line in the newstation selection matrix (#WID_BRAS_NEWST_LIST widget).
uint coverage_height; ///< Height of the coverage texts.
Scrollbar *vscroll; ///< Vertical scrollbar of the new station list.
Scrollbar *vscroll2; ///< Vertical scrollbar of the matrix with new stations.
typedef GUIList<StationClassID, StringFilter &> GUIStationClassList; ///< Type definition for the list to hold available station classes.
static const uint EDITBOX_MAX_SIZE = 16; ///< The maximum number of characters for the filter edit box.
static Listing last_sorting; ///< Default sorting of #GUIStationClassList.
static Filtering last_filtering; ///< Default filtering of #GUIStationClassList.
static GUIStationClassList::SortFunction * const sorter_funcs[]; ///< Sort functions of the #GUIStationClassList.
static GUIStationClassList::FilterFunction * const filter_funcs[]; ///< Filter functions of the #GUIStationClassList.
GUIStationClassList station_classes; ///< Available station classes.
StringFilter string_filter; ///< Filter for available station classes.
QueryString filter_editbox; ///< Filter editbox.
/**
* Scrolls #WID_BRAS_NEWST_SCROLL so that the selected station class is visible.
*
* Note that this method should be called shortly after SelectClassAndStation() which will ensure
* an actual existing station class is selected, or the one at position 0 which will always be
* the default TTD rail station.
*/
void EnsureSelectedStationClassIsVisible()
{
uint pos = 0;
for (auto station_class : this->station_classes) {
if (station_class == _railstation.station_class) break;
pos++;
}
this->vscroll->SetCount((int)this->station_classes.size());
this->vscroll->ScrollTowards(pos);
}
/**
* Verify whether the currently selected station size is allowed after selecting a new station class/type.
* If not, change the station size variables ( _settings_client.gui.station_numtracks and _settings_client.gui.station_platlength ).
@@ -1176,7 +1191,7 @@ private:
}
public:
BuildRailStationWindow(WindowDesc *desc, Window *parent, bool newstation) : PickerWindowBase(desc, parent)
BuildRailStationWindow(WindowDesc *desc, Window *parent, bool newstation) : PickerWindowBase(desc, parent), filter_editbox(EDITBOX_MAX_SIZE * MAX_CHAR_LENGTH, EDITBOX_MAX_SIZE)
{
this->coverage_height = 2 * FONT_HEIGHT_NORMAL + 3 * WD_PAR_VSEP_NORMAL;
this->vscroll = nullptr;
@@ -1191,10 +1206,24 @@ public:
newst_additions->SetDisplayedPlane(newstation ? 0 : SZSP_NONE);
newst_additions = this->GetWidget<NWidgetStacked>(WID_BRAS_SHOW_NEWST_RESIZE);
newst_additions->SetDisplayedPlane(newstation ? 0 : SZSP_NONE);
/* Hide the station class filter if no stations other than the default one are available. */
this->GetWidget<NWidgetStacked>(WID_BRAS_FILTER_CONTAINER)->SetDisplayedPlane(newstation ? 0 : SZSP_NONE);
if (newstation) {
this->vscroll = this->GetScrollbar(WID_BRAS_NEWST_SCROLL);
this->vscroll2 = this->GetScrollbar(WID_BRAS_MATRIX_SCROLL);
this->querystrings[WID_BRAS_FILTER_EDITBOX] = &this->filter_editbox;
this->station_classes.SetListing(this->last_sorting);
this->station_classes.SetFiltering(this->last_filtering);
this->station_classes.SetSortFuncs(this->sorter_funcs);
this->station_classes.SetFilterFuncs(this->filter_funcs);
}
this->station_classes.ForceRebuild();
BuildStationClassesAvailable();
SelectClassAndStation();
this->FinishInitNested(TRANSPORT_RAIL);
this->LowerWidget(_railstation.orientation + WID_BRAS_PLATFORM_DIR_X);
@@ -1207,30 +1236,23 @@ public:
this->SetWidgetLoweredState(WID_BRAS_HIGHLIGHT_OFF, !_settings_client.gui.station_show_coverage);
this->SetWidgetLoweredState(WID_BRAS_HIGHLIGHT_ON, _settings_client.gui.station_show_coverage);
if (!newstation || _railstation.station_class >= (int)StationClass::GetClassCount()) {
/* New stations are not available or changed, so ensure the default station
* type is 'selected'. */
_railstation.station_class = STAT_CLASS_DFLT;
if (!newstation) {
_railstation.station_class = StationClassID::STAT_CLASS_DFLT;
_railstation.station_type = 0;
this->vscroll2 = nullptr;
}
if (newstation) {
} else {
_railstation.station_count = StationClass::Get(_railstation.station_class)->GetSpecCount();
_railstation.station_type = min(_railstation.station_type, _railstation.station_count - 1);
int count = 0;
for (uint i = 0; i < StationClass::GetClassCount(); i++) {
if (i == STAT_CLASS_WAYP) continue;
count++;
}
this->vscroll->SetCount(count);
this->vscroll->SetPosition(Clamp(_railstation.station_class - 2, 0, max(this->vscroll->GetCount() - this->vscroll->GetCapacity(), 0)));
_railstation.station_type = std::min<int>(_railstation.station_type, _railstation.station_count - 1);
NWidgetMatrix *matrix = this->GetWidget<NWidgetMatrix>(WID_BRAS_MATRIX);
matrix->SetScrollbar(this->vscroll2);
matrix->SetCount(_railstation.station_count);
matrix->SetClicked(_railstation.station_type);
EnsureSelectedStationClassIsVisible();
}
this->InvalidateData();
}
virtual ~BuildRailStationWindow()
@@ -1238,6 +1260,122 @@ public:
DeleteWindowById(WC_SELECT_STATION, 0);
}
/** Sort station classes by StationClassID. */
static bool StationClassIDSorter(StationClassID const &a, StationClassID const &b)
{
return a < b;
}
/** Filter station classes by class name. */
static bool CDECL TagNameFilter(StationClassID const * sc, StringFilter &filter)
{
char buffer[DRAW_STRING_BUFFER];
GetString(buffer, StationClass::Get(*sc)->name, lastof(buffer));
filter.ResetState();
filter.AddLine(buffer);
return filter.GetState();
}
/** Builds the filter list of available station classes. */
void BuildStationClassesAvailable()
{
if (!this->station_classes.NeedRebuild()) return;
this->station_classes.clear();
for (uint i = 0; i < StationClass::GetClassCount(); i++) {
StationClassID station_class_id = (StationClassID)i;
if (station_class_id == StationClassID::STAT_CLASS_WAYP) {
// Skip waypoints.
continue;
}
StationClass *station_class = StationClass::Get(station_class_id);
if (station_class->GetUISpecCount() == 0) continue;
station_classes.push_back(station_class_id);
}
if (_railstation.newstations) {
this->station_classes.Filter(this->string_filter);
this->station_classes.shrink_to_fit();
this->station_classes.RebuildDone();
this->station_classes.Sort();
this->vscroll->SetCount((uint)this->station_classes.size());
}
}
/**
* Checks if the previously selected current station class and station
* can be shown as selected to the user when the dialog is opened.
*/
void SelectClassAndStation()
{
if (_railstation.station_class == StationClassID::STAT_CLASS_DFLT) {
/* This happens during the first time the window is open during the game life cycle. */
this->SelectOtherClass(StationClassID::STAT_CLASS_DFLT);
} else {
/* Check if the previously selected station class is not available anymore as a
* result of starting a new game without the corresponding NewGRF. */
bool available = false;
for (uint i = 0; i < StationClass::GetClassCount(); ++i) {
if ((StationClassID)i == _railstation.station_class) {
available = true;
break;
}
}
this->SelectOtherClass(available ? _railstation.station_class : StationClassID::STAT_CLASS_DFLT);
}
}
/**
* Select the specified station class.
* @param station_class Station class select.
*/
void SelectOtherClass(StationClassID station_class)
{
_railstation.station_class = station_class;
}
void OnInvalidateData(int data = 0, bool gui_scope = true) override
{
if (!gui_scope) return;
this->BuildStationClassesAvailable();
}
EventState OnHotkey(int hotkey) override
{
switch (hotkey) {
case BRASHK_FOCUS_FILTER_BOX:
this->SetFocusedWidget(WID_BRAS_FILTER_EDITBOX);
SetFocusedWindow(this); // The user has asked to give focus to the text box, so make sure this window is focused.
break;
case CM_BRASHK_ROTATE:
this->RaiseWidget(_railstation.orientation + WID_BRAS_PLATFORM_DIR_X);
_railstation.orientation = OtherAxis(_railstation.orientation);
this->LowerWidget(_railstation.orientation + WID_BRAS_PLATFORM_DIR_X);
this->SetDirty();
DeleteWindowById(WC_SELECT_STATION, 0);
return ES_HANDLED;
default:
return ES_NOT_HANDLED;
}
return ES_HANDLED;
}
void OnEditboxChanged(int wid) override
{
string_filter.SetFilterTerm(this->filter_editbox.text.buf);
this->station_classes.SetFilterState(!string_filter.IsEmpty());
this->station_classes.ForceRebuild();
this->InvalidateData();
}
void OnPaint() override
{
bool newstations = _railstation.newstations;
@@ -1256,7 +1394,7 @@ public:
int rad = (_settings_game.station.modified_catchment) ? CA_TRAIN : CA_UNMODIFIED;
if (_settings_client.gui.cm_use_improved_station_join || _settings_client.gui.station_show_coverage)
if (citymania::UseImprovedStationJoin() || _settings_client.gui.station_show_coverage)
SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
for (uint bits = 0; bits < 7; bits++) {
@@ -1296,11 +1434,10 @@ public:
switch (widget) {
case WID_BRAS_NEWST_LIST: {
Dimension d = {0, 0};
for (uint i = 0; i < StationClass::GetClassCount(); i++) {
if (i == STAT_CLASS_WAYP) continue;
d = maxdim(d, GetStringBoundingBox(StationClass::Get((StationClassID)i)->name));
for (auto station_class : this->station_classes) {
d = maxdim(d, GetStringBoundingBox(StationClass::Get(station_class)->name));
}
size->width = max(size->width, d.width + padding.width);
size->width = std::max(size->width, d.width + padding.width);
this->line_height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM;
size->height = 5 * this->line_height;
resize->height = this->line_height;
@@ -1317,16 +1454,15 @@ public:
/* If newstations exist, compute the non-zero minimal size. */
Dimension d = {0, 0};
StringID str = this->GetWidget<NWidgetCore>(widget)->widget_data;
for (StationClassID statclass = STAT_CLASS_BEGIN; statclass < (StationClassID)StationClass::GetClassCount(); statclass++) {
if (statclass == STAT_CLASS_WAYP) continue;
StationClass *stclass = StationClass::Get(statclass);
for (auto station_class : this->station_classes) {
StationClass *stclass = StationClass::Get(station_class);
for (uint16 j = 0; j < stclass->GetSpecCount(); j++) {
const StationSpec *statspec = stclass->GetSpec(j);
SetDParam(0, (statspec != nullptr && statspec->name != 0) ? statspec->name : STR_STATION_CLASS_DFLT);
d = maxdim(d, GetStringBoundingBox(str));
}
}
size->width = max(size->width, d.width + padding.width);
size->width = std::max(size->width, d.width + padding.width);
break;
}
@@ -1384,12 +1520,11 @@ public:
case WID_BRAS_NEWST_LIST: {
uint statclass = 0;
uint row = 0;
for (uint i = 0; i < StationClass::GetClassCount(); i++) {
if (i == STAT_CLASS_WAYP) continue;
for (auto station_class : this->station_classes) {
if (this->vscroll->IsVisible(statclass)) {
DrawString(r.left + WD_MATRIX_LEFT, r.right - WD_MATRIX_RIGHT, row * this->line_height + r.top + WD_MATRIX_TOP,
StationClass::Get((StationClassID)i)->name,
(StationClassID)i == _railstation.station_class ? TC_WHITE : TC_BLACK);
StationClass::Get(station_class)->name,
station_class == _railstation.station_class ? TC_WHITE : TC_BLACK);
row++;
}
statclass++;
@@ -1568,29 +1703,23 @@ public:
case WID_BRAS_NEWST_LIST: {
int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_BRAS_NEWST_LIST, 0, this->line_height);
if (y >= (int)StationClass::GetClassCount()) return;
for (uint i = 0; i < StationClass::GetClassCount(); i++) {
if (i == STAT_CLASS_WAYP) continue;
if (y == 0) {
if (_railstation.station_class != (StationClassID)i) {
_railstation.station_class = (StationClassID)i;
StationClass *stclass = StationClass::Get(_railstation.station_class);
_railstation.station_count = stclass->GetSpecCount();
_railstation.station_type = min((int)_railstation.station_type, max(0, (int)_railstation.station_count - 1));
if (y >= (int)this->station_classes.size()) return;
StationClassID station_class_id = this->station_classes[y];
if (_railstation.station_class != station_class_id) {
StationClass *station_class = StationClass::Get(station_class_id);
_railstation.station_class = station_class_id;
_railstation.station_count = station_class->GetSpecCount();
_railstation.station_type = 0;
this->CheckSelectedSize(stclass->GetSpec(_railstation.station_type));
this->CheckSelectedSize(station_class->GetSpec(_railstation.station_type));
NWidgetMatrix *matrix = this->GetWidget<NWidgetMatrix>(WID_BRAS_MATRIX);
matrix->SetCount(_railstation.station_count);
matrix->SetClicked(_railstation.station_type);
}
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
this->SetDirty();
DeleteWindowById(WC_SELECT_STATION, 0);
break;
}
y--;
NWidgetMatrix *matrix = this->GetWidget<NWidgetMatrix>(WID_BRAS_MATRIX);
matrix->SetCount(_railstation.station_count);
matrix->SetClicked(_railstation.station_type);
}
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
this->SetDirty();
DeleteWindowById(WC_SELECT_STATION, 0);
break;
}
@@ -1620,38 +1749,39 @@ public:
CheckRedrawStationCoverage(this);
}
/* CityMania code start */
EventState OnHotkey(int hotkey) override
{
switch ((BuildRailStationWindow::Hotkey)hotkey) {
/* Indicate to the OnClick that the action comes from a hotkey rather
* then from a click and that the CTRL state should be ignored. */
case BuildRailStationWindow::Hotkey::ROTATE:
this->RaiseWidget(_railstation.orientation + WID_BRAS_PLATFORM_DIR_X);
_railstation.orientation = OtherAxis(_railstation.orientation);
this->LowerWidget(_railstation.orientation + WID_BRAS_PLATFORM_DIR_X);
this->SetDirty();
DeleteWindowById(WC_SELECT_STATION, 0);
return ES_HANDLED;
default:
NOT_REACHED();
}
return ES_NOT_HANDLED;
}
static HotkeyList hotkeys;
/* CityMania code end */
};
/* CityMania code start */
static Hotkey build_station_hotkeys[] = {
Hotkey(CM_WKC_MOUSE_MIDDLE, "rotate", (int)BuildRailStationWindow::Hotkey::ROTATE),
/**
* Handler for global hotkeys of the BuildRailStationWindow.
* @param hotkey Hotkey
* @return ES_HANDLED if hotkey was accepted.
*/
static EventState BuildRailStationGlobalHotkeys(int hotkey)
{
if (_game_mode == GM_MENU) return ES_NOT_HANDLED;
Window *w = ShowStationBuilder(FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL));
if (w == nullptr) return ES_NOT_HANDLED;
return w->OnHotkey(hotkey);
}
static Hotkey buildrailstation_hotkeys[] = {
Hotkey('F', "focus_filter_box", BRASHK_FOCUS_FILTER_BOX),
Hotkey(CM_WKC_MOUSE_MIDDLE, "cm_rotate", CM_BRASHK_ROTATE),
HOTKEY_LIST_END
};
HotkeyList BuildRailStationWindow::hotkeys("cm_build_rail_station", build_station_hotkeys);
/* CityMania code end */
HotkeyList BuildRailStationWindow::hotkeys("buildrailstation", buildrailstation_hotkeys, BuildRailStationGlobalHotkeys);
Listing BuildRailStationWindow::last_sorting = { false, 0 };
Filtering BuildRailStationWindow::last_filtering = { false, 0 };
BuildRailStationWindow::GUIStationClassList::SortFunction * const BuildRailStationWindow::sorter_funcs[] = {
&StationClassIDSorter,
};
BuildRailStationWindow::GUIStationClassList::FilterFunction * const BuildRailStationWindow::filter_funcs[] = {
&TagNameFilter,
};
static const NWidgetPart _nested_station_builder_widgets[] = {
NWidget(NWID_HORIZONTAL),
@@ -1663,16 +1793,23 @@ static const NWidgetPart _nested_station_builder_widgets[] = {
EndContainer(),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
NWidget(NWID_HORIZONTAL),
NWidget(NWID_HORIZONTAL), SetPadding(2, 0, 0, 2),
NWidget(NWID_VERTICAL),
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BRAS_FILTER_CONTAINER),
NWidget(NWID_HORIZONTAL), SetPadding(0, 5, 2, 0),
NWidget(WWT_TEXT, COLOUR_DARK_GREEN), SetFill(0, 1), SetDataTip(STR_LIST_FILTER_TITLE, STR_NULL),
NWidget(WWT_EDITBOX, COLOUR_GREY, WID_BRAS_FILTER_EDITBOX), SetFill(1, 0), SetResize(1, 0),
SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
EndContainer(),
EndContainer(),
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BRAS_SHOW_NEWST_ADDITIONS),
NWidget(NWID_HORIZONTAL), SetPIP(7, 0, 7), SetPadding(2, 0, 1, 0),
NWidget(NWID_HORIZONTAL), SetPadding(0, 5, 2, 0),
NWidget(WWT_MATRIX, COLOUR_GREY, WID_BRAS_NEWST_LIST), SetMinimalSize(122, 71), SetFill(1, 0),
SetMatrixDataTip(1, 0, STR_STATION_BUILD_STATION_CLASS_TOOLTIP), SetScrollbar(WID_BRAS_NEWST_SCROLL),
NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_BRAS_NEWST_SCROLL),
EndContainer(),
EndContainer(),
NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(144, 11), SetDataTip(STR_STATION_BUILD_ORIENTATION, STR_NULL), SetPadding(1, 2, 0, 2),
NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(144, 11), SetDataTip(STR_STATION_BUILD_ORIENTATION, STR_NULL), SetPadding(1, 2, 0, 0),
NWidget(NWID_HORIZONTAL),
NWidget(NWID_SPACER), SetMinimalSize(7, 0), SetFill(1, 0),
NWidget(WWT_PANEL, COLOUR_GREY, WID_BRAS_PLATFORM_DIR_X), SetMinimalSize(66, 60), SetFill(0, 0), SetDataTip(0x0, STR_STATION_BUILD_RAILROAD_ORIENTATION_TOOLTIP), EndContainer(),
@@ -1711,7 +1848,7 @@ static const NWidgetPart _nested_station_builder_widgets[] = {
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_DRAG_N_DROP), SetMinimalSize(75, 12), SetDataTip(STR_STATION_BUILD_DRAG_DROP, STR_STATION_BUILD_DRAG_DROP_TOOLTIP),
NWidget(NWID_SPACER), SetMinimalSize(2, 0), SetFill(1, 0),
EndContainer(),
NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(144, 11), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetPadding(3, 2, 0, 2),
NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(144, 11), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetPadding(3, 2, 0, 0),
NWidget(NWID_HORIZONTAL),
NWidget(NWID_SPACER), SetMinimalSize(2, 0), SetFill(1, 0),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_HIGHLIGHT_OFF), SetMinimalSize(60, 12),
@@ -1725,7 +1862,7 @@ static const NWidgetPart _nested_station_builder_widgets[] = {
/* We need an additional background for the matrix, as the matrix cannot handle the scrollbar due to not being an NWidgetCore. */
NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetScrollbar(WID_BRAS_MATRIX_SCROLL),
NWidget(NWID_HORIZONTAL),
NWidget(NWID_MATRIX, COLOUR_DARK_GREEN, WID_BRAS_MATRIX), SetScrollbar(WID_BRAS_MATRIX_SCROLL), SetPIP(0, 2, 0), SetPadding(2, 0, 0, 0),
NWidget(NWID_MATRIX, COLOUR_DARK_GREEN, WID_BRAS_MATRIX), SetScrollbar(WID_BRAS_MATRIX_SCROLL), SetPIP(0, 2, 0),
NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BRAS_IMAGE), SetMinimalSize(66, 60),
SetFill(0, 0), SetResize(0, 0), SetDataTip(0x0, STR_STATION_BUILD_STATION_TYPE_TOOLTIP), SetScrollbar(WID_BRAS_MATRIX_SCROLL),
EndContainer(),
@@ -1736,7 +1873,7 @@ static const NWidgetPart _nested_station_builder_widgets[] = {
EndContainer(),
EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_BRAS_COVERAGE_TEXTS), SetFill(1, 1), SetResize(1, 0),
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_BRAS_COVERAGE_TEXTS), SetPadding(2, 5, 0, 1), SetFill(1, 1), SetResize(1, 0),
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BRAS_SHOW_NEWST_RESIZE),
NWidget(NWID_VERTICAL),
NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetFill(0, 1), EndContainer(),
@@ -1753,14 +1890,14 @@ static WindowDesc _station_builder_desc(
WC_BUILD_STATION, WC_BUILD_TOOLBAR,
WDF_CONSTRUCTION,
_nested_station_builder_widgets, lengthof(_nested_station_builder_widgets),
&BuildRailStationWindow::hotkeys // CityMania addition
&BuildRailStationWindow::hotkeys
);
/** Open station build window */
static void ShowStationBuilder(Window *parent)
static Window *ShowStationBuilder(Window *parent)
{
bool newstations = StationClass::GetClassCount() > 2 || StationClass::Get(STAT_CLASS_DFLT)->GetSpecCount() != 1;
new BuildRailStationWindow(&_station_builder_desc, parent, newstations);
return new BuildRailStationWindow(&_station_builder_desc, parent, newstations);
}
struct BuildSignalWindow : public PickerWindowBase {
@@ -1814,9 +1951,9 @@ public:
for (uint lowered = 0; lowered < 2; lowered++) {
Point offset;
Dimension sprite_size = GetSpriteSize(rti->gui_sprites.signals[type][variant][lowered], &offset);
this->sig_sprite_bottom_offset = max<int>(this->sig_sprite_bottom_offset, sprite_size.height);
this->sig_sprite_size.width = max<int>(this->sig_sprite_size.width, sprite_size.width - offset.x);
this->sig_sprite_size.height = max<int>(this->sig_sprite_size.height, sprite_size.height - offset.y);
this->sig_sprite_bottom_offset = std::max<int>(this->sig_sprite_bottom_offset, sprite_size.height);
this->sig_sprite_size.width = std::max<int>(this->sig_sprite_size.width, sprite_size.width - offset.x);
this->sig_sprite_size.height = std::max<int>(this->sig_sprite_size.height, sprite_size.height - offset.y);
}
}
}
@@ -1826,10 +1963,10 @@ public:
{
if (widget == WID_BS_DRAG_SIGNALS_DENSITY_LABEL) {
/* Two digits for signals density. */
size->width = max(size->width, 2 * GetDigitWidth() + padding.width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT);
size->width = std::max(size->width, 2 * GetDigitWidth() + padding.width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT);
} else if (IsInsideMM(widget, WID_BS_SEMAPHORE_NORM, WID_BS_ELECTRIC_PBS_OWAY + 1)) {
size->width = max(size->width, this->sig_sprite_size.width + WD_IMGBTN_LEFT + WD_IMGBTN_RIGHT);
size->height = max(size->height, this->sig_sprite_size.height + WD_IMGBTN_TOP + WD_IMGBTN_BOTTOM);
size->width = std::max(size->width, this->sig_sprite_size.width + WD_IMGBTN_LEFT + WD_IMGBTN_RIGHT);
size->height = std::max(size->height, this->sig_sprite_size.height + WD_IMGBTN_TOP + WD_IMGBTN_BOTTOM);
}
}
@@ -2109,8 +2246,8 @@ static WindowDesc _build_depot_desc(
WDP_AUTO, nullptr, 0, 0,
WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
WDF_CONSTRUCTION,
_nested_build_depot_widgets, lengthof(_nested_build_depot_widgets),
&BuildRailDepotWindow::hotkeys // CityMania addition
_nested_build_depot_widgets, lengthof(_nested_build_depot_widgets)
,&BuildRailDepotWindow::hotkeys // CityMania addition
);
static void ShowBuildTrainDepotPicker(Window *parent)
@@ -2223,6 +2360,7 @@ static void ShowBuildWaypointPicker(Window *parent)
void InitializeRailGui()
{
_build_depot_direction = (DiagDirection)(DIAGDIR_NW + 1);
_railstation.station_class = StationClassID::STAT_CLASS_DFLT;
}
/**