home *** CD-ROM | disk | FTP | other *** search
/ Game.EXE 2002 May / Game.EXE_05_2002.iso / Alawar / Lib / 2D / Sequences.h < prev   
Encoding:
C/C++ Source or Header  |  2002-04-03  |  1.5 KB  |  69 lines

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