* Output value of a specific setting to the console * @param name Name of the setting to output its value * @param force_newgame force the newgame settings */
| 1968 | * @param force_newgame force the newgame settings |
| 1969 | */ |
| 1970 | void IConsoleGetSetting(std::string_view name, bool force_newgame) |
| 1971 | { |
| 1972 | const SettingDesc *sd = GetSettingFromName(name); |
| 1973 | /* Company settings are not in "list_settings", so don't try to read them. */ |
| 1974 | if (sd == nullptr || sd->flags.Test(SettingFlag::PerCompany)) { |
| 1975 | IConsolePrint(CC_ERROR, "'{}' is an unknown setting.", name); |
| 1976 | return; |
| 1977 | } |
| 1978 | |
| 1979 | const void *object = (_game_mode == GM_MENU || force_newgame) ? &_settings_newgame : &_settings_game; |
| 1980 | |
| 1981 | if (sd->IsStringSetting()) { |
| 1982 | IConsolePrint(CC_INFO, "Current value for '{}' is '{}'.", sd->GetName(), sd->AsStringSetting()->Read(object)); |
| 1983 | } else if (sd->IsIntSetting()) { |
| 1984 | std::string value = sd->FormatValue(object); |
| 1985 | const IntSettingDesc *int_setting = sd->AsIntSetting(); |
| 1986 | auto [min_val, max_val] = int_setting->GetRange(); |
| 1987 | auto def_val = int_setting->GetDefaultValue(); |
| 1988 | IConsolePrint(CC_INFO, "Current value for '{}' is '{}' (min: {}{}, max: {}, def: {}).", |
| 1989 | sd->GetName(), value, sd->flags.Test(SettingFlag::GuiZeroIsSpecial) ? "(0) " : "", min_val, max_val, def_val); |
| 1990 | } |
| 1991 | } |
| 1992 | |
| 1993 | static void IConsoleListSettingsTable(const SettingTable &table, std::string_view prefilter) |
| 1994 | { |
no test coverage detected