Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __CS_CSANIM2D_H__
00021 #define __CS_CSANIM2D_H__
00022
00027 #include "csextern.h"
00028
00029 #include "cstool/cspixmap.h"
00030 #include "csutil/array.h"
00031 #include "csutil/parray.h"
00032
00033 struct iGraphics3D;
00034 struct iTextureHandle;
00035
00036 class csPixmap;
00037 class csAnimatedPixmap;
00038
00040 class CS_CRYSTALSPACE_EXPORT csAnimationTemplate
00041 {
00042 private:
00044 csPDelArray<csPixmap> Frames;
00049 csArray<csTicks> FinishTimes;
00050
00051 public:
00053 csAnimationTemplate();
00055 ~csAnimationTemplate();
00056
00058 inline size_t GetFrameCount() const
00059 {return Frames.GetSize ();}
00061 inline csTicks GetLength() const
00062 {
00063 if (GetFrameCount() == 0)
00064 return 0;
00065 else
00066 return (csTicks)(FinishTimes.Get (GetFrameCount()-1));
00067 }
00069 inline void AddFrame(csTicks Delay, csPixmap *s)
00070 {FinishTimes.Push(GetLength() + Delay); Frames.Push (s);}
00072 inline void AddFrame(csTicks Delay, iTextureHandle *Tex)
00073 {AddFrame(Delay, new csSimplePixmap(Tex));}
00075 inline void AddFrame(csTicks Delay, iTextureHandle *Tex, int x, int y,
00076 int w, int h)
00077 {AddFrame(Delay, new csSimplePixmap(Tex, x, y, w, h));}
00078
00080 inline csPixmap *GetFrame(size_t n) const
00081 {return Frames.Get(n);}
00083 csPixmap *GetFrameByTime(csTicks Time);
00084
00086 csAnimatedPixmap *CreateInstance();
00087 };
00088
00089
00091 class CS_CRYSTALSPACE_EXPORT csAnimatedPixmap : public csPixmap
00092 {
00093 public:
00095 csAnimatedPixmap(csAnimationTemplate *tpl);
00097 virtual ~csAnimatedPixmap();
00098
00099
00100 virtual int Width();
00101 virtual int Height();
00102 virtual iTextureHandle *GetTextureHandle();
00103 virtual void DrawScaled (iGraphics3D* g3d, int sx, int sy, int sw, int sh,
00104 uint8 Alpha = 0);
00105 virtual void DrawTiled (iGraphics3D* g3d, int sx, int sy, int sw, int sh,
00106 int orgx, int orgy, uint8 Alpha = 0);
00107 virtual void Advance(csTicks ElapsedTime);
00108
00109 private:
00110 csAnimationTemplate *Template;
00111 csTicks CurrentTime;
00112 csPixmap *CurrentFrame;
00113 };
00114
00115 #endif // __CS_CSANIM2D_H__