Add: store base graphics parameters in openttd.cfg.

This commit is contained in:
frosch
2023-10-02 14:37:43 +02:00
committed by frosch
parent f09fda1ff0
commit de3f29d7b2
7 changed files with 50 additions and 0 deletions

View File

@@ -999,6 +999,20 @@ static void GraphicsSetLoadConfig(IniFile &ini)
if (const IniItem *item = group->GetItem("shortname"); item != nullptr && item->value && item->value->size() == 8) {
BaseGraphics::ini_data.shortname = BSWAP32(std::strtoul(item->value->c_str(), nullptr, 16));
}
if (const IniItem *item = group->GetItem("extra_version"); item != nullptr && item->value) BaseGraphics::ini_data.extra_version = std::strtoul(item->value->c_str(), nullptr, 10);
if (const IniItem *item = group->GetItem("extra_params"); item != nullptr && item->value) {
auto &extra_params = BaseGraphics::ini_data.extra_params;
extra_params.resize(lengthof(GRFConfig::param));
int count = ParseIntList(item->value->c_str(), &extra_params.front(), extra_params.size());
if (count < 0) {
SetDParamStr(0, BaseGraphics::ini_data.name);
ShowErrorMessage(STR_CONFIG_ERROR, STR_CONFIG_ERROR_ARRAY, WL_CRITICAL);
count = 0;
}
extra_params.resize(count);
}
}
}
@@ -1187,6 +1201,12 @@ static void GraphicsSetSaveConfig(IniFile &ini)
group.GetOrCreateItem("name").SetValue(used_set->name);
group.GetOrCreateItem("shortname").SetValue(fmt::format("{:08X}", BSWAP32(used_set->shortname)));
const GRFConfig *extra_cfg = used_set->GetExtraConfig();
if (extra_cfg != nullptr && extra_cfg->num_params > 0) {
group.GetOrCreateItem("extra_version").SetValue(fmt::format("{}", extra_cfg->version));
group.GetOrCreateItem("extra_params").SetValue(GRFBuildParamList(extra_cfg));
}
}
/* Save a GRF configuration to the given group name */