From d418217e0ac6ada2217d5e5171f6baa3707380c9 Mon Sep 17 00:00:00 2001 From: Rémy Raes Date: Mon, 30 Jan 2023 11:44:37 +0100 Subject: feat: Remote mods directory (#403) * feat: create remote mod directory * feat: look for mods in remote mods directory --- NorthstarDLL/mods/modmanager.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'NorthstarDLL/mods/modmanager.cpp') diff --git a/NorthstarDLL/mods/modmanager.cpp b/NorthstarDLL/mods/modmanager.cpp index a47aa854..38966236 100644 --- a/NorthstarDLL/mods/modmanager.cpp +++ b/NorthstarDLL/mods/modmanager.cpp @@ -354,6 +354,7 @@ void ModManager::LoadMods() // ensure dirs exist fs::remove_all(GetCompiledAssetsPath()); fs::create_directories(GetModFolderPath()); + fs::create_directories(GetRemoteModFolderPath()); m_DependencyConstants.clear(); @@ -374,9 +375,13 @@ void ModManager::LoadMods() } // get mod directories - for (fs::directory_entry dir : fs::directory_iterator(GetModFolderPath())) - if (fs::exists(dir.path() / "mod.json")) - modDirs.push_back(dir.path()); + std::filesystem::directory_iterator classicModsDir = fs::directory_iterator(GetModFolderPath()); + std::filesystem::directory_iterator remoteModsDir = fs::directory_iterator(GetRemoteModFolderPath()); + + for (std::filesystem::directory_iterator modIterator : {classicModsDir, remoteModsDir}) + for (fs::directory_entry dir : modIterator) + if (fs::exists(dir.path() / "mod.json")) + modDirs.push_back(dir.path()); for (fs::path modDir : modDirs) { @@ -805,6 +810,10 @@ fs::path GetModFolderPath() { return fs::path(GetNorthstarPrefix() + MOD_FOLDER_SUFFIX); } +fs::path GetRemoteModFolderPath() +{ + return fs::path(GetNorthstarPrefix() + REMOTE_MOD_FOLDER_SUFFIX); +} fs::path GetCompiledAssetsPath() { return fs::path(GetNorthstarPrefix() + COMPILED_ASSETS_SUFFIX); -- cgit v1.2.3