diff options
Diffstat (limited to 'NorthstarDLL/mods/modmanager.cpp')
-rw-r--r-- | NorthstarDLL/mods/modmanager.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/NorthstarDLL/mods/modmanager.cpp b/NorthstarDLL/mods/modmanager.cpp index b7194d04..982f5068 100644 --- a/NorthstarDLL/mods/modmanager.cpp +++ b/NorthstarDLL/mods/modmanager.cpp @@ -104,6 +104,7 @@ Mod::Mod(fs::path modDir, char* jsonBuf) ParseScripts(modJson); ParseLocalization(modJson); ParseDependencies(modJson); + ParsePluginDependencies(modJson); ParseInitScript(modJson); // A mod is remote if it's located in the remote mods folder @@ -483,6 +484,28 @@ void Mod::ParseDependencies(rapidjson_document& json) } } +void Mod::ParsePluginDependencies(rapidjson_document& json) +{ + if (!json.HasMember("PluginDependencies")) + return; + + if (!json["PluginDependencies"].IsArray()) + { + spdlog::warn("'PluginDependencies' field is not an object, skipping..."); + return; + } + + for (auto& name : json["PluginDependencies"].GetArray()) + { + if (!name.IsString()) + continue; + + spdlog::info("Plugin Constant {} defined by {}", name.GetString(), Name); + + PluginDependencyConstants.push_back(name.GetString()); + } +} + void Mod::ParseInitScript(rapidjson_document& json) { if (!json.HasMember("InitScript")) @@ -688,6 +711,11 @@ void ModManager::LoadMods() m_DependencyConstants.emplace(pair); } + for (std::string& dependency : mod.PluginDependencyConstants) + { + m_PluginDependencyConstants.insert(dependency); + } + if (m_bHasEnabledModsCfg && m_EnabledModsCfg.HasMember(mod.Name.c_str())) mod.m_bEnabled = m_EnabledModsCfg[mod.Name.c_str()].IsTrue(); else |