From 25699606815a9c8a9274c0fa84b3ad11e85b6e9f Mon Sep 17 00:00:00 2001 From: Almamu Date: Wed, 13 Aug 2025 08:50:34 +0200 Subject: [PATCH] refactor: update render to use new data model --- CMakeLists.txt | 104 ++--- .../Application/CApplicationContext.h | 2 + .../Application/CWallpaperApplication.cpp | 60 +-- .../Application/CWallpaperApplication.h | 15 +- src/WallpaperEngine/Core/CObject.cpp | 116 ----- src/WallpaperEngine/Core/CObject.h | 86 ---- src/WallpaperEngine/Core/CProject.cpp | 118 ----- src/WallpaperEngine/Core/CProject.h | 53 --- src/WallpaperEngine/Core/CWallpaper.cpp | 12 - src/WallpaperEngine/Core/CWallpaper.h | 44 -- src/WallpaperEngine/Core/Core.cpp | 39 -- src/WallpaperEngine/Core/Core.h | 5 - src/WallpaperEngine/Core/Objects/CEffect.cpp | 319 -------------- src/WallpaperEngine/Core/Objects/CEffect.h | 102 ----- src/WallpaperEngine/Core/Objects/CImage.cpp | 142 ------ src/WallpaperEngine/Core/Objects/CImage.h | 122 ------ src/WallpaperEngine/Core/Objects/CSound.cpp | 53 --- src/WallpaperEngine/Core/Objects/CSound.h | 48 --- .../Core/Objects/Effects/CBind.cpp | 24 -- .../Core/Objects/Effects/CBind.h | 43 -- .../Core/Objects/Effects/CFBO.cpp | 31 -- .../Core/Objects/Effects/CFBO.h | 44 -- .../Core/Objects/Images/CMaterial.cpp | 120 ------ .../Core/Objects/Images/CMaterial.h | 89 ---- .../Core/Objects/Images/Materials/CPass.cpp | 105 ----- .../Core/Objects/Images/Materials/CPass.h | 84 ---- src/WallpaperEngine/Core/Scenes/CCamera.cpp | 28 -- src/WallpaperEngine/Core/Scenes/CCamera.h | 24 -- .../Core/Scenes/CProjection.cpp | 46 -- src/WallpaperEngine/Core/Scenes/CProjection.h | 29 -- .../Core/UserSettings/CUserSettingBoolean.cpp | 1 - .../Core/UserSettings/CUserSettingBoolean.h | 1 - .../Core/UserSettings/CUserSettingFloat.cpp | 1 - .../Core/UserSettings/CUserSettingFloat.h | 1 - .../Core/UserSettings/CUserSettingVector3.h | 1 - .../Core/Wallpapers/CScene.cpp | 172 -------- src/WallpaperEngine/Core/Wallpapers/CScene.h | 88 ---- .../Core/Wallpapers/CVideo.cpp | 14 - src/WallpaperEngine/Core/Wallpapers/CVideo.h | 25 -- src/WallpaperEngine/Core/Wallpapers/CWeb.cpp | 14 - src/WallpaperEngine/Core/Wallpapers/CWeb.h | 31 -- .../Data/Dumpers/StringPrinter.cpp | 2 +- src/WallpaperEngine/Data/Model/Effect.h | 2 +- src/WallpaperEngine/Data/Model/Material.h | 4 +- src/WallpaperEngine/Data/Model/Object.h | 1 + src/WallpaperEngine/Data/Model/Project.h | 5 +- src/WallpaperEngine/Data/Model/Types.h | 17 +- src/WallpaperEngine/Data/Model/Wallpaper.h | 8 +- .../Data/Parsers/EffectParser.cpp | 8 +- .../Data/Parsers/EffectParser.h | 6 +- .../Data/Parsers/MaterialParser.cpp | 11 +- .../Data/Parsers/MaterialParser.h | 8 +- .../Data/Parsers/ModelParser.cpp | 6 +- .../Data/Parsers/ModelParser.h | 4 +- .../Data/Parsers/ObjectParser.cpp | 20 +- .../Data/Parsers/ObjectParser.h | 14 +- .../Data/Parsers/ProjectParser.cpp | 10 +- .../Data/Parsers/ProjectParser.h | 2 +- .../Data/Parsers/ShaderConstantParser.cpp | 6 +- .../Data/Parsers/ShaderConstantParser.h | 4 +- .../Data/Parsers/WallpaperParser.cpp | 30 +- .../Data/Parsers/WallpaperParser.h | 10 +- .../PrettyPrinter/CPrettyPrinter.cpp | 403 ------------------ .../PrettyPrinter/CPrettyPrinter.h | 108 ----- src/WallpaperEngine/Render/CCamera.cpp | 25 +- src/WallpaperEngine/Render/CCamera.h | 16 +- src/WallpaperEngine/Render/CFBO.h | 4 +- src/WallpaperEngine/Render/CFBOProvider.cpp | 57 +++ src/WallpaperEngine/Render/CFBOProvider.h | 24 ++ src/WallpaperEngine/Render/CObject.cpp | 10 +- src/WallpaperEngine/Render/CObject.h | 11 +- src/WallpaperEngine/Render/CRenderContext.cpp | 2 + src/WallpaperEngine/Render/CTextureCache.cpp | 6 +- src/WallpaperEngine/Render/CWallpaper.cpp | 73 ++-- src/WallpaperEngine/Render/CWallpaper.h | 56 +-- .../Render/Objects/CEffect.cpp | 60 --- src/WallpaperEngine/Render/Objects/CEffect.h | 47 -- src/WallpaperEngine/Render/Objects/CImage.cpp | 202 +++++---- src/WallpaperEngine/Render/Objects/CImage.h | 19 +- src/WallpaperEngine/Render/Objects/CSound.cpp | 12 +- src/WallpaperEngine/Render/Objects/CSound.h | 8 +- .../Render/Objects/Effects/CMaterial.cpp | 34 -- .../Render/Objects/Effects/CMaterial.h | 42 -- .../Render/Objects/Effects/CPass.cpp | 156 ++++--- .../Render/Objects/Effects/CPass.h | 34 +- .../Render/Shaders/CShader.cpp | 9 +- src/WallpaperEngine/Render/Shaders/CShader.h | 13 +- .../Render/Shaders/CShaderUnit.cpp | 18 +- .../Render/Shaders/CShaderUnit.h | 28 +- .../Render/Wallpapers/CScene.cpp | 137 +++--- .../Render/Wallpapers/CScene.h | 21 +- .../Render/Wallpapers/CVideo.cpp | 11 +- .../Render/Wallpapers/CVideo.h | 6 +- .../Render/Wallpapers/CWeb.cpp | 9 +- src/WallpaperEngine/Render/Wallpapers/CWeb.h | 9 +- .../WebBrowser/CEF/CSubprocessApp.cpp | 3 +- .../WebBrowser/CEF/CWPSchemeHandler.cpp | 10 +- .../WebBrowser/CEF/CWPSchemeHandler.h | 14 +- .../CEF/CWPSchemeHandlerFactory.cpp | 2 +- .../WebBrowser/CEF/CWPSchemeHandlerFactory.h | 11 +- src/main.cpp | 6 +- 101 files changed, 757 insertions(+), 3593 deletions(-) delete mode 100644 src/WallpaperEngine/Core/CObject.cpp delete mode 100644 src/WallpaperEngine/Core/CObject.h delete mode 100644 src/WallpaperEngine/Core/CProject.cpp delete mode 100644 src/WallpaperEngine/Core/CProject.h delete mode 100644 src/WallpaperEngine/Core/CWallpaper.cpp delete mode 100644 src/WallpaperEngine/Core/CWallpaper.h delete mode 100644 src/WallpaperEngine/Core/Objects/CEffect.cpp delete mode 100644 src/WallpaperEngine/Core/Objects/CEffect.h delete mode 100644 src/WallpaperEngine/Core/Objects/CImage.cpp delete mode 100644 src/WallpaperEngine/Core/Objects/CImage.h delete mode 100644 src/WallpaperEngine/Core/Objects/CSound.cpp delete mode 100644 src/WallpaperEngine/Core/Objects/CSound.h delete mode 100644 src/WallpaperEngine/Core/Objects/Effects/CBind.cpp delete mode 100644 src/WallpaperEngine/Core/Objects/Effects/CBind.h delete mode 100644 src/WallpaperEngine/Core/Objects/Effects/CFBO.cpp delete mode 100644 src/WallpaperEngine/Core/Objects/Effects/CFBO.h delete mode 100644 src/WallpaperEngine/Core/Objects/Images/CMaterial.cpp delete mode 100644 src/WallpaperEngine/Core/Objects/Images/CMaterial.h delete mode 100644 src/WallpaperEngine/Core/Objects/Images/Materials/CPass.cpp delete mode 100644 src/WallpaperEngine/Core/Objects/Images/Materials/CPass.h delete mode 100644 src/WallpaperEngine/Core/Scenes/CCamera.cpp delete mode 100644 src/WallpaperEngine/Core/Scenes/CCamera.h delete mode 100644 src/WallpaperEngine/Core/Scenes/CProjection.cpp delete mode 100644 src/WallpaperEngine/Core/Scenes/CProjection.h delete mode 100644 src/WallpaperEngine/Core/Wallpapers/CScene.cpp delete mode 100644 src/WallpaperEngine/Core/Wallpapers/CScene.h delete mode 100644 src/WallpaperEngine/Core/Wallpapers/CVideo.cpp delete mode 100644 src/WallpaperEngine/Core/Wallpapers/CVideo.h delete mode 100644 src/WallpaperEngine/Core/Wallpapers/CWeb.cpp delete mode 100644 src/WallpaperEngine/Core/Wallpapers/CWeb.h delete mode 100644 src/WallpaperEngine/PrettyPrinter/CPrettyPrinter.cpp delete mode 100644 src/WallpaperEngine/PrettyPrinter/CPrettyPrinter.h create mode 100644 src/WallpaperEngine/Render/CFBOProvider.cpp create mode 100644 src/WallpaperEngine/Render/CFBOProvider.h delete mode 100644 src/WallpaperEngine/Render/Objects/CEffect.cpp delete mode 100644 src/WallpaperEngine/Render/Objects/CEffect.h delete mode 100644 src/WallpaperEngine/Render/Objects/Effects/CMaterial.cpp delete mode 100644 src/WallpaperEngine/Render/Objects/Effects/CMaterial.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 57bea0f..6f72994 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -261,9 +261,6 @@ add_executable( src/WallpaperEngine/Logging/CLog.cpp src/WallpaperEngine/Logging/CLog.h - src/WallpaperEngine/PrettyPrinter/CPrettyPrinter.cpp - src/WallpaperEngine/PrettyPrinter/CPrettyPrinter.h - src/WallpaperEngine/Application/CApplicationContext.cpp src/WallpaperEngine/Application/CApplicationContext.h src/WallpaperEngine/Application/CWallpaperApplication.cpp @@ -361,6 +358,8 @@ add_executable( src/WallpaperEngine/Render/CRenderContext.cpp src/WallpaperEngine/Render/CTextureCache.h src/WallpaperEngine/Render/CTextureCache.cpp + src/WallpaperEngine/Render/CFBOProvider.cpp + src/WallpaperEngine/Render/CFBOProvider.h src/WallpaperEngine/Render/Helpers/CContextAware.cpp src/WallpaperEngine/Render/Helpers/CContextAware.h @@ -384,15 +383,11 @@ add_executable( src/WallpaperEngine/Render/Objects/CImage.cpp src/WallpaperEngine/Render/Objects/CSound.h src/WallpaperEngine/Render/Objects/CSound.cpp - src/WallpaperEngine/Render/Objects/CEffect.h - src/WallpaperEngine/Render/Objects/CEffect.cpp src/WallpaperEngine/Render/CFBO.h src/WallpaperEngine/Render/CFBO.cpp src/WallpaperEngine/Render/Objects/Effects/CPass.h src/WallpaperEngine/Render/Objects/Effects/CPass.cpp - src/WallpaperEngine/Render/Objects/Effects/CMaterial.h - src/WallpaperEngine/Render/Objects/Effects/CMaterial.cpp src/WallpaperEngine/WebBrowser/CEF/CRenderHandler.cpp src/WallpaperEngine/WebBrowser/CEF/CRenderHandler.h @@ -421,19 +416,6 @@ add_executable( src/WallpaperEngine/Core/UserSettings/CUserSettingFloat.cpp src/WallpaperEngine/Core/UserSettings/CUserSettingFloat.h - src/WallpaperEngine/Core/CProject.cpp - src/WallpaperEngine/Core/CProject.h - src/WallpaperEngine/Core/CWallpaper.cpp - src/WallpaperEngine/Core/CWallpaper.h - src/WallpaperEngine/Core/Wallpapers/CScene.cpp - src/WallpaperEngine/Core/Wallpapers/CScene.h - src/WallpaperEngine/Core/Wallpapers/CVideo.cpp - src/WallpaperEngine/Core/Wallpapers/CVideo.h - src/WallpaperEngine/Core/Wallpapers/CWeb.cpp - src/WallpaperEngine/Core/Wallpapers/CWeb.h - src/WallpaperEngine/Core/CObject.cpp - src/WallpaperEngine/Core/CObject.h - src/WallpaperEngine/Core/Projects/CProperty.h src/WallpaperEngine/Core/Projects/CProperty.cpp src/WallpaperEngine/Core/Projects/CPropertyColor.h @@ -447,24 +429,8 @@ add_executable( src/WallpaperEngine/Core/Projects/CPropertyText.h src/WallpaperEngine/Core/Projects/CPropertyText.cpp - src/WallpaperEngine/Core/Scenes/CCamera.cpp - src/WallpaperEngine/Core/Scenes/CCamera.h - src/WallpaperEngine/Core/Scenes/CProjection.cpp - src/WallpaperEngine/Core/Scenes/CProjection.h - - src/WallpaperEngine/Core/Objects/CImage.cpp - src/WallpaperEngine/Core/Objects/CImage.h - src/WallpaperEngine/Core/Objects/CSound.cpp - src/WallpaperEngine/Core/Objects/CSound.h - src/WallpaperEngine/Core/Objects/CEffect.cpp - src/WallpaperEngine/Core/Objects/CEffect.h - src/WallpaperEngine/Core/Objects/CParticle.cpp - src/WallpaperEngine/Core/Objects/CParticle.h - - src/WallpaperEngine/Core/Objects/Effects/CFBO.h - src/WallpaperEngine/Core/Objects/Effects/CFBO.cpp - src/WallpaperEngine/Core/Objects/Effects/CBind.h - src/WallpaperEngine/Core/Objects/Effects/CBind.cpp +# src/WallpaperEngine/Core/Objects/CParticle.cpp +# src/WallpaperEngine/Core/Objects/CParticle.h src/WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstant.h src/WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstant.cpp @@ -481,35 +447,29 @@ add_executable( src/WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstantProperty.h src/WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstantProperty.cpp - src/WallpaperEngine/Core/Objects/Particles/CControlPoint.cpp - src/WallpaperEngine/Core/Objects/Particles/CControlPoint.h - src/WallpaperEngine/Core/Objects/Particles/CEmitter.cpp - src/WallpaperEngine/Core/Objects/Particles/CEmitter.h - src/WallpaperEngine/Core/Objects/Particles/CInitializer.cpp - src/WallpaperEngine/Core/Objects/Particles/CInitializer.h - - src/WallpaperEngine/Core/Objects/Particles/Initializers/CLifeTimeRandom.cpp - src/WallpaperEngine/Core/Objects/Particles/Initializers/CLifeTimeRandom.h - src/WallpaperEngine/Core/Objects/Particles/Initializers/CSizeRandom.cpp - src/WallpaperEngine/Core/Objects/Particles/Initializers/CSizeRandom.h - src/WallpaperEngine/Core/Objects/Particles/Initializers/CRotationRandom.cpp - src/WallpaperEngine/Core/Objects/Particles/Initializers/CRotationRandom.h - src/WallpaperEngine/Core/Objects/Particles/Initializers/CVelocityRandom.cpp - src/WallpaperEngine/Core/Objects/Particles/Initializers/CVelocityRandom.h - src/WallpaperEngine/Core/Objects/Particles/Initializers/CColorRandom.cpp - src/WallpaperEngine/Core/Objects/Particles/Initializers/CColorRandom.h - src/WallpaperEngine/Core/Objects/Particles/Initializers/CAlphaRandom.cpp - src/WallpaperEngine/Core/Objects/Particles/Initializers/CAlphaRandom.h - src/WallpaperEngine/Core/Objects/Particles/Initializers/CAngularVelocityRandom.cpp - src/WallpaperEngine/Core/Objects/Particles/Initializers/CAngularVelocityRandom.h - src/WallpaperEngine/Core/Objects/Particles/Initializers/CTurbulentVelocityRandom.cpp - src/WallpaperEngine/Core/Objects/Particles/Initializers/CTurbulentVelocityRandom.h - - src/WallpaperEngine/Core/Objects/Images/CMaterial.cpp - src/WallpaperEngine/Core/Objects/Images/CMaterial.h - - src/WallpaperEngine/Core/Objects/Images/Materials/CPass.cpp - src/WallpaperEngine/Core/Objects/Images/Materials/CPass.h +# src/WallpaperEngine/Core/Objects/Particles/CControlPoint.cpp +# src/WallpaperEngine/Core/Objects/Particles/CControlPoint.h +# src/WallpaperEngine/Core/Objects/Particles/CEmitter.cpp +# src/WallpaperEngine/Core/Objects/Particles/CEmitter.h +# src/WallpaperEngine/Core/Objects/Particles/CInitializer.cpp +# src/WallpaperEngine/Core/Objects/Particles/CInitializer.h +# +# src/WallpaperEngine/Core/Objects/Particles/Initializers/CLifeTimeRandom.cpp +# src/WallpaperEngine/Core/Objects/Particles/Initializers/CLifeTimeRandom.h +# src/WallpaperEngine/Core/Objects/Particles/Initializers/CSizeRandom.cpp +# src/WallpaperEngine/Core/Objects/Particles/Initializers/CSizeRandom.h +# src/WallpaperEngine/Core/Objects/Particles/Initializers/CRotationRandom.cpp +# src/WallpaperEngine/Core/Objects/Particles/Initializers/CRotationRandom.h +# src/WallpaperEngine/Core/Objects/Particles/Initializers/CVelocityRandom.cpp +# src/WallpaperEngine/Core/Objects/Particles/Initializers/CVelocityRandom.h +# src/WallpaperEngine/Core/Objects/Particles/Initializers/CColorRandom.cpp +# src/WallpaperEngine/Core/Objects/Particles/Initializers/CColorRandom.h +# src/WallpaperEngine/Core/Objects/Particles/Initializers/CAlphaRandom.cpp +# src/WallpaperEngine/Core/Objects/Particles/Initializers/CAlphaRandom.h +# src/WallpaperEngine/Core/Objects/Particles/Initializers/CAngularVelocityRandom.cpp +# src/WallpaperEngine/Core/Objects/Particles/Initializers/CAngularVelocityRandom.h +# src/WallpaperEngine/Core/Objects/Particles/Initializers/CTurbulentVelocityRandom.cpp +# src/WallpaperEngine/Core/Objects/Particles/Initializers/CTurbulentVelocityRandom.h src/WallpaperEngine/Data/Model/Types.h src/WallpaperEngine/Data/Model/Project.h @@ -541,11 +501,11 @@ add_executable( ${WAYLAND_SOURCES} ${X11_SOURCES} ${DEMOMODE_SOURCES} - src/WallpaperEngine/Data/Dumpers/StringPrinter.cpp - src/WallpaperEngine/Data/Dumpers/StringPrinter.h - src/WallpaperEngine/Data/JSON.cpp - src/WallpaperEngine/Data/Parsers/EffectParser.cpp - src/WallpaperEngine/Data/Parsers/EffectParser.h) + src/WallpaperEngine/Data/Dumpers/StringPrinter.cpp + src/WallpaperEngine/Data/Dumpers/StringPrinter.h + src/WallpaperEngine/Data/JSON.cpp + src/WallpaperEngine/Data/Parsers/EffectParser.cpp + src/WallpaperEngine/Data/Parsers/EffectParser.h) target_link_libraries (linux-wallpaperengine PUBLIC ${OPENGL_LIBRARIES} diff --git a/src/WallpaperEngine/Application/CApplicationContext.h b/src/WallpaperEngine/Application/CApplicationContext.h index 95a3772..20eb075 100644 --- a/src/WallpaperEngine/Application/CApplicationContext.h +++ b/src/WallpaperEngine/Application/CApplicationContext.h @@ -12,6 +12,8 @@ #include "WallpaperEngine/Assets/ITexture.h" #include "WallpaperEngine/Render/CWallpaperState.h" +#include "WallpaperEngine/Data/Model/Project.h" + namespace WallpaperEngine::Application { /** * Application information as parsed off the command line arguments diff --git a/src/WallpaperEngine/Application/CWallpaperApplication.cpp b/src/WallpaperEngine/Application/CWallpaperApplication.cpp index a83baf3..e6a71f5 100644 --- a/src/WallpaperEngine/Application/CWallpaperApplication.cpp +++ b/src/WallpaperEngine/Application/CWallpaperApplication.cpp @@ -8,13 +8,13 @@ #include "WallpaperEngine/Audio/Drivers/Detectors/CPulseAudioPlayingDetector.h" #include "WallpaperEngine/Logging/CLog.h" #include "WallpaperEngine/Render/CRenderContext.h" -#include "WallpaperEngine/PrettyPrinter/CPrettyPrinter.h" -#include "WallpaperEngine/Core/Wallpapers/CWeb.h" #include "WallpaperEngine/Render/Drivers/CVideoFactories.h" #include "WallpaperEngine/Data/Parsers/ProjectParser.h" #include "WallpaperEngine/Data/Dumpers/StringPrinter.h" +#include "WallpaperEngine/Data/Model/Wallpaper.h" + #if DEMOMODE #include "recording.h" #endif /* DEMOMODE */ @@ -29,7 +29,9 @@ float g_Time; float g_TimeLast; float g_Daytime; -namespace WallpaperEngine::Application { +using namespace WallpaperEngine::Application; +using namespace WallpaperEngine::Data::Model; + CWallpaperApplication::CWallpaperApplication (CApplicationContext& context) : m_context (context) { this->loadBackgrounds (); @@ -37,7 +39,8 @@ CWallpaperApplication::CWallpaperApplication (CApplicationContext& context) : this->setupBrowser(); } -void CWallpaperApplication::setupContainer (const std::shared_ptr& container, const std::string& bg) const { +ContainerUniquePtr CWallpaperApplication::setupContainer (const std::string& bg) const { + auto container = std::make_unique (); const std::filesystem::path basepath = bg; container->add (std::make_unique (basepath)); @@ -185,6 +188,8 @@ void CWallpaperApplication::setupContainer (const std::shared_ptradd (std::move(virtualContainer)); + + return container; } void CWallpaperApplication::loadBackgrounds () { @@ -204,27 +209,16 @@ void CWallpaperApplication::loadBackgrounds () { } } -std::shared_ptr CWallpaperApplication::loadBackground (const std::string& bg) { - const auto container = std::make_shared (); - - this->setupContainer (container, bg); - - // do the parsing with the new parser first +ProjectUniquePtr CWallpaperApplication::loadBackground (const std::string& bg) { + auto container = this->setupContainer (bg); auto json = WallpaperEngine::Data::JSON::JSON::parse (container->readFileAsString ("project.json")); - const auto project = WallpaperEngine::Data::Parsers::ProjectParser::parse (json, container); - auto dumper = WallpaperEngine::Data::Dumpers::StringPrinter (); - - dumper.printWallpaper (*project->wallpaper); - - std::cout << dumper.str () << std::endl; - - return Core::CProject::fromFile ("project.json", container); + return WallpaperEngine::Data::Parsers::ProjectParser::parse (json, std::move(container)); } -void CWallpaperApplication::setupPropertiesForProject (const std::shared_ptr& project) { +void CWallpaperApplication::setupPropertiesForProject (const Project& project) { // show properties if required - for (const auto& [key, cur] : project->getProperties ()) { + for (const auto& [key, cur] : project.properties) { // update the value of the property auto override = this->m_context.settings.general.properties.find (key); @@ -241,15 +235,16 @@ void CWallpaperApplication::setupPropertiesForProject (const std::shared_ptrm_backgrounds) - this->setupPropertiesForProject (info); + this->setupPropertiesForProject (*info); } void CWallpaperApplication::setupBrowser () { bool anyWebProject = std::any_of ( this->m_backgrounds.begin (), this->m_backgrounds.end (), - [](const std::pair>& pair) -> bool { - return pair.second->getWallpaper()->is (); - }); + [](const std::pair& pair) -> bool { + return pair.second->wallpaper->is (); + } + ); // do not perform any initialization if no web background is present if (!anyWebProject) { @@ -350,9 +345,12 @@ void CWallpaperApplication::setupOutput () { void CWallpaperApplication::setupAudio () { // ensure audioprocessing is required by any background, and we have it enabled - bool audioProcessingRequired = std::any_of (this->m_backgrounds.begin (), this->m_backgrounds.end (), [](const auto& pair) -> bool { - return pair.second->supportsAudioProcessing (); - }); + bool audioProcessingRequired = std::any_of ( + this->m_backgrounds.begin (), this->m_backgrounds.end (), + [](const std::pair& pair) -> bool { + return pair.second->supportsAudioProcessing; + } + ); if (audioProcessingRequired && this->m_context.settings.audio.audioprocessing) { this->m_audioRecorder = std::make_unique (); @@ -382,7 +380,7 @@ void CWallpaperApplication::prepareOutputs () { m_renderContext->setWallpaper ( background, WallpaperEngine::Render::CWallpaper::fromWallpaper ( - info->getWallpaper (), *m_renderContext, *m_audioContext, m_browserContext.get (), + *info->wallpaper, *m_renderContext, *m_audioContext, m_browserContext.get (), this->m_context.settings.general.screenScalings [background], this->m_context.settings.general.screenClamps [background] ) @@ -399,6 +397,8 @@ void CWallpaperApplication::show () { static struct tm* timeinfo; if (this->m_context.settings.general.dumpStructure) { + // TODO: REWRITE TO USE THE NEW DUMPER + /* auto prettyPrinter = PrettyPrinter::CPrettyPrinter (); for (const auto& [background, info] : this->m_renderContext->getWallpapers ()) { @@ -406,6 +406,7 @@ void CWallpaperApplication::show () { } std::cout << prettyPrinter.str () << std::endl; + */ } #if DEMOMODE @@ -506,7 +507,7 @@ void CWallpaperApplication::signal (int signal) { this->m_context.state.general.keepRunning = false; } -const std::map>& CWallpaperApplication::getBackgrounds () const { +const std::map& CWallpaperApplication::getBackgrounds () const { return this->m_backgrounds; } @@ -517,4 +518,3 @@ CApplicationContext& CWallpaperApplication::getContext () const { const WallpaperEngine::Render::Drivers::Output::COutput& CWallpaperApplication::getOutput () const { return this->m_renderContext->getOutput (); } -} // namespace WallpaperEngine::Application diff --git a/src/WallpaperEngine/Application/CWallpaperApplication.h b/src/WallpaperEngine/Application/CWallpaperApplication.h index 2aa8465..5ef96f0 100644 --- a/src/WallpaperEngine/Application/CWallpaperApplication.h +++ b/src/WallpaperEngine/Application/CWallpaperApplication.h @@ -4,8 +4,6 @@ #include "WallpaperEngine/Assets/CCombinedContainer.h" -#include "WallpaperEngine/Core/CProject.h" - #include "WallpaperEngine/Render/CRenderContext.h" #include "WallpaperEngine/Render/CWallpaper.h" #include "WallpaperEngine/Render/Drivers/CGLFWOpenGLDriver.h" @@ -17,7 +15,10 @@ #include "WallpaperEngine/Input/CInputContext.h" #include "WallpaperEngine/WebBrowser/CWebBrowserContext.h" +#include "WallpaperEngine/Data/Model/Types.h" + namespace WallpaperEngine::Application { +using namespace WallpaperEngine::Data::Model; /** * Small wrapper class over the actual wallpaper's main application skeleton * @@ -40,7 +41,7 @@ class CWallpaperApplication { /** * @return Maps screens to loaded backgrounds */ - [[nodiscard]] const std::map>& getBackgrounds () const; + [[nodiscard]] const std::map& getBackgrounds () const; /** * @return The current application context */ @@ -61,7 +62,7 @@ class CWallpaperApplication { * @param container * @param bg */ - void setupContainer (const std::shared_ptr& container, const std::string& bg) const; + ContainerUniquePtr setupContainer (const std::string& bg) const; /** * Loads projects based off the settings */ @@ -72,7 +73,7 @@ class CWallpaperApplication { * @param bg * @return */ - [[nodiscard]] std::shared_ptr loadBackground (const std::string& bg); + [[nodiscard]] ProjectUniquePtr loadBackground (const std::string& bg); /** * Prepares all background's values and updates their properties if required */ @@ -82,7 +83,7 @@ class CWallpaperApplication { * * @param project */ - void setupPropertiesForProject (const std::shared_ptr& project); + void setupPropertiesForProject (const Project& project); /** * Prepares CEF browser to be used */ @@ -109,7 +110,7 @@ class CWallpaperApplication { /** The application context that contains the current app settings */ CApplicationContext& m_context; /** Maps screens to backgrounds */ - std::map> m_backgrounds {}; + std::map m_backgrounds {}; std::unique_ptr m_audioDetector = nullptr; std::unique_ptr m_audioContext = nullptr; diff --git a/src/WallpaperEngine/Core/CObject.cpp b/src/WallpaperEngine/Core/CObject.cpp deleted file mode 100644 index 83efacd..0000000 --- a/src/WallpaperEngine/Core/CObject.cpp +++ /dev/null @@ -1,116 +0,0 @@ -#include "CObject.h" - -#include - -#include "WallpaperEngine/Core/CProject.h" -#include "WallpaperEngine/Core/Objects/CImage.h" -#include "WallpaperEngine/Core/Objects/CParticle.h" -#include "WallpaperEngine/Core/Objects/CSound.h" -#include "WallpaperEngine/Core/UserSettings/CUserSettingBoolean.h" -#include "WallpaperEngine/Core/Wallpapers/CScene.h" - -#include "WallpaperEngine/Assets/CContainer.h" -#include "WallpaperEngine/Logging/CLog.h" - -using namespace WallpaperEngine::Core; -using namespace WallpaperEngine::Assets; -using namespace WallpaperEngine::Core::UserSettings; - -CObject::CObject ( - std::shared_ptr project, const CUserSettingBoolean* visible, int id, std::string name, - const CUserSettingVector3* origin, const CUserSettingVector3* scale, const CUserSettingVector3* angles, - std::vector dependencies -) : - m_visible (visible), - m_id (id), - m_name (std::move(name)), - m_origin (origin), - m_scale (scale), - m_angles (angles), - m_project (project), - m_dependencies (std::move(dependencies)) {} - -const CObject* CObject::fromJSON ( - const json& data, std::shared_ptr project, const std::shared_ptr& container -) { - const auto id = jsonFindRequired (data, "id", "Objects must have id"); - const auto visible = jsonFindUserConfig (data, *project, "visible", true); - const auto origin = jsonFindUserConfig (data, *project, "origin", {0, 0, 0}); - const auto scale = jsonFindUserConfig (data, *project, "scale", {1, 1, 1}); - const auto angles_val = jsonFindUserConfig (data, *project, "angles", glm::vec3 (0, 0, 0)); - const auto name = jsonFindRequired (data, "name", "Objects must have name"); - const auto effects_it = data.find ("effects"); - const auto dependencies_it = data.find ("dependencies"); - - const auto image_it = data.find ("image"); - const auto sound_it = data.find ("sound"); - const auto particle_it = data.find ("particle"); - const auto text_it = data.find ("text"); - const auto light_it = data.find ("light"); - - std::vector dependencies; - std::vector effects; - - const CObject* object; - - if (dependencies_it != data.end () && dependencies_it->is_array ()) - for (const auto& cur : *dependencies_it) - dependencies.push_back (cur); - - if (image_it != data.end () && !image_it->is_null ()) { - object = Objects::CImage::fromJSON ( - project, data, container, visible, id, name, origin, scale, angles_val, effects_it, dependencies); - } else if (sound_it != data.end () && !sound_it->is_null ()) { - object = Objects::CSound::fromJSON (project, data, visible, id, name, origin, scale, angles_val, dependencies); - } else if (particle_it != data.end () && !particle_it->is_null ()) { - /// TODO: XXXHACK -- TO REMOVE WHEN PARTICLE SUPPORT IS PROPERLY IMPLEMENTED - try { - object = Objects::CParticle::fromFile ( - project, particle_it->get (), container, visible, id, name, origin, angles_val, scale, dependencies); - } catch (std::runtime_error&) { - return nullptr; - } - } else if (text_it != data.end () && !text_it->is_null ()) { - /// TODO: XXXHACK -- TO REMOVE WHEN TEXT SUPPORT IS IMPLEMENTED - return nullptr; - } else if (light_it != data.end () && !light_it->is_null ()) { - /// TODO: XXXHACK -- TO REMOVE WHEN LIGHT SUPPORT IS IMPLEMENTED - return nullptr; - } else { - sLog.exception ("Unknown object type detected: ", name); - } - - return object; -} - -const glm::vec3& CObject::getOrigin () const { - return this->m_origin->getVec3 (); -} - -const glm::vec3& CObject::getScale () const { - return this->m_scale->getVec3 (); -} - -const glm::vec3& CObject::getAngles () const { - return this->m_angles->getVec3 (); -} - -const std::string& CObject::getName () const { - return this->m_name; -} - -const std::vector& CObject::getDependencies () const { - return this->m_dependencies; -} - -bool CObject::isVisible () const { - return this->m_visible->getBool (); -} - -std::shared_ptr CObject::getProject () const { - return this->m_project; -} - -int CObject::getId () const { - return this->m_id; -} diff --git a/src/WallpaperEngine/Core/CObject.h b/src/WallpaperEngine/Core/CObject.h deleted file mode 100644 index c0102ef..0000000 --- a/src/WallpaperEngine/Core/CObject.h +++ /dev/null @@ -1,86 +0,0 @@ -#pragma once - -#include "Core.h" - -#include "WallpaperEngine/Assets/CContainer.h" -#include "WallpaperEngine/Core/Objects/CEffect.h" -#include "WallpaperEngine/Core/UserSettings/CUserSettingBoolean.h" -#include "WallpaperEngine/Core/UserSettings/CUserSettingFloat.h" -#include "WallpaperEngine/Core/UserSettings/CUserSettingVector3.h" - -namespace WallpaperEngine::Core::Wallpapers { -class CScene; -} - -namespace WallpaperEngine::Core::Objects { -class CEffect; -} - -namespace WallpaperEngine::Core::UserSettings { -class CUserSettingBoolean; -} - -namespace WallpaperEngine::Core { -using json = nlohmann::json; -using namespace WallpaperEngine::Assets; -using namespace WallpaperEngine::Core::UserSettings; - -class CObject { - friend class Wallpapers::CScene; - - public: - static const CObject* fromJSON ( const json& data, std::shared_ptr project, - const std::shared_ptr& container); - - 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); - } - - [[nodiscard]] const std::vector& getDependencies () const; - [[nodiscard]] int getId () const; - - [[nodiscard]] const glm::vec3& getOrigin () const; - [[nodiscard]] const glm::vec3& getScale () const; - [[nodiscard]] const glm::vec3& getAngles () const; - [[nodiscard]] const std::string& getName () const; - - [[nodiscard]] bool isVisible () const; - [[nodiscard]] std::shared_ptr getProject () const; - - protected: - CObject ( - std::shared_ptr scene, const CUserSettingBoolean* visible, int id, std::string name, - const CUserSettingVector3* origin, const CUserSettingVector3* scale, const CUserSettingVector3* angles, - std::vector dependencies); - - virtual ~CObject () = default; - - private: - const CUserSettingBoolean* m_visible; - int m_id = 0; - const std::string m_name; - const CUserSettingVector3* m_origin; - const CUserSettingVector3* m_scale; - const CUserSettingVector3* m_angles; - - const std::vector m_dependencies; - - const std::shared_ptr m_project; -}; -} // namespace WallpaperEngine::Core diff --git a/src/WallpaperEngine/Core/CProject.cpp b/src/WallpaperEngine/Core/CProject.cpp deleted file mode 100644 index 3760f42..0000000 --- a/src/WallpaperEngine/Core/CProject.cpp +++ /dev/null @@ -1,118 +0,0 @@ -#include - -#include - -#include "CProject.h" -#include "WallpaperEngine/Core/Wallpapers/CScene.h" -#include "WallpaperEngine/Core/Wallpapers/CVideo.h" -#include "WallpaperEngine/Core/Wallpapers/CWeb.h" -#include "WallpaperEngine/Logging/CLog.h" - -using namespace WallpaperEngine::Core; -using namespace WallpaperEngine::Core::Wallpapers; -using namespace WallpaperEngine::Assets; - -static int backgroundId = -1; - -CProject::CProject ( - std::string title, std::string type, std::string workshopid, std::shared_ptr container, - bool supportsaudioprocessing, const std::map>& properties -) : - m_workshopid(std::move(workshopid)), - m_title (std::move(title)), - m_type (std::move(type)), - m_container (std::move(container)), - m_properties (properties), - m_supportsaudioprocessing (supportsaudioprocessing) {} - -std::shared_ptr CProject::fromFile (const std::string& filename, std::shared_ptr container) { - json content = json::parse (container->readFileAsString (filename)); - - const auto dependency = jsonFindDefault (content, "dependency", "No dependency"); - - if (dependency != "No dependency") { - sLog.exception ("Project have dependency. They are not supported, quiting"); - } - - // workshopid is not required, but we have to use it for some identification stuff, - // so using a static, decreasing number should be enough - bool supportsaudioprocessing = false; - auto type = jsonFindRequired (content, "type", "Project type missing"); - const auto file = jsonFindRequired (content, "file", "Project's main file missing"); - auto general = content.find ("general"); - std::shared_ptr wallpaper = nullptr; - std::map> properties; - - std::transform (type.begin (), type.end (), type.begin (), tolower); - - if (general != content.end ()) { - supportsaudioprocessing = jsonFindDefault (general, "supportsaudioprocessing", false); - const auto properties_it = general->find ("properties"); - - if (properties_it != general->end ()) { - for (const auto& cur : properties_it->items ()) { - auto property = Projects::CProperty::fromJSON (cur.value (), cur.key ()); - - if (property == nullptr) { - continue; - } - - properties.emplace (property->getName (), std::move (property)); - } - } - } - - std::shared_ptr project = std::make_shared ( - jsonFindRequired (content, "title", "Project title missing"), - type, - jsonFindDefault (content, "workshopid", std::to_string (backgroundId--)), - container, - supportsaudioprocessing, - properties - ); - - if (type == "scene") - wallpaper = CScene::fromFile (file, project, container); - else if (type == "video") - wallpaper = std::make_shared (file, project); - else if (type == "web") - wallpaper = std::make_shared (file, project); - else - sLog.exception ("Unsupported wallpaper type: ", type); - - project->setWallpaper (wallpaper); - - return project; -} - -void CProject::setWallpaper (std::shared_ptr wallpaper) { - this->m_wallpaper = wallpaper; -} - -const std::shared_ptr CProject::getWallpaper () const { - return this->m_wallpaper; -} - -const std::string& CProject::getTitle () const { - return this->m_title; -} - -const std::string& CProject::getType () const { - return this->m_type; -} - -const std::map>& CProject::getProperties () const { - return this->m_properties; -} - -const std::string& CProject::getWorkshopId () const { - return this->m_workshopid; -} - -std::shared_ptr CProject::getContainer () const { - return this->m_container; -} - -bool CProject::supportsAudioProcessing () const { - return this->m_supportsaudioprocessing; -} \ No newline at end of file diff --git a/src/WallpaperEngine/Core/CProject.h b/src/WallpaperEngine/Core/CProject.h deleted file mode 100644 index 18c0a5f..0000000 --- a/src/WallpaperEngine/Core/CProject.h +++ /dev/null @@ -1,53 +0,0 @@ -#pragma once - -#include -#include - -#include "CWallpaper.h" -#include "WallpaperEngine/Core/Core.h" -#include "WallpaperEngine/Core/Projects/CProperty.h" - -#include "WallpaperEngine/Assets/CContainer.h" - -namespace WallpaperEngine::Core::Projects { -class CProperty; -} - -namespace WallpaperEngine::Core { -using json = nlohmann::json; -using namespace WallpaperEngine::Assets; - -class CWallpaper; - -class CProject { - public: - CProject ( - std::string title, std::string type, std::string workshopid, std::shared_ptr container, - bool supportsaudioprocessing, const std::map>& properties); - - static std::shared_ptr fromFile (const std::string& filename, std::shared_ptr container); - - [[nodiscard]] const std::shared_ptr getWallpaper () const; - [[nodiscard]] const std::string& getTitle () const; - [[nodiscard]] const std::string& getType () const; - [[nodiscard]] const std::map>& getProperties () const; - [[nodiscard]] const std::string& getWorkshopId () const; - - [[nodiscard]] bool supportsAudioProcessing () const; - - [[nodiscard]] std::shared_ptr getContainer () const; - - protected: - void setWallpaper (std::shared_ptr wallpaper); - - private: - std::map> m_properties; - - const std::string m_workshopid; - const std::string m_title; - const std::string m_type; - const bool m_supportsaudioprocessing; - std::shared_ptr m_wallpaper = nullptr; - std::shared_ptr m_container = nullptr; -}; -} // namespace WallpaperEngine::Core diff --git a/src/WallpaperEngine/Core/CWallpaper.cpp b/src/WallpaperEngine/Core/CWallpaper.cpp deleted file mode 100644 index a403787..0000000 --- a/src/WallpaperEngine/Core/CWallpaper.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "CWallpaper.h" - -#include - -using namespace WallpaperEngine::Core; - -CWallpaper::CWallpaper (std::shared_ptr project) : - m_project (project) {} - -std::shared_ptr CWallpaper::getProject () const { - return this->m_project; -} diff --git a/src/WallpaperEngine/Core/CWallpaper.h b/src/WallpaperEngine/Core/CWallpaper.h deleted file mode 100644 index a2a78d2..0000000 --- a/src/WallpaperEngine/Core/CWallpaper.h +++ /dev/null @@ -1,44 +0,0 @@ -#pragma once - -#include -#include - -#include "CProject.h" - -namespace WallpaperEngine::Core { -class CProject; - -class CWallpaper { - public: - 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); - } - - std::shared_ptr getProject () const; - - protected: - friend class CProject; - - explicit CWallpaper (std::shared_ptr project); - virtual ~CWallpaper() = default; - - private: - std::shared_ptr m_project; -}; -} // namespace WallpaperEngine::Core diff --git a/src/WallpaperEngine/Core/Core.cpp b/src/WallpaperEngine/Core/Core.cpp index 93effef..0f33015 100644 --- a/src/WallpaperEngine/Core/Core.cpp +++ b/src/WallpaperEngine/Core/Core.cpp @@ -500,42 +500,3 @@ template const glm::vec4 Core::jsonFindDefault (const nlohmann::json& data, cons 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); - -template const T* Core::jsonFindUserConfig ( - const nlohmann::json::const_iterator& data, const CProject& project, const char* key, typename T::data_type defaultValue -) { - const auto it = data->find (key); - - if (it == data->end () || it->type () == nlohmann::detail::value_t::null) - return T::fromScalar (defaultValue); - - return T::fromJSON (*it, project.getProperties ()); -} - -template const CUserSettingBoolean* Core::jsonFindUserConfig ( - const nlohmann::json::const_iterator& data, const CProject& project, const char* key, - CUserSettingBoolean::data_type defaultValue); -template const CUserSettingVector3* Core::jsonFindUserConfig ( - const nlohmann::json::const_iterator& data, const CProject& project, const char* key, - CUserSettingVector3::data_type defaultValue); -template const CUserSettingFloat* Core::jsonFindUserConfig ( - const nlohmann::json::const_iterator& data, const CProject& project, const char* key, - CUserSettingFloat::data_type defaultValue); - -template const T* Core::jsonFindUserConfig ( - const nlohmann::json& data, const CProject& project, const char* key, typename T::data_type defaultValue -) { - const auto it = data.find (key); - - if (it == data.end () || it->type () == nlohmann::detail::value_t::null) - return T::fromScalar (defaultValue); - - return T::fromJSON (*it, project.getProperties ()); -} - -template const CUserSettingBoolean* Core::jsonFindUserConfig ( - const nlohmann::json& data, const CProject& project, const char* key, CUserSettingBoolean::data_type defaultValue); -template const CUserSettingVector3* Core::jsonFindUserConfig ( - const nlohmann::json& data, const CProject& project, const char* key, CUserSettingVector3::data_type defaultValue); -template const CUserSettingFloat* Core::jsonFindUserConfig ( - const nlohmann::json& data, const CProject& project, const char* key, CUserSettingFloat::data_type defaultValue); diff --git a/src/WallpaperEngine/Core/Core.h b/src/WallpaperEngine/Core/Core.h index 0dc9bab..f3fb7fd 100644 --- a/src/WallpaperEngine/Core/Core.h +++ b/src/WallpaperEngine/Core/Core.h @@ -1,6 +1,5 @@ #pragma once -#include "CProject.h" #include #include #include @@ -44,8 +43,4 @@ 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); -template const T* jsonFindUserConfig ( - const nlohmann::json::const_iterator& data, const CProject& project, const char* key, typename T::data_type defaultValue); -template const T* jsonFindUserConfig ( - const nlohmann::json& data, const CProject& project, const char* key, typename T::data_type defaultValue); } // namespace WallpaperEngine::Core diff --git a/src/WallpaperEngine/Core/Objects/CEffect.cpp b/src/WallpaperEngine/Core/Objects/CEffect.cpp deleted file mode 100644 index 7d2c482..0000000 --- a/src/WallpaperEngine/Core/Objects/CEffect.cpp +++ /dev/null @@ -1,319 +0,0 @@ -#include "CEffect.h" - -#include - -#include "WallpaperEngine/Core/CProject.h" -#include "WallpaperEngine/Core/Objects/CImage.h" -#include "WallpaperEngine/Core/Objects/Images/Materials/CPass.h" -#include "WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstant.h" -#include "WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstantFloat.h" -#include "WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstantInteger.h" -#include "WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstantVector2.h" -#include "WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstantVector3.h" -#include "WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstantVector4.h" -#include "WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstantProperty.h" - -#include "WallpaperEngine/Core/UserSettings/CUserSettingBoolean.h" -#include "WallpaperEngine/Logging/CLog.h" - -using namespace WallpaperEngine; -using namespace WallpaperEngine::Core::Objects; -using namespace WallpaperEngine::Core::UserSettings; - -CEffect::CEffect ( - std::string name, std::string description, std::string group, std::string preview, - std::shared_ptr project, const CUserSettingBoolean* visible, - std::vector dependencies, std::vector fbos, - std::vector materials -) : - m_name (std::move(name)), - m_description (std::move(description)), - m_group (std::move(group)), - m_preview (std::move(preview)), - m_visible (visible), - m_dependencies (std::move(dependencies)), - m_fbos (std::move(fbos)), - m_project (project), - m_materials (std::move(materials)) {} - -const CEffect* CEffect::fromJSON ( - const json& data, const CUserSettingBoolean* visible, std::shared_ptr project, - const Images::CMaterial* material, const std::shared_ptr& container -) { - const auto file = jsonFindRequired (data, "file", "Object effect must have a file"); - const auto effectpasses_it = data.find ("passes"); - - json content = json::parse (container->readFileAsString(file)); - - const auto effectName = jsonFindRequired (content, "name", "Effect must have a name"); - const auto passes_it = jsonFindRequired (content, "passes", "Effect must have a pass list"); - const auto fbos_it = content.find ("fbos"); - - // info to override in the pass information, used by material generation - std::map overrides; - std::vector fbos; - - if (fbos_it != content.end ()) - fbos = CEffect::fbosFromJSON (fbos_it); - - if (effectpasses_it != data.end ()) { - overrides = overridesFromJSON (effectpasses_it, material, project); - } - - return new CEffect ( - effectName, - jsonFindDefault (content, "description", ""), - jsonFindRequired (content, "group", "Effect must have a group"), - jsonFindDefault (content, "preview", ""), - project, - visible, - dependenciesFromJSON (jsonFindRequired (content, "dependencies", "")), - fbos, - materialsFromJSON (passes_it, effectName, container, overrides) - ); -} - -std::map CEffect::combosFromJSON (const json::const_iterator& combos_it) { - std::map combos; - - for (const auto& cur : combos_it->items ()) { - auto uppercase = std::string (cur.key ()); - - std::transform (uppercase.begin (), uppercase.end (), uppercase.begin (), ::toupper); - combos.emplace (uppercase, cur.value ()); - } - - return combos; -} - -std::map CEffect::constantsFromJSON ( - const json::const_iterator& constants_it, std::shared_ptr project -) { - std::map constants; - - for (auto& cur : constants_it->items ()) { - auto val = cur.value (); - - Effects::Constants::CShaderConstant* constant = nullptr; - - // if the constant is an object, that means the constant has some extra information - // for the UI, take the value, which is what we need - - if (cur.value ().is_object ()) { - auto user = cur.value ().find ("user"); - auto it = cur.value ().find ("value"); - - if (user == cur.value ().end () && it == cur.value ().end ()) { - sLog.error (R"(Found object for shader constant without "value" and "user" setting)"); - continue; - } - - if (user != cur.value ().end () && user->is_string ()) { - // look for a property with the correct name - const auto& properties = project->getProperties (); - const auto property = properties.find (*user); - - if (property != properties.end ()) { - constant = new Effects::Constants::CShaderConstantProperty (property->second); - } else { - sLog.error ("Shader constant pointing to non-existant project property: ", user->get ()); - val = it.value (); - } - } else { - val = it.value (); - } - } - - // TODO: REFACTOR THIS SO IT'S NOT SO DEEP INTO THE FUNCTION - if (constant == nullptr) { - if (val.is_number_float ()) { - constant = new Effects::Constants::CShaderConstantFloat (val.get ()); - } else if (val.is_number_integer ()) { - constant = new Effects::Constants::CShaderConstantInteger (val.get ()); - } else if (val.is_string ()) { - // count the amount of spaces to determine which type of vector we have - std::string value = val; - - size_t spaces = - std::count_if (value.begin (), value.end (), [&] (const auto& item) { return item == ' '; }); - - if (spaces == 1) { - constant = - new Effects::Constants::CShaderConstantVector2 (WallpaperEngine::Core::aToVector2 (value)); - } else if (spaces == 2) { - constant = - new Effects::Constants::CShaderConstantVector3 (WallpaperEngine::Core::aToVector3 (value)); - } else if (spaces == 3) { - constant = - new Effects::Constants::CShaderConstantVector4 (WallpaperEngine::Core::aToVector4 (value)); - } else { - sLog.exception ("unknown shader constant type ", value); - } - } else { - sLog.exception ("unknown shader constant type ", val); - } - } - - constants.emplace (cur.key (), constant); - } - - return constants; -} - -std::vector CEffect::fbosFromJSON (const json::const_iterator& fbos_it) { - std::vector fbos; - - for (const auto& cur : (*fbos_it)) - fbos.push_back (Effects::CFBO::fromJSON (cur)); - - return fbos; -} - -std::vector CEffect::dependenciesFromJSON (const json::const_iterator& dependencies_it) { - std::vector dependencies; - - for (const auto& cur : (*dependencies_it)) - dependencies.push_back (cur); - - return dependencies; -} - -std::vector CEffect::materialsFromJSON ( - const json::const_iterator& passes_it, const std::string& name, const std::shared_ptr& container, - std::map overrides -) { - std::vector materials; - - int materialNumber = -1; - for (const auto& cur : (*passes_it)) { - ++materialNumber; - const auto materialfile = cur.find ("material"); - const auto target_it = cur.find ("target"); - const auto bind_it = cur.find ("bind"); - const auto command_it = cur.find ("command"); - const auto compose_it = cur.find ("compose"); - const Images::CMaterial* material = nullptr; - - if (compose_it != cur.end ()) { - sLog.error ("Composing materials is not supported yet..."); - } - - if (materialfile != cur.end ()) { - std::map textureBindings; - - if (bind_it != cur.end ()) { - for (const auto& bindCur : (*bind_it)) { - const auto* bind = Effects::CBind::fromJSON (bindCur); - textureBindings.emplace (bind->getIndex (), bind); - } - } - - const Images::CMaterial::OverrideInfo* overrideInfo = nullptr; - const auto overrideIt = overrides.find (materialNumber); - - if (overrideIt != overrides.end ()) { - overrideInfo = &overrideIt->second; - } - - if (target_it == cur.end ()) { - material = Images::CMaterial::fromFile ( - materialfile->get (), container, false, textureBindings, overrideInfo); - } else { - material = Images::CMaterial::fromFile ( - materialfile->get (), *target_it, container, false, textureBindings, overrideInfo); - } - } else if (command_it != cur.end ()) { - material = Images::CMaterial::fromCommand (cur); - } else { - sLog.exception ("Material without command nor material file: ", name, " (", materialNumber,")"); - } - - materials.push_back (material); - } - - return materials; -} - -std::map CEffect::overridesFromJSON ( - const json::const_iterator& passes_it, const Images::CMaterial* material, - std::shared_ptr project -) { - std::map result; - - int materialNumber = -1; - for (const auto& cur : (*passes_it)) { - ++materialNumber; - auto constants_it = cur.find ("constantshadervalues"); - auto combos_it = cur.find ("combos"); - auto textures_it = cur.find ("textures"); - Images::CMaterial::OverrideInfo override; - int textureNumber = -1; - - if (combos_it != cur.end ()) { - override.combos = CEffect::combosFromJSON (combos_it); - } - - if (constants_it != cur.end ()) { - override.constants = CEffect::constantsFromJSON (constants_it, project); - } - - if (textures_it != cur.end ()) { - // TODO: MAYBE CHANGE THIS TO BE SOMEWHERE ELSE? THIS IS REALLY MODIFYING THE DATA - // BUT IT'S USEFUL TO HAVE TO SIMPLIFY RENDERING CODE - for (const auto& texture : (*textures_it)) { - ++textureNumber; - std::string name; - - if (texture.is_null () && textureNumber > 0) { - continue; - } - - if (textureNumber == 0) { - auto passTextures = (*material->getPasses ().begin ())->getTextures (); - - if (passTextures.empty()) { - continue; - } else { - name = passTextures.begin ()->second; - } - } else { - name = texture; - } - - override.textures.emplace (textureNumber, name); - } - } - - result.emplace (materialNumber, override); - } - - return result; -} - -const std::vector& CEffect::getDependencies () const { - return this->m_dependencies; -} - -const std::vector& CEffect::getMaterials () const { - return this->m_materials; -} - -const std::vector& CEffect::getFbos () const { - return this->m_fbos; -} - -const Core::CProject& CEffect::getProject () const { - return *this->m_project; -} - -bool CEffect::isVisible () const { - return this->m_visible->getBool (); -} - -const Effects::CFBO* CEffect::findFBO (const std::string& name) { - for (const auto& cur : this->m_fbos) - if (cur->getName () == name) - return cur; - - sLog.exception ("cannot find fbo ", name); -} diff --git a/src/WallpaperEngine/Core/Objects/CEffect.h b/src/WallpaperEngine/Core/Objects/CEffect.h deleted file mode 100644 index 602ec56..0000000 --- a/src/WallpaperEngine/Core/Objects/CEffect.h +++ /dev/null @@ -1,102 +0,0 @@ -#pragma once - -#include "WallpaperEngine/Assets/CContainer.h" -#include "WallpaperEngine/Core/CObject.h" -#include "WallpaperEngine/Core/Core.h" -#include "WallpaperEngine/Core/Objects/Effects/CFBO.h" -#include "WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstant.h" -#include "WallpaperEngine/Core/Objects/Images/CMaterial.h" - -namespace WallpaperEngine::Core { -class CObject; -class CProject; -} - -namespace WallpaperEngine::Core::UserSettings { -class CUserSettingBoolean; -} - -namespace WallpaperEngine::Core::Objects { -using json = nlohmann::json; -using namespace WallpaperEngine::Assets; -using namespace WallpaperEngine::Core::UserSettings; - -/** - * Represents an effect applied to background objects - */ -class CEffect { - public: - CEffect ( - std::string name, std::string description, std::string group, std::string preview, - std::shared_ptr , const CUserSettingBoolean* visible, - std::vector dependencies, std::vector fbos, - std::vector materials); - - static const CEffect* fromJSON ( - const json& data, const CUserSettingBoolean* visible, std::shared_ptr project, - const Images::CMaterial* material, const std::shared_ptr& container); - - /** - * @return List of dependencies for the effect to work - */ - [[nodiscard]] const std::vector& getDependencies () const; - /** - * @return List of materials the effect applies - */ - [[nodiscard]] const std::vector& getMaterials () const; - /** - * @return The list of FBOs to be used for this effect - */ - [[nodiscard]] const std::vector& getFbos () const; - /** - * @return If the effect is visible or not - */ - [[nodiscard]] bool isVisible () const; - /** - * @return The project this effect is part of - */ - [[nodiscard]] const CProject& getProject () const; - /** - * Searches the FBOs list for the given FBO - * - * @param name The FBO to search for - * - * @return - */ - const Effects::CFBO* findFBO (const std::string& name); - - protected: - static std::map constantsFromJSON ( - const json::const_iterator& constants_it, std::shared_ptr project); - static std::map combosFromJSON (const json::const_iterator& combos_it); - static std::vector fbosFromJSON (const json::const_iterator& fbos_it); - static std::vector dependenciesFromJSON (const json::const_iterator& dependencies_it); - static std::vector materialsFromJSON ( - const json::const_iterator& passes_it, const std::string& name, - const std::shared_ptr& container, std::map); - static std::map overridesFromJSON ( - const json::const_iterator& passes_it, const Images::CMaterial* material, - std::shared_ptr project); - - private: - /** Effect's name */ - const std::string m_name; - /** Effect's description used in the UI */ - const std::string m_description; - /** Effect's group used in the UI */ - const std::string m_group; - /** A project that previews the given effect, used in the UI */ - const std::string m_preview; - /** If the effect is visible or not */ - const UserSettings::CUserSettingBoolean* m_visible; - /** Project this effect is part of */ - std::shared_ptr m_project; - - /** List of dependencies for the effect */ - const std::vector m_dependencies; - /** List of materials the effect applies */ - const std::vector m_materials; - /** List of FBOs required for this effect */ - const std::vector m_fbos; -}; -} // namespace WallpaperEngine::Core::Objects diff --git a/src/WallpaperEngine/Core/Objects/CImage.cpp b/src/WallpaperEngine/Core/Objects/CImage.cpp deleted file mode 100644 index eb6c0b1..0000000 --- a/src/WallpaperEngine/Core/Objects/CImage.cpp +++ /dev/null @@ -1,142 +0,0 @@ -#include "CImage.h" - -#include - -#include "WallpaperEngine/Core/Objects/Images/CMaterial.h" -#include "WallpaperEngine/Core/UserSettings/CUserSettingBoolean.h" -#include "WallpaperEngine/Core/UserSettings/CUserSettingFloat.h" -#include "WallpaperEngine/Core/UserSettings/CUserSettingVector3.h" -#include "WallpaperEngine/Core/Wallpapers/CScene.h" - -using namespace WallpaperEngine::Core::Objects; -using namespace WallpaperEngine::Core::UserSettings; - -CImage::CImage ( - std::shared_ptr project, const Images::CMaterial* material, - const CUserSettingBoolean* visible, int id, std::string name, const CUserSettingVector3* origin, - const CUserSettingVector3* scale, const CUserSettingVector3* angles, glm::vec2 size, std::string alignment, - const CUserSettingVector3* color, const CUserSettingFloat* alpha, float brightness, uint32_t colorBlendMode, - glm::vec2 parallaxDepth, bool fullscreen, bool passthrough, bool autosize, - std::vector effects, std::vector dependencies -) : - CObject (project, visible, id, std::move(name), origin, scale, angles, std::move(dependencies)), - m_size (size), - m_parallaxDepth (parallaxDepth), - m_material (material), - m_alignment (std::move(alignment)), - m_alpha (alpha), - m_brightness (brightness), - m_color (color), - m_colorBlendMode (colorBlendMode), - m_fullscreen (fullscreen), - m_passthrough (passthrough), - m_autosize (autosize), - m_effects (std::move(effects)) {} - -const WallpaperEngine::Core::CObject* CImage::fromJSON ( - std::shared_ptr project, const json& data, const std::shared_ptr& container, - const CUserSettingBoolean* visible, int id, std::string name, const CUserSettingVector3* origin, - const CUserSettingVector3* scale, const CUserSettingVector3* angles, const json::const_iterator& effects_it, - std::vector dependencies -) { - const auto image = jsonFindRequired (data, "image", "Image must have an image"); - std::vector effects; - json content = json::parse (container->readFileAsString (image)); - - const auto material = Images::CMaterial::fromFile ( - jsonFindRequired (content, "material", "Image must have a material"), - container, - jsonFindDefault (content, "solidlayer", false) - ); - - if (effects_it != data.end () && effects_it->is_array ()) { - for (auto& cur : *effects_it) { - const auto effectVisible = jsonFindUserConfig (cur, *project, "visible", true); - - // TODO: USER CANNOT MODIFY VALUES ON THE FLY, BUT IT MIGHT BE INTERESTING TO SUPPORT THAT AT SOME POINT? - // TODO: AT LEAST THE ORIGINAL SOFTWARE ALLOWS YOU TO DO THAT IN THE PREVIEW WINDOW - // TODO: THAT MIGHT INCREASE COMPLEXITY THO... - // TODO: ESPECIALLY IF THAT CHANGES RENDERING OF PASSES/IMAGES - // TODO: DECISIONS, DECISIONS, DECISIONS... - if (!effectVisible->getBool ()) - continue; - - effects.push_back ( - Objects::CEffect::fromJSON ( - cur, effectVisible, project, material, container - ) - ); - } - } - - return new CImage ( - project, - material, - visible, - id, - std::move(name), - origin, - scale, - angles, - jsonFindDefault (data, "size", glm::vec2 (0.0, 0.0)), - jsonFindDefault (data, "alignment", "center"), - jsonFindUserConfig (data, *project, "color", {1, 1, 1}), - jsonFindUserConfig (data, *project, "alpha", 1.0), - jsonFindDefault (data, "brightness", 1.0), - jsonFindDefault (data, "colorBlendMode", 0), - jsonFindDefault (data, "parallaxDepth", glm::vec2 (0.0, 0.0)), - jsonFindDefault (content, "fullscreen", false), - jsonFindDefault (content, "passthrough", false), - jsonFindDefault (content, "autosize", false), - effects, - std::move(dependencies) - ); -} - -const Images::CMaterial* CImage::getMaterial () const { - return this->m_material; -} - -const glm::vec2& CImage::getSize () const { - return this->m_size; -} - -const std::string& CImage::getAlignment () const { - return this->m_alignment; -} - -float CImage::getAlpha () const { - return this->m_alpha->getFloat (); -} - -const glm::vec3& CImage::getColor () const { - return this->m_color->getVec3 (); -} - -float CImage::getBrightness () const { - return this->m_brightness; -} - -uint32_t CImage::getColorBlendMode () const { - return this->m_colorBlendMode; -} - -const glm::vec2& CImage::getParallaxDepth () const { - return this->m_parallaxDepth; -} - -bool CImage::isFullscreen () const { - return this->m_fullscreen; -} - -bool CImage::isPassthrough () const { - return this->m_passthrough; -} - -bool CImage::isAutosize () const { - return this->m_autosize; -} - -const std::vector& CImage::getEffects () const { - return this->m_effects; -} diff --git a/src/WallpaperEngine/Core/Objects/CImage.h b/src/WallpaperEngine/Core/Objects/CImage.h deleted file mode 100644 index f78cc4b..0000000 --- a/src/WallpaperEngine/Core/Objects/CImage.h +++ /dev/null @@ -1,122 +0,0 @@ -#pragma once - -#include - -#include "WallpaperEngine/Core/Objects/Images/CMaterial.h" - -#include "WallpaperEngine/Core/CObject.h" -#include "WallpaperEngine/Core/Core.h" - -#include "WallpaperEngine/Assets/CContainer.h" - -#include "WallpaperEngine/Core/UserSettings/CUserSettingBoolean.h" -#include "WallpaperEngine/Core/UserSettings/CUserSettingFloat.h" -#include "WallpaperEngine/Core/UserSettings/CUserSettingVector3.h" - -namespace WallpaperEngine::Core::Wallpapers { -class CScene; -} - -namespace WallpaperEngine::Core::Objects { -using json = nlohmann::json; -using namespace WallpaperEngine::Assets; -using namespace WallpaperEngine::Core::UserSettings; - -/** - * Represents an image in a background - */ -class CImage : public CObject { - friend class CObject; - - public: - static const CObject* fromJSON ( - std::shared_ptr project, const json& data, - const std::shared_ptr& container, const CUserSettingBoolean* visible, int id, - std::string name, const CUserSettingVector3* origin, const CUserSettingVector3* scale, - const CUserSettingVector3* angles, const json::const_iterator& effects_it, std::vector dependencies); - - /** - * @return The base material to use for the image - */ - [[nodiscard]] const Images::CMaterial* getMaterial () const; - /** - * @return The size of the image - */ - [[nodiscard]] const glm::vec2& getSize () const; - /** - * @return The type of alignment to use for image positioning - */ - [[nodiscard]] const std::string& getAlignment () const; - /** - * @return The alpha value for the image's rendering - */ - [[nodiscard]] float getAlpha () const; - /** - * @return The color to use for the image - */ - [[nodiscard]] const glm::vec3& getColor () const; - /** - * @return The brightness to use for the image - */ - [[nodiscard]] float getBrightness () const; - /** - * @return The color blending mode to be used, special value for shaders - */ - [[nodiscard]] uint32_t getColorBlendMode () const; - /** - * @return Parallax depth of the image - */ - [[nodiscard]] const glm::vec2& getParallaxDepth () const; - /** - * @return If the image is fullscreen or not - */ - [[nodiscard]] bool isFullscreen () const; - /** - * @return If the image is passthrough or not - */ - [[nodiscard]] bool isPassthrough () const; - /** - * @return If the image is autosized or not - */ - [[nodiscard]] bool isAutosize () const; - /** - * @return All of the effects applied to this image - */ - [[nodiscard]] const std::vector& getEffects () const; - - protected: - CImage ( - std::shared_ptr project, const Images::CMaterial* material, - const CUserSettingBoolean* visible, int id, std::string name, const CUserSettingVector3* origin, - const CUserSettingVector3* scale, const CUserSettingVector3* angles, glm::vec2 size, std::string alignment, - const CUserSettingVector3* color, const CUserSettingFloat* alpha, float brightness, uint32_t colorBlendMode, - glm::vec2 parallaxDepth, bool fullscreen, bool passthrough, bool autosize, - std::vector effects, std::vector dependencies); - - private: - /** The image's size */ - const glm::vec2 m_size; - /** Parallax depth */ - const glm::vec2 m_parallaxDepth; - /** Base material for the image */ - const Images::CMaterial* m_material; - /** What type of alignment to use for the image's position */ - const std::string m_alignment; - /** The alpha value for the image */ - const CUserSettingFloat* m_alpha; - /** The brightness for the image */ - float m_brightness; - /** The color to use for the image */ - const CUserSettingVector3* m_color; - /** The color blending mode used for the image, special value for shaders */ - const uint32_t m_colorBlendMode; - /** Override for effects */ - const std::vector m_effects; - /** If the image is fullscreen or not */ - bool m_fullscreen = false; - /** If the image is passthrough or not */ - bool m_passthrough = false; - /** If the image's size should be automatically determined */ - bool m_autosize = false; -}; -} // namespace WallpaperEngine::Core::Objects diff --git a/src/WallpaperEngine/Core/Objects/CSound.cpp b/src/WallpaperEngine/Core/Objects/CSound.cpp deleted file mode 100644 index 3ca94e6..0000000 --- a/src/WallpaperEngine/Core/Objects/CSound.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#include "CSound.h" - -#include -#include "WallpaperEngine/Core/CObject.h" -#include "WallpaperEngine/Logging/CLog.h" - -using namespace WallpaperEngine::Core::Objects; - -CSound::CSound ( - std::shared_ptr project, const CUserSettingBoolean* visible, int id, std::string name, - const CUserSettingVector3* origin, const CUserSettingVector3* scale, const CUserSettingVector3* angles, - bool repeat, std::vector sounds, std::vector dependencies -) : - CObject (project, visible, id, std::move(name), origin, scale, angles, std::move(dependencies)), - m_repeat (repeat), - m_sounds (std::move(sounds)) {} - -const WallpaperEngine::Core::CObject* CSound::fromJSON ( - std::shared_ptr project, const json& data, const CUserSettingBoolean* visible, - int id, const std::string& name, const CUserSettingVector3* origin, const CUserSettingVector3* scale, - const CUserSettingVector3* angles, std::vector dependencies -) { - // TODO: PARSE AUDIO VOLUME - std::vector sounds; - const auto sound_it = jsonFindRequired (data, "sound", "Sound information not present"); - - if (!sound_it->is_array ()) - sLog.exception ("Expected sound list on element ", name); - - for (const auto& cur : (*sound_it)) - sounds.push_back (cur); - - return new CSound ( - project, - visible, - id, - name, - origin, - scale, - angles, - jsonFindDefault (data, "playbackmode", "") == "loop", - sounds, - std::move(dependencies) - ); -} - -const std::vector& CSound::getSounds () const { - return this->m_sounds; -} - -bool CSound::isRepeat () const { - return this->m_repeat; -} diff --git a/src/WallpaperEngine/Core/Objects/CSound.h b/src/WallpaperEngine/Core/Objects/CSound.h deleted file mode 100644 index 8784788..0000000 --- a/src/WallpaperEngine/Core/Objects/CSound.h +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once - -#include "WallpaperEngine/Core/CObject.h" -#include "WallpaperEngine/Core/Core.h" -#include "WallpaperEngine/Core/UserSettings/CUserSettingBoolean.h" - -namespace WallpaperEngine::Core::Wallpapers { -class CScene; -} - -namespace WallpaperEngine::Core::Objects { -using json = nlohmann::json; -using namespace WallpaperEngine::Core::UserSettings; - -/** - * Represents a sound played while the background is working - */ -class CSound : public CObject { - friend class CObject; - - public: - static const CObject* fromJSON ( - std::shared_ptr project, const json& data, const CUserSettingBoolean* visible, - int id, const std::string& name, const CUserSettingVector3* origin, const CUserSettingVector3* scale, - const CUserSettingVector3* angles, std::vector dependencies); - - /** - * @return The list of sounds to play - */ - [[nodiscard]] const std::vector& getSounds () const; - /** - * @return If the sound should repeat or not - */ - [[nodiscard]] bool isRepeat () const; - - protected: - CSound ( - std::shared_ptr project, const CUserSettingBoolean* visible, int id, std::string name, - const CUserSettingVector3* origin, const CUserSettingVector3* scale, const CUserSettingVector3* angles, - bool repeat, std::vector sounds, std::vector dependencies); - - private: - /** If the sounds should repeat or not */ - bool m_repeat = false; - /** The list of sounds to play */ - std::vector m_sounds = {}; -}; -} // namespace WallpaperEngine::Core::Objects diff --git a/src/WallpaperEngine/Core/Objects/Effects/CBind.cpp b/src/WallpaperEngine/Core/Objects/Effects/CBind.cpp deleted file mode 100644 index 37ad6a9..0000000 --- a/src/WallpaperEngine/Core/Objects/Effects/CBind.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "CBind.h" - -#include - -using namespace WallpaperEngine::Core::Objects::Effects; - -CBind::CBind (std::string name, uint32_t index) : - m_name (std::move(name)), - m_index (index) {} - -const CBind* CBind::fromJSON (const json& data) { - return new CBind ( - jsonFindRequired (data, "name", "bind must have texture name"), - jsonFindRequired (data, "index", "bind must have index") - ); -} - -const std::string& CBind::getName () const { - return this->m_name; -} - -const uint32_t& CBind::getIndex () const { - return this->m_index; -} \ No newline at end of file diff --git a/src/WallpaperEngine/Core/Objects/Effects/CBind.h b/src/WallpaperEngine/Core/Objects/Effects/CBind.h deleted file mode 100644 index 6fd790c..0000000 --- a/src/WallpaperEngine/Core/Objects/Effects/CBind.h +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once - -#include - -#include "WallpaperEngine/Core/Core.h" - -namespace WallpaperEngine::Core::Objects::Effects { -using json = nlohmann::json; - -/** - * Material's bind information, describes for passes what textures to bind - * in what positions for shaders. Used to override the textures specified inside - * the object's passes - */ -class CBind { - public: - /** - * Parses bind information off the given json data - * - * @param data - * @return - */ - static const CBind* fromJSON (const json& data); - - /** - * @return The texture name, previous to use the one already specified by the object's passes - */ - [[nodiscard]] const std::string& getName () const; - /** - * @return The texture index to replace - */ - [[nodiscard]] const uint32_t& getIndex () const; - - protected: - CBind (std::string name, uint32_t index); - - private: - /** The texture's name */ - const std::string m_name; - /** The texture index to replace */ - const uint32_t m_index; -}; -} // namespace WallpaperEngine::Core::Objects::Effects diff --git a/src/WallpaperEngine/Core/Objects/Effects/CFBO.cpp b/src/WallpaperEngine/Core/Objects/Effects/CFBO.cpp deleted file mode 100644 index ad1c459..0000000 --- a/src/WallpaperEngine/Core/Objects/Effects/CFBO.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "CFBO.h" - -#include - -using namespace WallpaperEngine::Core; -using namespace WallpaperEngine::Core::Objects::Effects; - -CFBO::CFBO (std::string name, float scale, std::string format) : - m_name (std::move(name)), - m_scale (scale), - m_format (std::move(format)) {} - -const CFBO* CFBO::fromJSON (const json& data) { - return new CFBO ( - jsonFindRequired (data, "name", "Name for an FBO is required"), - jsonFindDefault (data, "scale", 1.0), - jsonFindDefault (data, "format", "") - ); -} - -const std::string& CFBO::getName () const { - return this->m_name; -} - -const float& CFBO::getScale () const { - return this->m_scale; -} - -const std::string& CFBO::getFormat () const { - return this->m_format; -} \ No newline at end of file diff --git a/src/WallpaperEngine/Core/Objects/Effects/CFBO.h b/src/WallpaperEngine/Core/Objects/Effects/CFBO.h deleted file mode 100644 index cc2e694..0000000 --- a/src/WallpaperEngine/Core/Objects/Effects/CFBO.h +++ /dev/null @@ -1,44 +0,0 @@ -#pragma once - -#include "WallpaperEngine/Core/Core.h" - -#include -#include - -namespace WallpaperEngine::Core::Objects::Effects { -using json = nlohmann::json; - -/** - * FBO = Frame Buffer Object - * - * Represents a framebuffer object used in objects with multiple effects or render passes - */ -class CFBO { - public: - static const CFBO* fromJSON (const json& data); - - /** - * @return The FBO name used to identify it in the background's files - */ - [[nodiscard]] const std::string& getName () const; - /** - * @return The scale factor of the FBO - */ - [[nodiscard]] const float& getScale () const; - /** - * @return The FBO's format for the render - */ - [[nodiscard]] const std::string& getFormat () const; - - protected: - CFBO (std::string name, float scale, std::string format); - - private: - /** The name of the FBO */ - const std::string m_name; - /** The scale factor of the FBO */ - const float m_scale; - /** The FBO's format for the render */ - const std::string m_format; -}; -} // namespace WallpaperEngine::Core::Objects::Effects \ No newline at end of file diff --git a/src/WallpaperEngine/Core/Objects/Images/CMaterial.cpp b/src/WallpaperEngine/Core/Objects/Images/CMaterial.cpp deleted file mode 100644 index bf2eaab..0000000 --- a/src/WallpaperEngine/Core/Objects/Images/CMaterial.cpp +++ /dev/null @@ -1,120 +0,0 @@ -#include "CMaterial.h" - -#include "WallpaperEngine/Core/Objects/Images/Materials/CPass.h" -#include "WallpaperEngine/Logging/CLog.h" -#include -#include - -using namespace WallpaperEngine::Assets; - -using namespace WallpaperEngine::Core::Objects; -using namespace WallpaperEngine::Core::Objects::Images; - -CMaterial::CMaterial ( - std::string name, bool solidlayer, std::map textureBindings, - std::vector passes -) : - m_name (std::move(name)), - m_textureBindings (std::move(textureBindings)), - m_passes (std::move(passes)), - m_solidlayer (solidlayer) {} -CMaterial::CMaterial ( - std::string name, std::string target, bool solidlayer, - std::map textureBindings, std::vector passes -) : - m_name (std::move(name)), - m_target (std::move(target)), - m_textureBindings (std::move(textureBindings)), - m_passes (std::move(passes)), - m_solidlayer (solidlayer) {} - -const CMaterial* CMaterial::fromFile ( - const std::filesystem::path& filename, const std::shared_ptr& container, bool solidlayer, - std::map textureBindings, const OverrideInfo* overrides -) { - return fromJSON (filename, json::parse (container->readFileAsString (filename)), solidlayer, std::move(textureBindings), overrides); -} - -const CMaterial* CMaterial::fromFile ( - const std::filesystem::path& filename, const std::string& target, const std::shared_ptr& container, bool solidlayer, - std::map textureBindings, const OverrideInfo* overrides -) { - return fromJSON (filename, json::parse (container->readFileAsString (filename)), target, solidlayer, std::move(textureBindings), overrides); -} - -const CMaterial* CMaterial::fromJSON ( - const std::string& name, const json& data, const std::string& target, bool solidlayer, - std::map textureBindings, const OverrideInfo* overrides -) { - const auto passes_it = jsonFindRequired (data, "passes", "Material must have at least one pass"); - std::vector passes; - - for (const auto& cur : (*passes_it)) - passes.push_back (Materials::CPass::fromJSON (cur, overrides)); - - return new CMaterial (name, target, solidlayer, std::move(textureBindings), passes); -} - -const CMaterial* CMaterial::fromJSON ( - const std::string& name, const json& data, bool solidlayer, std::map textureBindings, - const OverrideInfo* overrides -) { - const auto passes_it = jsonFindRequired (data, "passes", "Material must have at least one pass"); - std::vector passes; - - for (const auto& cur : (*passes_it)) - passes.push_back (Materials::CPass::fromJSON (cur, overrides)); - - return new CMaterial (name, solidlayer, std::move(textureBindings), passes); -} - -const CMaterial* CMaterial::fromCommand (const json& data) { - const std::string& command = jsonFindRequired (data, "command", "Command material must have a command"); - const std::string& target = jsonFindRequired (data, "target", "Command material must have a target"); - const std::string& source = jsonFindRequired (data, "source", "Command material must have a source"); - std::vector passes; - - if (command == "copy") { - passes.push_back ( - Materials::CPass::fromJSON ({ - {"blending", "normal"}, - {"cullmode", "nocull"}, - {"depthtest", "disabled"}, - {"depthwrite", "disabled"}, - {"shader", "commands/copy"}, - {"textures", json::array ({source, target})} - }, nullptr) - ); - } else if (command == "swap") { - // TODO: HOW TO IMPLEMENT THIS ONE? - sLog.exception ("Command material swap not implemented yet"); - } else { - sLog.exception ("Unknown command: ", command); - } - - return new CMaterial (command, false, {}, passes); -} - -const std::vector& CMaterial::getPasses () const { - return this->m_passes; -} - -const std::map& CMaterial::getTextureBinds () const { - return this->m_textureBindings; -} - -const std::string& CMaterial::getTarget () const { - return this->m_target; -} - -const std::string& CMaterial::getName () const { - return this->m_name; -} - -bool CMaterial::hasTarget () const { - return !this->m_target.empty (); -} - -bool CMaterial::isSolidLayer () const { - return this->m_solidlayer; -} \ No newline at end of file diff --git a/src/WallpaperEngine/Core/Objects/Images/CMaterial.h b/src/WallpaperEngine/Core/Objects/Images/CMaterial.h deleted file mode 100644 index e1a3496..0000000 --- a/src/WallpaperEngine/Core/Objects/Images/CMaterial.h +++ /dev/null @@ -1,89 +0,0 @@ -#pragma once - -#include "WallpaperEngine/Core/Objects/Effects/CBind.h" - -#include "WallpaperEngine/Assets/CContainer.h" -#include "WallpaperEngine/Core/Core.h" -#include "WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstant.h" - -namespace WallpaperEngine::Core::Objects::Images::Materials { -class CPass; -} - -namespace WallpaperEngine::Core::Objects::Images { -using json = nlohmann::json; -using namespace WallpaperEngine::Assets; - -/** - * Represents a material in use in the background - */ -class CMaterial { - public: - struct OverrideInfo { - std::map combos; - std::map constants; - std::map textures; - }; - - static const CMaterial* fromFile ( - const std::filesystem::path& filename, const std::shared_ptr& container, bool solidlayer = false, - std::map textureBindings = {}, const OverrideInfo* overrides = nullptr); - static const CMaterial* fromFile ( - const std::filesystem::path& filename, const std::string& target, const std::shared_ptr& container, - bool solidlayer = false, std::map textureBindings = {}, - const OverrideInfo* overrides = nullptr); - static const CMaterial* fromJSON ( - const std::string& name, const json& data, bool solidlayer = false, - std::map textureBindings = {}, const OverrideInfo* overrides = nullptr); - static const CMaterial* fromJSON ( - const std::string& name, const json& data, const std::string& target, bool solidlayer = false, - std::map textureBindings = {}, const OverrideInfo* overrides = nullptr); - static const CMaterial* fromCommand (const json& data); - - /** - * @return All the rendering passes that happen for this material - */ - [[nodiscard]] const std::vector& getPasses () const; - /** - * @return The textures that have to be bound while rendering the material. - * These act as an override of the textures specified by the parent effect - */ - [[nodiscard]] const std::map& getTextureBinds () const; - /** - * @return The materials destination (fbo) if required - */ - [[nodiscard]] const std::string& getTarget () const; - /** - * @return Indicates if this material has a specific destination (fbo) while rendering - */ - [[nodiscard]] bool hasTarget () const; - /** - * @return The name of the material - */ - [[nodiscard]] const std::string& getName () const; - /** - * @return If this material is a solidlayer or not - */ - [[nodiscard]] bool isSolidLayer () const; - - protected: - CMaterial ( - std::string name, bool solidlayer, std::map textureBindings, - std::vector passes); - CMaterial ( - std::string name, std::string target, bool solidlayer, std::map textureBindings, - std::vector passes); - - private: - /** All the shader passes required to render this material */ - const std::vector m_passes; - /** List of texture bind overrides to use for this material */ - const std::map m_textureBindings; - /** The FBO target to render to (if any) */ - const std::string m_target; - /** The material's name */ - const std::string m_name; - /** If this material is a solid layer or not */ - const bool m_solidlayer; -}; -} // namespace WallpaperEngine::Core::Objects::Images diff --git a/src/WallpaperEngine/Core/Objects/Images/Materials/CPass.cpp b/src/WallpaperEngine/Core/Objects/Images/Materials/CPass.cpp deleted file mode 100644 index e07c9b4..0000000 --- a/src/WallpaperEngine/Core/Objects/Images/Materials/CPass.cpp +++ /dev/null @@ -1,105 +0,0 @@ -#include "CPass.h" -#include "WallpaperEngine/Logging/CLog.h" - -#include - -using namespace WallpaperEngine::Core::Objects::Effects::Constants; -using namespace WallpaperEngine::Core::Objects::Images::Materials; - -CPass::CPass (std::string blending, std::string cullmode, std::string depthtest, std::string depthwrite, - std::string shader, std::map textures, std::map combos, - std::map constants) : - m_blending (std::move(blending)), - m_cullmode (std::move(cullmode)), - m_depthtest (std::move(depthtest)), - m_depthwrite (std::move(depthwrite)), - m_shader (std::move(shader)), - m_textures (std::move(textures)), - m_combos (std::move(combos)), - m_constants (std::move(constants)) {} - -const CPass* CPass::fromJSON (const json& data, const CMaterial::OverrideInfo* overrides) { - // TODO: FIGURE OUT DEFAULT BLENDING MODE - const auto textures_it = data.find ("textures"); - const auto combos_it = data.find ("combos"); - - std::map textures; - std::map combos; - std::map constants; - - if (textures_it != data.end ()) { - // TODO: FETCH THIS FROM CImage TO MAKE IT COMPATIBLE WITH OLDER WALLPAPERS - if (!textures_it->is_array ()) - sLog.exception ("Material's textures must be a list"); - - int textureNumber = -1; - for (const auto& cur : (*textures_it)) - textures.emplace (++textureNumber, cur.is_null () ? "" : cur); - } - - if (combos_it != data.end ()) { - for (const auto& cur : combos_it->items ()) { - if (cur.value ().is_number_integer ()) { - std::string uppercase = std::string (cur.key ()); - - std::transform (uppercase.begin (), uppercase.end (), uppercase.begin (), ::toupper); - combos.emplace (uppercase, cur.value ()); - } else { - sLog.exception ("unexpected non-integer combo on pass"); - } - } - } - - // apply overrides - if (overrides != nullptr) { - for (const auto& [name, value] : overrides->combos) - combos[name] = value; - for (const auto& [name, value] : overrides->constants) - constants[name] = value; - for (const auto& [id, value] : overrides->textures) - textures[id] = value; - } - - return new CPass ( - jsonFindDefault (data, "blending", "normal"), - jsonFindDefault (data, "cullmode", "nocull"), - jsonFindRequired (data, "depthtest", "Material pass must have depthtest specified"), - jsonFindRequired (data, "depthwrite", "Material pass must have depthwrite specified"), - jsonFindRequired (data, "shader", "Material pass must have shader specified"), - textures, - combos, - constants - ); -} - -const std::map& CPass::getTextures () const { - return this->m_textures; -} - -const std::map& CPass::getConstants () const { - return this->m_constants; -} - -const std::map& CPass::getCombos () const { - return this->m_combos; -} - -const std::string& CPass::getShader () const { - return this->m_shader; -} - -const std::string& CPass::getBlendingMode () const { - return this->m_blending; -} - -const std::string& CPass::getCullingMode () const { - return this->m_cullmode; -} - -const std::string& CPass::getDepthTest () const { - return this->m_depthtest; -} - -const std::string& CPass::getDepthWrite () const { - return this->m_depthwrite; -} diff --git a/src/WallpaperEngine/Core/Objects/Images/Materials/CPass.h b/src/WallpaperEngine/Core/Objects/Images/Materials/CPass.h deleted file mode 100644 index e14889a..0000000 --- a/src/WallpaperEngine/Core/Objects/Images/Materials/CPass.h +++ /dev/null @@ -1,84 +0,0 @@ -#pragma once - -#include "WallpaperEngine/Core/Core.h" -#include "WallpaperEngine/Core/Objects/Images/CMaterial.h" -#include "WallpaperEngine/Core/Objects/Effects/Constants/CShaderConstant.h" - -namespace WallpaperEngine::Core::Objects { -class CEffect; -} - -namespace WallpaperEngine::Core::Objects::Images { -class CMaterial; -} - -namespace WallpaperEngine::Core::Objects::Images::Materials { -using json = nlohmann::json; - -/** - * Represents a shader pass of an object - */ -class CPass { - friend class WallpaperEngine::Core::Objects::CEffect; - - public: - static const CPass* fromJSON (const json& data, const CMaterial::OverrideInfo* overrides); - - /** - * @return The list of textures to bind while rendering - */ - [[nodiscard]] const std::map& getTextures () const; - /** - * @return Shader constants that alter how the shader should behave - */ - [[nodiscard]] const std::map& getConstants () const; - /** - * @return Shader combos that alter how the shader should behave - */ - [[nodiscard]] const std::map& getCombos () const; - /** - * @return Shader to be used while rendering the pass - */ - [[nodiscard]] const std::string& getShader () const; - /** - * @return The blending mode to use while rendering - */ - [[nodiscard]] const std::string& getBlendingMode () const; - /** - * @return The culling mode to use while rendering - */ - [[nodiscard]] const std::string& getCullingMode () const; - /** - * @return If depth testing has to happen while rendering - */ - [[nodiscard]] const std::string& getDepthTest () const; - /** - * @return If depth write has to happen while rendering - */ - [[nodiscard]] const std::string& getDepthWrite () const; - - protected: - CPass (std::string blending, std::string cullmode, std::string depthtest, std::string depthwrite, - std::string shader, std::map textures, std::map combos, - std::map constants); - - private: - // TODO: CREATE ENUMERATIONS FOR THESE INSTEAD OF USING STRING VALUES! - /** The blending mode to use */ - const std::string m_blending; - /** The culling mode to use */ - const std::string m_cullmode; - /** If depthtesting has to happen while drawing */ - const std::string m_depthtest; - /** If depthwrite has to happen while drawing */ - const std::string m_depthwrite; - /** The shader to use */ - const std::string m_shader; - /** The list of textures to use */ - const std::map m_textures; - /** Different combo settings for shader input */ - const std::map m_combos; - /** Shader constant values to use for the shaders */ - const std::map m_constants; -}; -} // namespace WallpaperEngine::Core::Objects::Images::Materials diff --git a/src/WallpaperEngine/Core/Scenes/CCamera.cpp b/src/WallpaperEngine/Core/Scenes/CCamera.cpp deleted file mode 100644 index 05118bc..0000000 --- a/src/WallpaperEngine/Core/Scenes/CCamera.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "CCamera.h" - -using namespace WallpaperEngine::Core::Scenes; - -CCamera::CCamera (glm::vec3 center, glm::vec3 eye, glm::vec3 up) : - m_center (center), - m_eye (eye), - m_up (up) {} - -const glm::vec3& CCamera::getCenter () const { - return this->m_center; -} - -const glm::vec3& CCamera::getEye () const { - return this->m_eye; -} - -const glm::vec3& CCamera::getUp () const { - return this->m_up; -} - -const CCamera* CCamera::fromJSON (const json::const_iterator& data) { - return new CCamera ( - jsonFindRequired (data, "center", "Camera must have a center position"), - jsonFindRequired (data, "eye", "Camera must have an eye position"), - jsonFindRequired (data, "up", "Camera must have a up position") - ); -} \ No newline at end of file diff --git a/src/WallpaperEngine/Core/Scenes/CCamera.h b/src/WallpaperEngine/Core/Scenes/CCamera.h deleted file mode 100644 index 5d2f17f..0000000 --- a/src/WallpaperEngine/Core/Scenes/CCamera.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -#include "WallpaperEngine/Core/Core.h" - -namespace WallpaperEngine::Core::Scenes { -using json = nlohmann::json; - -class CCamera { - public: - static const CCamera* fromJSON (const json::const_iterator& data); - - const glm::vec3& getCenter () const; - const glm::vec3& getEye () const; - const glm::vec3& getUp () const; - - protected: - CCamera (glm::vec3 center, glm::vec3 eye, glm::vec3 up); - - private: - const glm::vec3 m_center; - const glm::vec3 m_eye; - const glm::vec3 m_up; -}; -} // namespace WallpaperEngine::Core::Scenes diff --git a/src/WallpaperEngine/Core/Scenes/CProjection.cpp b/src/WallpaperEngine/Core/Scenes/CProjection.cpp deleted file mode 100644 index d9ee5b0..0000000 --- a/src/WallpaperEngine/Core/Scenes/CProjection.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "CProjection.h" - -using namespace WallpaperEngine::Core::Scenes; - -CProjection::CProjection (int width, int height) : - m_width (width), - m_height (height), - m_isAuto (false) {} - -CProjection::CProjection (bool isAuto) : - m_width (0), - m_height (0), - m_isAuto (isAuto) {} - -const int& CProjection::getWidth () const { - return this->m_width; -} - -const int& CProjection::getHeight () const { - return this->m_height; -} - -bool CProjection::isAuto () const { - return this->m_isAuto; -} - -void CProjection::setWidth (int width) const { - this->m_width = width; -} - -void CProjection::setHeight (int height) const { - this->m_height = height; -} - -const CProjection* CProjection::fromJSON (const json::const_iterator& data) { - const auto auto_it = jsonFindDefault (data, "auto", false); - - const auto width_it = jsonFindRequired (data, "width", "Projection must have width"); - const auto height_it = jsonFindRequired (data, "height", "Projection must have height"); - - // TODO: PROPERLY SUPPORT AUTO-DETECTING SIZE - if (auto_it) - return new CProjection (true); - - return new CProjection (*width_it, *height_it); -} \ No newline at end of file diff --git a/src/WallpaperEngine/Core/Scenes/CProjection.h b/src/WallpaperEngine/Core/Scenes/CProjection.h deleted file mode 100644 index d3bfee4..0000000 --- a/src/WallpaperEngine/Core/Scenes/CProjection.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include "WallpaperEngine/Core/Core.h" - -namespace WallpaperEngine::Core::Scenes { -using json = nlohmann::json; - -class CProjection { - public: - static const CProjection* fromJSON (const json::const_iterator& data); - - [[nodiscard]] const int& getWidth () const; - [[nodiscard]] const int& getHeight () const; - [[nodiscard]] bool isAuto () const; - - // TODO: CHANGE THIS SO THE RENDER IS THE ONE RESPONSIBLE FOR THIS? - void setWidth (int width) const; - void setHeight (int height) const; - - protected: - CProjection (int width, int height); - explicit CProjection (bool isAuto); - - private: - mutable int m_width; - mutable int m_height; - const bool m_isAuto; -}; -} // namespace WallpaperEngine::Core::Scenes diff --git a/src/WallpaperEngine/Core/UserSettings/CUserSettingBoolean.cpp b/src/WallpaperEngine/Core/UserSettings/CUserSettingBoolean.cpp index d2d8611..ba6601f 100644 --- a/src/WallpaperEngine/Core/UserSettings/CUserSettingBoolean.cpp +++ b/src/WallpaperEngine/Core/UserSettings/CUserSettingBoolean.cpp @@ -3,7 +3,6 @@ #include #include "WallpaperEngine/Core/Core.h" -#include "WallpaperEngine/Core/CProject.h" #include "WallpaperEngine/Core/Projects/CProperty.h" #include "WallpaperEngine/Core/Projects/CPropertyBoolean.h" #include "WallpaperEngine/Core/Projects/CPropertyCombo.h" diff --git a/src/WallpaperEngine/Core/UserSettings/CUserSettingBoolean.h b/src/WallpaperEngine/Core/UserSettings/CUserSettingBoolean.h index ebfd4a0..8b6930e 100644 --- a/src/WallpaperEngine/Core/UserSettings/CUserSettingBoolean.h +++ b/src/WallpaperEngine/Core/UserSettings/CUserSettingBoolean.h @@ -1,7 +1,6 @@ #pragma once #include "CUserSettingValue.h" -#include "WallpaperEngine/Core/CProject.h" namespace WallpaperEngine::Core::Projects { class CProperty; diff --git a/src/WallpaperEngine/Core/UserSettings/CUserSettingFloat.cpp b/src/WallpaperEngine/Core/UserSettings/CUserSettingFloat.cpp index 36d58e9..7e99230 100644 --- a/src/WallpaperEngine/Core/UserSettings/CUserSettingFloat.cpp +++ b/src/WallpaperEngine/Core/UserSettings/CUserSettingFloat.cpp @@ -3,7 +3,6 @@ #include #include "WallpaperEngine/Core/Core.h" -#include "WallpaperEngine/Core/CProject.h" #include "WallpaperEngine/Core/Projects/CProperty.h" #include "WallpaperEngine/Core/Projects/CPropertySlider.h" #include "WallpaperEngine/Logging/CLog.h" diff --git a/src/WallpaperEngine/Core/UserSettings/CUserSettingFloat.h b/src/WallpaperEngine/Core/UserSettings/CUserSettingFloat.h index 72c13ad..eea2fa1 100644 --- a/src/WallpaperEngine/Core/UserSettings/CUserSettingFloat.h +++ b/src/WallpaperEngine/Core/UserSettings/CUserSettingFloat.h @@ -1,7 +1,6 @@ #pragma once #include "CUserSettingValue.h" -#include "WallpaperEngine/Core/CProject.h" namespace WallpaperEngine::Core::Projects { class CProperty; diff --git a/src/WallpaperEngine/Core/UserSettings/CUserSettingVector3.h b/src/WallpaperEngine/Core/UserSettings/CUserSettingVector3.h index c9609bc..992c461 100644 --- a/src/WallpaperEngine/Core/UserSettings/CUserSettingVector3.h +++ b/src/WallpaperEngine/Core/UserSettings/CUserSettingVector3.h @@ -3,7 +3,6 @@ #include #include "CUserSettingValue.h" -#include "WallpaperEngine/Core/CProject.h" namespace WallpaperEngine::Core::Projects { class CProperty; diff --git a/src/WallpaperEngine/Core/Wallpapers/CScene.cpp b/src/WallpaperEngine/Core/Wallpapers/CScene.cpp deleted file mode 100644 index 9e53446..0000000 --- a/src/WallpaperEngine/Core/Wallpapers/CScene.cpp +++ /dev/null @@ -1,172 +0,0 @@ -#include "CScene.h" - -#include -#include "WallpaperEngine/Core/CProject.h" - -#include "WallpaperEngine/Core/UserSettings/CUserSettingBoolean.h" -#include "WallpaperEngine/Core/UserSettings/CUserSettingFloat.h" -#include "WallpaperEngine/Core/UserSettings/CUserSettingVector3.h" - -using namespace WallpaperEngine::Core; -using namespace WallpaperEngine::Core::Wallpapers; - -CScene::CScene ( - std::shared_ptr project, std::shared_ptr container, const Scenes::CCamera* camera, - glm::vec3 ambientColor, const CUserSettingBoolean* bloom, const CUserSettingFloat* bloomStrength, - const CUserSettingFloat* bloomThreshold, bool cameraFade, bool cameraParallax, float cameraParallaxAmount, - float cameraParallaxDelay, float cameraParallaxMouseInfluence, bool cameraPreview, bool cameraShake, - float cameraShakeAmplitude, float cameraShakeRoughness, float cameraShakeSpeed, - const CUserSettingVector3* clearColor, const Scenes::CProjection* orthogonalProjection, glm::vec3 skylightColor -) : - CWallpaper (project), - m_container (std::move(container)), - m_camera (camera), - m_ambientColor (ambientColor), - m_bloom (bloom), - m_bloomStrength (bloomStrength), - m_bloomThreshold (bloomThreshold), - m_cameraFade (cameraFade), - m_cameraParallax (cameraParallax), - m_cameraParallaxAmount (cameraParallaxAmount), - m_cameraParallaxDelay (cameraParallaxDelay), - m_cameraParallaxMouseInfluence (cameraParallaxMouseInfluence), - m_cameraPreview (cameraPreview), - m_cameraShake (cameraShake), - m_cameraShakeAmplitude (cameraShakeAmplitude), - m_cameraShakeRoughness (cameraShakeRoughness), - m_cameraShakeSpeed (cameraShakeSpeed), - m_clearColor (clearColor), - m_orthogonalProjection (orthogonalProjection), - m_skylightColor (skylightColor) {} - -std::shared_ptr CScene::fromFile ( - const std::string& filename, std::shared_ptr project, - const std::shared_ptr& container -) { - json content = json::parse (container->readFileAsString (filename)); - - const auto general_it = jsonFindRequired (content, "general", "Scenes must have a general section"); - const auto objects_it = jsonFindRequired (content, "objects", "Scenes must have a list of objects to display"); - - // TODO: FIND IF THESE DEFAULTS ARE SENSIBLE OR NOT AND PERFORM PROPER VALIDATION WHEN CAMERA PREVIEW AND CAMERA - // PARALLAX ARE PRESENT - - auto scene = std::make_shared ( - project, container, - Scenes::CCamera::fromJSON (jsonFindRequired (content, "camera", "Scenes must have a defined camera")), - jsonFindDefault (*general_it, "ambientcolor", glm::vec3 (0, 0, 0)), - jsonFindUserConfig (*general_it, *project, "bloom", false), - jsonFindUserConfig (*general_it, *project, "bloomstrength", 0.0), - jsonFindUserConfig (*general_it, *project, "bloomthreshold", 0.0), - jsonFindDefault (*general_it, "camerafade", false), - jsonFindDefault (*general_it, "cameraparallax", true), - jsonFindDefault (*general_it, "cameraparallaxamount", 1.0f), - jsonFindDefault (*general_it, "cameraparallaxdelay", 0.0f), - jsonFindDefault (*general_it, "cameraparallaxmouseinfluence", 1.0f), - jsonFindDefault (*general_it, "camerapreview", false), - jsonFindDefault (*general_it, "camerashake", false), - jsonFindDefault (*general_it, "camerashakeamplitude", 0.0f), - jsonFindDefault (*general_it, "camerashakeroughness", 0.0f), - jsonFindDefault (*general_it, "camerashakespeed", 0.0f), - jsonFindUserConfig (*general_it, *project, "clearcolor", {1, 1, 1}), - Scenes::CProjection::fromJSON (jsonFindRequired (*general_it, "orthogonalprojection", "General section must have orthogonal projection info")), - jsonFindDefault (*general_it, "skylightcolor", glm::vec3 (0, 0, 0)) - ); - - for (const auto& cur : *objects_it) - scene->insertObject (CObject::fromJSON (cur, project, container)); - - return scene; -} - -const std::map& CScene::getObjects () const { - return this->m_objects; -} - -const std::vector& CScene::getObjectsByRenderOrder () const { - return this->m_objectsByRenderOrder; -} - -void CScene::insertObject (const CObject* object) { - /// TODO: XXXHACK -- TO REMOVE WHEN PARTICLE SUPPORT IS PROPERLY IMPLEMENTED - if (object != nullptr) { - this->m_objects.emplace (object->getId (), object); - this->m_objectsByRenderOrder.emplace_back (object); - } -} - -std::shared_ptr CScene::getContainer () const { - return this->m_container; -} - -const Scenes::CCamera* CScene::getCamera () const { - return this->m_camera; -} - -const glm::vec3& CScene::getAmbientColor () const { - return this->m_ambientColor; -} - -bool CScene::isBloom () const { - return this->m_bloom->getBool (); -} - -float CScene::getBloomStrength () const { - return this->m_bloomStrength->getFloat (); -} - -float CScene::getBloomThreshold () const { - return this->m_bloomThreshold->getFloat (); -} - -bool CScene::isCameraFade () const { - return this->m_cameraFade; -} - -bool CScene::isCameraParallax () const { - return this->m_cameraParallax; -} - -float CScene::getCameraParallaxAmount () const { - return this->m_cameraParallaxAmount; -} - -float CScene::getCameraParallaxDelay () const { - return this->m_cameraParallaxDelay; -} - -float CScene::getCameraParallaxMouseInfluence () const { - return this->m_cameraParallaxMouseInfluence; -} - -bool CScene::isCameraPreview () const { - return this->m_cameraPreview; -} - -bool CScene::isCameraShake () const { - return this->m_cameraShake; -} - -float CScene::getCameraShakeAmplitude () const { - return this->m_cameraShakeAmplitude; -} - -float CScene::getCameraShakeRoughness () const { - return this->m_cameraShakeRoughness; -} - -float CScene::getCameraShakeSpeed () const { - return this->m_cameraShakeSpeed; -} - -const glm::vec3& CScene::getClearColor () const { - return this->m_clearColor->getVec3 (); -} - -const Scenes::CProjection* CScene::getOrthogonalProjection () const { - return this->m_orthogonalProjection; -} - -const glm::vec3& CScene::getSkylightColor () const { - return this->m_skylightColor; -} diff --git a/src/WallpaperEngine/Core/Wallpapers/CScene.h b/src/WallpaperEngine/Core/Wallpapers/CScene.h deleted file mode 100644 index dfdff47..0000000 --- a/src/WallpaperEngine/Core/Wallpapers/CScene.h +++ /dev/null @@ -1,88 +0,0 @@ -#pragma once - -#include "WallpaperEngine/Core/CObject.h" -#include "WallpaperEngine/Core/CWallpaper.h" - -#include "WallpaperEngine/Core/Core.h" - -#include "WallpaperEngine/Core/Scenes/CCamera.h" -#include "WallpaperEngine/Core/Scenes/CProjection.h" - -namespace WallpaperEngine::Core { -class CObject; -} - -namespace WallpaperEngine::Core::Wallpapers { -using json = nlohmann::json; - -class CScene : public CWallpaper { - public: - CScene ( - std::shared_ptr project, std::shared_ptr container, - const Scenes::CCamera* camera, glm::vec3 ambientColor, const CUserSettingBoolean* bloom, - const CUserSettingFloat* bloomStrength, const CUserSettingFloat* bloomThreshold, bool cameraFade, - bool cameraParallax, float cameraParallaxAmount, float cameraParallaxDelay, float cameraParallaxMouseInfluence, - bool cameraPreview, bool cameraShake, float cameraShakeAmplitude, float cameraShakeRoughness, - float cameraShakeSpeed, const CUserSettingVector3* clearColor, const Scenes::CProjection* orthogonalProjection, - glm::vec3 skylightColor); - - static std::shared_ptr fromFile ( - const std::string& filename, std::shared_ptr project, - const std::shared_ptr& container); - [[nodiscard]] const std::map& getObjects () const; - - [[nodiscard]] const std::vector& getObjectsByRenderOrder () const; - [[nodiscard]] const glm::vec3& getAmbientColor () const; - [[nodiscard]] bool isBloom () const; - [[nodiscard]] float getBloomStrength () const; - [[nodiscard]] float getBloomThreshold () const; - [[nodiscard]] bool isCameraFade () const; - [[nodiscard]] bool isCameraParallax () const; - [[nodiscard]] float getCameraParallaxAmount () const; - [[nodiscard]] float getCameraParallaxDelay () const; - [[nodiscard]] float getCameraParallaxMouseInfluence () const; - [[nodiscard]] bool isCameraPreview () const; - [[nodiscard]] bool isCameraShake () const; - [[nodiscard]] float getCameraShakeAmplitude () const; - [[nodiscard]] float getCameraShakeRoughness () const; - [[nodiscard]] float getCameraShakeSpeed () const; - [[nodiscard]] const glm::vec3& getClearColor () const; - [[nodiscard]] const Scenes::CProjection* getOrthogonalProjection () const; - [[nodiscard]] const glm::vec3& getSkylightColor () const; - - [[nodiscard]] const Scenes::CCamera* getCamera () const; - - protected: - friend class CWallpaper; - - void insertObject (const CObject* object); - - [[nodiscard]] std::shared_ptr getContainer () const; - - private: - const std::shared_ptr m_container; - const Scenes::CCamera* m_camera; - - // data from general section on the json - const glm::vec3 m_ambientColor; - const CUserSettingBoolean* m_bloom; - const CUserSettingFloat* m_bloomStrength; - const CUserSettingFloat* m_bloomThreshold; - const bool m_cameraFade; - const bool m_cameraParallax; - const float m_cameraParallaxAmount; - const float m_cameraParallaxDelay; - const float m_cameraParallaxMouseInfluence; - const bool m_cameraPreview; - const bool m_cameraShake; - const float m_cameraShakeAmplitude; - const float m_cameraShakeRoughness; - const float m_cameraShakeSpeed; - const CUserSettingVector3* m_clearColor; - const Scenes::CProjection* m_orthogonalProjection; - const glm::vec3 m_skylightColor; - - std::map m_objects = {}; - std::vector m_objectsByRenderOrder = {}; -}; -} // namespace WallpaperEngine::Core diff --git a/src/WallpaperEngine/Core/Wallpapers/CVideo.cpp b/src/WallpaperEngine/Core/Wallpapers/CVideo.cpp deleted file mode 100644 index 31f7865..0000000 --- a/src/WallpaperEngine/Core/Wallpapers/CVideo.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "CVideo.h" - -#include - -using namespace WallpaperEngine::Core; -using namespace WallpaperEngine::Core::Wallpapers; - -CVideo::CVideo (std::string filename, std::shared_ptr project) : - CWallpaper (project), - m_filename (std::move(filename)) {} - -const std::string& CVideo::getFilename () const { - return this->m_filename; -} diff --git a/src/WallpaperEngine/Core/Wallpapers/CVideo.h b/src/WallpaperEngine/Core/Wallpapers/CVideo.h deleted file mode 100644 index 1391f04..0000000 --- a/src/WallpaperEngine/Core/Wallpapers/CVideo.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -#include "WallpaperEngine/Core/CWallpaper.h" -#include "WallpaperEngine/Core/Core.h" - -extern "C" { -#include -#include -#include -#include -} - -namespace WallpaperEngine::Core::Wallpapers { -class CVideo : public CWallpaper { - public: - CVideo (std::string filename, std::shared_ptr project); - - const std::string& getFilename () const; - - protected: - friend class CWallpaper; - - const std::string m_filename; -}; -} // namespace WallpaperEngine::Core diff --git a/src/WallpaperEngine/Core/Wallpapers/CWeb.cpp b/src/WallpaperEngine/Core/Wallpapers/CWeb.cpp deleted file mode 100644 index 755a86f..0000000 --- a/src/WallpaperEngine/Core/Wallpapers/CWeb.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "CWeb.h" - -#include - -using namespace WallpaperEngine::Core; -using namespace WallpaperEngine::Core::Wallpapers; - -const std::string& CWeb::getFilename () const { - return this->m_filename; -} - -CWeb::CWeb (std::string filename, std::shared_ptr project) : - CWallpaper (project), - m_filename (std::move(filename)) {} diff --git a/src/WallpaperEngine/Core/Wallpapers/CWeb.h b/src/WallpaperEngine/Core/Wallpapers/CWeb.h deleted file mode 100644 index 3272a15..0000000 --- a/src/WallpaperEngine/Core/Wallpapers/CWeb.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -#include "WallpaperEngine/Core/CWallpaper.h" -#include "WallpaperEngine/Core/Core.h" - -// Chromium Embedded Framework -#include "include/cef_render_handler.h" -#include "include/cef_client.h" -#include "include/cef_app.h" - -extern "C" -{ -#include -#include -#include -#include -} - -namespace WallpaperEngine::Core::Wallpapers { -class CWeb : public CWallpaper { - public: - CWeb (std::string filename, std::shared_ptr project); - - const std::string& getFilename () const; - - protected: - friend class CWallpaper; - - const std::string m_filename; -}; -} \ No newline at end of file diff --git a/src/WallpaperEngine/Data/Dumpers/StringPrinter.cpp b/src/WallpaperEngine/Data/Dumpers/StringPrinter.cpp index 1c72c1d..3e544a0 100644 --- a/src/WallpaperEngine/Data/Dumpers/StringPrinter.cpp +++ b/src/WallpaperEngine/Data/Dumpers/StringPrinter.cpp @@ -39,7 +39,7 @@ void StringPrinter::printWallpaper (const Wallpaper& wallpaper) { for (const auto& object : scene->objects) { this->lineEnd (); - this->printObject (*object.second); + this->printObject (*object); this->lineEnd (); } diff --git a/src/WallpaperEngine/Data/Model/Effect.h b/src/WallpaperEngine/Data/Model/Effect.h index 95d5d36..54b76e8 100644 --- a/src/WallpaperEngine/Data/Model/Effect.h +++ b/src/WallpaperEngine/Data/Model/Effect.h @@ -29,7 +29,7 @@ struct EffectPass { /** The material to use for this effect's pass */ MaterialUniquePtr material; /** Texture bindings for this effect's pass */ - std::map binds; + TextureMap binds; /** The command this material executes (if specified) */ std::optional command; /** The target this material renders to (if specified) */ diff --git a/src/WallpaperEngine/Data/Model/Material.h b/src/WallpaperEngine/Data/Model/Material.h index 458dbf9..1b6f698 100644 --- a/src/WallpaperEngine/Data/Model/Material.h +++ b/src/WallpaperEngine/Data/Model/Material.h @@ -21,9 +21,9 @@ struct MaterialPass { /** Shader file to use for this pass */ std::string shader; /** List of textures defined for this pass */ - std::map textures; + TextureMap textures; /** The combos and their values to pass onto the shader */ - std::map combos; + ComboMap combos; }; struct Material { diff --git a/src/WallpaperEngine/Data/Model/Object.h b/src/WallpaperEngine/Data/Model/Object.h index dc7af0a..0dfdf8b 100644 --- a/src/WallpaperEngine/Data/Model/Object.h +++ b/src/WallpaperEngine/Data/Model/Object.h @@ -110,6 +110,7 @@ class Image : public Object, public ImageData { struct SoundData { /** Playback mode, loop, */ + // TODO: WRITE AN ENUM FOR THIS std::optional playbackmode; std::vector sounds; }; diff --git a/src/WallpaperEngine/Data/Model/Project.h b/src/WallpaperEngine/Data/Model/Project.h index 383ec2e..493904a 100644 --- a/src/WallpaperEngine/Data/Model/Project.h +++ b/src/WallpaperEngine/Data/Model/Project.h @@ -6,7 +6,6 @@ #include "Types.h" namespace WallpaperEngine::Data::Model { -using json = WallpaperEngine::Data::JSON::JSON; /** * Represents a wallpaper engine project */ @@ -31,8 +30,8 @@ struct Project { Properties properties; /** The wallpaper this project defines */ - WallpaperSharedPtr wallpaper; + WallpaperUniquePtr wallpaper; /** VFS to access the project's files */ - ContainerWeakPtr container; + ContainerUniquePtr container; }; }; diff --git a/src/WallpaperEngine/Data/Model/Types.h b/src/WallpaperEngine/Data/Model/Types.h index 1e4e860..20a7f43 100644 --- a/src/WallpaperEngine/Data/Model/Types.h +++ b/src/WallpaperEngine/Data/Model/Types.h @@ -58,15 +58,12 @@ using ShaderConstantUniquePtr = std::unique_ptr ; using ShaderConstantMap = std::map ; -using ProjectSharedPtr = std::shared_ptr ; -using WallpaperSharedPtr = std::shared_ptr ; -using WallpaperWeakPtr = std::weak_ptr ; -using ProjectWeakPtr = std::weak_ptr ; -using ContainerSharedPtr = std::shared_ptr ; -using ContainerWeakPtr = std::weak_ptr ; -using SceneSharedPtr = std::shared_ptr ; -using WebSharedPtr = std::shared_ptr ; -using VideoSharedPtr = std::shared_ptr