]> _ Git - fluidbook-toolbox.git/commitdiff
wait #6300 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 29 Sep 2023 10:31:21 +0000 (12:31 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 29 Sep 2023 10:31:21 +0000 (12:31 +0200)
app/Elearning/QuizCompiler/Animations.php
app/Models/QuizTheme.php

index 3301c31d1020982dac42c0890a3bce18ff5ac08d..c5d78fc6d5cfeba0bea687a0c6cbabcf411d004b 100644 (file)
@@ -13,6 +13,7 @@ trait Animations
 
     const OK_COLOR = '#16BFBF';
     const NOK_COLOR = '#D0167C';
+    const CONFETTI_COLOR = '#E4FF19';
 
     /**
      * @param $vdir VirtualDirectory
@@ -20,14 +21,19 @@ trait Animations
      */
     protected function writeAnimations()
     {
-        $colors = [self::OK_COLOR => $this->theme->okColor, self::NOK_COLOR => $this->theme->nokColor];
+        $colors = [
+            self::OK_COLOR => $this->theme->okColor,
+            self::CONFETTI_COLOR => $this->theme->okColor,
+            self::NOK_COLOR => $this->theme->nokColor
+        ];
         $animationReplace = [];
+        $animationPregReplace = [];
 
         // Replace colors
         foreach ($colors as $from => $to) {
-            $f = (new Color($from))->toLottie();
+            $f = (new Color($from))->toLottie(5,true);
             $t = (new Color($to))->toLottie();
-            $animationReplace['[' . $f[0] . ',' . $f[1] . ',' . $f[2]] = '[' . $t[0] . ',' . $t[1] . ',' . $t[2];
+            $animationPregReplace['/\[' . $f[0] . ',' . $f[1] . ',' . $f[2] . '/'] = '[' . $t[0] . ',' . $t[1] . ',' . $t[2];
         }
         // Replace font
         $font = FluidbookFont::getAvailableFonts()[$this->theme->font ?: 'SourceSans'];
@@ -42,6 +48,9 @@ trait Animations
 
             $c = file_get_contents($file->getPathname());
             $c = strtr($c, $animationReplace);
+            foreach ($animationPregReplace as $regex => $replace) {
+                $c = preg_replace($regex, $replace, $c);
+            }
             $animations[$file->getBasename('.' . $file->getExtension())] = $c;
         }
         $this->data['animations'] = new Data($animations);
index 5285a643fd6ebcbef4a93e979280e50bbb9eff30..3b81c7a79782daddc0da72eb1eb0ce83dbb93de3 100644 (file)
@@ -145,9 +145,9 @@ class QuizTheme extends ToolboxModel
         $this->addField('outroCustom', Checkbox::class, __('Définir une forme personnalisée'));
         $this->addField('outroImage', FluidbookThemeImage::class, __('Desktop'), ['hint' => __('Taille recommandée : :size', ['size' => '1200 x 680px']), 'when' => ['outroCustom' => 1]]);
         $this->addField('outroImageMobile', FluidbookThemeImage::class, __('Mobile'), ['hint' => __('Taille recommandée : :size', ['size' => '390 x 844px']), 'when' => ['outroCustom' => 1]]);
-        $this->addField('', FormSeparator::class, '');
-        $this->addField('outroSuccessAnimation', FluidbookThemeImage::class, __('Animation de réussite'), ['hint' => __('390 x 390px')]);
-        $this->addField('outroFailAnimation', FluidbookThemeImage::class, __('Animation d\'échec'), ['hint' => __('390 x 390px')]);
+        //$this->addField('', FormSeparator::class, '');
+        $this->addField('outroSuccessAnimation', Hidden::class, __('Animation de réussite'), ['hint' => __('390 x 390px')]);
+        $this->addField('outroFailAnimation', Hidden::class, __('Animation d\'échec'), ['hint' => __('390 x 390px')]);
     }
 
     public function getTextsColor()