Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
9e1dee2
feat: display a warning message if no mod.json file was found in mod …
Alystrasz Feb 4, 2023
e9059ab
feat: don't display error messages with hidden directories (hello Gecko)
Alystrasz Feb 4, 2023
f5e816c
refactor: remove useless import
Alystrasz Feb 4, 2023
c0e44c9
fix: display error message when mod.json is located at the wrong loca…
Alystrasz Feb 5, 2023
d200783
style: format
Alystrasz Feb 5, 2023
c0d09ef
Merge branch 'main' into feat/bad-mod-formatting-warnings
Alystrasz Feb 6, 2023
80d8dba
Merge branch 'main' into feat/bad-mod-formatting-warnings
Alystrasz Feb 7, 2023
0782d62
Merge branch 'main' into feat/bad-mod-formatting-warnings
Alystrasz Feb 26, 2023
8b2ebf3
expose incorrect installs to UI and fix typing
uniboi Feb 26, 2023
bb05dd4
Merge pull request #3 from uniboi/format-warnings-2
Alystrasz Feb 26, 2023
d107ee8
style: format
Alystrasz Feb 26, 2023
da26b57
Merge branch 'main' into feat/bad-mod-formatting-warnings
Alystrasz Mar 30, 2023
364da35
include path and mod name in sq api
uniboi Apr 3, 2023
d8ccc10
Merge branch 'main' into feat/bad-mod-formatting-warnings
Alystrasz May 4, 2023
cb69bef
Merge branch 'main' of https://github.com/R2Northstar/NorthstarLaunch…
uniboi May 7, 2023
42c0888
use structs for the script mod menu
uniboi May 7, 2023
f119831
Merge branch 'feat/bad-mod-formatting-warnings' of https://github.com…
uniboi May 7, 2023
308f611
Merge branch 'feat/bad-mod-formatting-warnings' into bad-mod-info
uniboi May 7, 2023
0abbdc6
Merge branch 'bad-mod-info' of github.com:uniboi/NorthstarLauncher in…
uniboi May 7, 2023
d0f9b3a
remove duplicate NSGetInvalidMods definition
uniboi May 7, 2023
3b99616
formatting
uniboi May 7, 2023
65d9563
Merge pull request #4 from uniboi/bad-mod-info
Alystrasz May 9, 2023
ed8baa9
Merge branch 'main' into feat/bad-mod-formatting-warnings
Alystrasz Jun 10, 2023
25847b4
refactor: use `rdbuf` to read mod json file
Alystrasz Jun 10, 2023
0cfdd68
Merge branch 'main' into feat/bad-mod-formatting-warnings
Alystrasz Jun 23, 2023
1866179
Merge branch 'main' into feat/bad-mod-formatting-warnings
Alystrasz Jul 16, 2023
cf07205
Merge branch 'main' into feat/bad-mod-formatting-warnings
Alystrasz Jul 22, 2023
a739756
Merge branch 'main' into feat/bad-mod-formatting-warnings
Alystrasz Aug 3, 2023
1f206d5
Merge branch 'main' into feat/bad-mod-formatting-warnings
Alystrasz Oct 6, 2023
47a5c79
Merge branch 'main' into feat/bad-mod-formatting-warnings
GeckoEidechse Oct 10, 2023
226666c
Merge branch 'main' into feat/bad-mod-formatting-warnings
ASpoonPlaysGames Oct 20, 2023
e398b5c
refactor: export manifest location checking to dedicated function
Alystrasz Oct 22, 2023
0d6b624
feat: verify mods in packages directory
Alystrasz Oct 22, 2023
4ed6c7a
fix: do not iterate classicModsDir twice
Alystrasz Oct 22, 2023
31497ab
build: restore scriptmodmenu.cpp to main branch state
Alystrasz Oct 22, 2023
31210de
fix: make VerifyModManifestLocation abort if input is not a directory
Alystrasz Oct 22, 2023
be7deff
Merge branch 'main' into feat/bad-mod-formatting-warnings
Alystrasz Oct 23, 2023
73f444e
Merge branch 'main' into feat/bad-mod-formatting-warnings
Alystrasz Nov 11, 2023
9621d52
Merge branch 'main' into feat/bad-mod-formatting-warnings
Alystrasz Nov 7, 2024
233054f
style: apply clang formatting
Alystrasz Nov 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions primedev/mods/modmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,40 @@ auto ModConCommandCallback(const CCommand& command)
};
}

void ModManager::VerifyModManifestLocation(fs::directory_entry modDir)
{
if (!fs::is_directory(modDir))
{
return;
}

std::string filename = modDir.path().filename().generic_string().c_str();
// Don't display an error for hidden directories
if (filename.at(0) == '.')
return;

for (fs::directory_entry subdir : fs::recursive_directory_iterator(modDir.path()))
{
fs::path modPath = subdir.path() / "mod.json";
if (fs::exists(modPath))
{
spdlog::warn(
"mod.json file for directory {} is located at the wrong location ({}).",
modDir.path().generic_string().c_str(),
subdir.path().generic_string().c_str());

// read mod json file
std::ifstream jsonStream(modPath);
std::stringstream jsonStringStream;
jsonStringStream << jsonStream.rdbuf();
jsonStream.close();

std::shared_ptr<Mod> mod = std::shared_ptr<Mod>(new Mod(subdir, (char*)jsonStringStream.str().c_str()));
this->m_invalidMods.push_back(mod);
}
}
}

void ModManager::LoadMods()
{
if (m_bHasLoadedMods)
Expand Down Expand Up @@ -642,9 +676,17 @@ void ModManager::LoadMods()
std::filesystem::directory_iterator remoteModsDir = fs::directory_iterator(GetRemoteModFolderPath());
std::filesystem::directory_iterator thunderstoreModsDir = fs::directory_iterator(GetThunderstoreModFolderPath());

this->m_invalidMods.clear();

for (fs::directory_entry dir : classicModsDir)
{
if (fs::exists(dir.path() / "mod.json"))
modDirs.push_back(dir.path());
else if (fs::is_directory(dir.path()))
{
VerifyModManifestLocation(dir);
}
}

// Special case for Thunderstore and remote mods directories
// Set up regex for `AUTHOR-MOD-VERSION` pattern
Expand All @@ -669,6 +711,10 @@ void ModManager::LoadMods()
{
modDirs.push_back(subDir.path());
}
else
{
VerifyModManifestLocation(subDir);
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions primedev/mods/modmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ class ModManager
std::vector<Mod> m_LoadedMods;
std::unordered_map<std::string, ModOverrideFile> m_ModFiles;
std::unordered_map<std::string, std::string> m_DependencyConstants;
std::vector<std::shared_ptr<Mod>> m_invalidMods;
std::unordered_set<std::string> m_PluginDependencyConstants;

public:
Expand All @@ -196,6 +197,9 @@ class ModManager
void TryBuildKeyValues(const char* filename);
void BuildPdef();
void BuildKBActionsList();

private:
void VerifyModManifestLocation(fs::directory_entry modDir);
};

fs::path GetModFolderPath();
Expand Down