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
00023 #include "csutil/csvector.h"
00024 #include "csutil/parray.h"
00025 #include "cstool/cspixmap.h"
00026
00027 struct iGraphics3D;
00028 class csPixmap;
00029 class csAnimatedPixmap;
00030
00032 class csAnimationTemplate
00033 {
00034 private:
00036 csPDelArray<csPixmap> Frames;
00041 csVector FinishTimes;
00042
00043 public:
00045 csAnimationTemplate();
00047 ~csAnimationTemplate();
00048
00050 inline int GetFrameCount() const
00051 {return Frames.Length();}
00053 inline csTicks GetLength() const
00054 {return (GetFrameCount()==0)?0:(csTicks)FinishTimes.Get(GetFrameCount()-1);}
00056 inline void AddFrame(csTicks Delay, csPixmap *s)
00057 {FinishTimes.Push((void*) (GetLength() + Delay)); Frames.Push (s);}
00059 inline void AddFrame(csTicks Delay, iTextureHandle *Tex)
00060 {AddFrame(Delay, new csSimplePixmap(Tex));}
00062 inline void AddFrame(csTicks Delay, iTextureHandle *Tex, int x, int y, int w, int h)
00063 {AddFrame(Delay, new csSimplePixmap(Tex, x, y, w, h));}
00064
00066 inline csPixmap *GetFrame(int n) const
00067 {return Frames.Get(n);}
00069 csPixmap *GetFrameByTime(csTicks Time);
00070
00072 csAnimatedPixmap *CreateInstance();
00073 };
00074
00075
00077 class csAnimatedPixmap : public csPixmap
00078 {
00079 public:
00081 csAnimatedPixmap(csAnimationTemplate *tpl);
00083 virtual ~csAnimatedPixmap();
00084
00085
00086 virtual int Width();
00087 virtual int Height();
00088 virtual iTextureHandle *GetTextureHandle();
00089 virtual void DrawScaled (iGraphics3D* g3d, int sx, int sy, int sw, int sh,
00090 uint8 Alpha = 0);
00091 virtual void DrawTiled (iGraphics3D* g3d, int sx, int sy, int sw, int sh,
00092 int orgx, int orgy, uint8 Alpha = 0);
00093 virtual void Advance(csTicks ElapsedTime);
00094
00095 private:
00096 csAnimationTemplate *Template;
00097 csTicks CurrentTime;
00098 csPixmap *CurrentFrame;
00099 };
00100
00101 #endif // __CS_CSANIM2D_H__