00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef KYRA_SPRITERESOURCE_INCLUDED
00033 #define KYRA_SPRITERESOURCE_INCLUDED
00034
00035 #ifdef _MSC_VER
00036
00037 #pragma warning( disable : 4530 )
00038 #pragma warning( disable : 4786 )
00039 #endif
00040
00041 #include "kyraresource.h"
00042
00043 #include "../engine/krmath.h"
00044 #include "action.h"
00045 #include <map>
00046
00055 class KrSpriteResource : public KrResource
00056 {
00057 public:
00058
00059 KrSpriteResource( U32 size, SDL_RWops* data );
00060
00061
00062
00063
00064
00065 KrSpriteResource( const std::string& spriteName );
00066
00067 virtual ~KrSpriteResource();
00068
00069
00070
00071 void AddAction( KrAction* action );
00072
00073 virtual U32 Type() { return KYRATAG_SPRITE; }
00074 virtual const std::string& TypeName() { return spriteName; }
00075 virtual KrSpriteResource* ToSpriteResource() { return this; }
00076
00078 int NumActions() { return actionArr.size(); }
00080 KrAction* GetAction( const std::string& actionName );
00082 KrAction* GetAction( U32 actionId );
00083
00089 KrCanvasResource* CreateCanvasResource( const std::string& actionName,
00090 int frame, int* hotx, int* hoty );
00091
00093 KrCanvasResource* CreateCanvasResource( U32 actionId,
00094 int frame, int* hotx, int* hoty );
00095
00096
00097 KrAction* GetActionByIndex( int i ) { return actionArr[i]; }
00098 const KrAction& ActionByIndex( int i ) { return *actionArr[i]; }
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110 void Draw( KrPaintInfo* paintInfo,
00111 const std::string& action,
00112 int frame,
00113 const KrMatrix2& matrix,
00114 const KrColorTransform& cForm,
00115 const grinliz::Rectangle2I& clip,
00116 int quality );
00117
00118
00119
00120
00121
00122 bool HitTestTransformed( int x, int y, int hitFlags ) { GLASSERT( 0 ); return false; }
00123
00124 virtual void CacheScale( GlFixed xScale, GlFixed yScale );
00125 virtual bool IsScaleCached( GlFixed xScale, GlFixed yScale );
00126 virtual void FreeScaleCache();
00127 virtual KrCollisionMap* GetCollisionMap( KrImage* state, int window );
00128
00129 virtual void Save( KrEncoder* );
00130
00131 protected:
00132 std::vector< KrAction* > actionArr;
00133
00134 private:
00135
00136 const static std::string spriteName;
00137
00138 std::map< std::string, KrAction* > actionMap;
00139 std::map< U32, KrAction* > actionIdMap;
00140 };
00141
00142
00143 #endif