summary refs log tree commit diff
path: root/resources
diff options
context:
space:
mode:
authorLoren Burkholder <computersemiexpert@outlook.com>2023-03-07 13:11:00 -0500
committerLoren Burkholder <computersemiexpert@outlook.com>2023-04-08 18:59:17 -0400
commit296385e6fe6f9ec543d96ba7ed068e793a12c3f3 (patch)
treec3ed93aad6abca94f22de1f50d6db1f165ca9812 /resources
parentImplement unknown msgtype functionality (diff)
downloadnheko-296385e6fe6f9ec543d96ba7ed068e793a12c3f3.tar.xz
Add rainfall effect
This is a proof-of-concept example of inplementing a msgtype not found
in the spec.
Diffstat (limited to 'resources')
-rw-r--r--resources/qml/TimelineView.qml62
1 files changed, 59 insertions, 3 deletions
diff --git a/resources/qml/TimelineView.qml b/resources/qml/TimelineView.qml
index a146a991..72570d4a 100644
--- a/resources/qml/TimelineView.qml
+++ b/resources/qml/TimelineView.qml
@@ -364,7 +364,9 @@ Item {
         onClicked: Rooms.resetCurrentRoom()
     }
 
-    ParticleSystem { id: confettiParticleSystem 
+    ParticleSystem {
+        id: confettiParticleSystem
+
         Component.onCompleted: pause();
         paused: !shouldEffectsRun
     }
@@ -420,6 +422,42 @@ Item {
         angle: 90
     }
 
+    ParticleSystem {
+        id: rainfallParticleSystem
+
+        Component.onCompleted: pause();
+        paused: !shouldEffectsRun
+    }
+
+    Emitter {
+        id: rainfallEmitter
+
+        width: parent.width
+        enabled: false
+        anchors.horizontalCenter: parent.horizontalCenter
+        y: -60
+        emitRate: parent.width / 50
+        lifeSpan: 10000
+        system: rainfallParticleSystem
+        velocity: PointDirection {
+            x: 0
+            y: 300
+            xVariation: 0
+            yVariation: 75
+        }
+
+        ItemParticle {
+            system: rainfallParticleSystem
+            fade: false
+            delegate: Rectangle {
+                width: 2
+                height: 30 + 30 * Math.random()
+                radius: 2
+                color: "#0099ff"
+            }
+        }
+    }
+
     NhekoDropArea {
         anchors.fill: parent
         roomid: room ? room.roomId : ""
@@ -428,7 +466,7 @@ Item {
     Timer {
         id: effectsTimer
         onTriggered: shouldEffectsRun = false;
-        interval: confettiEmitter.lifeSpan
+        interval: Math.max(confettiEmitter.lifeSpan, rainfallEmitter.lifeSpan)
         repeat: false
         running: false
     }
@@ -471,7 +509,25 @@ Item {
             if (!Settings.fancyEffects)
                 return
 
-            effectsTimer.start();
+            effectsTimer.restart();
+        }
+
+        function onRainfall()
+        {
+            if (!Settings.fancyEffects)
+                return
+
+            shouldEffectsRun = true;
+            rainfallEmitter.pulse(parent.height * 7.5)
+            room.markSpecialEffectsDone()
+        }
+
+        function onRainfallDone()
+        {
+            if (!Settings.fancyEffects)
+                return
+
+            effectsTimer.restart();
         }
 
         target: room