Add setting to allow hiding viewport labels of inidivudal waypoints
This commit is contained in:
@@ -68,6 +68,7 @@ CommandProc CmdBuildTunnel;
|
||||
CommandProc CmdBuildTrainDepot;
|
||||
CommandProcEx CmdBuildRailWaypoint;
|
||||
CommandProc CmdRenameWaypoint;
|
||||
CommandProc CmdSetWaypointLabelHidden;
|
||||
CommandProc CmdRemoveFromRailWaypoint;
|
||||
|
||||
CommandProc CmdBuildRoadStop;
|
||||
@@ -316,6 +317,7 @@ static const Command _command_proc_table[] = {
|
||||
DEF_CMD(CmdConvertRail, 0, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_CONVERT_RAIL
|
||||
DEF_CMD(CmdBuildRailWaypoint, 0, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_RAIL_WAYPOINT
|
||||
DEF_CMD(CmdRenameWaypoint, 0, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_WAYPOINT
|
||||
DEF_CMD(CmdSetWaypointLabelHidden, 0, CMDT_OTHER_MANAGEMENT ), // CMD_SET_WAYPOINT_LABEL_HIDDEN
|
||||
DEF_CMD(CmdRemoveFromRailWaypoint, 0, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_REMOVE_FROM_RAIL_WAYPOINT
|
||||
|
||||
DEF_CMD(CmdBuildRoadStop, CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_ROAD_STOP
|
||||
|
@@ -252,6 +252,7 @@ enum Commands {
|
||||
|
||||
CMD_BUILD_RAIL_WAYPOINT, ///< build a waypoint
|
||||
CMD_RENAME_WAYPOINT, ///< rename a waypoint
|
||||
CMD_SET_WAYPOINT_LABEL_HIDDEN, ///< set whether waypoint label is hidden
|
||||
CMD_REMOVE_FROM_RAIL_WAYPOINT, ///< remove a (rectangle of) tiles from a rail waypoint
|
||||
|
||||
CMD_BUILD_ROAD_STOP, ///< build a road stop
|
||||
|
@@ -420,9 +420,11 @@ STR_SETTINGS_MENU_FULL_ANIMATION :Full animation
|
||||
STR_SETTINGS_MENU_FULL_DETAIL :Full detail
|
||||
STR_SETTINGS_MENU_TRANSPARENT_BUILDINGS :Transparent buildings
|
||||
STR_SETTINGS_MENU_TRANSPARENT_SIGNS :Transparent signs
|
||||
STR_SETTINGS_MENU_MONEY_TEXT_EFFECTS :Income/cost texts displayed
|
||||
############ range ends here
|
||||
|
||||
STR_SETTINGS_MENU_MONEY_TEXT_EFFECTS :Income/cost texts displayed
|
||||
STR_SETTINGS_MENU_SHOW_HIDDEN_SIGNS :Hidden signs and names displayed
|
||||
|
||||
# File menu
|
||||
###length 5
|
||||
STR_FILE_MENU_SAVE_GAME :Save game
|
||||
@@ -1611,6 +1613,9 @@ STR_CONFIG_SETTING_DEMOLISH_CONFIRM_MODE_ALL :Industries and
|
||||
STR_CONFIG_SETTING_DUAL_PANE_TRAIN_PURCHASE_WINDOW :Separate locomotives and wagons in train purchase window: {STRING2}
|
||||
STR_CONFIG_SETTING_DUAL_PANE_TRAIN_PURCHASE_WINDOW_HELPTEXT :When enabled, the train purchase window shows locomotives and wagons in separate side-by-side lists.
|
||||
|
||||
STR_CONFIG_SETTING_ALLOW_HIDE_WAYPOINT_LABEL :Allow hiding waypoint viewport labels: {STRING2}
|
||||
STR_CONFIG_SETTING_ALLOW_HIDE_WAYPOINT_LABEL_HELPTEXT :When enabled, waypoints can have their viewport labels individually hidden.{}This is useful when waypoints are used decoratively or when minor waypoints do not require a label.
|
||||
|
||||
STR_CONFIG_SETTING_ADV_SIG_BRIDGE_TUN_MODES :Enable signals on bridges/tunnels advanced modes: {STRING2}
|
||||
STR_CONFIG_SETTING_ADV_SIG_BRIDGE_TUN_MODES_HELPTEXT :Enables use of advanced modes of signal simulation on bridges and tunnels. When disabled, bridges/tunnels which are not already in an advanced mode cannot be changed to an advanced mode, however other players may choose to enable this setting and use an advanced mode.
|
||||
|
||||
@@ -4611,6 +4616,8 @@ STR_BUOY_VIEW_CHANGE_BUOY_NAME :{BLACK}Change b
|
||||
|
||||
STR_EDIT_WAYPOINT_NAME :{WHITE}Edit waypoint name
|
||||
|
||||
STR_WAYPOINT_VIEW_HIDE_VIEWPORT_LABEL :{BLACK}Hide the name label for this waypoint
|
||||
|
||||
# Finances window
|
||||
STR_FINANCES_CAPTION :{WHITE}{COMPANY} Finances {BLACK}{COMPANY_NUM}
|
||||
STR_FINANCES_EXPENDITURE_INCOME_TITLE :{WHITE}Expenditure/Income
|
||||
|
@@ -54,6 +54,7 @@ enum DisplayOptions {
|
||||
/** Extra Display Options */
|
||||
enum ExtraDisplayOptions {
|
||||
XDO_SHOW_MONEY_TEXT_EFFECTS = 0, ///< Display money text effects.
|
||||
XDO_SHOW_HIDDEN_SIGNS = 1, ///< Show hidden signs
|
||||
};
|
||||
|
||||
extern GameMode _game_mode;
|
||||
|
@@ -165,6 +165,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
|
||||
{ XSLFI_COMPANY_PW, XSCF_IGNORABLE_ALL, 1, 1, "company_password", nullptr, nullptr, "PLYP" },
|
||||
{ XSLFI_ST_INDUSTRY_CARGO_MODE, XSCF_IGNORABLE_UNKNOWN, 1, 1, "st_industry_cargo_mode", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_TL_SPEED_LIMIT, XSCF_IGNORABLE_UNKNOWN, 1, 1, "tl_speed_limit", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_WAYPOINT_FLAGS, XSCF_NULL, 1, 1, "waypoint_flags", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_SCRIPT_INT64, XSCF_NULL, 1, 1, "script_int64", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_NULL, XSCF_NULL, 0, 0, nullptr, nullptr, nullptr, nullptr },// This is the end marker
|
||||
};
|
||||
|
@@ -119,6 +119,7 @@ enum SlXvFeatureIndex {
|
||||
XSLFI_COMPANY_PW, ///< Company passwords
|
||||
XSLFI_ST_INDUSTRY_CARGO_MODE, ///< Station industry cargo mode setting
|
||||
XSLFI_TL_SPEED_LIMIT, ///< Through load maximum speed setting
|
||||
XSLFI_WAYPOINT_FLAGS, ///< Waypoint flags
|
||||
|
||||
XSLFI_SCRIPT_INT64, ///< See: SLV_SCRIPT_INT64
|
||||
|
||||
|
@@ -461,6 +461,7 @@ static const SaveLoad _waypoint_desc[] = {
|
||||
SLE_CONDVAR(Waypoint, train_station.tile, SLE_UINT32, SLV_124, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Waypoint, train_station.w, SLE_FILE_U8 | SLE_VAR_U16, SLV_124, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Waypoint, train_station.h, SLE_FILE_U8 | SLE_VAR_U16, SLV_124, SL_MAX_VERSION),
|
||||
SLE_CONDVAR_X(Waypoint, waypoint_flags, SLE_UINT16, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_WAYPOINT_FLAGS)),
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -1923,6 +1923,7 @@ static SettingsContainer &GetSettingsTree()
|
||||
interface->Add(new SettingEntry("gui.vehicle_names"));
|
||||
interface->Add(new SettingEntry("gui.station_rating_tooltip_mode"));
|
||||
interface->Add(new SettingEntry("gui.dual_pane_train_purchase_window"));
|
||||
interface->Add(new SettingEntry("gui.allow_hiding_waypoint_labels"));
|
||||
}
|
||||
|
||||
SettingsPage *advisors = main->Add(new SettingsPage(STR_CONFIG_SETTING_ADVISORS));
|
||||
|
@@ -246,6 +246,7 @@ struct GUISettings : public TimeSettings {
|
||||
uint8 station_rating_tooltip_mode; ///< Station rating tooltip mode
|
||||
uint8 demolish_confirm_mode; ///< Demolition confirmation mode
|
||||
bool dual_pane_train_purchase_window; ///< Dual pane train purchase window
|
||||
bool allow_hiding_waypoint_labels; ///< Allow hiding waypoint viewport labels
|
||||
|
||||
uint16 console_backlog_timeout; ///< the minimum amount of time items should be in the console backlog before they will be removed in ~3 seconds granularity.
|
||||
uint16 console_backlog_length; ///< the minimum amount of items in the console backlog before items will be removed.
|
||||
|
@@ -66,11 +66,6 @@ BaseStation::~BaseStation()
|
||||
DeleteWindowById(WC_AIRCRAFT_LIST, VehicleListIdentifier(VL_STATION_LIST, VEH_AIRCRAFT, this->owner, this->index).Pack());
|
||||
DeleteWindowById(WC_DEPARTURES_BOARD, this->index);
|
||||
DeleteWindowById(WC_STATION_CARGO, this->index);
|
||||
|
||||
if (HasBit(_display_opt, Station::IsExpected(this) ? DO_SHOW_STATION_NAMES : DO_SHOW_WAYPOINT_NAMES) &&
|
||||
!(_local_company != this->owner && this->owner != OWNER_NONE && !HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS))) {
|
||||
this->sign.MarkDirty(ZOOM_LVL_DRAW_SPR);
|
||||
}
|
||||
}
|
||||
|
||||
Station::Station(TileIndex tile) :
|
||||
@@ -174,6 +169,8 @@ Station::~Station()
|
||||
|
||||
_station_kdtree.Remove(this->index);
|
||||
if (_viewport_sign_kdtree_valid && this->sign.kdtree_valid) _viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeStation(this->index));
|
||||
|
||||
if (ShouldShowBaseStationViewportLabel(this)) this->sign.MarkDirty(ZOOM_LVL_DRAW_SPR);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -478,8 +478,7 @@ void Station::UpdateVirtCoord()
|
||||
|
||||
SetDParam(0, this->index);
|
||||
SetDParam(1, this->facilities);
|
||||
bool shown = HasBit(_display_opt, DO_SHOW_STATION_NAMES) && !(_local_company != this->owner && this->owner != OWNER_NONE && !HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS));
|
||||
this->sign.UpdatePosition(shown ? ZOOM_LVL_DRAW_SPR : ZOOM_LVL_END, pt.x, pt.y, STR_VIEWPORT_STATION);
|
||||
this->sign.UpdatePosition(ShouldShowBaseStationViewportLabel(this) ? ZOOM_LVL_DRAW_SPR : ZOOM_LVL_END, pt.x, pt.y, STR_VIEWPORT_STATION);
|
||||
|
||||
if (_viewport_sign_kdtree_valid) _viewport_sign_kdtree.Insert(ViewportSignKdtreeItem::MakeStation(this->index));
|
||||
|
||||
|
@@ -69,4 +69,6 @@ static inline Money StationMaintenanceCost(uint32 num)
|
||||
|
||||
Money AirportMaintenanceCost(Owner owner);
|
||||
|
||||
bool ShouldShowBaseStationViewportLabel(const BaseStation *bst);
|
||||
|
||||
#endif /* STATION_FUNC_H */
|
||||
|
@@ -3018,3 +3018,12 @@ void GuiShowStationRatingTooltip(Window *parent, const Station *st, const CargoS
|
||||
DeleteWindowById(WC_STATION_RATING_TOOLTIP, 0);
|
||||
new StationRatingTooltipWindow(parent, st, cs);
|
||||
}
|
||||
|
||||
bool ShouldShowBaseStationViewportLabel(const BaseStation *bst)
|
||||
{
|
||||
if (!HasBit(_display_opt, Station::IsExpected(bst) ? DO_SHOW_STATION_NAMES : DO_SHOW_WAYPOINT_NAMES)) return false;
|
||||
if (HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS) && (_local_company != bst->owner && bst->owner != OWNER_NONE)) return false;
|
||||
if (Waypoint::IsExpected(bst) && HasBit(Waypoint::From(bst)->waypoint_flags, WPF_HIDE_LABEL) && _settings_client.gui.allow_hiding_waypoint_labels &&
|
||||
!HasBit(_extra_display_opt, XDO_SHOW_HIDDEN_SIGNS)) return false;
|
||||
return true;
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ extern std::string _config_language_file;
|
||||
|
||||
static std::initializer_list<const char*> _support8bppmodes{"no", "system" , "hardware"};
|
||||
static std::initializer_list<const char*> _display_opt_modes{"SHOW_TOWN_NAMES", "SHOW_STATION_NAMES", "SHOW_SIGNS", "FULL_ANIMATION", "", "FULL_DETAIL", "WAYPOINTS", "SHOW_COMPETITOR_SIGNS"};
|
||||
static std::initializer_list<const char*> _extra_display_opt_modes{"SHOW_MONEY_TEXT_EFFECTS"};
|
||||
static std::initializer_list<const char*> _extra_display_opt_modes{"SHOW_MONEY_TEXT_EFFECTS", "SHOW_HIDDEN_SIGNS"};
|
||||
|
||||
#ifdef WITH_COCOA
|
||||
extern bool _allow_hidpi_window;
|
||||
|
@@ -5428,6 +5428,14 @@ def = true
|
||||
str = STR_CONFIG_SETTING_DUAL_PANE_TRAIN_PURCHASE_WINDOW
|
||||
strhelp = STR_CONFIG_SETTING_DUAL_PANE_TRAIN_PURCHASE_WINDOW_HELPTEXT
|
||||
|
||||
[SDTC_BOOL]
|
||||
var = gui.allow_hiding_waypoint_labels
|
||||
flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC
|
||||
def = false
|
||||
str = STR_CONFIG_SETTING_ALLOW_HIDE_WAYPOINT_LABEL
|
||||
strhelp = STR_CONFIG_SETTING_ALLOW_HIDE_WAYPOINT_LABEL_HELPTEXT
|
||||
post_cb = [](auto) { MarkWholeScreenDirty(); InvalidateWindowClassesData(WC_WAYPOINT_VIEW, 0); }
|
||||
|
||||
; For the dedicated build we'll enable dates in logs by default.
|
||||
[SDTC_BOOL]
|
||||
ifdef = DEDICATED
|
||||
|
@@ -312,6 +312,7 @@ enum OptionMenuEntries {
|
||||
OME_TRANSPARENTBUILDINGS,
|
||||
OME_SHOW_STATIONSIGNS,
|
||||
OME_SHOW_MONEYTEXT,
|
||||
OME_SHOW_HIDDEN_SIGNS,
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -338,6 +339,9 @@ static CallBackFunction ToolbarOptionsClick(Window *w)
|
||||
list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_WAYPOINTS_DISPLAYED, OME_SHOW_WAYPOINTNAMES, false, HasBit(_display_opt, DO_SHOW_WAYPOINT_NAMES)));
|
||||
list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_SIGNS_DISPLAYED, OME_SHOW_SIGNS, false, HasBit(_display_opt, DO_SHOW_SIGNS)));
|
||||
list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_SHOW_COMPETITOR_SIGNS, OME_SHOW_COMPETITOR_SIGNS, false, HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS)));
|
||||
if (_settings_client.gui.allow_hiding_waypoint_labels) {
|
||||
list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_SHOW_HIDDEN_SIGNS, OME_SHOW_HIDDEN_SIGNS, false, HasBit(_extra_display_opt, XDO_SHOW_HIDDEN_SIGNS)));
|
||||
}
|
||||
list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_FULL_ANIMATION, OME_FULL_ANIMATION, false, HasBit(_display_opt, DO_FULL_ANIMATION)));
|
||||
list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_FULL_DETAIL, OME_FULL_DETAILS, false, HasBit(_display_opt, DO_FULL_DETAIL)));
|
||||
list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_TRANSPARENT_BUILDINGS, OME_TRANSPARENTBUILDINGS, false, IsTransparencySet(TO_HOUSES)));
|
||||
@@ -378,6 +382,7 @@ static CallBackFunction MenuClickSettings(int index)
|
||||
case OME_TRANSPARENTBUILDINGS: ToggleTransparency(TO_HOUSES); break;
|
||||
case OME_SHOW_STATIONSIGNS: ToggleTransparency(TO_SIGNS); break;
|
||||
case OME_SHOW_MONEYTEXT: ToggleBit(_extra_display_opt, XDO_SHOW_MONEY_TEXT_EFFECTS); break;
|
||||
case OME_SHOW_HIDDEN_SIGNS: ToggleBit(_extra_display_opt, XDO_SHOW_HIDDEN_SIGNS); break;
|
||||
}
|
||||
MarkWholeScreenDirty();
|
||||
return CBF_NONE;
|
||||
|
@@ -1748,6 +1748,7 @@ static void ViewportAddKdtreeSigns(DrawPixelInfo *dpi, bool towns_only)
|
||||
bool show_towns = HasBit(_display_opt, DO_SHOW_TOWN_NAMES) && _game_mode != GM_MENU;
|
||||
bool show_signs = HasBit(_display_opt, DO_SHOW_SIGNS) && !IsInvisibilitySet(TO_SIGNS) && !towns_only;
|
||||
bool show_competitors = HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS) && !towns_only;
|
||||
bool hide_hidden_waypoints = _settings_client.gui.allow_hiding_waypoint_labels && !HasBit(_extra_display_opt, XDO_SHOW_HIDDEN_SIGNS);
|
||||
|
||||
const BaseStation *st;
|
||||
const Sign *si;
|
||||
@@ -1775,6 +1776,7 @@ static void ViewportAddKdtreeSigns(DrawPixelInfo *dpi, bool towns_only)
|
||||
|
||||
/* Don't draw if station is owned by another company and competitor station names are hidden. Stations owned by none are never ignored. */
|
||||
if (!show_competitors && _local_company != st->owner && st->owner != OWNER_NONE) break;
|
||||
if (hide_hidden_waypoints && HasBit(Waypoint::From(st)->waypoint_flags, WPF_HIDE_LABEL)) break;
|
||||
|
||||
stations.push_back(st);
|
||||
break;
|
||||
@@ -4056,6 +4058,7 @@ static bool CheckClickOnViewportSign(const Viewport *vp, int x, int y)
|
||||
bool show_towns = HasBit(_display_opt, DO_SHOW_TOWN_NAMES);
|
||||
bool show_signs = HasBit(_display_opt, DO_SHOW_SIGNS) && !IsInvisibilitySet(TO_SIGNS);
|
||||
bool show_competitors = HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS);
|
||||
bool hide_hidden_waypoints = _settings_client.gui.allow_hiding_waypoint_labels && !HasBit(_extra_display_opt, XDO_SHOW_HIDDEN_SIGNS);
|
||||
|
||||
/* Topmost of each type that was hit */
|
||||
BaseStation *st = nullptr, *last_st = nullptr;
|
||||
@@ -4076,6 +4079,7 @@ static bool CheckClickOnViewportSign(const Viewport *vp, int x, int y)
|
||||
if (!show_waypoints) break;
|
||||
st = BaseStation::Get(item.id.station);
|
||||
if (!show_competitors && _local_company != st->owner && st->owner != OWNER_NONE) break;
|
||||
if (hide_hidden_waypoints && HasBit(Waypoint::From(st)->waypoint_flags, WPF_HIDE_LABEL)) break;
|
||||
if (CheckClickOnViewportSign(vp, x, y, &st->sign)) last_st = st;
|
||||
break;
|
||||
|
||||
|
@@ -62,4 +62,6 @@ Waypoint::~Waypoint()
|
||||
|
||||
/* Remove all news items */
|
||||
DeleteStationNews(this->index);
|
||||
|
||||
if (ShouldShowBaseStationViewportLabel(this)) this->sign.MarkDirty(ZOOM_LVL_DRAW_SPR);
|
||||
}
|
||||
|
@@ -12,15 +12,23 @@
|
||||
|
||||
#include "base_station_base.h"
|
||||
|
||||
/**
|
||||
* Enum to handle waypoint flags.
|
||||
*/
|
||||
enum WaypointFlags {
|
||||
WPF_HIDE_LABEL = 0, ///< Hide waypoint label
|
||||
};
|
||||
|
||||
/** Representation of a waypoint. */
|
||||
struct Waypoint FINAL : SpecializedStation<Waypoint, true> {
|
||||
uint16 town_cn; ///< The N-1th waypoint for this town (consecutive number)
|
||||
uint16 town_cn; ///< The N-1th waypoint for this town (consecutive number)
|
||||
uint16 waypoint_flags; ///< Waypoint flags, see WaypointFlags
|
||||
|
||||
/**
|
||||
* Create a waypoint at the given tile.
|
||||
* @param tile The location of the waypoint.
|
||||
*/
|
||||
Waypoint(TileIndex tile = INVALID_TILE) : SpecializedStation<Waypoint, true>(tile) { }
|
||||
Waypoint(TileIndex tile = INVALID_TILE) : SpecializedStation<Waypoint, true>(tile), waypoint_flags(0) { }
|
||||
~Waypoint();
|
||||
|
||||
void UpdateVirtCoord() override;
|
||||
|
@@ -42,8 +42,7 @@ void Waypoint::UpdateVirtCoord()
|
||||
if (_viewport_sign_kdtree_valid && this->sign.kdtree_valid) _viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeWaypoint(this->index));
|
||||
|
||||
SetDParam(0, this->index);
|
||||
bool shown = HasBit(_display_opt, DO_SHOW_WAYPOINT_NAMES) && !(_local_company != this->owner && this->owner != OWNER_NONE && !HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS));
|
||||
this->sign.UpdatePosition(shown ? ZOOM_LVL_DRAW_SPR : ZOOM_LVL_END, pt.x, pt.y - 32 * ZOOM_LVL_BASE, STR_VIEWPORT_WAYPOINT);
|
||||
this->sign.UpdatePosition(ShouldShowBaseStationViewportLabel(this) ? ZOOM_LVL_DRAW_SPR : ZOOM_LVL_END, pt.x, pt.y - 32 * ZOOM_LVL_BASE, STR_VIEWPORT_WAYPOINT);
|
||||
|
||||
if (_viewport_sign_kdtree_valid) _viewport_sign_kdtree.Insert(ViewportSignKdtreeItem::MakeWaypoint(this->index));
|
||||
|
||||
@@ -450,3 +449,35 @@ CommandCost CmdRenameWaypoint(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
|
||||
}
|
||||
return CommandCost();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether waypoint label is hidden
|
||||
* @param tile unused
|
||||
* @param flags type of operation
|
||||
* @param p1 id of waypoint
|
||||
* @param p2 hidden state
|
||||
* @param text the new name or an empty string when resetting to the default
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdSetWaypointLabelHidden(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
{
|
||||
Waypoint *wp = Waypoint::GetIfValid(p1);
|
||||
if (wp == nullptr) return CMD_ERROR;
|
||||
|
||||
if (wp->owner != OWNER_NONE) {
|
||||
CommandCost ret = CheckOwnership(wp->owner);
|
||||
if (ret.Failed()) return ret;
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
SB(wp->waypoint_flags, WPF_HIDE_LABEL, 1, p2 != 0 ? 1 : 0);
|
||||
|
||||
if (HasBit(_display_opt, DO_SHOW_WAYPOINT_NAMES) &&
|
||||
!(_local_company != wp->owner && wp->owner != OWNER_NONE && !HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS))) {
|
||||
wp->sign.MarkDirty(ZOOM_LVL_DRAW_SPR);
|
||||
}
|
||||
|
||||
InvalidateWindowData(WC_WAYPOINT_VIEW, wp->index);
|
||||
}
|
||||
return CommandCost();
|
||||
}
|
||||
|
@@ -34,6 +34,7 @@ struct WaypointWindow : Window {
|
||||
private:
|
||||
VehicleType vt; ///< Vehicle type using the waypoint.
|
||||
Waypoint *wp; ///< Waypoint displayed by the window.
|
||||
bool show_hide_label; ///< Show hide label button
|
||||
|
||||
/**
|
||||
* Get the center tile of the waypoint.
|
||||
@@ -65,6 +66,8 @@ public:
|
||||
this->GetWidget<NWidgetCore>(WID_W_CENTER_VIEW)->tool_tip = STR_WAYPOINT_VIEW_CENTER_TOOLTIP;
|
||||
this->GetWidget<NWidgetCore>(WID_W_RENAME)->tool_tip = STR_WAYPOINT_VIEW_CHANGE_WAYPOINT_NAME;
|
||||
}
|
||||
this->show_hide_label = (this->vt == VEH_TRAIN && _settings_client.gui.allow_hiding_waypoint_labels);
|
||||
this->GetWidget<NWidgetStacked>(WID_W_TOGGLE_HIDDEN_SEL)->SetDisplayedPlane(this->show_hide_label ? 0 : SZSP_NONE);
|
||||
this->FinishInitNested(window_number);
|
||||
|
||||
this->owner = this->wp->owner;
|
||||
@@ -109,6 +112,10 @@ public:
|
||||
case WID_W_DEPARTURES: // show departure times of vehicles
|
||||
ShowWaypointDepartures((StationID)this->wp->index);
|
||||
break;
|
||||
|
||||
case WID_W_TOGGLE_HIDDEN:
|
||||
DoCommandP(0, this->window_number, HasBit(this->wp->waypoint_flags, WPF_HIDE_LABEL) ? 0 : 1, CMD_SET_WAYPOINT_LABEL_HIDDEN | CMD_MSG(STR_ERROR_CAN_T_CHANGE_WAYPOINT_NAME));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,9 +129,19 @@ public:
|
||||
if (!gui_scope) return;
|
||||
/* You can only change your own waypoints */
|
||||
this->SetWidgetDisabledState(WID_W_RENAME, !this->wp->IsInUse() || (this->wp->owner != _local_company && this->wp->owner != OWNER_NONE));
|
||||
this->SetWidgetDisabledState(WID_W_TOGGLE_HIDDEN, !this->wp->IsInUse() || this->wp->owner != _local_company);
|
||||
/* Disable the widget for waypoints with no use */
|
||||
this->SetWidgetDisabledState(WID_W_SHOW_VEHICLES, !this->wp->IsInUse());
|
||||
|
||||
this->SetWidgetLoweredState(WID_W_TOGGLE_HIDDEN, HasBit(this->wp->waypoint_flags, WPF_HIDE_LABEL));
|
||||
|
||||
bool show_hide_label = (this->vt == VEH_TRAIN && _settings_client.gui.allow_hiding_waypoint_labels);
|
||||
if (show_hide_label != this->show_hide_label) {
|
||||
this->show_hide_label = show_hide_label;
|
||||
this->GetWidget<NWidgetStacked>(WID_W_TOGGLE_HIDDEN_SEL)->SetDisplayedPlane(this->show_hide_label ? 0 : SZSP_NONE);
|
||||
this->ReInit();
|
||||
}
|
||||
|
||||
ScrollWindowToTile(this->GetCenterTile(), this, true);
|
||||
}
|
||||
|
||||
@@ -176,6 +193,9 @@ static const NWidgetPart _nested_waypoint_view_widgets[] = {
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_W_DEPARTURES), SetMinimalSize(100, 12), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_STATION_VIEW_DEPARTURES_BUTTON, STR_STATION_VIEW_DEPARTURES_TOOLTIP),
|
||||
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_W_TOGGLE_HIDDEN_SEL),
|
||||
NWidget(WWT_IMGBTN, COLOUR_GREY, WID_W_TOGGLE_HIDDEN), SetMinimalSize(15, 12), SetDataTip(SPR_MISC_GUI_BASE, STR_WAYPOINT_VIEW_HIDE_VIEWPORT_LABEL),
|
||||
EndContainer(),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_W_SHOW_VEHICLES), SetMinimalSize(15, 12), SetDataTip(STR_SHIP, STR_STATION_VIEW_SCHEDULED_SHIPS_TOOLTIP),
|
||||
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
|
||||
EndContainer(),
|
||||
|
@@ -18,6 +18,8 @@ enum WaypointWidgets {
|
||||
WID_W_RENAME, ///< Rename this waypoint.
|
||||
WID_W_SHOW_VEHICLES, ///< Show the vehicles visiting this waypoint.
|
||||
WID_W_DEPARTURES, ///< Departures button.
|
||||
WID_W_TOGGLE_HIDDEN, ///< Toggle label hidden.
|
||||
WID_W_TOGGLE_HIDDEN_SEL, ///< Toggle label hidden selector.
|
||||
};
|
||||
|
||||
#endif /* WIDGETS_WAYPOINT_WIDGET_H */
|
||||
|
Reference in New Issue
Block a user