From 02c22d71624e567a770b9faa352ed0da3c39104f Mon Sep 17 00:00:00 2001 From: GeckoEidechse Date: Fri, 5 Jul 2024 21:10:16 +0200 Subject: feat: Add support for manual mods folder --- primedev/mods/modmanager.cpp | 10 ++++++++++ primedev/mods/modmanager.h | 2 ++ 2 files changed, 12 insertions(+) (limited to 'primedev') diff --git a/primedev/mods/modmanager.cpp b/primedev/mods/modmanager.cpp index b2a7e713..90f54449 100644 --- a/primedev/mods/modmanager.cpp +++ b/primedev/mods/modmanager.cpp @@ -616,6 +616,7 @@ void ModManager::LoadMods() // ensure dirs exist fs::remove_all(GetCompiledAssetsPath()); fs::create_directories(GetCoreModFolderPath()); + fs::create_directories(GetManualModFolderPath()); fs::create_directories(GetThunderstoreLegacyModFolderPath()); fs::create_directories(GetRemoteModFolderPath()); @@ -639,6 +640,7 @@ void ModManager::LoadMods() // get mod directories std::filesystem::directory_iterator coreModsDir = fs::directory_iterator(GetCoreModFolderPath()); + std::filesystem::directory_iterator manualModsDir = fs::directory_iterator(GetManualModFolderPath()); std::filesystem::directory_iterator remoteModsDir = fs::directory_iterator(GetRemoteModFolderPath()); std::filesystem::directory_iterator thunderstoreModsDir = fs::directory_iterator(GetThunderstoreLegacyModFolderPath()); @@ -646,6 +648,10 @@ void ModManager::LoadMods() if (fs::exists(dir.path() / "mod.json")) modDirs.push_back(dir.path()); + for (fs::directory_entry dir : manualModsDir) + if (fs::exists(dir.path() / "mod.json")) + modDirs.push_back(dir.path()); + // Special case for Thunderstore and remote mods directories // Set up regex for `AUTHOR-MOD-VERSION` pattern std::regex pattern(R"(.*\\([a-zA-Z0-9_]+)-([a-zA-Z0-9_]+)-(\d+\.\d+\.\d+))"); @@ -1131,6 +1137,10 @@ fs::path GetCoreModFolderPath() { return fs::path(GetNorthstarPrefix() + CORE_MOD_FOLDER_SUFFIX); } +fs::path GetManualModFolderPath() +{ + return fs::path(GetNorthstarPrefix() + MANUAL_MOD_FOLDER_SUFFIX); +} fs::path GetThunderstoreLegacyModFolderPath() { return fs::path(GetNorthstarPrefix() + THUNDERSTORE_MOD_FOLDER_SUFFIX); diff --git a/primedev/mods/modmanager.h b/primedev/mods/modmanager.h index ace79e32..517b33a7 100644 --- a/primedev/mods/modmanager.h +++ b/primedev/mods/modmanager.h @@ -10,6 +10,7 @@ #include const std::string CORE_MOD_FOLDER_SUFFIX = "\\mods\\core"; +const std::string MANUAL_MOD_FOLDER_SUFFIX = "\\mods\\manual"; const std::string THUNDERSTORE_MOD_FOLDER_SUFFIX = "\\mods\\thunderstore-legacy"; const std::string REMOTE_MOD_FOLDER_SUFFIX = "\\runtime\\remote\\mods"; const fs::path MOD_OVERRIDE_DIR = "mod"; @@ -180,6 +181,7 @@ public: }; fs::path GetCoreModFolderPath(); +fs::path GetManualModFolderPath(); fs::path GetRemoteModFolderPath(); fs::path GetThunderstoreLegacyModFolderPath(); fs::path GetCompiledAssetsPath(); -- cgit v1.2.3