home *** CD-ROM | disk | FTP | other *** search
/ Game.EXE 2002 April / Game.EXE_04_2002.iso / Alawar / Sequences.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-02-25  |  1.5 KB  |  64 lines

  1. #ifndef SEQUENCES_H
  2. #define SEQUENCES_H
  3.  
  4. #include "String.h"
  5. #include <list>
  6. #include <vector>
  7. class HardwarePicture2D;
  8. class Scene2D;
  9.  
  10. class Sequences
  11. {
  12. public:
  13.     static const Sequences * load(const String & name, Scene2D * scene);
  14.     static void unload(const Sequences * seq);
  15.     static unsigned cached_count();
  16.  
  17.     explicit Sequences(const String & name, Scene2D * scene);
  18.     virtual ~Sequences();
  19.     void render_frame(unsigned seq, unsigned fr, unsigned alpha)const;
  20.     unsigned get_width(unsigned seq, unsigned fr)const;
  21.     unsigned get_sequence_count()const;
  22.     unsigned get_height(unsigned seq, unsigned fr)const;
  23.     unsigned get_frame_count(unsigned seq)const;
  24.     unsigned get_duration(unsigned seq, unsigned fr)const;
  25.  
  26.     const String & get_name()const
  27.     {
  28.         return name;
  29.     }
  30. private:
  31.     struct Frame
  32.     {
  33.         unsigned duration;
  34.         unsigned width;
  35.         unsigned height;
  36.         HardwarePicture2D * ha;
  37.         Frame( unsigned duration, unsigned width, unsigned height, HardwarePicture2D * ha )
  38.             :    duration( duration ),
  39.                 width( width ),
  40.                 height( height ),
  41.                 ha( ha )
  42.         {}
  43.     };
  44.  
  45.     struct Sequence
  46.     {
  47.         unsigned get_frame_count()const;
  48.         unsigned get_height(unsigned fr)const;
  49.         unsigned get_width(unsigned fr)const;
  50.         unsigned get_duration(unsigned fr)const;
  51.         void render_frame(Scene2D * scene, unsigned fr, int alpha)const;
  52.  
  53.         std::vector<Frame> frames;
  54.     };
  55.  
  56.     std::vector<Sequence> data;
  57.     String name;
  58.     Scene2D * scene;
  59.     int ref_count;
  60.  
  61.     static std::list<Sequences *> * sequences;
  62.     static int counter;
  63. };
  64. #endif //SEQUENCES_H