diff options
| author | Malkierian <malkierian@gmail.com> | 2025-11-03 18:48:48 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-03 18:48:48 -0700 |
| commit | f015a1b339c8ecb53e6d9b4e9347e2d13d739837 (patch) | |
| tree | 321c0c2a479ecc835522dae286e2059bab4b8b8b | |
| parent | b2090dcf838b6f2e30efacd61f6c603fd97b92bd (diff) | |
Apply expected lexicographical sort to initial and new mod addition list. (#5904)
| -rw-r--r-- | soh/soh/Enhancements/mod_menu.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/soh/soh/Enhancements/mod_menu.cpp b/soh/soh/Enhancements/mod_menu.cpp index 9e3fda114..e60eee7e9 100644 --- a/soh/soh/Enhancements/mod_menu.cpp +++ b/soh/soh/Enhancements/mod_menu.cpp @@ -55,6 +55,7 @@ void SetEnabledModsCVarValue() { } CVarSetString(CVAR_ENABLED_MODS_NAME, s.c_str()); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } void AfterModChange() { @@ -128,8 +129,9 @@ void UpdateModFiles(bool init = false, bool reset = false) { disabledModFiles.clear(); unsupportedFiles.clear(); filePaths.clear(); - std::string modsPath = Ship::Context::LocateFileAcrossAppDirs("mods", appShortName); bool changed = false; + std::string modsPath = Ship::Context::LocateFileAcrossAppDirs("mods", appShortName); + std::map<std::string, std::string> tempMods; if (modsPath.length() > 0 && std::filesystem::exists(modsPath)) { std::vector<std::filesystem::path> enabledFiles; if (std::filesystem::is_directory(modsPath)) { @@ -147,11 +149,17 @@ void UpdateModFiles(bool init = false, bool reset = false) { bool enabled = std::find(enabledModFiles.begin(), enabledModFiles.end(), filename) != enabledModFiles.end(); if (!enabled) { - enabledModFiles.push_back(filename); - changed = true; + tempMods.emplace(p.path().lexically_normal().generic_string(), filename); } filePaths.emplace(filename, p.path()); } + if (tempMods.size() > 0) { + changed = true; + for (auto [path, name] : tempMods) { + enabledModFiles.push_back(name); + } + tempMods.clear(); + } if (init) { std::vector<std::string> enabledTemp(enabledModFiles); for (std::string mod : enabledTemp) { @@ -159,13 +167,14 @@ void UpdateModFiles(bool init = false, bool reset = false) { GetArchiveManager()->AddArchive(filePaths.at(mod).generic_string()); } else { enabledModFiles.erase(std::find(enabledModFiles.begin(), enabledModFiles.end(), mod)); + changed = true; } } } } - } - if (changed) { - SetEnabledModsCVarValue(); + if (changed) { + SetEnabledModsCVarValue(); + } } } |
