OpenTTD Source 20260206-master-g4d4e37dbf1
settings_func.h File Reference

Functions related to setting/changing the settings. More...

#include "company_type.h"
#include "string_type.h"
#include "newgrf_config.h"

Go to the source code of this file.

Functions

void IConsoleSetSetting (std::string_view name, std::string_view value, bool force_newgame=false)
void IConsoleSetSetting (std::string_view name, int32_t value)
void IConsoleGetSetting (std::string_view name, bool force_newgame=false)
 Output value of a specific setting to the console.
void IConsoleListSettings (std::string_view prefilter)
 List all settings and their value to the console.
void LoadFromConfig (bool minimal=false)
 Load the values from the configuration files.
void SaveToConfig ()
 Save the values to the configuration file.
void IniLoadWindowSettings (IniFile &ini, std::string_view grpname, WindowDesc *desc)
 Load a WindowDesc from config.
void IniSaveWindowSettings (IniFile &ini, std::string_view grpname, WindowDesc *desc)
 Save a WindowDesc to config.
StringList GetGRFPresetList ()
 Get the list of known NewGrf presets.
GRFConfigList LoadGRFPresetFromConfig (std::string_view config_name)
 Load a NewGRF configuration by preset-name.
void SaveGRFPresetToConfig (std::string_view config_name, GRFConfigList &config)
 Save a NewGRF configuration with a preset name.
void DeleteGRFPresetFromConfig (std::string_view config_name)
 Delete a NewGRF configuration by preset name.
void SetDefaultCompanySettings (CompanyID cid)
 Set the company settings for a new company to their default values.
void SyncCompanySettings ()
 Sync all company settings in a multiplayer game.

Detailed Description

Functions related to setting/changing the settings.

Definition in file settings_func.h.

Function Documentation

◆ DeleteGRFPresetFromConfig()

void DeleteGRFPresetFromConfig ( std::string_view config_name)

Delete a NewGRF configuration by preset name.

Parameters
config_nameName of the preset.

Definition at line 1592 of file settings.cpp.

References _config_file, IniLoadFile::RemoveGroup(), and IniFile::SaveToDisk().

Referenced by NewGRFWindow::OnClick().

◆ GetGRFPresetList()

StringList GetGRFPresetList ( )

Get the list of known NewGrf presets.

Returns
List of preset names.

Definition at line 1541 of file settings.cpp.

References _config_file, IniLoadFile::groups, and IniGroup::name.

Referenced by NewGRFWindow::OnClick(), NewGRFWindow::OnQueryTextFinished(), and SavePresetWindow::SavePresetWindow().

◆ IConsoleGetSetting()

void IConsoleGetSetting ( std::string_view name,
bool force_newgame )

◆ IConsoleListSettings()

void IConsoleListSettings ( std::string_view prefilter)

List all settings and their value to the console.

Parameters
prefilterIf not nullptr, only list settings with names that begin with prefilter prefix

Definition at line 2004 of file settings.cpp.

References CC_HELP, GenericSettingTables(), IConsolePrint(), PrivateSettingTables(), and SecretSettingTables().

◆ IConsoleSetSetting()

void IConsoleSetSetting ( std::string_view name,
std::string_view value,
bool force_newgame = false )

Definition at line 1922 of file settings.cpp.

◆ IniLoadWindowSettings()

void IniLoadWindowSettings ( IniFile & ini,
std::string_view grpname,
WindowDesc * desc )

Load a WindowDesc from config.

Parameters
iniIniFile handle to the ini file with the source data
grpnamecharacter string identifying the section-header of the ini file that will be parsed
descDestination WindowDesc

Definition at line 870 of file settings.cpp.

References IniLoadSettings().

Referenced by WindowDesc::LoadFromConfig().

◆ IniSaveWindowSettings()

void IniSaveWindowSettings ( IniFile & ini,
std::string_view grpname,
WindowDesc * desc )

Save a WindowDesc to config.

Parameters
iniIniFile handle to the ini file where the destination data is saved
grpnamecharacter string identifying the section-header of the ini file
descSource WindowDesc

Definition at line 881 of file settings.cpp.

References IniSaveSettings().

Referenced by WindowDesc::SaveToConfig().

◆ LoadFromConfig()

◆ LoadGRFPresetFromConfig()

GRFConfigList LoadGRFPresetFromConfig ( std::string_view config_name)

Load a NewGRF configuration by preset-name.

Parameters
config_nameName of the preset.
Returns
NewGRF configuration.
See also
GetGRFPresetList

Definition at line 1561 of file settings.cpp.

References _config_file, and GRFLoadConfig().

Referenced by NewGRFWindow::OnDropdownSelect().

◆ SaveGRFPresetToConfig()

void SaveGRFPresetToConfig ( std::string_view config_name,
GRFConfigList & config )

Save a NewGRF configuration with a preset name.

Parameters
config_nameName of the preset.
configNewGRF configuration to save.
See also
GetGRFPresetList

Definition at line 1578 of file settings.cpp.

References _config_file, and IniFile::SaveToDisk().

Referenced by NewGRFWindow::OnQueryTextFinished().

◆ SaveToConfig()

◆ SetDefaultCompanySettings()

void SetDefaultCompanySettings ( CompanyID cid)

Set the company settings for a new company to their default values.

Definition at line 1853 of file settings.cpp.

References _current_company, SettingDesc::AsIntSetting(), IntSettingDesc::GetDefaultValue(), GetSettingDesc(), IntSettingDesc::MakeValueValidAndWrite(), and CompanyProperties::settings.

Referenced by DoStartupNewCompany().

◆ SyncCompanySettings()

void SyncCompanySettings ( )

Sync all company settings in a multiplayer game.

Definition at line 1866 of file settings.cpp.

References _current_company, _local_company, _settings_client, SettingDesc::AsIntSetting(), SettingDesc::GetName(), GetSettingDesc(), and IntSettingDesc::Read().

Referenced by CmdCompanyCtrl().