Add setting to control station rating tooltip detail level

Default to simple
This commit is contained in:
Jonathan G Rennison
2021-06-15 02:00:58 +01:00
parent e7909b4bee
commit 1cc8053003
5 changed files with 97 additions and 59 deletions

View File

@@ -1453,6 +1453,12 @@ STR_CONFIG_SETTING_VEHICLE_NAMES_LONG :Long
STR_CONFIG_SETTING_SHADED_TREES_ON_SLOPES :Shade trees on slopes: {STRING2} STR_CONFIG_SETTING_SHADED_TREES_ON_SLOPES :Shade trees on slopes: {STRING2}
STR_CONFIG_SETTING_SHADED_TREES_ON_SLOPES_HELPTEXT :Change brightness of trees drawn on slopes. Improves the look of tree cover in mountainous areas. STR_CONFIG_SETTING_SHADED_TREES_ON_SLOPES_HELPTEXT :Change brightness of trees drawn on slopes. Improves the look of tree cover in mountainous areas.
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_OFF :Off
STR_CONFIG_SETTING_STATION_RATING_TOOLTIP_MODE_SIMPLE :Simple
STR_CONFIG_SETTING_STATION_RATING_TOOLTIP_MODE_DETAILED :Detailed
STR_CONFIG_SETTING_ADV_SIG_BRIDGE_TUN_MODES :Enable signals on bridges/tunnels advanced modes: {STRING2} 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. 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.
@@ -6520,39 +6526,40 @@ STR_STATION_RATING_TOOLTIP_NEWGRF_WAITTIME :Time since last
STR_STATION_RATING_MAX_PERCENTAGE : (max {PLUS_NUM}%) STR_STATION_RATING_MAX_PERCENTAGE : (max {PLUS_NUM}%)
STR_STATION_RATING_MAX_PERCENTAGE_COMMA :, max {PLUS_NUM}% STR_STATION_RATING_MAX_PERCENTAGE_COMMA :, max {PLUS_NUM}%
STR_STATION_RATING_PERCENTAGE_COMMA :, {PLUS_NUM}%
STR_STATION_RATING_TOOLTIP_SPEED :Max speed of last vehicle{STRING1}: {STRING2} ({STRING}) STR_STATION_RATING_TOOLTIP_SPEED :Max speed of last vehicle{STRING1}: {STRING3} ({STRING})
STR_STATION_RATING_TOOLTIP_SPEED_ZERO :{RED}{VELOCITY}, {PLUS_NUM}% STR_STATION_RATING_TOOLTIP_SPEED_ZERO :{RED}{VELOCITY}{STRING1}
STR_STATION_RATING_TOOLTIP_SPEED_0 :{ORANGE}{VELOCITY}, {PLUS_NUM}% STR_STATION_RATING_TOOLTIP_SPEED_0 :{ORANGE}{VELOCITY}{STRING1}
STR_STATION_RATING_TOOLTIP_SPEED_1 :{GOLD}{VELOCITY}, {PLUS_NUM}% STR_STATION_RATING_TOOLTIP_SPEED_1 :{GOLD}{VELOCITY}{STRING1}
STR_STATION_RATING_TOOLTIP_SPEED_2 :{YELLOW}{VELOCITY}, {PLUS_NUM}% STR_STATION_RATING_TOOLTIP_SPEED_2 :{YELLOW}{VELOCITY}{STRING1}
STR_STATION_RATING_TOOLTIP_SPEED_3 :{GREEN}{VELOCITY}, {PLUS_NUM}% STR_STATION_RATING_TOOLTIP_SPEED_3 :{GREEN}{VELOCITY}{STRING1}
STR_STATION_RATING_TOOLTIP_AGE :Age of last vehicle{STRING1}: {STRING2} STR_STATION_RATING_TOOLTIP_AGE :Age of last vehicle{STRING1}: {STRING3}
STR_STATION_RATING_TOOLTIP_AGE_0 :{ORANGE}{NUM} year{P "" s}, {PLUS_NUM}% STR_STATION_RATING_TOOLTIP_AGE_0 :{ORANGE}{NUM} year{P "" s}{STRING1}
STR_STATION_RATING_TOOLTIP_AGE_1 :{GOLD}{NUM} year{P "" s}, {PLUS_NUM}% STR_STATION_RATING_TOOLTIP_AGE_1 :{GOLD}{NUM} year{P "" s}{STRING1}
STR_STATION_RATING_TOOLTIP_AGE_2 :{YELLOW}{NUM} year{P "" s}, {PLUS_NUM}% STR_STATION_RATING_TOOLTIP_AGE_2 :{YELLOW}{NUM} year{P "" s}{STRING1}
STR_STATION_RATING_TOOLTIP_AGE_3 :{GREEN}{NUM} year{P "" s}, {PLUS_NUM}% STR_STATION_RATING_TOOLTIP_AGE_3 :{GREEN}{NUM} year{P "" s}{STRING1}
STR_STATION_RATING_TOOLTIP_WAITTIME :Time since last pickup{STRING1}: {STRING2} STR_STATION_RATING_TOOLTIP_WAITTIME :Time since last pickup{STRING1}: {STRING3}
STR_STATION_RATING_TOOLTIP_WAITTIME_SHIP :Time since last pickup{STRING1}: {STRING2} (by ship) STR_STATION_RATING_TOOLTIP_WAITTIME_SHIP :Time since last pickup{STRING1}: {STRING3} (by ship)
STR_STATION_RATING_TOOLTIP_WAITTIME_0 :{RED}{NUM} day{P "" s}, {PLUS_NUM}% STR_STATION_RATING_TOOLTIP_WAITTIME_0 :{RED}{NUM} day{P "" s}{STRING1}
STR_STATION_RATING_TOOLTIP_WAITTIME_1 :{ORANGE}{NUM} day{P "" s}, {PLUS_NUM}% STR_STATION_RATING_TOOLTIP_WAITTIME_1 :{ORANGE}{NUM} day{P "" s}{STRING1}
STR_STATION_RATING_TOOLTIP_WAITTIME_2 :{GOLD}{NUM} day{P "" s}, {PLUS_NUM}% STR_STATION_RATING_TOOLTIP_WAITTIME_2 :{GOLD}{NUM} day{P "" s}{STRING1}
STR_STATION_RATING_TOOLTIP_WAITTIME_3 :{YELLOW}{NUM} day{P "" s}, {PLUS_NUM}% STR_STATION_RATING_TOOLTIP_WAITTIME_3 :{YELLOW}{NUM} day{P "" s}{STRING1}
STR_STATION_RATING_TOOLTIP_WAITTIME_4 :{GREEN}{NUM} day{P "" s}, {PLUS_NUM}% STR_STATION_RATING_TOOLTIP_WAITTIME_4 :{GREEN}{NUM} day{P "" s}{STRING1}
STR_STATION_RATING_TOOLTIP_WAITUNITS :Cargo waiting (on average per next stop{STRING1}): {STRING2} STR_STATION_RATING_TOOLTIP_WAITUNITS :Cargo waiting (on average per next stop{STRING1}): {STRING3}
STR_STATION_RATING_TOOLTIP_WAITUNITS_0 :{RED}{NUM}, {PLUS_NUM}% STR_STATION_RATING_TOOLTIP_WAITUNITS_0 :{RED}{NUM}{STRING1}
STR_STATION_RATING_TOOLTIP_WAITUNITS_1 :{ORANGE}{NUM}, {PLUS_NUM}% STR_STATION_RATING_TOOLTIP_WAITUNITS_1 :{ORANGE}{NUM}{STRING1}
STR_STATION_RATING_TOOLTIP_WAITUNITS_2 :{GOLD}{NUM}, {PLUS_NUM}% STR_STATION_RATING_TOOLTIP_WAITUNITS_2 :{GOLD}{NUM}{STRING1}
STR_STATION_RATING_TOOLTIP_WAITUNITS_3 :{YELLOW}{NUM}, {PLUS_NUM}% STR_STATION_RATING_TOOLTIP_WAITUNITS_3 :{YELLOW}{NUM}{STRING1}
STR_STATION_RATING_TOOLTIP_WAITUNITS_4 :{YELLOW}{NUM}, {PLUS_NUM}% STR_STATION_RATING_TOOLTIP_WAITUNITS_4 :{YELLOW}{NUM}{STRING1}
STR_STATION_RATING_TOOLTIP_WAITUNITS_5 :{GREEN}{NUM}, {PLUS_NUM}% STR_STATION_RATING_TOOLTIP_WAITUNITS_5 :{GREEN}{NUM}{STRING1}
STR_STATION_RATING_TOOLTIP_STATUE :Statue in town{STRING1}: {STRING1} STR_STATION_RATING_TOOLTIP_STATUE :Statue in town{STRING1}: {STRING2}
STR_STATION_RATING_TOOLTIP_STATUE_NO :{GOLD}no, {PLUS_NUM}% STR_STATION_RATING_TOOLTIP_STATUE_NO :{GOLD}no{STRING1}
STR_STATION_RATING_TOOLTIP_STATUE_YES :{GREEN}yes, {PLUS_NUM}% STR_STATION_RATING_TOOLTIP_STATUE_YES :{GREEN}yes{STRING1}
STR_STATION_RATING_TOOLTIP_TRAIN :Train STR_STATION_RATING_TOOLTIP_TRAIN :Train
STR_STATION_RATING_TOOLTIP_ROAD_VEHICLE :Road Vehicle STR_STATION_RATING_TOOLTIP_ROAD_VEHICLE :Road Vehicle

