1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-25 00:37:24 +02:00

Reworked mod handling in Launcher in order to unify code with lib

This commit is contained in:
Ivan Savenko
2024-11-12 20:00:21 +00:00
parent 4945370fe3
commit f8724b9558
24 changed files with 746 additions and 1127 deletions

View File

@ -203,7 +203,7 @@ std::vector<TModID> ModsPresetState::getActiveMods() const
for(const auto & activeMod : activeRootMods)
{
activeRootMods.push_back(activeMod);
allActiveMods.push_back(activeMod);
for(const auto & submod : getModSettings(activeMod))
if(submod.second)
@ -212,7 +212,7 @@ std::vector<TModID> ModsPresetState::getActiveMods() const
return allActiveMods;
}
ModsStorage::ModsStorage(const std::vector<TModID> & modsToLoad)
ModsStorage::ModsStorage(const std::vector<TModID> & modsToLoad, const std::vector<JsonNode> & repositoryList)
{
JsonNode coreModConfig(JsonPath::builtin("config/gameConfig.json"));
coreModConfig.setModScope(ModScope::scopeBuiltin());
@ -245,14 +245,21 @@ const ModDescription & ModsStorage::getMod(const TModID & fullID) const
}
ModManager::ModManager()
:ModManager(std::vector<JsonNode>())
{
}
ModManager::ModManager(const std::vector<JsonNode> & repositoryList)
: modsState(std::make_unique<ModsState>())
, modsPreset(std::make_unique<ModsPresetState>())
{
eraseMissingModsFromPreset();
//TODO: load only active mods & all their submods in game mode
modsStorage = std::make_unique<ModsStorage>(modsState->getAllMods(), repositoryList);
addNewModsToPreset();
std::vector<TModID> desiredModList = modsPreset->getActiveMods();
modsStorage = std::make_unique<ModsStorage>(desiredModList);
generateLoadOrder(desiredModList);
}
@ -273,6 +280,11 @@ const TModList & ModManager::getActiveMods() const
return activeMods;
}
const TModList & ModManager::getAllMods() const
{
return activeMods; //TODO
}
void ModManager::eraseMissingModsFromPreset()
{
const TModList & installedMods = modsState->getAllMods();
@ -383,6 +395,7 @@ void ModManager::generateLoadOrder(std::vector<TModID> modsToResolve)
break;
}
assert(!sortedValidMods.empty());
activeMods = sortedValidMods;
brokenMods = modsToResolve;
}