summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/GraphicsModSystem/Config/GraphicsModAsset.cpp
diff options
context:
space:
mode:
authorAdmiral H. Curtiss <pikachu025@gmail.com>2023-08-22 02:18:40 +0200
committerGitHub <noreply@github.com>2023-08-22 02:18:40 +0200
commitdbe6a5f7e4caca71de9d9ba86916f82c0bc21683 (patch)
tree84fd8c6f664f1df62350f9d7b5aa9d110b6aee02 /Source/Core/VideoCommon/GraphicsModSystem/Config/GraphicsModAsset.cpp
parent3451cb1ca2583f9c2b02d0d216355047787c134b (diff)
parent55061216855af89f21eee1174fa81d927bc94991 (diff)
Merge pull request #11300 from iwubcode/custom-shaders
VideoCommon: add a graphics mod action that allows you to modify the game's base rendering
Diffstat (limited to 'Source/Core/VideoCommon/GraphicsModSystem/Config/GraphicsModAsset.cpp')
-rw-r--r--Source/Core/VideoCommon/GraphicsModSystem/Config/GraphicsModAsset.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Config/GraphicsModAsset.cpp b/Source/Core/VideoCommon/GraphicsModSystem/Config/GraphicsModAsset.cpp
new file mode 100644
index 0000000000..fb5572b3da
--- /dev/null
+++ b/Source/Core/VideoCommon/GraphicsModSystem/Config/GraphicsModAsset.cpp
@@ -0,0 +1,52 @@
+// Copyright 2023 Dolphin Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "VideoCommon/GraphicsModSystem/Config/GraphicsModAsset.h"
+
+#include "Common/Logging/Log.h"
+
+bool GraphicsModAssetConfig::DeserializeFromConfig(const picojson::object& obj)
+{
+ auto name_iter = obj.find("name");
+ if (name_iter == obj.end())
+ {
+ ERROR_LOG_FMT(VIDEO, "Failed to load mod configuration file, specified asset has no name");
+ return false;
+ }
+ if (!name_iter->second.is<std::string>())
+ {
+ ERROR_LOG_FMT(VIDEO, "Failed to load mod configuration file, specified asset has a name "
+ "that is not a string");
+ return false;
+ }
+ m_name = name_iter->second.to_str();
+
+ auto data_iter = obj.find("data");
+ if (data_iter == obj.end())
+ {
+ ERROR_LOG_FMT(VIDEO, "Failed to load mod configuration file, specified asset '{}' has no data",
+ m_name);
+ return false;
+ }
+ if (!data_iter->second.is<picojson::object>())
+ {
+ ERROR_LOG_FMT(VIDEO,
+ "Failed to load mod configuration file, specified asset '{}' has data "
+ "that is not an object",
+ m_name);
+ return false;
+ }
+ for (const auto& [key, value] : data_iter->second.get<picojson::object>())
+ {
+ if (!value.is<std::string>())
+ {
+ ERROR_LOG_FMT(VIDEO,
+ "Failed to load mod configuration file, specified asset '{}' has data "
+ "with a value for key '{}' that is not a string",
+ m_name, key);
+ }
+ m_map[key] = value.to_str();
+ }
+
+ return true;
+}