From 4dc9a61223373f774740307266e8fe1c9e570312 Mon Sep 17 00:00:00 2001 From: Almamu Date: Tue, 19 Aug 2025 19:26:39 +0200 Subject: [PATCH] chore: cleanup of properties, dynamic values and shader variables --- CMakeLists.txt | 13 +- .../Application/CWallpaperApplication.cpp | 2 + src/WallpaperEngine/Core/Core.cpp | 498 ------------------ src/WallpaperEngine/Core/Core.h | 46 -- .../Core/DynamicValues/CDynamicValue.h | 95 ---- .../Core/Projects/CProperty.cpp | 30 +- src/WallpaperEngine/Core/Projects/CProperty.h | 49 +- .../Core/Projects/CPropertyBoolean.cpp | 9 +- .../Core/Projects/CPropertyBoolean.h | 6 +- .../Core/Projects/CPropertyColor.cpp | 18 +- .../Core/Projects/CPropertyColor.h | 8 +- .../Core/Projects/CPropertyCombo.cpp | 19 +- .../Core/Projects/CPropertyCombo.h | 6 +- .../Core/Projects/CPropertySlider.cpp | 12 +- .../Core/Projects/CPropertySlider.h | 8 +- .../Core/Projects/CPropertyText.cpp | 10 +- .../Core/Projects/CPropertyText.h | 6 +- .../Data/Builders/UserSettingBuilder.h | 4 +- .../Data/Builders/VectorBuilder.h | 19 +- src/WallpaperEngine/Data/JSON.cpp | 1 + src/WallpaperEngine/Data/JSON.h | 24 +- .../Model/DynamicValue.cpp} | 382 ++++++++------ src/WallpaperEngine/Data/Model/DynamicValue.h | 105 ++++ src/WallpaperEngine/Data/Model/Types.h | 12 +- src/WallpaperEngine/Data/Model/UserSetting.h | 4 +- .../Data/Parsers/ProjectParser.cpp | 1 + src/WallpaperEngine/Data/Utils/SFINAE.h | 25 + src/WallpaperEngine/Render/CFBOProvider.h | 2 + .../Render/Objects/Effects/CPass.cpp | 2 +- .../Render/Objects/Effects/CPass.h | 2 +- src/WallpaperEngine/Render/Shaders/CShader.h | 1 - .../Render/Shaders/CShaderUnit.cpp | 56 +- .../Render/Shaders/CShaderUnit.h | 4 +- .../Shaders/Variables/CShaderVariable.h | 35 +- .../Variables/CShaderVariableFloat.cpp | 8 +- .../Shaders/Variables/CShaderVariableFloat.h | 3 +- .../Variables/CShaderVariableInteger.cpp | 10 +- .../Variables/CShaderVariableInteger.h | 5 +- .../Variables/CShaderVariableVector2.cpp | 8 +- .../Variables/CShaderVariableVector2.h | 3 +- .../Variables/CShaderVariableVector3.cpp | 8 +- .../Variables/CShaderVariableVector3.h | 3 +- .../Variables/CShaderVariableVector4.cpp | 8 +- .../Variables/CShaderVariableVector4.h | 3 +- .../Render/Wallpapers/CScene.cpp | 2 - 45 files changed, 512 insertions(+), 1063 deletions(-) delete mode 100644 src/WallpaperEngine/Core/Core.cpp delete mode 100644 src/WallpaperEngine/Core/Core.h delete mode 100644 src/WallpaperEngine/Core/DynamicValues/CDynamicValue.h rename src/WallpaperEngine/{Core/DynamicValues/CDynamicValue.cpp => Data/Model/DynamicValue.cpp} (65%) create mode 100644 src/WallpaperEngine/Data/Model/DynamicValue.h create mode 100644 src/WallpaperEngine/Data/Utils/SFINAE.h diff --git a/CMakeLists.txt b/CMakeLists.txt index f9eeb54..49e64a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -198,8 +198,7 @@ if(X11_SUPPORT_FOUND) src/WallpaperEngine/Render/Drivers/Output/CX11Output.cpp src/WallpaperEngine/Render/Drivers/Output/CX11Output.h src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.cpp - src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.h - src/WallpaperEngine/Data/Model/UserSetting.h) + src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.h) SET(X11_INCLUDES ${X11_INCLUDE_DIR} ${XRANDR_INCLUDE_DIR}) @@ -284,9 +283,6 @@ add_executable( src/WallpaperEngine/Assets/CTexture.h src/WallpaperEngine/Assets/CTexture.cpp - src/WallpaperEngine/Core/Core.h - src/WallpaperEngine/Core/Core.cpp - src/WallpaperEngine/Audio/Drivers/Recorders/CPulseAudioPlaybackRecorder.cpp src/WallpaperEngine/Audio/Drivers/Recorders/CPulseAudioPlaybackRecorder.h src/WallpaperEngine/Audio/Drivers/Recorders/CPlaybackRecorder.cpp @@ -404,9 +400,6 @@ add_executable( src/WallpaperEngine/WebBrowser/CWebBrowserContext.cpp src/WallpaperEngine/WebBrowser/CWebBrowserContext.h - src/WallpaperEngine/Core/DynamicValues/CDynamicValue.cpp - src/WallpaperEngine/Core/DynamicValues/CDynamicValue.h - src/WallpaperEngine/Core/Projects/CProperty.h src/WallpaperEngine/Core/Projects/CProperty.cpp src/WallpaperEngine/Core/Projects/CPropertyColor.h @@ -427,8 +420,12 @@ add_executable( src/WallpaperEngine/Data/Model/Material.h src/WallpaperEngine/Data/Model/Effect.h src/WallpaperEngine/Data/Model/Model.h + src/WallpaperEngine/Data/Model/UserSetting.h + src/WallpaperEngine/Data/Model/DynamicValue.h + src/WallpaperEngine/Data/Model/DynamicValue.cpp src/WallpaperEngine/Data/Utils/TypeCaster.cpp src/WallpaperEngine/Data/Utils/TypeCaster.h + src/WallpaperEngine/Data/Utils/SFINAE.h src/WallpaperEngine/Data/Parsers/ProjectParser.cpp src/WallpaperEngine/Data/Parsers/ProjectParser.h src/WallpaperEngine/Data/Parsers/WallpaperParser.cpp diff --git a/src/WallpaperEngine/Application/CWallpaperApplication.cpp b/src/WallpaperEngine/Application/CWallpaperApplication.cpp index e6a71f5..a32ec59 100644 --- a/src/WallpaperEngine/Application/CWallpaperApplication.cpp +++ b/src/WallpaperEngine/Application/CWallpaperApplication.cpp @@ -10,6 +10,8 @@ #include "WallpaperEngine/Render/CRenderContext.h" #include "WallpaperEngine/Render/Drivers/CVideoFactories.h" +#include "WallpaperEngine/Core/Projects/CProperty.h" + #include "WallpaperEngine/Data/Parsers/ProjectParser.h" #include "WallpaperEngine/Data/Dumpers/StringPrinter.h" diff --git a/src/WallpaperEngine/Core/Core.cpp b/src/WallpaperEngine/Core/Core.cpp deleted file mode 100644 index 2758281..0000000 --- a/src/WallpaperEngine/Core/Core.cpp +++ /dev/null @@ -1,498 +0,0 @@ -#include "Core.h" - -#include "WallpaperEngine/Logging/CLog.h" - -using namespace WallpaperEngine; - -glm::vec4 Core::aToVector4 (const char* str) { - float x = strtof (str, const_cast (&str)); - while (*str == ' ') - str++; - float y = strtof (str, const_cast (&str)); - while (*str == ' ') - str++; - float z = strtof (str, const_cast (&str)); - while (*str == ' ') - str++; - float w = strtof (str, const_cast (&str)); - - return {x, y, z, w}; -} - -glm::vec3 Core::aToVector3 (const char* str) { - float x = strtof (str, const_cast (&str)); - while (*str == ' ') - str++; - float y = strtof (str, const_cast (&str)); - while (*str == ' ') - str++; - float z = strtof (str, const_cast (&str)); - - return {x, y, z}; -} - -glm::vec2 Core::aToVector2 (const char* str) { - float x = strtof (str, const_cast (&str)); - while (*str == ' ') - str++; - float y = strtof (str, const_cast (&str)); - - return {x, y}; -} - -glm::ivec4 Core::aToVector4i (const char* str) { - int x = strtol (str, const_cast (&str), 10); - while (*str == ' ') - str++; - int y = strtol (str, const_cast (&str), 10); - while (*str == ' ') - str++; - int z = strtol (str, const_cast (&str), 10); - while (*str == ' ') - str++; - int w = strtol (str, const_cast (&str), 10); - - return {x, y, z, w}; -} - -glm::ivec3 Core::aToVector3i (const char* str) { - int x = strtol (str, const_cast (&str), 10); - while (*str == ' ') - str++; - int y = strtol (str, const_cast (&str), 10); - while (*str == ' ') - str++; - int z = strtol (str, const_cast (&str), 10); - - return {x, y, z}; -} - -glm::ivec2 Core::aToVector2i (const char* str) { - int x = strtol (str, const_cast (&str), 10); - while (*str == ' ') - str++; - int y = strtol (str, const_cast (&str), 10); - - return {x, y}; -} - -glm::vec4 Core::aToVector4 (const std::string& str) { - return Core::aToVector4 (str.c_str ()); -} - -glm::vec3 Core::aToVector3 (const std::string& str) { - return Core::aToVector3 (str.c_str ()); -} - -glm::vec2 Core::aToVector2 (const std::string& str) { - return Core::aToVector2 (str.c_str ()); -} - -glm::ivec4 Core::aToVector4i (const std::string& str) { - return Core::aToVector4i (str.c_str ()); -} - -glm::ivec3 Core::aToVector3i (const std::string& str) { - return Core::aToVector3i (str.c_str ()); -} - -glm::ivec2 Core::aToVector2i (const std::string& str) { - return Core::aToVector2i (str.c_str ()); -} - -glm::vec3 Core::aToColorf (const char* str) { - float r = strtof (str, const_cast (&str)); - while (*str == ' ') - str++; - float g = strtof (str, const_cast (&str)); - while (*str == ' ') - str++; - float b = strtof (str, const_cast (&str)); - - return {r, g, b}; -} - -glm::vec3 Core::aToColorf (const std::string& str) { - return aToColorf (str.c_str ()); -} - -glm::ivec3 Core::aToColori (const char* str) { - auto r = static_cast (strtol (str, const_cast (&str), 10)); - while (*str == ' ') - str++; - auto g = static_cast (strtol (str, const_cast (&str), 10)); - while (*str == ' ') - str++; - auto b = static_cast (strtol (str, const_cast (&str), 10)); - - return {r, g, b}; -} - -glm::ivec3 Core::aToColori (const std::string& str) { - return aToColori (str.c_str ()); -} - -template bool typeCheck (const nlohmann::json::const_iterator& value) { - if (value->type () == nlohmann::detail::value_t::null) { - return false; - } - - // type checks - if constexpr ((std::is_same_v || std::is_same_v) ) { - if (value->type () != nlohmann::detail::value_t::number_float && - value->type () != nlohmann::detail::value_t::number_integer && - value->type () != nlohmann::detail::value_t::number_unsigned) { - return false; - } - } else if constexpr (std::is_same_v) { - if (value->type () != nlohmann::detail::value_t::string) { - return false; - } - } else if constexpr (std::is_same_v) { - if (value->type () != nlohmann::detail::value_t::boolean) { - return false; - } - } else if constexpr ( - std::is_same_v || std::is_same_v || std::is_same_v || - std::is_same_v || std::is_same_v || std::is_same_v) { - if (value->type () != nlohmann::detail::value_t::string) { - return false; - } - } - - return true; -} - -template const T Core::jsonFindRequired ( - const nlohmann::json::const_iterator& data, const char* key, const char* notFoundMsg -) { - const auto iterator = jsonFindRequired (data, key, notFoundMsg); - - // vector types need of special handling - if constexpr (std::is_same_v) { - // std::strings are special, type checking doesn't need to happen, we just want the string representation - // of whatever is in there - if (iterator->is_number_integer ()) { - return std::to_string (iterator->get ()); - } else if (iterator->is_number_float ()) { - return std::to_string (iterator->get ()); - } else if (iterator->is_boolean()) { - return std::to_string (iterator->get ()); - } else if (iterator->is_null ()) { - return "null"; - } else if (iterator->is_string ()) { - return *iterator; - } - } else if constexpr (std::is_same_v) { - if (!typeCheck (iterator)) { - sLog.exception ("key value doesn't match expected type. Got ", iterator->type_name(), " expected vector-like-string", ": ", notFoundMsg); - } - - return aToVector4 (*iterator); - } else if constexpr (std::is_same_v) { - if (!typeCheck (iterator)) { - sLog.exception ("key value doesn't match expected type. Got ", iterator->type_name(), " expected vector-like-string", ": ", notFoundMsg); - } - - return aToVector3 (*iterator); - } else if constexpr (std::is_same_v) { - if (!typeCheck (iterator)) { - sLog.exception ("key value doesn't match expected type. Got ", iterator->type_name(), " expected vector-like-string", ": ", notFoundMsg); - } - - return aToVector2 (*iterator); - } else if constexpr (std::is_same_v) { - if (!typeCheck (iterator)) { - sLog.exception ("key value doesn't match expected type. Got ", iterator->type_name(), " expected vector-like-string", ": ", notFoundMsg); - } - - return aToVector4i (*iterator); - } else if constexpr (std::is_same_v) { - if (!typeCheck (iterator)) { - sLog.exception ("key value doesn't match expected type. Got ", iterator->type_name(), " expected vector-like-string", ": ", notFoundMsg); - } - - return aToVector3i (*iterator); - } else if constexpr (std::is_same_v) { - if (!typeCheck (iterator)) { - sLog.exception ("key value doesn't match expected type. Got ", iterator->type_name(), " expected vector-like-string", ": ", notFoundMsg); - } - - return aToVector2i (*iterator); - } else if (typeCheck (iterator)) { - return *iterator; - } - - sLog.exception ("key value doesn't match expected type. Got ", iterator->type_name(), ": ", notFoundMsg); -} - -template const bool Core::jsonFindRequired (const nlohmann::json::const_iterator& data, const char* key, const char* notFoundMsg); -template const std::string Core::jsonFindRequired (const nlohmann::json::const_iterator& data, const char* key, const char* notFoundMsg); -template const int16_t Core::jsonFindRequired (const nlohmann::json::const_iterator& data, const char* key, const char* notFoundMsg); -template const uint16_t Core::jsonFindRequired (const nlohmann::json::const_iterator& data, const char* key, const char* notFoundMsg); -template const int32_t Core::jsonFindRequired (const nlohmann::json::const_iterator& data, const char* key, const char* notFoundMsg); -template const uint32_t Core::jsonFindRequired (const nlohmann::json::const_iterator& data, const char* key, const char* notFoundMsg); -template const int64_t Core::jsonFindRequired (const nlohmann::json::const_iterator& data, const char* key, const char* notFoundMsg); -template const uint64_t Core::jsonFindRequired (const nlohmann::json::const_iterator& data, const char* key, const char* notFoundMsg); -template const float Core::jsonFindRequired (const nlohmann::json::const_iterator& data, const char* key, const char* notFoundMsg); -template const double Core::jsonFindRequired (const nlohmann::json::const_iterator& data, const char* key, const char* notFoundMsg); -template const glm::vec4 Core::jsonFindRequired (const nlohmann::json::const_iterator& data, const char* key, const char* notFoundMsg); -template const glm::vec3 Core::jsonFindRequired (const nlohmann::json::const_iterator& data, const char* key, const char* notFoundMsg); -template const glm::vec2 Core::jsonFindRequired (const nlohmann::json::const_iterator& data, const char* key, const char* notFoundMsg); -template const glm::ivec4 Core::jsonFindRequired (const nlohmann::json::const_iterator& data, const char* key, const char* notFoundMsg); -template const glm::ivec3 Core::jsonFindRequired (const nlohmann::json::const_iterator& data, const char* key, const char* notFoundMsg); -template const glm::ivec2 Core::jsonFindRequired (const nlohmann::json::const_iterator& data, const char* key, const char* notFoundMsg); - -template const T Core::jsonFindRequired ( - const nlohmann::json& data, const char* key, const char* notFoundMsg -) { - const auto iterator = jsonFindRequired (data, key, notFoundMsg); - - // vector types need of special handling - if constexpr (std::is_same_v) { - // std::strings are special, type checking doesn't need to happen, we just want the string representation - // of whatever is in there - if (iterator->is_number_integer ()) { - return std::to_string (iterator->get ()); - } else if (iterator->is_number_float ()) { - return std::to_string (iterator->get ()); - } else if (iterator->is_boolean()) { - return std::to_string (iterator->get ()); - } else if (iterator->is_null ()) { - return "null"; - } else if (iterator->is_string ()) { - return *iterator; - } - } else if constexpr (std::is_same_v) { - if (!typeCheck (iterator)) { - sLog.exception ("key value doesn't match expected type. Got ", iterator->type_name(), " expected vector-like-string", ": ", notFoundMsg); - } - - return aToVector4 (*iterator); - } else if constexpr (std::is_same_v) { - if (!typeCheck (iterator)) { - sLog.exception ("key value doesn't match expected type. Got ", iterator->type_name(), " expected vector-like-string", ": ", notFoundMsg); - } - - return aToVector3 (*iterator); - } else if constexpr (std::is_same_v) { - if (!typeCheck (iterator)) { - sLog.exception ("key value doesn't match expected type. Got ", iterator->type_name(), " expected vector-like-string", ": ", notFoundMsg); - } - - return aToVector2 (*iterator); - } else if constexpr (std::is_same_v) { - if (!typeCheck (iterator)) { - sLog.exception ("key value doesn't match expected type. Got ", iterator->type_name(), " expected vector-like-string", ": ", notFoundMsg); - } - - return aToVector4i (*iterator); - } else if constexpr (std::is_same_v) { - if (!typeCheck (iterator)) { - sLog.exception ("key value doesn't match expected type. Got ", iterator->type_name(), " expected vector-like-string", ": ", notFoundMsg); - } - - return aToVector3i (*iterator); - } else if constexpr (std::is_same_v) { - if (!typeCheck (iterator)) { - sLog.exception ("key value doesn't match expected type. Got ", iterator->type_name(), " expected vector-like-string", ": ", notFoundMsg); - } - - return aToVector2i (*iterator); - } else if (typeCheck (iterator)) { - return *iterator; - } - - sLog.exception ("key value doesn't match expected type. Got ", iterator->type_name(), ": ", notFoundMsg); -} - -template const bool Core::jsonFindRequired (const nlohmann::json& data, const char* key, const char* notFoundMsg); -template const std::string Core::jsonFindRequired (const nlohmann::json& data, const char* key, const char* notFoundMsg); -template const int16_t Core::jsonFindRequired (const nlohmann::json& data, const char* key, const char* notFoundMsg); -template const uint16_t Core::jsonFindRequired (const nlohmann::json& data, const char* key, const char* notFoundMsg); -template const int32_t Core::jsonFindRequired (const nlohmann::json& data, const char* key, const char* notFoundMsg); -template const uint32_t Core::jsonFindRequired (const nlohmann::json& data, const char* key, const char* notFoundMsg); -template const int64_t Core::jsonFindRequired (const nlohmann::json& data, const char* key, const char* notFoundMsg); -template const uint64_t Core::jsonFindRequired (const nlohmann::json& data, const char* key, const char* notFoundMsg); -template const float Core::jsonFindRequired (const nlohmann::json& data, const char* key, const char* notFoundMsg); -template const double Core::jsonFindRequired (const nlohmann::json& data, const char* key, const char* notFoundMsg); -template const glm::vec4 Core::jsonFindRequired (const nlohmann::json& data, const char* key, const char* notFoundMsg); -template const glm::vec3 Core::jsonFindRequired (const nlohmann::json& data, const char* key, const char* notFoundMsg); -template const glm::vec2 Core::jsonFindRequired (const nlohmann::json& data, const char* key, const char* notFoundMsg); -template const glm::ivec4 Core::jsonFindRequired (const nlohmann::json& data, const char* key, const char* notFoundMsg); -template const glm::ivec3 Core::jsonFindRequired (const nlohmann::json& data, const char* key, const char* notFoundMsg); -template const glm::ivec2 Core::jsonFindRequired (const nlohmann::json& data, const char* key, const char* notFoundMsg); - -nlohmann::json::const_iterator Core::jsonFindRequired ( - const nlohmann::json::const_iterator& data, const char* key, const char* notFoundMsg -) { - auto value = data->find (key); - - if (value == data->end ()) - sLog.exception ("Cannot find required key (", key, ") in json: ", notFoundMsg); - - return value; -} - -nlohmann::json::const_iterator Core::jsonFindRequired ( - const nlohmann::json& data, const char* key, const char* notFoundMsg -) { - auto value = data.find (key); - - if (value == data.end ()) - sLog.exception ("Cannot find required key (", key, ") in json: ", notFoundMsg); - - return value; -} - -template const T Core::jsonFindDefault ( - const nlohmann::json::const_iterator& data, const char* key, const T defaultValue -) { - const auto value = data->find (key); - - if (value == data->end () || value->type () == nlohmann::detail::value_t::null) - return defaultValue; - - // vector types need of special handling - if constexpr (std::is_same_v) { - // std::strings are special, type checking doesn't need to happen, we just want the string representation - // of whatever is in there - if (value->is_number_integer ()) { - return std::to_string (value->get ()); - } else if (value->is_number_float ()) { - return std::to_string (value->get ()); - } else if (value->is_boolean()) { - return std::to_string (value->get ()); - } else if (value->is_null ()) { - return "null"; - } else if (value->is_string ()) { - return *value; - } - } else if constexpr (std::is_same_v) { - if (!typeCheck (value)) { - return defaultValue; - } - - return aToVector4 (*value); - } else if constexpr (std::is_same_v) { - if (!typeCheck (value)) { - return defaultValue; - } - - return aToVector3 (*value); - } else if constexpr (std::is_same_v) { - if (!typeCheck (value)) { - return defaultValue; - } - - return aToVector2 (*value); - } else if constexpr (std::is_same_v) { - if (!typeCheck (value)) { - return defaultValue; - } - - return aToVector4i (*value); - } else if constexpr (std::is_same_v) { - if (!typeCheck (value)) { - return defaultValue; - } - - return aToVector3i (*value); - } else if constexpr (std::is_same_v) { - if (!typeCheck (value)) { - return defaultValue; - } - - return aToVector2i (*value); - } else if (typeCheck (value)) { - return *value; - } - - return defaultValue; -} - -template const bool Core::jsonFindDefault (const nlohmann::json::const_iterator& data, const char* key, const bool defaultValue); -template const std::string Core::jsonFindDefault (const nlohmann::json::const_iterator& data, const char* key, const std::string defaultValue); -template const int16_t Core::jsonFindDefault (const nlohmann::json::const_iterator& data, const char* key, const int16_t defaultValue); -template const uint16_t Core::jsonFindDefault (const nlohmann::json::const_iterator& data, const char* key, const uint16_t defaultValue); -template const int32_t Core::jsonFindDefault (const nlohmann::json::const_iterator& data, const char* key, const int32_t defaultValue); -template const uint32_t Core::jsonFindDefault (const nlohmann::json::const_iterator& data, const char* key, const uint32_t defaultValue); -template const int64_t Core::jsonFindDefault (const nlohmann::json::const_iterator& data, const char* key, const int64_t defaultValue); -template const uint64_t Core::jsonFindDefault (const nlohmann::json::const_iterator& data, const char* key, const uint64_t defaultValue); -template const float Core::jsonFindDefault (const nlohmann::json::const_iterator& data, const char* key, const float defaultValue); -template const double Core::jsonFindDefault (const nlohmann::json::const_iterator& data, const char* key, const double defaultValue); -template const glm::vec2 Core::jsonFindDefault (const nlohmann::json::const_iterator& data, const char* key, const glm::vec2 defaultValue); -template const glm::vec3 Core::jsonFindDefault (const nlohmann::json::const_iterator& data, const char* key, const glm::vec3 defaultValue); -template const glm::vec4 Core::jsonFindDefault (const nlohmann::json::const_iterator& data, const char* key, const glm::vec4 defaultValue); -template const glm::ivec2 Core::jsonFindDefault (const nlohmann::json::const_iterator& data, const char* key, const glm::ivec2 defaultValue); -template const glm::ivec3 Core::jsonFindDefault (const nlohmann::json::const_iterator& data, const char* key, const glm::ivec3 defaultValue); -template const glm::ivec4 Core::jsonFindDefault (const nlohmann::json::const_iterator& data, const char* key, const glm::ivec4 defaultValue); - -template const T Core::jsonFindDefault ( - const nlohmann::json& data, const char* key, const T defaultValue -) { - const auto value = data.find (key); - - if (value == data.end () || value->type () == nlohmann::detail::value_t::null) - return defaultValue; - - // vector types need of special handling - if constexpr (std::is_same_v) { - if (!typeCheck (value)) { - return defaultValue; - } - - return aToVector4 (*value); - } else if constexpr (std::is_same_v) { - if (!typeCheck (value)) { - return defaultValue; - } - - return aToVector3 (*value); - } else if constexpr (std::is_same_v) { - if (!typeCheck (value)) { - return defaultValue; - } - - return aToVector2 (*value); - } else if constexpr (std::is_same_v) { - if (!typeCheck (value)) { - return defaultValue; - } - - return aToVector4i (*value); - } else if constexpr (std::is_same_v) { - if (!typeCheck (value)) { - return defaultValue; - } - - return aToVector3i (*value); - } else if constexpr (std::is_same_v) { - if (!typeCheck (value)) { - return defaultValue; - } - - return aToVector2i (*value); - } else if (typeCheck (value)) { - return *value; - } - - return defaultValue; -} - -template const bool Core::jsonFindDefault (const nlohmann::json& data, const char* key, const bool defaultValue); -template const std::string Core::jsonFindDefault (const nlohmann::json& data, const char* key, const std::string defaultValue); -template const int16_t Core::jsonFindDefault (const nlohmann::json& data, const char* key, const int16_t defaultValue); -template const uint16_t Core::jsonFindDefault (const nlohmann::json& data, const char* key, const uint16_t defaultValue); -template const int32_t Core::jsonFindDefault (const nlohmann::json& data, const char* key, const int32_t defaultValue); -template const uint32_t Core::jsonFindDefault (const nlohmann::json& data, const char* key, const uint32_t defaultValue); -template const int64_t Core::jsonFindDefault (const nlohmann::json& data, const char* key, const int64_t defaultValue); -template const uint64_t Core::jsonFindDefault (const nlohmann::json& data, const char* key, const uint64_t defaultValue); -template const float Core::jsonFindDefault (const nlohmann::json& data, const char* key, const float defaultValue); -template const double Core::jsonFindDefault (const nlohmann::json& data, const char* key, const double defaultValue); -template const glm::vec2 Core::jsonFindDefault (const nlohmann::json& data, const char* key, const glm::vec2 defaultValue); -template const glm::vec3 Core::jsonFindDefault (const nlohmann::json& data, const char* key, const glm::vec3 defaultValue); -template const glm::vec4 Core::jsonFindDefault (const nlohmann::json& data, const char* key, const glm::vec4 defaultValue); -template const glm::ivec2 Core::jsonFindDefault (const nlohmann::json& data, const char* key, const glm::ivec2 defaultValue); -template const glm::ivec3 Core::jsonFindDefault (const nlohmann::json& data, const char* key, const glm::ivec3 defaultValue); -template const glm::ivec4 Core::jsonFindDefault (const nlohmann::json& data, const char* key, const glm::ivec4 defaultValue); diff --git a/src/WallpaperEngine/Core/Core.h b/src/WallpaperEngine/Core/Core.h deleted file mode 100644 index f3fb7fd..0000000 --- a/src/WallpaperEngine/Core/Core.h +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include - -namespace WallpaperEngine::Core { -class CProject; - -glm::vec4 aToVector4 (const char* str); -glm::vec3 aToVector3 (const char* str); -glm::vec2 aToVector2 (const char* str); - -glm::vec4 aToVector4 (const std::string& str); -glm::vec3 aToVector3 (const std::string& str); -glm::vec2 aToVector2 (const std::string& str); - -glm::ivec4 aToVector4i (const char* str); -glm::ivec3 aToVector3i (const char* str); -glm::ivec2 aToVector2i (const char* str); - -glm::ivec4 aToVector4i (const std::string& str); -glm::ivec3 aToVector3i (const std::string& str); -glm::ivec2 aToVector2i (const std::string& str); - -glm::vec3 aToColorf (const char* str); -glm::vec3 aToColorf (const std::string& str); - -glm::ivec3 aToColori (const char* str); -glm::ivec3 aToColori (const std::string& str); - -template const T jsonFindRequired ( - const nlohmann::json::const_iterator& data, const char* key, const char* notFoundMsg); -template const T jsonFindRequired ( - const nlohmann::json& data, const char* key, const char* notFoundMsg); -nlohmann::json::const_iterator jsonFindRequired ( - const nlohmann::json::const_iterator& data, const char* key, const char* notFoundMsg); -nlohmann::json::const_iterator jsonFindRequired ( - const nlohmann::json& data, const char* key, const char* notFoundMsg); -template const T jsonFindDefault ( - const nlohmann::json::const_iterator& data, const char* key, const T defaultValue); -template const T jsonFindDefault ( - const nlohmann::json& data, const char* key, const T defaultValue); -} // namespace WallpaperEngine::Core diff --git a/src/WallpaperEngine/Core/DynamicValues/CDynamicValue.h b/src/WallpaperEngine/Core/DynamicValues/CDynamicValue.h deleted file mode 100644 index 904fbba..0000000 --- a/src/WallpaperEngine/Core/DynamicValues/CDynamicValue.h +++ /dev/null @@ -1,95 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -namespace WallpaperEngine::Data::Parsers { -class UserSettingParser; -} - -namespace WallpaperEngine::Data::Builders { -class UserSettingBuilder; -} - -namespace WallpaperEngine::Core::DynamicValues { -class CDynamicValue { - //TODO: THIS SHOULD BE CHANGED ONCE THINGS ARE FINISHED - friend class WallpaperEngine::Data::Parsers::UserSettingParser; - friend class WallpaperEngine::Data::Builders::UserSettingBuilder; - public: - enum UnderlyingType { - Unknown = -1, - IVec4 = 0, - IVec3 = 1, - IVec2 = 2, - Vec4 = 3, - Vec3 = 4, - Vec2 = 5, - Float = 6, - Int = 7, - Boolean = 8 - }; - - virtual ~CDynamicValue (); - - [[nodiscard]] const glm::ivec4& getIVec4 () const; - [[nodiscard]] const glm::ivec3& getIVec3 () const; - [[nodiscard]] const glm::ivec2& getIVec2 () const; - [[nodiscard]] const glm::vec4& getVec4 () const; - [[nodiscard]] const glm::vec3& getVec3 () const; - [[nodiscard]] const glm::vec2& getVec2 () const; - [[nodiscard]] const float& getFloat () const; - [[nodiscard]] const int& getInt () const; - [[nodiscard]] const bool& getBool () const; - [[nodiscard]] UnderlyingType getType () const; - [[nodiscard]] std::string toString () const; - - /** - * Connects the current instance to the given instance, updating it's values - * based on current instance's changes - * - * @param value - */ - void connectOutgoing (CDynamicValue* value) const; - void update (float newValue); - void update (int newValue); - void update (bool newValue); - void update (const glm::vec2& newValue); - void update (const glm::vec3& newValue); - void update (const glm::vec4& newValue); - void update (const glm::ivec2& newValue); - void update (const glm::ivec3& newValue); - void update (const glm::ivec4& newValue); - - protected: - /** - * Registers an incoming connection (another CDynamicValue affecting the current instance's value) - * Useful mainly for destroying the connection on delete - * - * @param value - */ - void connectIncoming (const CDynamicValue* value) const; - void destroyOutgoingConnection (CDynamicValue* value) const; - /** - * Propagates the current value to all it's connections - */ - virtual void propagate () const; - - private: - mutable std::vector m_outgoingConnections = {}; - mutable std::vector m_incomingConnections = {}; - UnderlyingType m_type = UnderlyingType::Unknown; - // different values that we will be casted to automagically - glm::ivec4 m_ivec4 = {}; - glm::ivec3 m_ivec3 = {}; - glm::ivec2 m_ivec2 = {}; - glm::vec4 m_vec4 = {}; - glm::vec3 m_vec3 = {}; - glm::vec2 m_vec2 = {}; - float m_float = 0.0f; - int m_int = 0; - bool m_bool = false; -}; -}; \ No newline at end of file diff --git a/src/WallpaperEngine/Core/Projects/CProperty.cpp b/src/WallpaperEngine/Core/Projects/CProperty.cpp index ccfb1ef..0b40e9d 100644 --- a/src/WallpaperEngine/Core/Projects/CProperty.cpp +++ b/src/WallpaperEngine/Core/Projects/CProperty.cpp @@ -10,23 +10,23 @@ using namespace WallpaperEngine::Core::Projects; -std::shared_ptr CProperty::fromJSON (const json& data, const std::string& name) { - const auto type = jsonFindRequired (data, "type", "Project properties must have the type field"); +std::shared_ptr CProperty::fromJSON (const JSON& data, const std::string& name) { + const auto type = data.require ("type", "Project properties must have the type field"); - if (*type == "color") + if (type == "color") return CPropertyColor::fromJSON (data, name); - if (*type == "bool") + if (type == "bool") return CPropertyBoolean::fromJSON (data, name); - if (*type == "slider") + if (type == "slider") return CPropertySlider::fromJSON (data, name); - if (*type == "combo") + if (type == "combo") return CPropertyCombo::fromJSON (data, name); - if (*type == "text") + if (type == "text") return CPropertyText::fromJSON (data, name); - if (*type != "group") { + if (type != "group") { // show the error and ignore this property - sLog.error ("Unexpected type for property: ", *type); + sLog.error ("Unexpected type for property: ", type); sLog.error (data); } @@ -37,18 +37,6 @@ CProperty::CProperty (std::string name, std::string text) : m_name (std::move(name)), m_text (std::move(text)) {} -void CProperty::subscribe (const function_type& callback) const { - this->m_subscriptions.push_back (callback); -} - -void CProperty::propagate () const { - CDynamicValue::propagate (); - - for (const auto& callback : this->m_subscriptions) { - callback(this); - } -} - const std::string& CProperty::getName () const { return this->m_name; } diff --git a/src/WallpaperEngine/Core/Projects/CProperty.h b/src/WallpaperEngine/Core/Projects/CProperty.h index f172ae4..80f49a4 100644 --- a/src/WallpaperEngine/Core/Projects/CProperty.h +++ b/src/WallpaperEngine/Core/Projects/CProperty.h @@ -1,46 +1,26 @@ #pragma once -#include "WallpaperEngine/Core/DynamicValues/CDynamicValue.h" -#include "WallpaperEngine/Core/Core.h" +#include "WallpaperEngine/Data/Utils/TypeCaster.h" +#include "WallpaperEngine/Data/Model/DynamicValue.h" +#include "WallpaperEngine/Data/JSON.h" namespace WallpaperEngine::Core::Projects { -using json = nlohmann::json; -using namespace WallpaperEngine::Core::DynamicValues; +using JSON = WallpaperEngine::Data::JSON::JSON; +using namespace WallpaperEngine::Data::Model; +using namespace WallpaperEngine::Data::Utils; /** * Represents a property in a background * * Properties are settings that alter how the background looks or works * and are configurable by the user so they can customize it to their likings */ -class CProperty : public CDynamicValue { +class CProperty : public DynamicValue, public TypeCaster { public: using UniquePtr = std::unique_ptr; using SharedPtr = std::shared_ptr; using WeakPtr = std::weak_ptr; - typedef std::function function_type; - virtual ~CProperty () = default; - static std::shared_ptr fromJSON (const json& data, const std::string& name); - - template [[nodiscard]] const T* as () const { - if (is ()) { - return static_cast (this); - } - - throw std::bad_cast (); - } - - template [[nodiscard]] T* as () { - if (is ()) { - return static_cast (this); - } - - throw std::bad_cast (); - } - - template [[nodiscard]] bool is () const { - return typeid (*this) == typeid(T); - } + static std::shared_ptr fromJSON (const JSON& data, const std::string& name); /** * @return Representation of what the property does and the default values @@ -59,25 +39,14 @@ class CProperty : public CDynamicValue { /** * @return Textual type representation of this property */ - [[nodiscard]] virtual const char* getType () const = 0; + [[nodiscard]] virtual const char* getPropertyType () const = 0; /** * @return Text of the property */ [[nodiscard]] const std::string& getText () const; - /** - * Registers a function to be called when this instance's value changes - * - * @param callback - */ - void subscribe (const function_type& callback) const; protected: - void propagate () const override; - CProperty (std::string name, std::string text); - - /** Functions to call when this property's value changes */ - mutable std::vector m_subscriptions; /** Name of the property */ const std::string m_name; /** Description of the property for the user */ diff --git a/src/WallpaperEngine/Core/Projects/CPropertyBoolean.cpp b/src/WallpaperEngine/Core/Projects/CPropertyBoolean.cpp index 0c59ce8..dc1d0f6 100644 --- a/src/WallpaperEngine/Core/Projects/CPropertyBoolean.cpp +++ b/src/WallpaperEngine/Core/Projects/CPropertyBoolean.cpp @@ -2,15 +2,14 @@ #include #include "CPropertyBoolean.h" -#include "WallpaperEngine/Core/Core.h" using namespace WallpaperEngine::Core::Projects; -std::shared_ptr CPropertyBoolean::fromJSON (const json& data, std::string name) { +std::shared_ptr CPropertyBoolean::fromJSON (const JSON& data, std::string name) { return std::make_shared ( - jsonFindRequired (data, "value", "Boolean property must have a value"), + data.require ("value", "Boolean property must have a value"), std::move(name), - jsonFindDefault (data, "text", "") + data.optional ("text", "") ); } @@ -31,7 +30,7 @@ std::string CPropertyBoolean::dump () const { return ss.str (); } -const char* CPropertyBoolean::getType () const { +const char* CPropertyBoolean::getPropertyType () const { return "bool"; } diff --git a/src/WallpaperEngine/Core/Projects/CPropertyBoolean.h b/src/WallpaperEngine/Core/Projects/CPropertyBoolean.h index ebaee63..72f3f85 100644 --- a/src/WallpaperEngine/Core/Projects/CPropertyBoolean.h +++ b/src/WallpaperEngine/Core/Projects/CPropertyBoolean.h @@ -3,7 +3,7 @@ #include "CProperty.h" namespace WallpaperEngine::Core::Projects { -using json = nlohmann::json; +using JSON = WallpaperEngine::Data::JSON::JSON; /** * Represents a boolean property @@ -12,10 +12,10 @@ class CPropertyBoolean final : public CProperty { public: CPropertyBoolean (bool value, std::string name, std::string text); - static std::shared_ptr fromJSON (const json& data, std::string name); + static std::shared_ptr fromJSON (const JSON& data, std::string name); [[nodiscard]] std::string dump () const override; void set (const std::string& value) override; - [[nodiscard]] const char* getType () const override; + [[nodiscard]] const char* getPropertyType () const override; }; } // namespace WallpaperEngine::Core::Projects diff --git a/src/WallpaperEngine/Core/Projects/CPropertyColor.cpp b/src/WallpaperEngine/Core/Projects/CPropertyColor.cpp index 71f8a21..a60ff88 100644 --- a/src/WallpaperEngine/Core/Projects/CPropertyColor.cpp +++ b/src/WallpaperEngine/Core/Projects/CPropertyColor.cpp @@ -3,6 +3,7 @@ #include "CPropertyColor.h" +using namespace WallpaperEngine::Data::Builders; using namespace WallpaperEngine::Core::Projects; glm::vec3 ParseColor (std::string value) { @@ -13,19 +14,20 @@ glm::vec3 ParseColor (std::string value) { } if (value.find ('.') == std::string::npos && value != "0 0 0" && value != "1 1 1") { - const glm::ivec3 intcolor = WallpaperEngine::Core::aToColori (value); + const auto intcolor = VectorBuilder::parse (value); return {intcolor.r / 255.0, intcolor.g / 255.0, intcolor.b / 255.0}; } - return WallpaperEngine::Core::aToColorf (value); + return VectorBuilder::parse (value); } -std::shared_ptr CPropertyColor::fromJSON (const json& data, std::string name) { - const auto value = jsonFindRequired (data, "value", "Color property must have a value"); - const auto text = jsonFindDefault (data, "text", ""); - - return std::make_shared (value, std::move(name), text); +std::shared_ptr CPropertyColor::fromJSON (const JSON& data, std::string name) { + return std::make_shared ( + data.require ("value", "Color property must have a value"), + std::move(name), + data.optional ("text", "") + ); } void CPropertyColor::set (const std::string& value) { @@ -45,7 +47,7 @@ std::string CPropertyColor::dump () const { return ss.str (); } -const char* CPropertyColor::getType () const { +const char* CPropertyColor::getPropertyType () const { return "color"; } diff --git a/src/WallpaperEngine/Core/Projects/CPropertyColor.h b/src/WallpaperEngine/Core/Projects/CPropertyColor.h index 317bbd5..4718e59 100644 --- a/src/WallpaperEngine/Core/Projects/CPropertyColor.h +++ b/src/WallpaperEngine/Core/Projects/CPropertyColor.h @@ -2,10 +2,10 @@ #include "CProperty.h" -#include "WallpaperEngine/Core/Core.h" +#include "WallpaperEngine/Data/JSON.h" namespace WallpaperEngine::Core::Projects { -using json = nlohmann::json; +using JSON = WallpaperEngine::Data::JSON::JSON; /** * Represents a color property @@ -14,10 +14,10 @@ class CPropertyColor final : public CProperty { public: CPropertyColor (const std::string& color, std::string name, std::string text); - static std::shared_ptr fromJSON (const json& data, std::string name); + static std::shared_ptr fromJSON (const JSON& data, std::string name); [[nodiscard]] std::string dump () const override; void set (const std::string& value) override; - [[nodiscard]] const char* getType () const override; + [[nodiscard]] const char* getPropertyType () const override; }; } // namespace WallpaperEngine::Core::Projects diff --git a/src/WallpaperEngine/Core/Projects/CPropertyCombo.cpp b/src/WallpaperEngine/Core/Projects/CPropertyCombo.cpp index 96dac63..e73fd2a 100644 --- a/src/WallpaperEngine/Core/Projects/CPropertyCombo.cpp +++ b/src/WallpaperEngine/Core/Projects/CPropertyCombo.cpp @@ -3,34 +3,33 @@ #include "CPropertyCombo.h" -#include "WallpaperEngine/Core/Core.h" #include "WallpaperEngine/Logging/CLog.h" using namespace WallpaperEngine::Core::Projects; -std::shared_ptr CPropertyCombo::fromJSON (const json& data, std::string name) { +std::shared_ptr CPropertyCombo::fromJSON (const JSON& data, std::string name) { std::vector values; - const auto options = jsonFindRequired (data, "options", "Options for a property combo is required"); + const auto options = data.require ("options", "Options for a property combo is required"); - if (!options->is_array ()) + if (!options.is_array ()) sLog.exception ("Property combo options should be an array"); - for (auto& cur : (*options)) { + for (auto& cur : options) { // TODO: PROPERLY REPORT THESE ISSUES if (!cur.is_object ()) continue; // check for label and value to ensure they're there values.push_back ({ - .label = jsonFindRequired (cur, "label", "Label is required for a property combo option"), - .value = jsonFindRequired (cur, "value", "Value is required for a property combo option") + .label = cur.require ("label", "Label is required for a property combo option"), + .value = cur.require ("value", "Value is required for a property combo option") }); } return std::make_shared ( std::move(name), - jsonFindDefault (data, "text", ""), - jsonFindRequired (data, "value", "Value is required for a property combo"), + data.optional ("text", ""), + data.require ("value", "Value is required for a property combo"), values ); } @@ -102,6 +101,6 @@ int CPropertyCombo::translateValueToIndex (const std::string& value) const { return index; } -const char* CPropertyCombo::getType () const { +const char* CPropertyCombo::getPropertyType () const { return "combo"; } diff --git a/src/WallpaperEngine/Core/Projects/CPropertyCombo.h b/src/WallpaperEngine/Core/Projects/CPropertyCombo.h index d7015b1..9d7b323 100644 --- a/src/WallpaperEngine/Core/Projects/CPropertyCombo.h +++ b/src/WallpaperEngine/Core/Projects/CPropertyCombo.h @@ -3,7 +3,7 @@ #include "CProperty.h" namespace WallpaperEngine::Core::Projects { -using json = nlohmann::json; +using JSON = WallpaperEngine::Data::JSON::JSON;; /** * Represents different combo values @@ -23,7 +23,7 @@ struct CPropertyComboValue { */ class CPropertyCombo final : public CProperty { public: - static std::shared_ptr fromJSON (const json& data, std::string name); + static std::shared_ptr fromJSON (const JSON& data, std::string name); CPropertyCombo ( std::string name, std::string text, const std::string& defaultValue, @@ -33,7 +33,7 @@ class CPropertyCombo final : public CProperty { void set (const std::string& value) override; int translateValueToIndex (const std::string& value) const; - [[nodiscard]] const char* getType () const override; + [[nodiscard]] const char* getPropertyType () const override; private: /** List of values available to select */ diff --git a/src/WallpaperEngine/Core/Projects/CPropertySlider.cpp b/src/WallpaperEngine/Core/Projects/CPropertySlider.cpp index d83e1ad..f8b7d47 100644 --- a/src/WallpaperEngine/Core/Projects/CPropertySlider.cpp +++ b/src/WallpaperEngine/Core/Projects/CPropertySlider.cpp @@ -4,12 +4,12 @@ using namespace WallpaperEngine::Core::Projects; -std::shared_ptr CPropertySlider::fromJSON (const json& data, const std::string& name) { +std::shared_ptr CPropertySlider::fromJSON (const JSON& data, const std::string& name) { const auto value = data.find ("value"); - const auto text = jsonFindDefault (data, "text", ""); - const auto min = jsonFindDefault (data, "min", 0.0f); - const auto max = jsonFindDefault (data, "max", 0.0f); - const auto step = jsonFindDefault (data, "step", 0.0f); + const auto text = data.optional ("text", ""); + const auto min = data.optional ("min", 0.0f); + const auto max = data.optional ("max", 0.0f); + const auto step = data.optional ("step", 0.0f); return std::make_shared (*value, name, text, min, max, step); } @@ -53,7 +53,7 @@ void CPropertySlider::set (const std::string& value) { this->update (newValue); } -const char* CPropertySlider::getType () const { +const char* CPropertySlider::getPropertyType () const { return "slider"; } diff --git a/src/WallpaperEngine/Core/Projects/CPropertySlider.h b/src/WallpaperEngine/Core/Projects/CPropertySlider.h index 3366a4a..bfb13f2 100644 --- a/src/WallpaperEngine/Core/Projects/CPropertySlider.h +++ b/src/WallpaperEngine/Core/Projects/CPropertySlider.h @@ -2,10 +2,8 @@ #include "CProperty.h" -#include "WallpaperEngine/Core/Core.h" - namespace WallpaperEngine::Core::Projects { -using json = nlohmann::json; +using JSON = WallpaperEngine::Data::JSON::JSON; /** * Represents a slider value with a minimum and maximum value @@ -14,7 +12,7 @@ class CPropertySlider final : public CProperty { public: CPropertySlider (float value, const std::string& name, const std::string& text, float min, float max, float step); - static std::shared_ptr fromJSON (const json& data, const std::string& name); + static std::shared_ptr fromJSON (const JSON& data, const std::string& name); /** * @return The slider's minimum value */ @@ -30,7 +28,7 @@ class CPropertySlider final : public CProperty { [[nodiscard]] std::string dump () const override; void set (const std::string& value) override; - [[nodiscard]] const char* getType () const override; + [[nodiscard]] const char* getPropertyType () const override; private: /** Minimum value */ diff --git a/src/WallpaperEngine/Core/Projects/CPropertyText.cpp b/src/WallpaperEngine/Core/Projects/CPropertyText.cpp index 3079bd5..6e27910 100644 --- a/src/WallpaperEngine/Core/Projects/CPropertyText.cpp +++ b/src/WallpaperEngine/Core/Projects/CPropertyText.cpp @@ -1,13 +1,15 @@ #include "CPropertyText.h" -#include "WallpaperEngine/Core/Core.h" #include #include using namespace WallpaperEngine::Core::Projects; -std::shared_ptr CPropertyText::fromJSON (const json& data, std::string name) { +std::shared_ptr CPropertyText::fromJSON (const JSON& data, std::string name) { //TODO: VALIDATE THIS IS RIGHT - return std::make_shared (std::move(name), *data.find ("type")); + return std::make_shared ( + std::move(name), + data.optional ("text", "") + ); } std::string CPropertyText::dump () const { @@ -24,7 +26,7 @@ void CPropertyText::set (const std::string& value) { this->m_text = value; } -const char* CPropertyText::getType () const { +const char* CPropertyText::getPropertyType () const { return "text"; } diff --git a/src/WallpaperEngine/Core/Projects/CPropertyText.h b/src/WallpaperEngine/Core/Projects/CPropertyText.h index 07cd717..b64e88d 100644 --- a/src/WallpaperEngine/Core/Projects/CPropertyText.h +++ b/src/WallpaperEngine/Core/Projects/CPropertyText.h @@ -3,7 +3,7 @@ #include "CProperty.h" namespace WallpaperEngine::Core::Projects { -using json = nlohmann::json; +using JSON = WallpaperEngine::Data::JSON::JSON; /** * Represents a text property @@ -12,11 +12,11 @@ class CPropertyText final : public CProperty { public: CPropertyText (std::string name, std::string text); - static std::shared_ptr fromJSON (const json& data, std::string name); + static std::shared_ptr fromJSON (const JSON& data, std::string name); [[nodiscard]] std::string dump () const override; void set (const std::string& value) override; - [[nodiscard]] const char* getType () const override; + [[nodiscard]] const char* getPropertyType () const override; private: }; } // namespace WallpaperEngine::Core::Projects diff --git a/src/WallpaperEngine/Data/Builders/UserSettingBuilder.h b/src/WallpaperEngine/Data/Builders/UserSettingBuilder.h index bc5dfe5..82c55cc 100644 --- a/src/WallpaperEngine/Data/Builders/UserSettingBuilder.h +++ b/src/WallpaperEngine/Data/Builders/UserSettingBuilder.h @@ -9,9 +9,7 @@ class UserSettingBuilder { public: template static UserSettingUniquePtr fromValue (T defaultValue) { - DynamicValueUniquePtr value = std::make_unique (); - - value->update (defaultValue); + DynamicValueUniquePtr value = std::make_unique (defaultValue); return std::make_unique (UserSetting { .value = std::move (value), diff --git a/src/WallpaperEngine/Data/Builders/VectorBuilder.h b/src/WallpaperEngine/Data/Builders/VectorBuilder.h index 5bf6f17..6d932a8 100644 --- a/src/WallpaperEngine/Data/Builders/VectorBuilder.h +++ b/src/WallpaperEngine/Data/Builders/VectorBuilder.h @@ -2,11 +2,15 @@ #include #include -#include +#include +#include #include "WallpaperEngine/Logging/CLog.h" +#include "WallpaperEngine/Data/Utils/SFINAE.h" namespace WallpaperEngine::Data::Builders { +using namespace WallpaperEngine::Data::Utils::SFINAE; + class VectorBuilder { private: /** @@ -60,7 +64,7 @@ class VectorBuilder { * @return */ template - static glm::vec parse (const std::string& str) { + [[nodiscard]] static glm::vec parse (const std::string& str) { const char* p = str.c_str (); // get up to 4 spaces @@ -118,6 +122,15 @@ class VectorBuilder { }; } } + template ::value, int> = 0> + [[nodiscard]] static T parse (const std::string& str) { + constexpr int length = GlmVecTraits::length; + constexpr glm::qualifier qualifier = GlmVecTraits::qualifier; + + // call the specialized version of the function + return parse::type, qualifier> (str); + } + private: }; template <> @@ -127,7 +140,7 @@ inline float VectorBuilder::convert (const char* str) { template <> inline int VectorBuilder::convert (const char* str) { - return std::strtol (str, nullptr, 10); + return std::stoi (str); } template <> diff --git a/src/WallpaperEngine/Data/JSON.cpp b/src/WallpaperEngine/Data/JSON.cpp index 4371890..65cda15 100644 --- a/src/WallpaperEngine/Data/JSON.cpp +++ b/src/WallpaperEngine/Data/JSON.cpp @@ -4,6 +4,7 @@ using namespace WallpaperEngine::Data::JSON; using namespace WallpaperEngine::Data::Model; +using namespace WallpaperEngine::Data::Parsers; UserSettingUniquePtr JsonExtensions::user (const std::string& key, const Properties& properties) const { const auto value = this->require (key, "User setting without default value must be present"); diff --git a/src/WallpaperEngine/Data/JSON.h b/src/WallpaperEngine/Data/JSON.h index b3564c3..0e08645 100644 --- a/src/WallpaperEngine/Data/JSON.h +++ b/src/WallpaperEngine/Data/JSON.h @@ -9,34 +9,14 @@ #include "WallpaperEngine/Data/Builders/UserSettingBuilder.h" #include "WallpaperEngine/Data/Builders/VectorBuilder.h" +#include "WallpaperEngine/Data/Utils/SFINAE.h" #include "WallpaperEngine/Data/Model/Types.h" #include "WallpaperEngine/Logging/CLog.h" -namespace WallpaperEngine::Data::Parsers { -class UserSettingParser; -} namespace WallpaperEngine::Data::JSON { using namespace WallpaperEngine::Data::Builders; -using namespace WallpaperEngine::Data::Parsers; using namespace WallpaperEngine::Data::Model; - -// sfinae to detect the type for template specialization -template -struct is_glm_vec : std::false_type {}; - -template -struct is_glm_vec> : std::true_type {}; - -// traits used to guess the type of the vector and it's length -template -struct GlmVecTraits; - -template -struct GlmVecTraits> { - static constexpr int length = L; - using type = T; - static constexpr glm::qualifier qualifier = Q; -}; +using namespace WallpaperEngine::Data::Utils::SFINAE; class JsonExtensions; diff --git a/src/WallpaperEngine/Core/DynamicValues/CDynamicValue.cpp b/src/WallpaperEngine/Data/Model/DynamicValue.cpp similarity index 65% rename from src/WallpaperEngine/Core/DynamicValues/CDynamicValue.cpp rename to src/WallpaperEngine/Data/Model/DynamicValue.cpp index 49e1689..7450ac3 100644 --- a/src/WallpaperEngine/Core/DynamicValues/CDynamicValue.cpp +++ b/src/WallpaperEngine/Data/Model/DynamicValue.cpp @@ -1,223 +1,89 @@ -#include -#include "CDynamicValue.h" +#include "DynamicValue.h" -using namespace WallpaperEngine::Core::DynamicValues; +using namespace WallpaperEngine::Data::Model; -CDynamicValue::~CDynamicValue() { - for (auto* connection : this->m_incomingConnections) { - connection->destroyOutgoingConnection (this); - } +DynamicValue::DynamicValue (const glm::ivec4& value) { + this->update (value); } -void CDynamicValue::update(float newValue) { - this->m_ivec4 = glm::ivec4(static_cast (newValue)); - this->m_ivec3 = glm::ivec3(static_cast (newValue)); - this->m_ivec2 = glm::ivec2(static_cast (newValue)); - this->m_vec4 = glm::vec4(newValue); - this->m_vec3 = glm::vec3(newValue); - this->m_vec2 = glm::vec2(newValue); - this->m_float = newValue; - this->m_int = static_cast (newValue); - this->m_bool = static_cast (newValue) != 0; - this->m_type = UnderlyingType::Float; - - this->propagate (); +DynamicValue::DynamicValue (const glm::ivec3& value) { + this->update (value); } -void CDynamicValue::update(int newValue) { - this->m_ivec4 = glm::ivec4(newValue); - this->m_ivec3 = glm::ivec3(newValue); - this->m_ivec2 = glm::ivec2(newValue); - this->m_vec4 = glm::vec4(static_cast (newValue)); - this->m_vec3 = glm::vec3(static_cast (newValue)); - this->m_vec2 = glm::vec2(static_cast (newValue)); - this->m_float = static_cast (newValue); - this->m_int = newValue; - this->m_bool = newValue != 0; - this->m_type = UnderlyingType::Int; - - this->propagate (); +DynamicValue::DynamicValue (const glm::ivec2& value) { + this->update (value); } -void CDynamicValue::update(bool newValue) { - this->m_ivec4 = glm::ivec4(newValue); - this->m_ivec3 = glm::ivec3(newValue); - this->m_ivec2 = glm::ivec2(newValue); - this->m_vec4 = glm::vec4(newValue); - this->m_vec3 = glm::vec3(newValue); - this->m_vec2 = glm::vec2(newValue); - this->m_float = newValue; - this->m_int = newValue; - this->m_bool = newValue; - this->m_type = UnderlyingType::Boolean; - - this->propagate (); +DynamicValue::DynamicValue (const glm::vec4& value) { + this->update (value); } -void CDynamicValue::update(const glm::vec2& newValue) { - this->m_ivec4 = glm::ivec4(newValue, 0, 0); - this->m_ivec3 = glm::ivec3(newValue, 0); - this->m_ivec2 = glm::ivec2(newValue); - this->m_vec2 = newValue; - this->m_vec3 = glm::vec3(newValue, 0.0f); - this->m_vec4 = glm::vec4(newValue, 0.0f, 0.0f); - this->m_float = newValue.x; - this->m_int = static_cast (newValue.x); - this->m_bool = newValue.x != 0.0f; - this->m_type = UnderlyingType::Vec2; - - this->propagate (); +DynamicValue::DynamicValue (const glm::vec3& value) { + this->update (value); } -void CDynamicValue::update(const glm::vec3& newValue) { - this->m_ivec4 = glm::ivec4(newValue, 0); - this->m_ivec3 = glm::ivec3(newValue); - this->m_ivec2 = glm::ivec2(newValue); - this->m_vec2 = glm::vec2(newValue); - this->m_vec3 = newValue; - this->m_vec4 = glm::vec4(newValue, 0.0f); - this->m_float = newValue.x; - this->m_int = static_cast (newValue.x); - this->m_bool = newValue.x != 0.0f; - this->m_type = UnderlyingType::Vec3; - - this->propagate (); +DynamicValue::DynamicValue (const glm::vec2& value) { + this->update (value); } -void CDynamicValue::update(const glm::vec4& newValue) { - this->m_ivec4 = glm::ivec4(newValue); - this->m_ivec3 = glm::ivec3(newValue); - this->m_ivec2 = glm::ivec2(newValue); - this->m_vec2 = glm::vec2(newValue); - this->m_vec3 = glm::vec3(newValue); - this->m_vec4 = newValue; - this->m_float = newValue.x; - this->m_int = static_cast (newValue.x); - this->m_bool = newValue.x != 0.0f; - this->m_type = UnderlyingType::Vec4; - - this->propagate (); +DynamicValue::DynamicValue (float value) { + this->update (value); } -void CDynamicValue::update(const glm::ivec2& newValue) { - this->m_ivec4 = glm::ivec4(newValue, 0, 0); - this->m_ivec3 = glm::ivec3(newValue, 0); - this->m_ivec2 = glm::ivec2(newValue); - this->m_vec2 = newValue; - this->m_vec3 = glm::vec3(newValue, 0.0f); - this->m_vec4 = glm::vec4(newValue, 0.0f, 0.0f); - this->m_float = static_cast (newValue.x); - this->m_int = static_cast (newValue.x); - this->m_bool = newValue.x != 0; - this->m_type = UnderlyingType::IVec2; - - this->propagate (); +DynamicValue::DynamicValue (int value) { + this->update (value); } -void CDynamicValue::update(const glm::ivec3& newValue) { - this->m_ivec4 = glm::ivec4(newValue, 0); - this->m_ivec3 = glm::ivec3(newValue); - this->m_ivec2 = glm::ivec2(newValue); - this->m_vec2 = glm::vec2(newValue); - this->m_vec3 = newValue; - this->m_vec4 = glm::vec4(newValue, 0.0f); - this->m_float = static_cast (newValue.x); - this->m_int = static_cast (newValue.x); - this->m_bool = newValue.x != 0; - this->m_type = UnderlyingType::IVec3; - - this->propagate (); +DynamicValue::DynamicValue (bool value) { + this->update (value); } -void CDynamicValue::update(const glm::ivec4& newValue) { - this->m_ivec4 = glm::ivec4(newValue); - this->m_ivec3 = glm::ivec3(newValue); - this->m_ivec2 = glm::ivec2(newValue); - this->m_vec2 = glm::vec2(newValue); - this->m_vec3 = glm::vec3(newValue); - this->m_vec4 = newValue; - this->m_float = static_cast (newValue.x); - this->m_int = static_cast (newValue.x); - this->m_bool = newValue.x != 0; - this->m_type = UnderlyingType::IVec4; - - this->propagate (); +DynamicValue::~DynamicValue () { + this->disconnect (); + this->m_listeners.clear (); } -void CDynamicValue::connectOutgoing (CDynamicValue* value) const { - this->m_outgoingConnections.push_back (value); - - // ensure that new connection has the right value - this->propagate (); - // ensure the other value keeps track of our connection too - value->connectIncoming (this); -} - -void CDynamicValue::connectIncoming (const CDynamicValue* value) const { - this->m_incomingConnections.push_back (value); -} - -void CDynamicValue::destroyOutgoingConnection (CDynamicValue* value) const { - this->m_outgoingConnections.erase ( - std::remove (this->m_outgoingConnections.begin (), this->m_outgoingConnections.end (), value), this->m_outgoingConnections.end () - ); -} - -void CDynamicValue::propagate () const { - for (auto* cur : this->m_outgoingConnections) { - cur->m_bool = this->m_bool; - cur->m_int = this->m_int; - cur->m_float = this->m_float; - cur->m_ivec2 = this->m_ivec2; - cur->m_ivec3 = this->m_ivec3; - cur->m_ivec4 = this->m_ivec4; - cur->m_vec2 = this->m_vec2; - cur->m_vec3 = this->m_vec3; - cur->m_vec4 = this->m_vec4; - } -} - -const glm::ivec4& CDynamicValue::getIVec4 () const { +const glm::ivec4& DynamicValue::getIVec4 () const { return this->m_ivec4; } -const glm::ivec3& CDynamicValue::getIVec3 () const { +const glm::ivec3& DynamicValue::getIVec3 () const { return this->m_ivec3; } -const glm::ivec2& CDynamicValue::getIVec2 () const { +const glm::ivec2& DynamicValue::getIVec2 () const { return this->m_ivec2; } -const glm::vec4& CDynamicValue::getVec4 () const { +const glm::vec4& DynamicValue::getVec4 () const { return this->m_vec4; } -const glm::vec3& CDynamicValue::getVec3 () const { +const glm::vec3& DynamicValue::getVec3 () const { return this->m_vec3; } -const glm::vec2& CDynamicValue::getVec2 () const { +const glm::vec2& DynamicValue::getVec2 () const { return this->m_vec2; } -const float& CDynamicValue::getFloat () const { +const float& DynamicValue::getFloat () const { return this->m_float; } -const int& CDynamicValue::getInt () const { +const int& DynamicValue::getInt () const { return this->m_int; } -const bool& CDynamicValue::getBool () const { +const bool& DynamicValue::getBool () const { return this->m_bool; } -CDynamicValue::UnderlyingType CDynamicValue::getType () const { +DynamicValue::UnderlyingType DynamicValue::getType () const { return this->m_type; } -std::string CDynamicValue::toString () const { +std::string DynamicValue::toString () const { switch (this->m_type) { case UnderlyingType::Float: return std::to_string (this->m_float); @@ -240,4 +106,184 @@ std::string CDynamicValue::toString () const { default: return "Unknown conversion for dynamic value of type: " + std::to_string (static_cast (this->m_type)); } +} + +void DynamicValue::update(float newValue) { + this->m_ivec4 = glm::ivec4(static_cast (newValue)); + this->m_ivec3 = glm::ivec3(static_cast (newValue)); + this->m_ivec2 = glm::ivec2(static_cast (newValue)); + this->m_vec4 = glm::vec4(newValue); + this->m_vec3 = glm::vec3(newValue); + this->m_vec2 = glm::vec2(newValue); + this->m_float = newValue; + this->m_int = static_cast (newValue); + this->m_bool = static_cast (newValue) != 0; + this->m_type = UnderlyingType::Float; + + this->propagate (); +} + +void DynamicValue::update(int newValue) { + this->m_ivec4 = glm::ivec4(newValue); + this->m_ivec3 = glm::ivec3(newValue); + this->m_ivec2 = glm::ivec2(newValue); + this->m_vec4 = glm::vec4(static_cast (newValue)); + this->m_vec3 = glm::vec3(static_cast (newValue)); + this->m_vec2 = glm::vec2(static_cast (newValue)); + this->m_float = static_cast (newValue); + this->m_int = newValue; + this->m_bool = newValue != 0; + this->m_type = UnderlyingType::Int; + + this->propagate (); +} + +void DynamicValue::update(bool newValue) { + this->m_ivec4 = glm::ivec4(newValue); + this->m_ivec3 = glm::ivec3(newValue); + this->m_ivec2 = glm::ivec2(newValue); + this->m_vec4 = glm::vec4(newValue); + this->m_vec3 = glm::vec3(newValue); + this->m_vec2 = glm::vec2(newValue); + this->m_float = newValue; + this->m_int = newValue; + this->m_bool = newValue; + this->m_type = UnderlyingType::Boolean; + + this->propagate (); +} + +void DynamicValue::update(const glm::vec2& newValue) { + this->m_ivec4 = glm::ivec4(newValue, 0, 0); + this->m_ivec3 = glm::ivec3(newValue, 0); + this->m_ivec2 = glm::ivec2(newValue); + this->m_vec2 = newValue; + this->m_vec3 = glm::vec3(newValue, 0.0f); + this->m_vec4 = glm::vec4(newValue, 0.0f, 0.0f); + this->m_float = newValue.x; + this->m_int = static_cast (newValue.x); + this->m_bool = newValue.x != 0.0f; + this->m_type = UnderlyingType::Vec2; + + this->propagate (); +} + +void DynamicValue::update(const glm::vec3& newValue) { + this->m_ivec4 = glm::ivec4(newValue, 0); + this->m_ivec3 = glm::ivec3(newValue); + this->m_ivec2 = glm::ivec2(newValue); + this->m_vec2 = glm::vec2(newValue); + this->m_vec3 = newValue; + this->m_vec4 = glm::vec4(newValue, 0.0f); + this->m_float = newValue.x; + this->m_int = static_cast (newValue.x); + this->m_bool = newValue.x != 0.0f; + this->m_type = UnderlyingType::Vec3; + + this->propagate (); +} + +void DynamicValue::update(const glm::vec4& newValue) { + this->m_ivec4 = glm::ivec4(newValue); + this->m_ivec3 = glm::ivec3(newValue); + this->m_ivec2 = glm::ivec2(newValue); + this->m_vec2 = glm::vec2(newValue); + this->m_vec3 = glm::vec3(newValue); + this->m_vec4 = newValue; + this->m_float = newValue.x; + this->m_int = static_cast (newValue.x); + this->m_bool = newValue.x != 0.0f; + this->m_type = UnderlyingType::Vec4; + + this->propagate (); +} + +void DynamicValue::update(const glm::ivec2& newValue) { + this->m_ivec4 = glm::ivec4(newValue, 0, 0); + this->m_ivec3 = glm::ivec3(newValue, 0); + this->m_ivec2 = glm::ivec2(newValue); + this->m_vec2 = newValue; + this->m_vec3 = glm::vec3(newValue, 0.0f); + this->m_vec4 = glm::vec4(newValue, 0.0f, 0.0f); + this->m_float = static_cast (newValue.x); + this->m_int = static_cast (newValue.x); + this->m_bool = newValue.x != 0; + this->m_type = UnderlyingType::IVec2; + + this->propagate (); +} + +void DynamicValue::update(const glm::ivec3& newValue) { + this->m_ivec4 = glm::ivec4(newValue, 0); + this->m_ivec3 = glm::ivec3(newValue); + this->m_ivec2 = glm::ivec2(newValue); + this->m_vec2 = glm::vec2(newValue); + this->m_vec3 = newValue; + this->m_vec4 = glm::vec4(newValue, 0.0f); + this->m_float = static_cast (newValue.x); + this->m_int = static_cast (newValue.x); + this->m_bool = newValue.x != 0; + this->m_type = UnderlyingType::IVec3; + + this->propagate (); +} + +void DynamicValue::update(const glm::ivec4& newValue) { + this->m_ivec4 = glm::ivec4(newValue); + this->m_ivec3 = glm::ivec3(newValue); + this->m_ivec2 = glm::ivec2(newValue); + this->m_vec2 = glm::vec2(newValue); + this->m_vec3 = glm::vec3(newValue); + this->m_vec4 = newValue; + this->m_float = static_cast (newValue.x); + this->m_int = static_cast (newValue.x); + this->m_bool = newValue.x != 0; + this->m_type = UnderlyingType::IVec4; + + this->propagate (); +} + +void DynamicValue::update (const DynamicValue& other) { + this->m_ivec4 = other.getIVec4 (); + this->m_ivec3 = other.getIVec3 (); + this->m_ivec2 = other.getIVec2 (); + this->m_vec2 = other.getVec2 (); + this->m_vec3 = other.getVec3 (); + this->m_vec4 = other.getVec4 (); + this->m_float = other.getFloat (); + this->m_int = other.getInt (); + this->m_bool = other.getBool (); + this->m_type = other.getType (); + + this->propagate (); +} + +std::function DynamicValue::listen (const std::function& callback) { + const auto it = this->m_listeners.insert (this->m_listeners.end (), callback); + + return [this, it] { + this->m_listeners.erase (it); + }; +} + +void DynamicValue::connect (DynamicValue* other) { + const auto deregisterFunction = other->listen ([this] (const DynamicValue& other) { + this->update (other); + }); + + this->m_connections.push_back (deregisterFunction); +} + +void DynamicValue::disconnect () { + for (const auto& deregister : this->m_connections) { + deregister (); + } + + this->m_connections.clear (); +} + +void DynamicValue::propagate () const { + for (const auto& callback : this->m_listeners) { + callback(*this); + } } \ No newline at end of file diff --git a/src/WallpaperEngine/Data/Model/DynamicValue.h b/src/WallpaperEngine/Data/Model/DynamicValue.h new file mode 100644 index 0000000..6d6f1d9 --- /dev/null +++ b/src/WallpaperEngine/Data/Model/DynamicValue.h @@ -0,0 +1,105 @@ +#pragma once + +#include +#include +#include + +namespace WallpaperEngine::Data::Model { +/** + * Class that represents different types of dynamic values + */ +class DynamicValue { + public: + enum UnderlyingType { + Null = 0, + IVec4 = 1, + IVec3 = 2, + IVec2 = 3, + Vec4 = 4, + Vec3 = 5, + Vec2 = 6, + Float = 7, + Int = 8, + Boolean = 9 + }; + + DynamicValue () = default; + explicit DynamicValue(const glm::ivec4& value); + explicit DynamicValue(const glm::ivec3& value); + explicit DynamicValue(const glm::ivec2& value); + explicit DynamicValue(const glm::vec4& value); + explicit DynamicValue(const glm::vec3& value); + explicit DynamicValue(const glm::vec2& value); + explicit DynamicValue(float value); + explicit DynamicValue(int value); + explicit DynamicValue(bool value); + ~DynamicValue (); + + [[nodiscard]] const glm::ivec4& getIVec4 () const; + [[nodiscard]] const glm::ivec3& getIVec3 () const; + [[nodiscard]] const glm::ivec2& getIVec2 () const; + [[nodiscard]] const glm::vec4& getVec4 () const; + [[nodiscard]] const glm::vec3& getVec3 () const; + [[nodiscard]] const glm::vec2& getVec2 () const; + [[nodiscard]] const float& getFloat () const; + [[nodiscard]] const int& getInt () const; + [[nodiscard]] const bool& getBool () const; + [[nodiscard]] UnderlyingType getType () const; + [[nodiscard]] std::string toString () const; + + void update (float newValue); + void update (int newValue); + void update (bool newValue); + void update (const glm::vec2& newValue); + void update (const glm::vec3& newValue); + void update (const glm::vec4& newValue); + void update (const glm::ivec2& newValue); + void update (const glm::ivec3& newValue); + void update (const glm::ivec4& newValue); + void update (const DynamicValue& newValue); + + /** + * Registers the given callback to be called when the value changes + * + * @param callback + * + * @return The de-register function to call when the listener is no longer needed + */ + std::function listen (const std::function& callback); + /** + * Connects the current instance to the given instance, updating this instance's value + * based on the given instance's value + * + * @param other + * + * @return The de-register function to call when the listener is no longer needed + */ + void connect (DynamicValue* other); + + /** + * Disconnects the current instance from all the connections to stop notifying + * new value changes + */ + void disconnect (); + + private: + /** + * Notifies any listeners that the value has changed + */ + void propagate () const; + + std::vector> m_listeners = {}; + std::vector> m_connections = {}; + + glm::ivec4 m_ivec4 = {}; + glm::ivec3 m_ivec3 = {}; + glm::ivec2 m_ivec2 = {}; + glm::vec4 m_vec4 = {}; + glm::vec3 m_vec3 = {}; + glm::vec2 m_vec2 = {}; + float m_float = 0.0f; + int m_int = 0; + bool m_bool = false; + UnderlyingType m_type = Null; +}; +} \ No newline at end of file diff --git a/src/WallpaperEngine/Data/Model/Types.h b/src/WallpaperEngine/Data/Model/Types.h index 2b1c101..6fff328 100644 --- a/src/WallpaperEngine/Data/Model/Types.h +++ b/src/WallpaperEngine/Data/Model/Types.h @@ -1,10 +1,16 @@ #pragma once +#include +#include +#include +#include #include #include "WallpaperEngine/Assets/CContainer.h" -#include "WallpaperEngine/Core/DynamicValues/CDynamicValue.h" -#include "WallpaperEngine/Core/Projects/CProperty.h" + +namespace WallpaperEngine::Core::Projects { +class CProperty; +} namespace WallpaperEngine::Data::Model { struct Project; @@ -19,6 +25,7 @@ class Image; struct ImageEffect; struct ImageEffectPassOverride; class Particle; +class DynamicValue; struct Material; struct MaterialPass; struct FBO; @@ -33,7 +40,6 @@ using Property = WallpaperEngine::Core::Projects::CProperty; using PropertySharedPtr = std::shared_ptr ; using PropertyWeakPtr = std::weak_ptr ; using Properties = std::map ; -using DynamicValue = WallpaperEngine::Core::DynamicValues::CDynamicValue; using DynamicValueUniquePtr = std::unique_ptr ; using DynamicValueSharedPtr = std::shared_ptr ; using DynamicValueWeakPtr = std::weak_ptr ; diff --git a/src/WallpaperEngine/Data/Model/UserSetting.h b/src/WallpaperEngine/Data/Model/UserSetting.h index ce3f46b..7ef7c71 100644 --- a/src/WallpaperEngine/Data/Model/UserSetting.h +++ b/src/WallpaperEngine/Data/Model/UserSetting.h @@ -3,11 +3,9 @@ #include #include +#include "DynamicValue.h" #include "Types.h" -#include "WallpaperEngine/Core/DynamicValues/CDynamicValue.h" -#include "WallpaperEngine/Core/Projects/CProperty.h" - namespace WallpaperEngine::Data::Model { struct ConditionInfo { public: diff --git a/src/WallpaperEngine/Data/Parsers/ProjectParser.cpp b/src/WallpaperEngine/Data/Parsers/ProjectParser.cpp index a26957e..9f2c7c7 100644 --- a/src/WallpaperEngine/Data/Parsers/ProjectParser.cpp +++ b/src/WallpaperEngine/Data/Parsers/ProjectParser.cpp @@ -6,6 +6,7 @@ #include "WallpaperParser.h" #include "WallpaperEngine/Data/Model/Wallpaper.h" +#include "WallpaperEngine/Core/Projects/CProperty.h" using namespace WallpaperEngine::Data::Parsers; diff --git a/src/WallpaperEngine/Data/Utils/SFINAE.h b/src/WallpaperEngine/Data/Utils/SFINAE.h new file mode 100644 index 0000000..f983fc8 --- /dev/null +++ b/src/WallpaperEngine/Data/Utils/SFINAE.h @@ -0,0 +1,25 @@ +#pragma once + +#include +#include + +namespace WallpaperEngine::Data::Utils::SFINAE { +// sfinae to detect the type for template specialization +template +struct is_glm_vec : std::false_type {}; + +template +struct is_glm_vec> : std::true_type {}; + +// traits used to guess the type of the vector and it's length +template +struct GlmVecTraits; + +template +struct GlmVecTraits> { + static constexpr int length = L; + using type = T; + static constexpr glm::qualifier qualifier = Q; +}; + +} \ No newline at end of file diff --git a/src/WallpaperEngine/Render/CFBOProvider.h b/src/WallpaperEngine/Render/CFBOProvider.h index 2b3d174..027ca55 100644 --- a/src/WallpaperEngine/Render/CFBOProvider.h +++ b/src/WallpaperEngine/Render/CFBOProvider.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "CFBO.h" #include "WallpaperEngine/Data/Model/Effect.h" diff --git a/src/WallpaperEngine/Render/Objects/Effects/CPass.cpp b/src/WallpaperEngine/Render/Objects/Effects/CPass.cpp index 433c89f..b367381 100644 --- a/src/WallpaperEngine/Render/Objects/Effects/CPass.cpp +++ b/src/WallpaperEngine/Render/Objects/Effects/CPass.cpp @@ -727,7 +727,7 @@ void CPass::addUniform (CShaderVariable* value) { this->addUniform (value, value); } -void CPass::addUniform (CShaderVariable* value, const CDynamicValue* setting) { +void CPass::addUniform (CShaderVariable* value, const DynamicValue* setting) { if (value->is ()) { this->addUniform (value->getName (), setting->getFloat ()); } else if (value->is ()) { diff --git a/src/WallpaperEngine/Render/Objects/Effects/CPass.h b/src/WallpaperEngine/Render/Objects/Effects/CPass.h index b1eb6a1..28c6a4e 100644 --- a/src/WallpaperEngine/Render/Objects/Effects/CPass.h +++ b/src/WallpaperEngine/Render/Objects/Effects/CPass.h @@ -114,7 +114,7 @@ class CPass final : public Helpers::CContextAware { void setupAttributes (); void addAttribute (const std::string& name, GLint type, GLint elements, const GLuint* value); void addUniform (CShaderVariable* value); - void addUniform (CShaderVariable* value, const CDynamicValue* setting); + void addUniform (CShaderVariable* value, const DynamicValue* setting); void addUniform (const std::string& name, int value); void addUniform (const std::string& name, double value); void addUniform (const std::string& name, float value); diff --git a/src/WallpaperEngine/Render/Shaders/CShader.h b/src/WallpaperEngine/Render/Shaders/CShader.h index 25e992b..10a41c8 100644 --- a/src/WallpaperEngine/Render/Shaders/CShader.h +++ b/src/WallpaperEngine/Render/Shaders/CShader.h @@ -6,7 +6,6 @@ #include "WallpaperEngine/Assets/CContainer.h" #include "WallpaperEngine/Assets/ITexture.h" -#include "WallpaperEngine/Core/Core.h" #include "WallpaperEngine/Render/Shaders/Variables/CShaderVariable.h" #include "CShaderUnit.h" diff --git a/src/WallpaperEngine/Render/Shaders/CShaderUnit.cpp b/src/WallpaperEngine/Render/Shaders/CShaderUnit.cpp index 45c1989..8e88515 100644 --- a/src/WallpaperEngine/Render/Shaders/CShaderUnit.cpp +++ b/src/WallpaperEngine/Render/Shaders/CShaderUnit.cpp @@ -15,6 +15,8 @@ #include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector3.h" #include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector4.h" +#include "WallpaperEngine/Data/Builders/VectorBuilder.h" + #define SHADER_HEADER(filename) "#version 330\n" \ "// ======================================================\n" \ "// Processed shader " + \ @@ -47,6 +49,7 @@ using namespace WallpaperEngine::Core; using namespace WallpaperEngine::Assets; +using namespace WallpaperEngine::Data::Builders; using namespace WallpaperEngine::Render::Shaders; CShaderUnit::CShaderUnit ( @@ -322,18 +325,18 @@ void CShaderUnit::preprocessRequires () { void CShaderUnit::parseComboConfiguration (const std::string& content, int defaultValue) { // TODO: SUPPORT REQUIRES SO WE PROPERLY FOLLOW THE REQUIRED CHAIN - json data = json::parse (content); - const auto combo = jsonFindRequired (data, "combo", "cannot parse combo information"); + const auto data = JSON::parse (content); + const auto combo = data.require ("combo", "cannot parse combo information"); // ignore type as it seems to be used only on the editor // const auto type = data.find ("type"); const auto defvalue = data.find ("default"); // check the combos - const auto entry = this->m_combos.find (combo->get ()); - const auto entryOverride = this->m_overrideCombos.find (combo->get ()); + const auto entry = this->m_combos.find (combo); + const auto entryOverride = this->m_overrideCombos.find (combo); // add the combo to the found list - this->m_usedCombos.emplace (*combo, true); + this->m_usedCombos.emplace (combo, true); // if the combo was not found in the predefined values this means that the default value in the JSON data can be // used so only define the ones that are not already defined @@ -341,15 +344,15 @@ void CShaderUnit::parseComboConfiguration (const std::string& content, int defau // if no combo is defined just load the default settings if (defvalue == data.end ()) { // TODO: PROPERLY SUPPORT EMPTY COMBOS - this->m_discoveredCombos.emplace (*combo, (int) defaultValue); + this->m_discoveredCombos.emplace (combo, (int) defaultValue); } else if (defvalue->is_number_float ()) { - sLog.exception ("float combos are not supported in shader ", this->m_file, ". ", *combo); + sLog.exception ("float combos are not supported in shader ", this->m_file, ". ", combo); } else if (defvalue->is_number_integer ()) { - this->m_discoveredCombos.emplace (*combo, defvalue->get ()); + this->m_discoveredCombos.emplace (combo, defvalue->get ()); } else if (defvalue->is_string ()) { - sLog.exception ("string combos are not supported in shader ", this->m_file, ". ", *combo); + sLog.exception ("string combos are not supported in shader ", this->m_file, ". ", combo); } else { - sLog.exception ("cannot parse combo information ", *combo, ". unknown type for ", defvalue->dump ()); + sLog.exception ("cannot parse combo information ", combo, ". unknown type for ", defvalue->dump ()); } } } @@ -357,45 +360,42 @@ void CShaderUnit::parseComboConfiguration (const std::string& content, int defau void CShaderUnit::parseParameterConfiguration ( const std::string& type, const std::string& name, const std::string& content ) { - json data = json::parse (content); - const auto material = data.find ("material"); - const auto defvalue = data.find ("default"); + const auto data = JSON::parse (content); + const auto material = data.optional ("material"); + const auto defvalue = data.optional ("default"); // auto range = data.find ("range"); const auto combo = data.find ("combo"); // this is not a real parameter auto constant = this->m_constants.end (); - if (material != data.end ()) + if (material.has_value ()) constant = this->m_constants.find (*material); - if (constant == this->m_constants.end () && defvalue == data.end ()) { + if (constant == this->m_constants.end () && !defvalue.has_value ()) { if (type != "sampler2D") sLog.exception ("Cannot parse parameter data for ", name, " in shader ", this->m_file); } Variables::CShaderVariable* parameter = nullptr; - // TODO: SUPPORT VALUES FOR ALL THESE TYPES - // TODO: MAYBE EVEN CONNECT THESE TO THE CORRESPONDING PROPERTY SO THINGS ARE UPDATED AS THE ORIGIN VALUES CHANGE? - // TODO: MAKE USE OF PARSERS INSTEAD OF CORE if (type == "vec4") { - parameter = new Variables::CShaderVariableVector4 (WallpaperEngine::Core::aToVector4 (*defvalue)); + parameter = new Variables::CShaderVariableVector4 (VectorBuilder::parse (defvalue->get ())); } else if (type == "vec3") { - parameter = new Variables::CShaderVariableVector3 (WallpaperEngine::Core::aToVector3 (*defvalue)); + parameter = new Variables::CShaderVariableVector3 (VectorBuilder::parse (*defvalue)); } else if (type == "vec2") { - parameter = new Variables::CShaderVariableVector2 (WallpaperEngine::Core::aToVector2 (*defvalue)); + parameter = new Variables::CShaderVariableVector2 (VectorBuilder::parse (*defvalue)); } else if (type == "float") { if (defvalue->is_string ()) { - parameter = new Variables::CShaderVariableFloat (strtof32 ((defvalue->get ()).c_str (), nullptr)); + parameter = new Variables::CShaderVariableFloat (std::stoi (defvalue->get ())); } else { - parameter = new Variables::CShaderVariableFloat (*defvalue); + parameter = new Variables::CShaderVariableFloat (defvalue->get ()); } } else if (type == "int") { if (defvalue->is_string ()) { - parameter = new Variables::CShaderVariableInteger (strtol((defvalue->get ()).c_str (), nullptr, 10)); + parameter = new Variables::CShaderVariableInteger (std::stoi(defvalue->get ())); } else { - parameter = new Variables::CShaderVariableInteger (*defvalue); + parameter = new Variables::CShaderVariableInteger (defvalue->get ()); } } else if (type == "sampler2D" || type == "sampler2DComparison") { // samplers can have special requirements, check what sampler we're working with and create definitions @@ -460,7 +460,7 @@ void CShaderUnit::parseParameterConfiguration ( } if (isRequired && !textureSlotUsed) { - if (defvalue == data.end ()) { + if (!defvalue.has_value ()) { isRequired = false; } else { // is the combo registered already? @@ -473,7 +473,7 @@ void CShaderUnit::parseParameterConfiguration ( isRequired = false; // otherwise a default value must be used } else if (defvalue->is_string ()) { - comboValue = strtol (defvalue->get ().c_str (), nullptr, 10); + comboValue = std::stoi (defvalue->get ().c_str ()); } else if (defvalue->is_number()) { comboValue = *defvalue; } else { @@ -500,7 +500,7 @@ void CShaderUnit::parseParameterConfiguration ( return; } - if (material != data.end () && parameter != nullptr) { + if (material.has_value () && parameter != nullptr) { parameter->setIdentifierName (*material); parameter->setName (name); diff --git a/src/WallpaperEngine/Render/Shaders/CShaderUnit.h b/src/WallpaperEngine/Render/Shaders/CShaderUnit.h index 4974f44..24f21fc 100644 --- a/src/WallpaperEngine/Render/Shaders/CShaderUnit.h +++ b/src/WallpaperEngine/Render/Shaders/CShaderUnit.h @@ -6,14 +6,14 @@ #include "CGLSLContext.h" #include "WallpaperEngine/Assets/CContainer.h" -#include "WallpaperEngine/Core/Core.h" +#include "WallpaperEngine/Data/JSON.h" #include "WallpaperEngine/Render/Shaders/Variables/CShaderVariable.h" #include "nlohmann/json.hpp" #include "WallpaperEngine/Data/Model/Types.h" namespace WallpaperEngine::Render::Shaders { -using json = nlohmann::json; +using JSON = WallpaperEngine::Data::JSON::JSON; using namespace WallpaperEngine::Assets; using namespace WallpaperEngine::Data::Model; diff --git a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariable.h b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariable.h index f5d09ce..ea7a637 100644 --- a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariable.h +++ b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariable.h @@ -1,32 +1,17 @@ #pragma once -#include "WallpaperEngine/Core/DynamicValues/CDynamicValue.h" +#include "WallpaperEngine/Data/Utils/TypeCaster.h" +#include "WallpaperEngine/Data/Model/DynamicValue.h" +#include #include namespace WallpaperEngine::Render::Shaders::Variables { -class CShaderVariable : public Core::DynamicValues::CDynamicValue { +using namespace WallpaperEngine::Data::Model; +using namespace WallpaperEngine::Data::Utils; + +class CShaderVariable : public DynamicValue, public TypeCaster { public: - virtual ~CShaderVariable () = default; - - template [[nodiscard]] const T* as () const { - if (is ()) { - return static_cast (this); - } - - throw std::bad_cast (); - } - - template [[nodiscard]] T* as () { - if (is ()) { - return static_cast (this); - } - - throw std::bad_cast (); - } - - template [[nodiscard]] bool is () const { - return typeid (*this) == typeid(T); - } + using DynamicValue::DynamicValue; [[nodiscard]] const std::string& getIdentifierName () const; [[nodiscard]] const std::string& getName () const; @@ -35,7 +20,7 @@ class CShaderVariable : public Core::DynamicValues::CDynamicValue { void setName (const std::string& name); private: - std::string m_identifierName = ""; - std::string m_name = ""; + std::string m_identifierName; + std::string m_name; }; } // namespace WallpaperEngine::Render::Shaders::Variables diff --git a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableFloat.cpp b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableFloat.cpp index d171b0d..8a43168 100644 --- a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableFloat.cpp +++ b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableFloat.cpp @@ -4,13 +4,7 @@ using namespace WallpaperEngine::Render::Shaders::Variables; -CShaderVariableFloat::CShaderVariableFloat (float defaultValue) : - CShaderVariable () { - this->update (defaultValue); -} - CShaderVariableFloat::CShaderVariableFloat (float defaultValue, const std::string& name) : - CShaderVariable () { + CShaderVariable (defaultValue) { this->setName (name); - this->update (defaultValue); } diff --git a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableFloat.h b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableFloat.h index 6a7b2ce..da64b7a 100644 --- a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableFloat.h +++ b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableFloat.h @@ -5,7 +5,8 @@ namespace WallpaperEngine::Render::Shaders::Variables { class CShaderVariableFloat final : public CShaderVariable { public: - explicit CShaderVariableFloat (float defaultValue); + using CShaderVariable::CShaderVariable; + CShaderVariableFloat (float defaultValue, const std::string& name); }; } // namespace WallpaperEngine::Render::Shaders::Variables diff --git a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableInteger.cpp b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableInteger.cpp index 3e551ba..4907d2c 100644 --- a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableInteger.cpp +++ b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableInteger.cpp @@ -4,13 +4,7 @@ using namespace WallpaperEngine::Render::Shaders::Variables; -CShaderVariableInteger::CShaderVariableInteger (int32_t defaultValue) : - CShaderVariable () { - this->update (defaultValue); -} - -CShaderVariableInteger::CShaderVariableInteger (int32_t defaultValue, const std::string& name) : - CShaderVariable () { +CShaderVariableInteger::CShaderVariableInteger (int defaultValue, const std::string& name) : + CShaderVariable (defaultValue) { this->setName (name); - this->update (defaultValue); } diff --git a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableInteger.h b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableInteger.h index bc53dd3..17ff7ea 100644 --- a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableInteger.h +++ b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableInteger.h @@ -5,7 +5,8 @@ namespace WallpaperEngine::Render::Shaders::Variables { class CShaderVariableInteger final : public CShaderVariable { public: - explicit CShaderVariableInteger (int32_t defaultValue); - CShaderVariableInteger (int32_t defaultValue, const std::string& name); + using CShaderVariable::CShaderVariable; + + CShaderVariableInteger (int defaultValue, const std::string& name); }; } // namespace WallpaperEngine::Render::Shaders::Variables diff --git a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector2.cpp b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector2.cpp index 84198ec..9bf915c 100644 --- a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector2.cpp +++ b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector2.cpp @@ -4,13 +4,7 @@ using namespace WallpaperEngine::Render::Shaders::Variables; -CShaderVariableVector2::CShaderVariableVector2 (const glm::vec2& defaultValue) : - CShaderVariable () { - this->update (defaultValue); -} - CShaderVariableVector2::CShaderVariableVector2 (const glm::vec2& defaultValue, const std::string& name) : - CShaderVariable () { + CShaderVariable (defaultValue) { this->setName (name); - this->update (defaultValue); } diff --git a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector2.h b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector2.h index b225277..396535b 100644 --- a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector2.h +++ b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector2.h @@ -6,7 +6,8 @@ namespace WallpaperEngine::Render::Shaders::Variables { class CShaderVariableVector2 final : public CShaderVariable { public: - explicit CShaderVariableVector2 (const glm::vec2& defaultValue); + using CShaderVariable::CShaderVariable; + CShaderVariableVector2 (const glm::vec2& defaultValue, const std::string& name); }; } // namespace WallpaperEngine::Render::Shaders::Variables diff --git a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector3.cpp b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector3.cpp index fadf009..3ae9532 100644 --- a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector3.cpp +++ b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector3.cpp @@ -2,13 +2,7 @@ using namespace WallpaperEngine::Render::Shaders::Variables; -CShaderVariableVector3::CShaderVariableVector3 (const glm::vec3& defaultValue) : - CShaderVariable () { - this->update (defaultValue); -} - CShaderVariableVector3::CShaderVariableVector3 (const glm::vec3& defaultValue, const std::string& name) : - CShaderVariable () { + CShaderVariable (defaultValue) { this->setName (name); - this->update (defaultValue); } diff --git a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector3.h b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector3.h index 7c989c1..55ffd96 100644 --- a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector3.h +++ b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector3.h @@ -7,7 +7,8 @@ namespace WallpaperEngine::Render::Shaders::Variables { class CShaderVariableVector3 final : public CShaderVariable { public: - explicit CShaderVariableVector3 (const glm::vec3& defaultValue); + using CShaderVariable::CShaderVariable; + CShaderVariableVector3 (const glm::vec3& defaultValue, const std::string& name); }; } // namespace WallpaperEngine::Render::Shaders::Variables diff --git a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector4.cpp b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector4.cpp index 1b8a519..f12253c 100644 --- a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector4.cpp +++ b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector4.cpp @@ -4,13 +4,7 @@ using namespace WallpaperEngine::Render::Shaders::Variables; -CShaderVariableVector4::CShaderVariableVector4 (const glm::vec4& defaultValue) : - CShaderVariable () { - this->update (defaultValue); -} - CShaderVariableVector4::CShaderVariableVector4 (const glm::vec4& defaultValue, const std::string& name) : - CShaderVariable () { + CShaderVariable (defaultValue) { this->setName (name); - this->update (defaultValue); } diff --git a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector4.h b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector4.h index d1e00d5..c5d8bcd 100644 --- a/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector4.h +++ b/src/WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector4.h @@ -6,7 +6,8 @@ namespace WallpaperEngine::Render::Shaders::Variables { class CShaderVariableVector4 final : public CShaderVariable { public: - explicit CShaderVariableVector4 (const glm::vec4& defaultValue); + using CShaderVariable::CShaderVariable; + CShaderVariableVector4 (const glm::vec4& defaultValue, const std::string& name); }; } // namespace WallpaperEngine::Render::Shaders::Variables diff --git a/src/WallpaperEngine/Render/Wallpapers/CScene.cpp b/src/WallpaperEngine/Render/Wallpapers/CScene.cpp index 1f69d35..5541261 100644 --- a/src/WallpaperEngine/Render/Wallpapers/CScene.cpp +++ b/src/WallpaperEngine/Render/Wallpapers/CScene.cpp @@ -55,7 +55,6 @@ CScene::CScene ( this->alias ("_alias_lightCookie", "_rt_shadowAtlas"); // set clear color - // TODO: MAKE USE OF THE REFERENCE POSSIBILITIES?! const glm::vec3 clearColor = scene->colors.clear->value->getVec3 (); glClearColor (clearColor.r, clearColor.g, clearColor.b, 1.0f); @@ -92,7 +91,6 @@ CScene::CScene ( // (it renders directly to the screen, whereas here we never do that from a scene) // - // TODO: TAKE THIS OUT OF HERE AND INTO THE GENERAL WALLPAPER APPLICATION?! const auto bloomOrigin = glm::vec3 { sceneWidth / 2, sceneHeight / 2, 0.0f }; const auto bloomSize = glm::vec2 { sceneWidth, sceneHeight };