diff --git a/launcher/modManager/cmodmanager.cpp b/launcher/modManager/cmodmanager.cpp index c8ae3dfc8..69cdb576b 100644 --- a/launcher/modManager/cmodmanager.cpp +++ b/launcher/modManager/cmodmanager.cpp @@ -65,13 +65,13 @@ QString detectModArchive(QString path, QString modName, std::vector CModManager::CModManager(CModList * modList) : modList(modList) { + modSettings = std::make_shared(); loadMods(); loadModSettings(); } void CModManager::loadModSettings() { - modSettings = std::make_shared(); modList->setModSettings(modSettings); } @@ -116,7 +116,9 @@ void CModManager::loadMods() json["storedLocally"].Bool() = true; mod = JsonUtils::toVariant(json); - localMods.insert(QString::fromUtf8(modname.c_str()).toLower(), mod); + QString modNameQt = QString::fromUtf8(modname.c_str()).toLower(); + localMods.insert(modNameQt, mod); + modSettings->registerNewMod(modNameQt, json["keepDisabled"].Bool()); } } modList->setLocalModList(localMods); diff --git a/launcher/modManager/modsettingsstorage.cpp b/launcher/modManager/modsettingsstorage.cpp index c5175eec0..0e07612c3 100644 --- a/launcher/modManager/modsettingsstorage.cpp +++ b/launcher/modManager/modsettingsstorage.cpp @@ -110,6 +110,22 @@ void ModSettingsStorage::setRootModActive(const QString & modName, bool on) JsonUtils::JsonToFile(settingsPath(), config); } +void ModSettingsStorage::registerNewMod(const QString & modName, bool keepDisabled) +{ + if (!modName.contains('.')) + return; + + QString rootModName = modName.section('.', 0, 0); + QString settingName = modName.section('.', 1); + + QVariantMap modSettings = getModSettings(rootModName); + + if (modSettings.contains(settingName)) + return; + + setModSettingActive(modName, !keepDisabled); +} + void ModSettingsStorage::setModSettingActive(const QString & modName, bool on) { QString presetName = getActivePreset(); diff --git a/launcher/modManager/modsettingsstorage.h b/launcher/modManager/modsettingsstorage.h index ddeb5c5e6..441c1922c 100644 --- a/launcher/modManager/modsettingsstorage.h +++ b/launcher/modManager/modsettingsstorage.h @@ -30,6 +30,8 @@ class ModSettingsStorage public: ModSettingsStorage(); + void registerNewMod(const QString & modName, bool keepDisabled); + void setModActive(const QString & modName, bool on); void setActivePreset(const QString & presetName);