diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 1329a1a668..c13095e73c 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -3239,6 +3239,12 @@ void ShowIndustryCargoesWindow() ShowIndustryCargoesWindow(NUM_INDUSTRYTYPES); } +enum DisplayStockpiledCargoesMode : uint8 { + DSCM_OFF, + DSCM_REQUIRED, + DSCM_STOCKPILED +}; + /** * Fills given data buffer with a string of characters that describe given industry, to be used to display a tooltip, when hovering over the industry tile. * @param tile Index of the industry tile. @@ -3248,6 +3254,10 @@ void ShowIndustryCargoesWindow() */ bool GetIndustryTooltipString(const TileIndex tile, char *buffer_position, const char *buffer_tail) { + if (!_settings_client.gui.industry_tooltip_show || + !(_settings_client.gui.industry_tooltip_show_name || _settings_client.gui.industry_tooltip_show_produced || + _settings_client.gui.industry_tooltip_show_required || _settings_client.gui.industry_tooltip_show_stockpiled != DSCM_OFF)) return false; + const Industry *industry = Industry::GetByTile(tile); const IndustrySpec *industry_spec = GetIndustrySpec(industry->type); @@ -3291,7 +3301,7 @@ bool GetIndustryTooltipString(const TileIndex tile, char *buffer_position, const bool isStockpileWithoutSuffix = suffix->display == CSD_CARGO_AMOUNT; bool isProperStockpileWithoutSuffix = isStockpileWithoutSuffix && stockpiling; // If callback 37 fails, the result is interpreted as a stockpile, for some reason. if (isStockpileWithSuffix || isProperStockpileWithoutSuffix) { - if (_settings_client.gui.industry_tooltip_show_stockpiled || !_settings_client.gui.industry_tooltip_show_stockpiled_as_required) continue; + if (_settings_client.gui.industry_tooltip_show_stockpiled != DSCM_REQUIRED) continue; } auto format = STR_INDUSTRY_VIEW_REQUIRED_TOOLTIP_NEXT; @@ -3321,7 +3331,7 @@ bool GetIndustryTooltipString(const TileIndex tile, char *buffer_position, const // Print out stockpiled cargo. - if (stockpiling && _settings_client.gui.industry_tooltip_show_stockpiled) { + if (stockpiling && _settings_client.gui.industry_tooltip_show_stockpiled == DSCM_STOCKPILED) { for (byte i = 0; i < accepted_cargo_count; ++i) { auto stockpiled_cargo = industry->accepts_cargo[i]; if (stockpiled_cargo == CT_INVALID) continue; diff --git a/src/lang/extra/english.txt b/src/lang/extra/english.txt index 4f786e3395..ff3b56ea2d 100644 --- a/src/lang/extra/english.txt +++ b/src/lang/extra/english.txt @@ -2174,6 +2174,10 @@ STR_CONFIG_SETTING_INDUSTRY_TOOLTIP_REQUIRED :Show required c STR_CONFIG_SETTING_INDUSTRY_TOOLTIP_REQUIRED_HELPTEXT :Show a list of cargoes required by industries in viewport tooltips when hovering over industry tiles. STR_CONFIG_SETTING_INDUSTRY_TOOLTIP_STOCKPILED :Show stockpiled cargoes in industry viewport tooltips: {STRING2} STR_CONFIG_SETTING_INDUSTRY_TOOLTIP_STOCKPILED_HELPTEXT :Show a list of cargoes stockpiled by industries in viewport tooltips when hovering over industry tiles. +STR_CONFIG_SETTING_INDUSTRY_TOOLTIP_STOCKPILED_OFF :Don't show +STR_CONFIG_SETTING_INDUSTRY_TOOLTIP_STOCKPILED_REQUIRED :Show in the list of required cargoes, if the latter is shown +STR_CONFIG_SETTING_INDUSTRY_TOOLTIP_STOCKPILED_STOCKPILED :Show as a list of amounts waiting to be processed + STR_CONFIG_SETTING_INDUSTRY_TOOLTIP_STOCKPILED_AS_REQUIRED :Show stockpiled cargoes as required in viewport tooltips: {STRING2} STR_CONFIG_SETTING_INDUSTRY_TOOLTIP_STOCKPILED_AS_REQUIRED_HELPTEXT:If normal display of stockpiled cargoes in viewport tooltips is disabled, then allow them to, at least, be displayed as required ones. STR_CONFIG_SETTING_INDUSTRY_TOOLTIP_PRODUCED :Show produced cargoes in industry viewport tooltips: {STRING2} diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 754bffcd96..fa30ccb1dc 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1982,7 +1982,6 @@ static SettingsContainer &GetSettingsTree() tooltips->Add(new ConditionallyHiddenSettingEntry("gui.industry_tooltip_show_name", []() -> bool { return !_settings_client.gui.industry_tooltip_show; })); tooltips->Add(new ConditionallyHiddenSettingEntry("gui.industry_tooltip_show_required", []() -> 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_produced", []() -> bool { return !_settings_client.gui.industry_tooltip_show; })); tooltips->Add(new SettingEntry("gui.depot_tooltip_mode")); tooltips->Add(new SettingEntry("gui.station_viewport_tooltip_name")); diff --git a/src/settings_type.h b/src/settings_type.h index 2903bc054a..3c348a0659 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -144,8 +144,7 @@ struct GUISettings : public TimeSettings { bool industry_tooltip_show; ///< whether to display tooltips, when hovering over industry tiles. bool industry_tooltip_show_name; ///< whether to display the name of the industry, when hovering over one of its tiles. bool industry_tooltip_show_required; ///< whether to display cargoes required 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. + uint8 industry_tooltip_show_stockpiled; ///< whether and how to display cargoes stockpiled 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_viewport_tooltip_name; ///< Show the name of the station in a viewport tooltip. (0 = never, 1 = only if station names are hidden, 2 = always) diff --git a/src/table/settings/settings.ini b/src/table/settings/settings.ini index 83e115a01e..3755b0b3ff 100644 --- a/src/table/settings/settings.ini +++ b/src/table/settings/settings.ini @@ -4584,22 +4584,17 @@ flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC def = false str = STR_CONFIG_SETTING_INDUSTRY_TOOLTIP_REQUIRED strhelp = STR_CONFIG_SETTING_INDUSTRY_TOOLTIP_REQUIRED_HELPTEXT -post_cb = [](auto) { InvalidateWindowClassesData(WC_GAME_OPTIONS); } -[SDTC_BOOL] +[SDTC_VAR] var = gui.industry_tooltip_show_stockpiled -flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC -def = false +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_INDUSTRY_TOOLTIP_STOCKPILED strhelp = STR_CONFIG_SETTING_INDUSTRY_TOOLTIP_STOCKPILED_HELPTEXT -post_cb = [](auto) { InvalidateWindowClassesData(WC_GAME_OPTIONS); } - -[SDTC_BOOL] -var = gui.industry_tooltip_show_stockpiled_as_required -flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC -def = true -str = STR_CONFIG_SETTING_INDUSTRY_TOOLTIP_STOCKPILED_AS_REQUIRED -strhelp = STR_CONFIG_SETTING_INDUSTRY_TOOLTIP_STOCKPILED_AS_REQUIRED_HELPTEXT +strval = STR_CONFIG_SETTING_INDUSTRY_TOOLTIP_STOCKPILED_OFF [SDTC_BOOL] var = gui.industry_tooltip_show_produced diff --git a/src/viewport_gui.cpp b/src/viewport_gui.cpp index 21a7173772..2b3a81a0c2 100644 --- a/src/viewport_gui.cpp +++ b/src/viewport_gui.cpp @@ -264,10 +264,6 @@ bool GetIndustryTooltipString(TileIndex tile, char *buffer_position, const char void ShowIndustryTooltip(Window *w, const TileIndex tile, char *buffer_position, const char *buffer_tail) { - if (!_settings_client.gui.industry_tooltip_show || - !(_settings_client.gui.industry_tooltip_show_name || _settings_client.gui.industry_tooltip_show_produced || - _settings_client.gui.industry_tooltip_show_required || _settings_client.gui.industry_tooltip_show_stockpiled)) return; - if (!GetIndustryTooltipString(tile, buffer_position, buffer_tail)) return; SetDParamStr(0, buffer_position);