mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-17 16:30:30 +02:00
Move Section out of IniFile so it can be forward declared. Unlocked further improvements to build speed.
This commit is contained in:
1 parent
72d5b29434
commit
5ec2da0f2d
20 files changed
+186
-170
No files matched your search
+21
-21
@@ -203,7 +203,7 @@ struct ConfigSetting {
|
||||
return type_ != TYPE_TERMINATOR;
|
||||
}
|
||||
|
||||
bool Get(IniFile::Section *section) {
|
||||
bool Get(Section *section) {
|
||||
switch (type_) {
|
||||
case TYPE_BOOL:
|
||||
if (cb_.b) {
|
||||
@@ -256,7 +256,7 @@ struct ConfigSetting {
|
||||
}
|
||||
}
|
||||
|
||||
void Set(IniFile::Section *section) {
|
||||
void Set(Section *section) {
|
||||
if (!save_)
|
||||
return;
|
||||
|
||||
@@ -1108,9 +1108,9 @@ static ConfigSectionSettings sections[] = {
|
||||
{"Theme", themeSettings},
|
||||
};
|
||||
|
||||
static void IterateSettings(IniFile &iniFile, std::function<void(IniFile::Section *section, ConfigSetting *setting)> func) {
|
||||
static void IterateSettings(IniFile &iniFile, std::function<void(Section *section, ConfigSetting *setting)> func) {
|
||||
for (size_t i = 0; i < ARRAY_SIZE(sections); ++i) {
|
||||
IniFile::Section *section = iniFile.GetOrCreateSection(sections[i].section);
|
||||
Section *section = iniFile.GetOrCreateSection(sections[i].section);
|
||||
for (auto setting = sections[i].settings; setting->HasMore(); ++setting) {
|
||||
func(section, setting);
|
||||
}
|
||||
@@ -1147,8 +1147,8 @@ std::map<std::string, std::pair<std::string, int>> GetLangValuesMapping() {
|
||||
langCodeMapping["CHINESE_TRADITIONAL"] = PSP_SYSTEMPARAM_LANGUAGE_CHINESE_TRADITIONAL;
|
||||
langCodeMapping["CHINESE_SIMPLIFIED"] = PSP_SYSTEMPARAM_LANGUAGE_CHINESE_SIMPLIFIED;
|
||||
|
||||
IniFile::Section *langRegionNames = mapping.GetOrCreateSection("LangRegionNames");
|
||||
IniFile::Section *systemLanguage = mapping.GetOrCreateSection("SystemLanguage");
|
||||
Section *langRegionNames = mapping.GetOrCreateSection("LangRegionNames");
|
||||
Section *systemLanguage = mapping.GetOrCreateSection("SystemLanguage");
|
||||
|
||||
for (size_t i = 0; i < keys.size(); i++) {
|
||||
std::string langName;
|
||||
@@ -1187,7 +1187,7 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
|
||||
// Continue anyway to initialize the config.
|
||||
}
|
||||
|
||||
IterateSettings(iniFile, [](IniFile::Section *section, ConfigSetting *setting) {
|
||||
IterateSettings(iniFile, [](Section *section, ConfigSetting *setting) {
|
||||
setting->Get(section);
|
||||
});
|
||||
|
||||
@@ -1195,7 +1195,7 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
|
||||
if (!File::Exists(currentDirectory))
|
||||
currentDirectory = "";
|
||||
|
||||
IniFile::Section *log = iniFile.GetOrCreateSection(logSectionName);
|
||||
Section *log = iniFile.GetOrCreateSection(logSectionName);
|
||||
|
||||
bool debugDefaults = false;
|
||||
#ifdef _DEBUG
|
||||
@@ -1203,7 +1203,7 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
|
||||
#endif
|
||||
LogManager::GetInstance()->LoadConfig(log, debugDefaults);
|
||||
|
||||
IniFile::Section *recent = iniFile.GetOrCreateSection("Recent");
|
||||
Section *recent = iniFile.GetOrCreateSection("Recent");
|
||||
recent->Get("MaxRecent", &iMaxRecent, 30);
|
||||
|
||||
// Fix issue from switching from uint (hex in .ini) to int (dec)
|
||||
@@ -1249,7 +1249,7 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
|
||||
}
|
||||
|
||||
// Check for an old dpad setting
|
||||
IniFile::Section *control = iniFile.GetOrCreateSection("Control");
|
||||
Section *control = iniFile.GetOrCreateSection("Control");
|
||||
float f;
|
||||
control->Get("DPadRadius", &f, 0.0f);
|
||||
if (f > 0.0f) {
|
||||
@@ -1338,13 +1338,13 @@ void Config::Save(const char *saveReason) {
|
||||
// Need to do this somewhere...
|
||||
bFirstRun = false;
|
||||
|
||||
IterateSettings(iniFile, [&](IniFile::Section *section, ConfigSetting *setting) {
|
||||
IterateSettings(iniFile, [&](Section *section, ConfigSetting *setting) {
|
||||
if (!bGameSpecific || !setting->perGame_) {
|
||||
setting->Set(section);
|
||||
}
|
||||
});
|
||||
|
||||
IniFile::Section *recent = iniFile.GetOrCreateSection("Recent");
|
||||
Section *recent = iniFile.GetOrCreateSection("Recent");
|
||||
recent->Set("MaxRecent", iMaxRecent);
|
||||
|
||||
for (int i = 0; i < iMaxRecent; i++) {
|
||||
@@ -1357,7 +1357,7 @@ void Config::Save(const char *saveReason) {
|
||||
}
|
||||
}
|
||||
|
||||
IniFile::Section *pinnedPaths = iniFile.GetOrCreateSection("PinnedPaths");
|
||||
Section *pinnedPaths = iniFile.GetOrCreateSection("PinnedPaths");
|
||||
pinnedPaths->Clear();
|
||||
for (size_t i = 0; i < vPinnedPaths.size(); ++i) {
|
||||
char keyName[64];
|
||||
@@ -1366,17 +1366,17 @@ void Config::Save(const char *saveReason) {
|
||||
}
|
||||
|
||||
if (!bGameSpecific) {
|
||||
IniFile::Section *postShaderSetting = iniFile.GetOrCreateSection("PostShaderSetting");
|
||||
Section *postShaderSetting = iniFile.GetOrCreateSection("PostShaderSetting");
|
||||
postShaderSetting->Clear();
|
||||
for (auto it = mPostShaderSetting.begin(), end = mPostShaderSetting.end(); it != end; ++it) {
|
||||
postShaderSetting->Set(it->first.c_str(), it->second);
|
||||
}
|
||||
}
|
||||
|
||||
IniFile::Section *control = iniFile.GetOrCreateSection("Control");
|
||||
Section *control = iniFile.GetOrCreateSection("Control");
|
||||
control->Delete("DPadRadius");
|
||||
|
||||
IniFile::Section *log = iniFile.GetOrCreateSection(logSectionName);
|
||||
Section *log = iniFile.GetOrCreateSection(logSectionName);
|
||||
if (LogManager::GetInstance())
|
||||
LogManager::GetInstance()->SaveConfig(log);
|
||||
|
||||
@@ -1614,16 +1614,16 @@ bool Config::saveGameConfig(const std::string &pGameId, const std::string &title
|
||||
|
||||
IniFile iniFile;
|
||||
|
||||
IniFile::Section *top = iniFile.GetOrCreateSection("");
|
||||
Section *top = iniFile.GetOrCreateSection("");
|
||||
top->AddComment(StringFromFormat("Game config for %s - %s", pGameId.c_str(), title.c_str()));
|
||||
|
||||
IterateSettings(iniFile, [](IniFile::Section *section, ConfigSetting *setting) {
|
||||
IterateSettings(iniFile, [](Section *section, ConfigSetting *setting) {
|
||||
if (setting->perGame_) {
|
||||
setting->Set(section);
|
||||
}
|
||||
});
|
||||
|
||||
IniFile::Section *postShaderSetting = iniFile.GetOrCreateSection("PostShaderSetting");
|
||||
Section *postShaderSetting = iniFile.GetOrCreateSection("PostShaderSetting");
|
||||
postShaderSetting->Clear();
|
||||
for (auto it = mPostShaderSetting.begin(), end = mPostShaderSetting.end(); it != end; ++it) {
|
||||
postShaderSetting->Set(it->first.c_str(), it->second);
|
||||
@@ -1653,7 +1653,7 @@ bool Config::loadGameConfig(const std::string &pGameId, const std::string &title
|
||||
mPostShaderSetting[it.first] = std::stof(it.second);
|
||||
}
|
||||
|
||||
IterateSettings(iniFile, [](IniFile::Section *section, ConfigSetting *setting) {
|
||||
IterateSettings(iniFile, [](Section *section, ConfigSetting *setting) {
|
||||
if (setting->perGame_) {
|
||||
setting->Get(section);
|
||||
}
|
||||
@@ -1671,7 +1671,7 @@ void Config::unloadGameConfig() {
|
||||
iniFile.Load(iniFilename_);
|
||||
|
||||
// Reload game specific settings back to standard.
|
||||
IterateSettings(iniFile, [](IniFile::Section *section, ConfigSetting *setting) {
|
||||
IterateSettings(iniFile, [](Section *section, ConfigSetting *setting) {
|
||||
if (setting->perGame_) {
|
||||
setting->Get(section);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user