From 20dc4401c5ae6001aa064911c1e5de0d57642ee4 Mon Sep 17 00:00:00 2001 From: iwubcode Date: Fri, 27 Jan 2023 18:35:05 -0600 Subject: [PATCH] VideoCommon: pass a graphics mod base path to the graphics mod, so it can lookup other relative files if necessary --- .../GraphicsModSystem/Runtime/GraphicsModActionFactory.cpp | 3 ++- .../GraphicsModSystem/Runtime/GraphicsModActionFactory.h | 3 ++- .../GraphicsModSystem/Runtime/GraphicsModManager.cpp | 6 +++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModActionFactory.cpp b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModActionFactory.cpp index 5eaac88c25..7b97155d8a 100644 --- a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModActionFactory.cpp +++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModActionFactory.cpp @@ -10,7 +10,8 @@ namespace GraphicsModActionFactory { -std::unique_ptr Create(std::string_view name, const picojson::value& json_data) +std::unique_ptr Create(std::string_view name, const picojson::value& json_data, + std::string_view path) { if (name == "print") { diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModActionFactory.h b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModActionFactory.h index 3c9cc6d6a7..7709d75617 100644 --- a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModActionFactory.h +++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModActionFactory.h @@ -12,5 +12,6 @@ namespace GraphicsModActionFactory { -std::unique_ptr Create(std::string_view name, const picojson::value& json_data); +std::unique_ptr Create(std::string_view name, const picojson::value& json_data, + std::string_view path); } diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.cpp b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.cpp index 8e381cdd87..a100801e8b 100644 --- a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.cpp +++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.cpp @@ -8,6 +8,7 @@ #include #include "Common/Logging/Log.h" +#include "Common/StringUtil.h" #include "Common/VariantUtil.h" #include "Core/ConfigManager.h" @@ -198,7 +199,10 @@ void GraphicsModManager::Load(const GraphicsModGroupConfig& config) const auto create_action = [](const std::string_view& action_name, const picojson::value& json_data, GraphicsModConfig mod_config) -> std::unique_ptr { - auto action = GraphicsModActionFactory::Create(action_name, json_data); + std::string base_path; + SplitPath(mod_config.GetAbsolutePath(), &base_path, nullptr, nullptr); + + auto action = GraphicsModActionFactory::Create(action_name, json_data, base_path); if (action == nullptr) { return nullptr;