diff options
| author | SulfurNitride <SulfurNitride@users.noreply.github.com> | 2026-02-14 02:45:12 -0600 |
|---|---|---|
| committer | SulfurNitride <SulfurNitride@users.noreply.github.com> | 2026-02-14 02:45:25 -0600 |
| commit | 817e8f5cd26739c69d930d21cd9dc4c0b6e4984e (patch) | |
| tree | 52aed11d6751bb7d20b06acf197d56fac113203d /libs/installer_fomod_plus/installer/lib/FlagMap.h | |
| parent | 51a9f8f197727f00896e5de44569b098923527dd (diff) | |
Add FUSE external mapping support, BG3/Oblivion Remastered fixes, fomod-plus and NaK integration
FUSE VFS now deploys non-data-dir mod mappings (Paks, OBSE, UE4SS, etc.)
via real symlinks and injects file-level data-dir mappings (plugins.txt,
loadorder.txt) into the VFS tree. Fixes game launches for Oblivion
Remastered (Root Builder path resolution, script extender support) and
BG3 (Wine prefix documents directory, file mapper symlinks on Linux).
Vendors mo2-fomod-plus plugin and NaK crate for FOMOD installer and
game finder/runtime support.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'libs/installer_fomod_plus/installer/lib/FlagMap.h')
| -rw-r--r-- | libs/installer_fomod_plus/installer/lib/FlagMap.h | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/libs/installer_fomod_plus/installer/lib/FlagMap.h b/libs/installer_fomod_plus/installer/lib/FlagMap.h new file mode 100644 index 0000000..4959cec --- /dev/null +++ b/libs/installer_fomod_plus/installer/lib/FlagMap.h @@ -0,0 +1,113 @@ +#pragma once + +#include "ViewModels.h" +#include "stringutil.h" + +#include <ranges> +#include <string> +#include <unordered_map> + +using Flag = std::pair<std::string, std::string>; +using FlagList = std::vector<Flag>; + +class FlagMap { +public: + + [[nodiscard]] std::vector<std::shared_ptr<PluginViewModel>> getPluginsSettingFlag(const std::string& key, const std::string& value) const + { + std::vector<std::shared_ptr<PluginViewModel>> result; + for (const auto& [plugin, theseFlags] : flags) { + for (const auto& [fst, snd] : theseFlags) { + if (toLower(fst) == toLower(key) && snd == value) { + result.emplace_back(plugin); + } + } + } + return result; + } + + /** + * + * @param key The flag key + * @return A list of flags currently set in this map with the given key. The list is ordered by step descending, then plugin ascending. + * So if steps 1, 2, and 3 set flag X in their first two plugins, it'll be ordered [3:1, 3:2, 2:1, 2:2, 1:2, 1:1] + */ + [[nodiscard]] FlagList getFlagsByKey(const std::string& key) const + { + FlagList result; + std::vector<std::pair<int, std::shared_ptr<PluginViewModel>>> orderedPlugins; + + // Collect all plugins with their stepIndex and ownIndex + for (const auto& plugin : flags | std::views::keys) { + orderedPlugins.emplace_back(plugin->getStepIndex(), plugin); + } + + // Sort plugins by stepIndex and ownIndex, stepIndex descending and ownIndex ascending + // TODO: Might need group sorting too. How can I just do the natural order?? + std::ranges::sort(orderedPlugins, [](const auto& a, const auto& b) { + return a.first > b.first || (a.first == b.first && a.second->getOwnIndex() < b.second->getOwnIndex()); + }); + + // Collect flags in the sorted order + for (const auto& plugin : orderedPlugins | std::views::values) { + for (const auto& flag : flags.at(plugin)) { + if (toLower(flag.first) == toLower(key)) { + result.emplace_back(flag); + } + } + } + return result; + } + + void setFlagsForPlugin(PluginRef plugin) + { + // Don't clutter the map with empty key-vals + if (plugin->getConditionFlags().empty()) { + return; + } + unsetFlagsForPlugin(plugin); + + FlagList flagList; + for (const auto& conditionFlag : plugin->getConditionFlags()) { + flagList.emplace_back(toLower(conditionFlag.name), conditionFlag.value); + } + flags[plugin] = flagList; + } + + void unsetFlagsForPlugin(PluginRef plugin) + { + if (flags.contains(plugin)) { + flags.erase(plugin); + } + } + + std::string toString() + { + auto result = std::string(); + result += "FlagMap:\n"; + + for (const auto& [plugin, theseFlags] : flags) { + result += plugin->getName() + " ["; + for (const auto& [fst, snd] : theseFlags) { + result += fst + ": " + snd + ", "; + } + result.erase(result.size() - 2); + result += "]\n"; + } + return result; + } + + void clearAll() + { + flags.clear(); + } + + [[nodiscard]] size_t getFlagCount() const + { + return flags.size(); + } + + +private: + std::unordered_map<std::shared_ptr<PluginViewModel>, FlagList> flags; +}; |
