1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

Merge pull request #5108 from IvanSavenko/preset_import

[1.6.1?] Mod preset import/export
This commit is contained in:
Ivan Savenko
2024-12-21 15:57:33 +02:00
committed by GitHub
8 changed files with 165 additions and 15 deletions

View File

@@ -857,6 +857,12 @@ void CModListView::installMods(QStringList archives)
modNames.push_back(modName);
}
if (!activatingPreset.isEmpty())
{
modStateModel->activatePreset(activatingPreset);
activatingPreset.clear();
}
// uninstall old version of mod, if installed
for(QString mod : modNames)
{
@@ -1147,3 +1153,25 @@ QString CModListView::getActivePreset() const
{
return modStateModel->getActivePreset();
}
JsonNode CModListView::exportCurrentPreset() const
{
return modStateModel->exportCurrentPreset();
}
void CModListView::importPreset(const JsonNode & data)
{
const auto & [presetName, modList] = modStateModel->importPreset(data);
if (modList.empty())
{
modStateModel->activatePreset(presetName);
modStateModel->reloadLocalState();
}
else
{
activatingPreset = presetName;
for (const auto & modID : modList)
doInstallMod(modID);
}
}