[Feature] Added depot viewport tooltips.
This commit is contained in:
@@ -1197,3 +1197,67 @@ void DeleteDepotHighlightOfVehicle(const Vehicle *v)
|
|||||||
if (w->sel == v->index) ResetObjectToPlace();
|
if (w->sel == v->index) ResetObjectToPlace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum DepotTooltipMode : uint8 {
|
||||||
|
DTM_OFF,
|
||||||
|
DTM_SIMPLE,
|
||||||
|
DTM_DETAILED
|
||||||
|
};
|
||||||
|
|
||||||
|
bool GetDepotTooltipString(const TileIndex tile, char *buffer_position, const char *buffer_tail)
|
||||||
|
{
|
||||||
|
if (_settings_client.gui.depot_tooltip_mode == DTM_OFF) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t total_vehicle_count = 0;
|
||||||
|
size_t stopped_vehicle_count = 0;
|
||||||
|
size_t waiting_vehicle_count = 0;
|
||||||
|
size_t consist_count = 0;
|
||||||
|
|
||||||
|
for (const Vehicle *v : Vehicle::Iterate()) {
|
||||||
|
if (v->tile == tile && !HasBit(v->subtype, GVSF_VIRTUAL) && v->IsInDepot()) {
|
||||||
|
if (v->IsPrimaryVehicle()) {
|
||||||
|
++total_vehicle_count;
|
||||||
|
if (v->IsWaitingInDepot()) ++waiting_vehicle_count;
|
||||||
|
if (v->IsStoppedInDepot()) ++stopped_vehicle_count;
|
||||||
|
}
|
||||||
|
if (v->type == VEH_TRAIN) {
|
||||||
|
const Train *loco_or_wago = Train::From(v);
|
||||||
|
if (loco_or_wago->IsFreeWagon()) {
|
||||||
|
++consist_count;
|
||||||
|
++total_vehicle_count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer_position[0] = '\0';
|
||||||
|
|
||||||
|
if (total_vehicle_count == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetDParam(0, total_vehicle_count);
|
||||||
|
|
||||||
|
if (_settings_client.gui.depot_tooltip_mode == DTM_SIMPLE || stopped_vehicle_count == 0 && waiting_vehicle_count == 0 && consist_count == 0) {
|
||||||
|
GetString(buffer_position, STR_DEPOT_VIEW_COUNT_TOOLTIP, buffer_tail);
|
||||||
|
} else {
|
||||||
|
buffer_position = GetString(buffer_position, STR_DEPOT_VIEW_TOTAL_TOOLTIP, buffer_tail);
|
||||||
|
if (stopped_vehicle_count > 0) {
|
||||||
|
SetDParam(0, stopped_vehicle_count);
|
||||||
|
buffer_position = GetString(buffer_position, STR_DEPOT_VIEW_STOPPED_TOOLTIP, buffer_tail);
|
||||||
|
}
|
||||||
|
if (waiting_vehicle_count > 0) {
|
||||||
|
SetDParam(0, waiting_vehicle_count);
|
||||||
|
buffer_position = GetString(buffer_position, STR_DEPOT_VIEW_WAITING_TOOLTIP, buffer_tail);
|
||||||
|
}
|
||||||
|
if (consist_count > 0) {
|
||||||
|
SetDParam(0, consist_count);
|
||||||
|
GetString(buffer_position, STR_DEPOT_VIEW_CONSISTS_TOOLTIP, buffer_tail);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@@ -1395,6 +1395,13 @@ STR_INDUSTRY_VIEW_STOCKPILED_TOOLTIP :{CARGO_LONG} wa
|
|||||||
STR_INDUSTRY_VIEW_TRANSPORTED_TOOLTIP_EXTENSION :{CARGO_LONG}{RAW_STRING} ({COMMA}%)
|
STR_INDUSTRY_VIEW_TRANSPORTED_TOOLTIP_EXTENSION :{CARGO_LONG}{RAW_STRING} ({COMMA}%)
|
||||||
STR_INDUSTRY_VIEW_INFO_TOOLTIP :{BLACK}{RAW_STRING}
|
STR_INDUSTRY_VIEW_INFO_TOOLTIP :{BLACK}{RAW_STRING}
|
||||||
|
|
||||||
|
STR_DEPOT_VIEW_COUNT_TOOLTIP :{COMMA} indside
|
||||||
|
STR_DEPOT_VIEW_TOTAL_TOOLTIP :Of {COMMA} inside:
|
||||||
|
STR_DEPOT_VIEW_STOPPED_TOOLTIP :{}{COMMA} {P is are} stopped
|
||||||
|
STR_DEPOT_VIEW_WAITING_TOOLTIP :{}{COMMA} {P is are} waiting
|
||||||
|
STR_DEPOT_VIEW_CONSISTS_TOOLTIP :{}{COMMA} {P is are} {P "a " ""}consist{P "" s}
|
||||||
|
STR_DEPOT_VIEW_INFO_TOOLTIP :{BLACK}{RAW_STRING}
|
||||||
|
|
||||||
STR_VEHICLE_LIST_AGE :{STRING2}, Age: {COMMA} year{P "" s} ({COMMA})
|
STR_VEHICLE_LIST_AGE :{STRING2}, Age: {COMMA} year{P "" s} ({COMMA})
|
||||||
STR_VEHICLE_LIST_AGE_RED :{STRING2}, Age: {RED}{COMMA} {BLACK}year{P "" s} ({COMMA})
|
STR_VEHICLE_LIST_AGE_RED :{STRING2}, Age: {RED}{COMMA} {BLACK}year{P "" s} ({COMMA})
|
||||||
STR_VEHICLE_LIST_CARGO_LIST :{STRING2}, Cargoes: {CARGO_LIST}
|
STR_VEHICLE_LIST_CARGO_LIST :{STRING2}, Cargoes: {CARGO_LIST}
|
||||||
@@ -2146,6 +2153,12 @@ STR_CONFIG_SETTING_INDUSTRY_TOOLTIP_STOCKPILED_AS_REQUIRED_HELPTEXT:If normal di
|
|||||||
STR_CONFIG_SETTING_INDUSTRY_TOOLTIP_PRODUCED :Show produced cargoes in industry viewport tooltips: {STRING2}
|
STR_CONFIG_SETTING_INDUSTRY_TOOLTIP_PRODUCED :Show produced cargoes in industry viewport tooltips: {STRING2}
|
||||||
STR_CONFIG_SETTING_INDUSTRY_TOOLTIP_PRODUCED_HELPTEXT :Show a list of cargoes produced by industries in viewport tooltips when hovering over industry tiles.
|
STR_CONFIG_SETTING_INDUSTRY_TOOLTIP_PRODUCED_HELPTEXT :Show a list of cargoes produced by industries in viewport tooltips when hovering over industry tiles.
|
||||||
|
|
||||||
|
STR_CONFIG_SETTING_DEPOT_TOOLTIP_MODE :Depot viewport tooltips: {STRING2}
|
||||||
|
STR_CONFIG_SETTING_DEPOT_TOOLTIP_MODE_HELPTEXT :Set whether to show viewport tooltips when hovering over depot tiles and how much information to display.
|
||||||
|
STR_CONFIG_SETTING_DEPOT_TOOLTIP_MODE_OFF :Off
|
||||||
|
STR_CONFIG_SETTING_DEPOT_TOOLTIP_MODE_SIMPLE :Simple
|
||||||
|
STR_CONFIG_SETTING_DEPOT_TOOLTIP_MODE_DETAILED :Detailed
|
||||||
|
|
||||||
STR_CONFIG_SETTING_STATION_RATING_TOOLTIP_MODE :Station rating tooltips: {STRING2}
|
STR_CONFIG_SETTING_STATION_RATING_TOOLTIP_MODE :Station rating tooltips: {STRING2}
|
||||||
STR_CONFIG_SETTING_STATION_RATING_TOOLTIP_MODE_HELPTEXT :Set whether station rating tooltips are shown and the level of information detail.
|
STR_CONFIG_SETTING_STATION_RATING_TOOLTIP_MODE_HELPTEXT :Set whether station rating tooltips are shown and the level of information detail.
|
||||||
STR_CONFIG_SETTING_STATION_RATING_TOOLTIP_MODE_OFF :Off
|
STR_CONFIG_SETTING_STATION_RATING_TOOLTIP_MODE_OFF :Off
|
||||||
|
@@ -1940,6 +1940,7 @@ static SettingsContainer &GetSettingsTree()
|
|||||||
tooltips->Add(new ConditionallyHiddenSettingEntry("gui.industry_tooltip_show_stockpiled", []() -> bool { return !_settings_client.gui.industry_tooltip_show; }));
|
tooltips->Add(new ConditionallyHiddenSettingEntry("gui.industry_tooltip_show_stockpiled", []() -> bool { return !_settings_client.gui.industry_tooltip_show; }));
|
||||||
tooltips->Add(new ConditionallyHiddenSettingEntry("gui.industry_tooltip_show_stockpiled_as_required", []() -> bool { return !_settings_client.gui.industry_tooltip_show || _settings_client.gui.industry_tooltip_show_stockpiled || !_settings_client.gui.industry_tooltip_show_required; }));
|
tooltips->Add(new ConditionallyHiddenSettingEntry("gui.industry_tooltip_show_stockpiled_as_required", []() -> bool { return !_settings_client.gui.industry_tooltip_show || _settings_client.gui.industry_tooltip_show_stockpiled || !_settings_client.gui.industry_tooltip_show_required; }));
|
||||||
tooltips->Add(new ConditionallyHiddenSettingEntry("gui.industry_tooltip_show_produced", []() -> bool { return !_settings_client.gui.industry_tooltip_show; }));
|
tooltips->Add(new ConditionallyHiddenSettingEntry("gui.industry_tooltip_show_produced", []() -> bool { return !_settings_client.gui.industry_tooltip_show; }));
|
||||||
|
tooltips->Add(new SettingEntry("gui.depot_tooltip_mode"));
|
||||||
tooltips->Add(new SettingEntry("gui.station_rating_tooltip_mode"));
|
tooltips->Add(new SettingEntry("gui.station_rating_tooltip_mode"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -140,6 +140,7 @@ struct GUISettings : public TimeSettings {
|
|||||||
bool industry_tooltip_show_stockpiled; ///< whether to display cargoes stockpiled by the industry, when hovering over one of its tiles.
|
bool industry_tooltip_show_stockpiled; ///< whether to display cargoes stockpiled by the industry, when hovering over one of its tiles.
|
||||||
bool industry_tooltip_show_stockpiled_as_required; ///< whether to display cargoes stockpiled by the industry as ones required by the industry, when hovering over one of its tiles and normal display of stockpiled cargoes in viewport tooltips is turned off.
|
bool industry_tooltip_show_stockpiled_as_required; ///< whether to display cargoes stockpiled by the industry as ones required by the industry, when hovering over one of its tiles and normal display of stockpiled cargoes in viewport tooltips is turned off.
|
||||||
bool industry_tooltip_show_produced; ///< whether to display cargoes produced by the industry, when hovering over one of its tiles.
|
bool industry_tooltip_show_produced; ///< whether to display cargoes produced by the industry, when hovering over one of its tiles.
|
||||||
|
uint8 depot_tooltip_mode; ///< Display mode for depot viewport tooltips. (0 = never, 1 = just a total number of vehicles, 2 = total number of vehicles in the depot along with a breakdown of numbers)
|
||||||
uint8 station_rating_tooltip_mode; ///< Station rating tooltip mode
|
uint8 station_rating_tooltip_mode; ///< Station rating tooltip mode
|
||||||
bool link_terraform_toolbar; ///< display terraform toolbar when displaying rail, road, water and airport toolbars
|
bool link_terraform_toolbar; ///< display terraform toolbar when displaying rail, road, water and airport toolbars
|
||||||
uint8 smallmap_land_colour; ///< colour used for land and heightmap at the smallmap
|
uint8 smallmap_land_colour; ///< colour used for land and heightmap at the smallmap
|
||||||
|
@@ -4608,6 +4608,17 @@ def = true
|
|||||||
str = STR_CONFIG_SETTING_INDUSTRY_TOOLTIP_PRODUCED
|
str = STR_CONFIG_SETTING_INDUSTRY_TOOLTIP_PRODUCED
|
||||||
strhelp = STR_CONFIG_SETTING_INDUSTRY_TOOLTIP_PRODUCED_HELPTEXT
|
strhelp = STR_CONFIG_SETTING_INDUSTRY_TOOLTIP_PRODUCED_HELPTEXT
|
||||||
|
|
||||||
|
[SDTC_VAR]
|
||||||
|
var = gui.depot_tooltip_mode
|
||||||
|
type = SLE_UINT8
|
||||||
|
flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC | SF_GUI_DROPDOWN
|
||||||
|
def = 1
|
||||||
|
min = 0
|
||||||
|
max = 2
|
||||||
|
str = STR_CONFIG_SETTING_DEPOT_TOOLTIP_MODE
|
||||||
|
strhelp = STR_CONFIG_SETTING_DEPOT_TOOLTIP_MODE_HELPTEXT
|
||||||
|
strval = STR_CONFIG_SETTING_DEPOT_TOOLTIP_MODE_OFF
|
||||||
|
|
||||||
[SDTC_VAR]
|
[SDTC_VAR]
|
||||||
var = gui.station_rating_tooltip_mode
|
var = gui.station_rating_tooltip_mode
|
||||||
type = SLE_UINT8
|
type = SLE_UINT8
|
||||||
|
@@ -247,6 +247,16 @@ void ShowIndustryTooltip(Window *w, const TileIndex tile, char *buffer_position,
|
|||||||
GuiShowTooltips(w, STR_INDUSTRY_VIEW_INFO_TOOLTIP, 0, nullptr, TCC_HOVER_VIEWPORT);
|
GuiShowTooltips(w, STR_INDUSTRY_VIEW_INFO_TOOLTIP, 0, nullptr, TCC_HOVER_VIEWPORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GetDepotTooltipString(TileIndex tile, char *buffer_position, const char *buffer_tail);
|
||||||
|
|
||||||
|
void ShowDepotTooltip(Window *w, const TileIndex tile, char *buffer_position, const char *buffer_tail)
|
||||||
|
{
|
||||||
|
if (!GetDepotTooltipString(tile, buffer_position, buffer_tail)) return;
|
||||||
|
|
||||||
|
SetDParamStr(0, buffer_position);
|
||||||
|
GuiShowTooltips(w, STR_DEPOT_VIEW_INFO_TOOLTIP, 0, nullptr, TCC_HOVER_VIEWPORT);
|
||||||
|
}
|
||||||
|
|
||||||
void ShowTooltipForTile(Window *w, const TileIndex tile)
|
void ShowTooltipForTile(Window *w, const TileIndex tile)
|
||||||
{
|
{
|
||||||
static char buffer[1024];
|
static char buffer[1024];
|
||||||
@@ -255,7 +265,10 @@ void ShowTooltipForTile(Window *w, const TileIndex tile)
|
|||||||
|
|
||||||
switch (GetTileType(tile)) {
|
switch (GetTileType(tile)) {
|
||||||
case MP_ROAD:
|
case MP_ROAD:
|
||||||
if (IsRoadDepot(tile)) return;
|
if (IsRoadDepot(tile)) {
|
||||||
|
ShowDepotTooltip(w, tile, buffer_start, buffer_tail);
|
||||||
|
return;
|
||||||
|
}
|
||||||
/* FALL THROUGH */
|
/* FALL THROUGH */
|
||||||
case MP_HOUSE: {
|
case MP_HOUSE: {
|
||||||
ShowTownNameTooltip(w, tile);
|
ShowTownNameTooltip(w, tile);
|
||||||
@@ -265,6 +278,22 @@ void ShowTooltipForTile(Window *w, const TileIndex tile)
|
|||||||
ShowIndustryTooltip(w, tile, buffer_start, buffer_tail);
|
ShowIndustryTooltip(w, tile, buffer_start, buffer_tail);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case MP_RAILWAY: {
|
||||||
|
if (!IsRailDepot(tile)) return;
|
||||||
|
ShowDepotTooltip(w, tile, buffer_start, buffer_tail);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MP_WATER: {
|
||||||
|
if (!IsShipDepot(tile)) return;
|
||||||
|
ShowDepotTooltip(w, tile, buffer_start, buffer_tail);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MP_STATION: {
|
||||||
|
if (IsHangar(tile)) {
|
||||||
|
ShowDepotTooltip(w, tile, buffer_start, buffer_tail);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user