mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Cleanup
This commit is contained in:
@@ -590,33 +590,21 @@ void RandomMapTab::saveOptions(const CMapGenOptions & options)
|
|||||||
|
|
||||||
void RandomMapTab::loadOptions()
|
void RandomMapTab::loadOptions()
|
||||||
{
|
{
|
||||||
// FIXME: Potential leak?
|
|
||||||
auto options = new CMapGenOptions();
|
|
||||||
|
|
||||||
|
|
||||||
auto rmgSettings = persistentStorage["rmg"]["rmg"];
|
auto rmgSettings = persistentStorage["rmg"]["rmg"];
|
||||||
if (!rmgSettings.Struct().empty())
|
if (!rmgSettings.Struct().empty())
|
||||||
{
|
{
|
||||||
|
mapGenOptions.reset(new CMapGenOptions());
|
||||||
JsonDeserializer handler(nullptr, rmgSettings);
|
JsonDeserializer handler(nullptr, rmgSettings);
|
||||||
handler.serializeStruct("lastSettings", *options);
|
handler.serializeStruct("lastSettings", *mapGenOptions);
|
||||||
|
|
||||||
// FIXME: Regenerate players, who are not saved
|
|
||||||
mapGenOptions.reset(options);
|
|
||||||
// Will check template and set other options as well
|
// Will check template and set other options as well
|
||||||
setTemplate(mapGenOptions->getMapTemplate());
|
setTemplate(mapGenOptions->getMapTemplate());
|
||||||
if(auto w = widget<ComboBox>("templateList"))
|
if(auto w = widget<ComboBox>("templateList"))
|
||||||
{
|
{
|
||||||
// FIXME: Private function, need id
|
|
||||||
w->setItem(mapGenOptions->getMapTemplate());
|
w->setItem(mapGenOptions->getMapTemplate());
|
||||||
logGlobal->warn("Set RMG template on drop-down list");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Else? Set default
|
|
||||||
logGlobal->warn("Loaded previous RMG settings");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
logGlobal->warn("Did not load previous RMG settings");
|
|
||||||
}
|
}
|
||||||
updateMapInfoByHost();
|
updateMapInfoByHost();
|
||||||
|
|
||||||
|
// TODO: Save & load difficulty?
|
||||||
}
|
}
|
||||||
@@ -837,23 +837,13 @@ void CMapGenOptions::serializeJson(JsonSerializeFormat & handler)
|
|||||||
handler.serializeString("templateName", templateName);
|
handler.serializeString("templateName", templateName);
|
||||||
if(!handler.saving)
|
if(!handler.saving)
|
||||||
{
|
{
|
||||||
// FIXME: doesn't load correctly? Name is "Jebus Cross"
|
|
||||||
setMapTemplate(templateName);
|
setMapTemplate(templateName);
|
||||||
if (mapTemplate)
|
|
||||||
{
|
|
||||||
logGlobal->warn("Loaded previous RMG template");
|
|
||||||
// FIXME: Update dropdown menu
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
logGlobal->warn("Failed to deserialize previous map template");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handler.serializeIdArray("roads", enabledRoads);
|
handler.serializeIdArray("roads", enabledRoads);
|
||||||
//TODO: Serialize CMapGenOptions::CPlayerSettings ? This won't b saved between sessions
|
|
||||||
if (!handler.saving)
|
if (!handler.saving)
|
||||||
{
|
{
|
||||||
|
// Player settings won't be saved
|
||||||
resetPlayersMap();
|
resetPlayersMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user