Bladeren bron

fix: user properties in parallax settings

Almamu 1 jaar geleden
bovenliggende
commit
9e3be9d406

+ 4 - 4
src/WallpaperEngine/Data/Model/Wallpaper.h

@@ -68,10 +68,10 @@ struct SceneData {
          * Parallax effect configuration
          */
         struct {
-            bool enabled;
-            float amount;
-            float delay;
-            float mouseInfluence;
+            UserSettingUniquePtr enabled;
+            UserSettingUniquePtr amount;
+            UserSettingUniquePtr delay;
+            UserSettingUniquePtr mouseInfluence;
         } parallax;
 
         /**

+ 4 - 4
src/WallpaperEngine/Data/Parsers/WallpaperParser.cpp

@@ -51,10 +51,10 @@ SceneUniquePtr WallpaperParser::parseScene (const JSON& file, Project& project)
                     .threshold = general.user ("bloomthreshold", properties, 0.0f),
                 },
                 .parallax = {
-                    .enabled = general.optional ("cameraparallax", false),
-                    .amount = general.optional ("cameraparallaxamount", 1.0f),
-                    .delay = general.optional ("cameraparallaxdelay", 0.0f),
-                    .mouseInfluence = general.optional ("cameraparallaxmouseinfluence", 1.0f),
+                    .enabled = general.user ("cameraparallax", properties, false),
+                    .amount = general.user ("cameraparallaxamount", properties, 1.0f),
+                    .delay = general.user ("cameraparallaxdelay", properties, 0.0f),
+                    .mouseInfluence = general.user ("cameraparallaxmouseinfluence", properties, 1.0f),
                 },
                 .shake = {
                     .enabled = general.user ("camerashake", properties, false),

+ 1 - 1
src/WallpaperEngine/Render/Objects/CImage.cpp

@@ -503,7 +503,7 @@ void CImage::updateScreenSpacePosition () {
         return;
     }
 
-    const double parallaxAmount = this->getScene ().getScene ().camera.parallax.amount;
+    const double parallaxAmount = this->getScene ().getScene ().camera.parallax.amount->value->getFloat ();
     const glm::vec2 depth = this->getImage ().parallaxDepth;
     const glm::vec2* displacement = this->getScene ().getParallaxDisplacement ();
 

+ 4 - 4
src/WallpaperEngine/Render/Wallpapers/CScene.cpp

@@ -243,11 +243,11 @@ void CScene::renderFrame (const glm::ivec4& viewport) {
     this->updateMouse (viewport);
 
     // update the parallax position if required
-    if (this->getScene ().camera.parallax.enabled && !this->getContext ().getApp ().getContext ().settings.mouse.disableparallax) {
-        const float influence = this->getScene ().camera.parallax.mouseInfluence;
-        const float amount = this->getScene ().camera.parallax.amount;
+    if (this->getScene ().camera.parallax.enabled->value->getBool () && !this->getContext ().getApp ().getContext ().settings.mouse.disableparallax) {
+        const float influence = this->getScene ().camera.parallax.mouseInfluence->value->getFloat ();
+        const float amount = this->getScene ().camera.parallax.amount->value->getFloat ();
         const float delay =
-            glm::min (static_cast<float> (this->getScene ().camera.parallax.delay), g_Time - g_TimeLast);
+            glm::min (static_cast<float> (this->getScene ().camera.parallax.delay->value->getBool ()), g_Time - g_TimeLast);
 
         this->m_parallaxDisplacement =
             glm::mix (this->m_parallaxDisplacement, (this->m_mousePosition * amount) * influence, delay);