File: fliPlay.ec

package info (click to toggle)
ecere-sdk 0.44.15-1
  • links: PTS
  • area: main
  • in suites: sid, stretch
  • size: 97,712 kB
  • ctags: 54,695
  • sloc: ansic: 593,042; makefile: 12,250; yacc: 4,955; lex: 707; objc: 259; python: 252; xml: 102
file content (103 lines) | stat: -rw-r--r-- 2,519 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import "fli.ec"

class FliPlay : Window
{
   Bitmap temp {};
   Bitmap image {};
   Fli animation {};
   Timer timer
   {
      this;

      bool DelayExpired()
      {
         Surface surface;

         animation.PlayFrame(image);

         surface = temp.GetSurface(0,0,null);
         /*
         if(surface)
            surface.Stretch(image, 0,0,0,0, temp.width, temp.height, image.width, image.height);
         */
         if(surface)
            surface.Blit(image, 0,0,0,0, image.width, image.height);
         delete surface;

         if(animation.frame >= animation.numFrames)
            //Destroy(0);
            animation.frame = 0;

         Update(null);
         return true;
      }
   };

   property const char * animation
   {
      set
      {
         timer.Stop();
         if(!(animation.Load(value)))
         {
            String s = PrintString("Couldn't load animation ", value, ".");
            MessageBox { caption = "Ecere FLC Player", contents = s }.Modal();
            Destroy(0);
            delete s;
         }
         else
         {
            image.Allocate(null, animation.width, animation.height, 0, pixelFormat8, true);
            temp.Allocate(null, animation.width, animation.height, 0, pixelFormat888, true);
            if(image)
            {
               animation.PlayFrame(image);
               timer.delay = animation.speed;
               timer.Start();
            }
         }

      }
   }

   /*
   void OnResize(int w, int h)
   {
      Surface surface;
      temp.Free();
      // temp.Allocate(null, w, h, 0, PixelFormatRGBA, false);
      temp.Allocate(null, w, h, 0, PixelFormat888, false);
      surface = temp.GetSurface(0,0,null);
      surface.Stretch(image, 0,0,0,0, temp.width, temp.height,
         image.width, image.height);
      delete surface;
   }
   */

   void OnRedraw(Surface surface)
   {
      if(animation.palUpdate)
      {
         display.SetPalette(animation.palette, false);
         animation.palUpdate = false;
      }
      //surface.Blit(temp, 0,0,0,0,temp.width,temp.height);
      // surface.Blit(image, 0,0,0,0,image.width,image.height);
      surface.Stretch(temp, 0,0,0,0, clientSize.w, clientSize.h, temp.width,temp.height);

      //surface.Stretch(image, 0,0,0,0, clientSize.w, clientSize.h, image.width,image.height);
   }

   void OnDestroy()
   {
      image.Free();
      temp.Free();
   }

   bool OnKeyDown(Key key, unichar ch)
   {
      if(key == escape)
         Destroy(0);
      return true;
   }
}