View File

@@ -1839,6 +1839,7 @@ static SettingsContainer &GetSettingsTree()
interface->Add(new SettingEntry("gui.show_depot_sell_gui")); interface->Add(new SettingEntry("gui.show_depot_sell_gui"));
interface->Add(new SettingEntry("gui.open_vehicle_gui_clone_share")); interface->Add(new SettingEntry("gui.open_vehicle_gui_clone_share"));
interface->Add(new SettingEntry("gui.vehicle_names")); interface->Add(new SettingEntry("gui.vehicle_names"));
interface->Add(new SettingEntry("gui.station_rating_tooltip_mode"));
} }
SettingsPage *advisors = main->Add(new SettingsPage(STR_CONFIG_SETTING_ADVISORS)); SettingsPage *advisors = main->Add(new SettingsPage(STR_CONFIG_SETTING_ADVISORS));

View File

@@ -220,6 +220,7 @@ struct GUISettings : public TimeSettings {
uint8 linkgraph_colours; ///< linkgraph overlay colours uint8 linkgraph_colours; ///< linkgraph overlay colours
uint8 vehicle_names; ///< Vehicle naming scheme uint8 vehicle_names; ///< Vehicle naming scheme
bool shade_trees_on_slopes; ///< Shade trees on slopes bool shade_trees_on_slopes; ///< Shade trees on slopes
uint8 station_rating_tooltip_mode; ///< Station rating tooltip mode
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_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. uint16 console_backlog_length; ///< the minimum amount of items in the console backlog before items will be removed.

View File

@@ -48,6 +48,12 @@
#include "safeguards.h" #include "safeguards.h"
#include "widgets/misc_widget.h" #include "widgets/misc_widget.h"
enum StationRatingTooltipMode {
SRTM_OFF,
SRTM_SIMPLE,
SRTM_DETAILED,
};
/** /**
* Calculates and draws the accepted or supplied cargo around the selected tile(s) * Calculates and draws the accepted or supplied cargo around the selected tile(s)
* @param left x position where the string is to be drawn * @param left x position where the string is to be drawn
@@ -1442,7 +1448,8 @@ struct StationViewWindow : public Window {
bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) override bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) override
{ {
if (widget != WID_SV_ACCEPT_RATING_LIST || this->GetWidget<NWidgetCore>(WID_SV_ACCEPTS_RATINGS)->widget_data == STR_STATION_VIEW_RATINGS_BUTTON) { if (widget != WID_SV_ACCEPT_RATING_LIST || this->GetWidget<NWidgetCore>(WID_SV_ACCEPTS_RATINGS)->widget_data == STR_STATION_VIEW_RATINGS_BUTTON ||
_settings_client.gui.station_rating_tooltip_mode == SRTM_OFF) {
return false; return false;
} }
@@ -2647,6 +2654,8 @@ public:
bool skip = false; bool skip = false;
int total_rating = 0; int total_rating = 0;
const bool detailed = _settings_client.gui.station_rating_tooltip_mode == SRTM_DETAILED;
if (_extra_cheats.station_rating.value) { if (_extra_cheats.station_rating.value) {
total_rating = 255; total_rating = 255;
skip = true; skip = true;
@@ -2710,7 +2719,7 @@ public:
const auto speed_rating = GetSpeedRating(ge); const auto speed_rating = GetSpeedRating(ge);
const auto rounded_speed_rating = RoundRating(speed_rating); const auto rounded_speed_rating = RoundRating(speed_rating);
SetDParam(0, STR_STATION_RATING_MAX_PERCENTAGE); SetDParam(0, detailed ? STR_STATION_RATING_MAX_PERCENTAGE : STR_EMPTY);
SetDParam(1, 17); SetDParam(1, 17);
if (ge->last_speed == 255) { if (ge->last_speed == 255) {
@@ -2724,24 +2733,25 @@ public:
} }
SetDParam(3, ge->last_speed); SetDParam(3, ge->last_speed);
SetDParam(4, rounded_speed_rating); SetDParam(4, detailed ? STR_STATION_RATING_PERCENTAGE_COMMA : STR_EMPTY);
SetDParam(5, rounded_speed_rating);
switch (ge->last_vehicle_type) switch (ge->last_vehicle_type)
{ {
case VEH_TRAIN: case VEH_TRAIN:
SetDParam(5, STR_STATION_RATING_TOOLTIP_TRAIN); SetDParam(6, STR_STATION_RATING_TOOLTIP_TRAIN);
break; break;
case VEH_ROAD: case VEH_ROAD:
SetDParam(5, STR_STATION_RATING_TOOLTIP_ROAD_VEHICLE); SetDParam(6, STR_STATION_RATING_TOOLTIP_ROAD_VEHICLE);
break; break;
case VEH_SHIP: case VEH_SHIP:
SetDParam(5, STR_STATION_RATING_TOOLTIP_SHIP); SetDParam(6, STR_STATION_RATING_TOOLTIP_SHIP);
break; break;
case VEH_AIRCRAFT: case VEH_AIRCRAFT:
SetDParam(5, STR_STATION_RATING_TOOLTIP_AIRCRAFT); SetDParam(6, STR_STATION_RATING_TOOLTIP_AIRCRAFT);
break; break;
default: default:
SetDParam(5, STR_STATION_RATING_TOOLTIP_INVALID); SetDParam(6, STR_STATION_RATING_TOOLTIP_INVALID);
break; break;
} }
@@ -2767,11 +2777,12 @@ public:
wait_time_stage = 1; wait_time_stage = 1;
} }
SetDParam(0, STR_STATION_RATING_MAX_PERCENTAGE); SetDParam(0, detailed ? STR_STATION_RATING_MAX_PERCENTAGE : STR_EMPTY);
SetDParam(1, 51); SetDParam(1, 51);
SetDParam(2, STR_STATION_RATING_TOOLTIP_WAITTIME_0 + wait_time_stage); SetDParam(2, STR_STATION_RATING_TOOLTIP_WAITTIME_0 + wait_time_stage);
SetDParam(3, ge->max_waiting_cargo); SetDParam(3, ge->max_waiting_cargo);
SetDParam(4, RoundRating(wait_time_rating)); SetDParam(4, detailed ? STR_STATION_RATING_PERCENTAGE_COMMA : STR_EMPTY);
SetDParam(5, RoundRating(wait_time_rating));
GetString(this->data[line_nr], GetString(this->data[line_nr],
(ge->last_vehicle_type == VEH_SHIP) ? (ge->last_vehicle_type == VEH_SHIP) ?
STR_STATION_RATING_TOOLTIP_WAITTIME_SHIP : STR_STATION_RATING_TOOLTIP_WAITTIME_SHIP :
@@ -2800,11 +2811,12 @@ public:
wait_units_stage = 1; wait_units_stage = 1;
} }
SetDParam(0, STR_STATION_RATING_MAX_PERCENTAGE_COMMA); SetDParam(0, detailed ? STR_STATION_RATING_MAX_PERCENTAGE_COMMA : STR_EMPTY);
SetDParam(1, 16); SetDParam(1, 16);
SetDParam(2, STR_STATION_RATING_TOOLTIP_WAITUNITS_0 + wait_units_stage); SetDParam(2, STR_STATION_RATING_TOOLTIP_WAITUNITS_0 + wait_units_stage);
SetDParam(3, ge->max_waiting_cargo); SetDParam(3, ge->max_waiting_cargo);
SetDParam(4, RoundRating(cargo_rating)); SetDParam(4, detailed ? STR_STATION_RATING_PERCENTAGE_COMMA : STR_EMPTY);
SetDParam(5, RoundRating(cargo_rating));
GetString(this->data[line_nr], GetString(this->data[line_nr],
STR_STATION_RATING_TOOLTIP_WAITUNITS, STR_STATION_RATING_TOOLTIP_WAITUNITS,
lastof(this->data[line_nr])); lastof(this->data[line_nr]));
@@ -2816,13 +2828,13 @@ public:
if (!_extra_cheats.station_rating.value) { if (!_extra_cheats.station_rating.value) {
// Statue // Statue
{
const auto statue_rating = GetStatueRating(st); const auto statue_rating = GetStatueRating(st);
if (statue_rating > 0 || detailed) {
SetDParam(0, STR_STATION_RATING_MAX_PERCENTAGE); SetDParam(0, detailed ? STR_STATION_RATING_MAX_PERCENTAGE : STR_EMPTY);
SetDParam(1, 10); SetDParam(1, 10);
SetDParam(2, (statue_rating > 0) ? STR_STATION_RATING_TOOLTIP_STATUE_YES : STR_STATION_RATING_TOOLTIP_STATUE_NO); SetDParam(2, (statue_rating > 0) ? STR_STATION_RATING_TOOLTIP_STATUE_YES : STR_STATION_RATING_TOOLTIP_STATUE_NO);
SetDParam(3, (statue_rating > 0) ? 10 : 0); SetDParam(3, detailed ? STR_STATION_RATING_PERCENTAGE_COMMA : STR_EMPTY);
SetDParam(4, (statue_rating > 0) ? 10 : 0);
GetString(this->data[line_nr], STR_STATION_RATING_TOOLTIP_STATUE, lastof(this->data[line_nr])); GetString(this->data[line_nr], STR_STATION_RATING_TOOLTIP_STATUE, lastof(this->data[line_nr]));
line_nr++; line_nr++;
@@ -2843,11 +2855,12 @@ public:
age_stage = 1; age_stage = 1;
} }
SetDParam(0, STR_STATION_RATING_MAX_PERCENTAGE); SetDParam(0, detailed ? STR_STATION_RATING_MAX_PERCENTAGE : STR_EMPTY);
SetDParam(1, 13); SetDParam(1, 13);
SetDParam(2, STR_STATION_RATING_TOOLTIP_AGE_0 + age_stage); SetDParam(2, STR_STATION_RATING_TOOLTIP_AGE_0 + age_stage);
SetDParam(3, ge->last_age); SetDParam(3, ge->last_age);
SetDParam(4, RoundRating(age_rating)); SetDParam(4, detailed ? STR_STATION_RATING_PERCENTAGE_COMMA : STR_EMPTY);
SetDParam(5, RoundRating(age_rating));
GetString(this->data[line_nr], STR_STATION_RATING_TOOLTIP_AGE, lastof(this->data[line_nr])); GetString(this->data[line_nr], STR_STATION_RATING_TOOLTIP_AGE, lastof(this->data[line_nr]));
line_nr++; line_nr++;
@@ -2857,9 +2870,11 @@ public:
total_rating = Clamp(total_rating, 0, 255); total_rating = Clamp(total_rating, 0, 255);
if (detailed) {
SetDParam(0, ToPercent8(total_rating)); SetDParam(0, ToPercent8(total_rating));
GetString(this->data[line_nr], STR_STATION_RATING_TOOLTIP_TOTAL_RATING, lastof(this->data[line_nr])); GetString(this->data[line_nr], STR_STATION_RATING_TOOLTIP_TOTAL_RATING, lastof(this->data[line_nr]));
line_nr++; line_nr++;
}
this->data[line_nr][0] = '\0'; this->data[line_nr][0] = '\0';
} }
@@ -2874,8 +2889,9 @@ public:
if (StrEmpty(this->data[i])) break; if (StrEmpty(this->data[i])) break;
uint width = GetStringBoundingBox(this->data[i]).width + WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT + 2; uint width = GetStringBoundingBox(this->data[i]).width + WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT + 2;
if (this->newgrf_rating_used && i >= 2 && i <= 4) if (this->newgrf_rating_used && i >= 2 && i <= 4) {
width += RATING_TOOLTIP_NEWGRF_INDENT; width += RATING_TOOLTIP_NEWGRF_INDENT;
}
size->width = std::max(size->width, width); size->width = std::max(size->width, width);
size->height += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL; size->height += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
} }

View File

@@ -5467,6 +5467,19 @@ strhelp = STR_CONFIG_SETTING_SHADED_TREES_ON_SLOPES_HELPTEXT
proc = RedrawScreen proc = RedrawScreen
cat = SC_BASIC cat = SC_BASIC
[SDTC_VAR]
var = gui.station_rating_tooltip_mode
type = SLE_UINT8
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
guiflags = SGF_MULTISTRING
def = 1
min = 0
max = 2
str = STR_CONFIG_SETTING_STATION_RATING_TOOLTIP_MODE
strhelp = STR_CONFIG_SETTING_STATION_RATING_TOOLTIP_MODE_HELPTEXT
strval = STR_CONFIG_SETTING_STATION_RATING_TOOLTIP_MODE_OFF
cat = SC_BASIC
; For the dedicated build we'll enable dates in logs by default. ; For the dedicated build we'll enable dates in logs by default.
[SDTC_BOOL] [SDTC_BOOL]
ifdef = DEDICATED ifdef = DEDICATED