diff options
| author | iwubcode <iwubcode@users.noreply.github.com> | 2023-07-10 22:23:32 -0500 |
|---|---|---|
| committer | iwubcode <iwubcode@users.noreply.github.com> | 2023-08-20 18:53:27 -0500 |
| commit | 55061216855af89f21eee1174fa81d927bc94991 (patch) | |
| tree | fc765e787f93f1d34d9fc1ee7c598e528955d49f /Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.cpp | |
| parent | 6ea0d178026f105bc4a27344bb6b867aac6109e0 (diff) | |
VideoCommon: add support to graphics mod manager to load in assets and pass it to graphics actions
Diffstat (limited to 'Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.cpp | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.cpp b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.cpp index 3e4cd6e4e6..0d2f0fe347 100644 --- a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.cpp +++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.cpp @@ -13,7 +13,9 @@ #include "Core/ConfigManager.h" +#include "VideoCommon/Assets/DirectFilesystemAssetLibrary.h" #include "VideoCommon/GraphicsModSystem/Config/GraphicsMod.h" +#include "VideoCommon/GraphicsModSystem/Config/GraphicsModAsset.h" #include "VideoCommon/GraphicsModSystem/Config/GraphicsModGroup.h" #include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModActionFactory.h" #include "VideoCommon/TextureInfo.h" @@ -187,6 +189,8 @@ void GraphicsModManager::Load(const GraphicsModGroupConfig& config) const auto& mods = config.GetMods(); + auto filesystem_library = std::make_shared<VideoCommon::DirectFilesystemAssetLibrary>(); + std::map<std::string, std::vector<GraphicsTargetConfig>> group_to_targets; for (const auto& mod : mods) { @@ -208,6 +212,29 @@ void GraphicsModManager::Load(const GraphicsModGroupConfig& config) group_to_targets[internal_group].push_back(target); } } + + std::string base_path; + SplitPath(mod.GetAbsolutePath(), &base_path, nullptr, nullptr); + for (const GraphicsModAssetConfig& asset : mod.m_assets) + { + auto asset_map = asset.m_map; + for (auto& [k, v] : asset_map) + { + if (v.is_absolute()) + { + WARN_LOG_FMT(VIDEO, + "Specified graphics mod asset '{}' for mod '{}' has an absolute path, you " + "shouldn't release this to users.", + asset.m_name, mod.m_title); + } + else + { + v = std::filesystem::path{base_path} / v; + } + } + + filesystem_library->SetAssetIDMapData(asset.m_name, std::move(asset_map)); + } } for (const auto& mod : mods) @@ -215,12 +242,11 @@ void GraphicsModManager::Load(const GraphicsModGroupConfig& config) for (const GraphicsModFeatureConfig& feature : mod.m_features) { const auto create_action = - [](const std::string_view& action_name, const picojson::value& json_data, - GraphicsModConfig mod_config) -> std::unique_ptr<GraphicsModAction> { - std::string base_path; - SplitPath(mod_config.GetAbsolutePath(), &base_path, nullptr, nullptr); - - auto action = GraphicsModActionFactory::Create(action_name, json_data, base_path); + [filesystem_library](const std::string_view& action_name, + const picojson::value& json_data, + GraphicsModConfig mod_config) -> std::unique_ptr<GraphicsModAction> { + auto action = + GraphicsModActionFactory::Create(action_name, json_data, std::move(filesystem_library)); if (action == nullptr) { return nullptr; |
