Skip to content

Commit

Permalink
feat: Remote mods directory (#403)
Browse files Browse the repository at this point in the history
* feat: create remote mod directory

* feat: look for mods in remote mods directory
  • Loading branch information
Alystrasz authored Jan 30, 2023
1 parent 2c02e7b commit d418217
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
15 changes: 12 additions & 3 deletions NorthstarDLL/mods/modmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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)
{
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions NorthstarDLL/mods/modmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ class ModManager
};

fs::path GetModFolderPath();
fs::path GetRemoteModFolderPath();
fs::path GetCompiledAssetsPath();

extern ModManager* g_pModManager;

0 comments on commit d418217

Please sign in to comment.