00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __CS_CSWSTEX_H__
00021 #define __CS_CSWSTEX_H__
00022
00027 #include "csgfx/csimage.h"
00028 #include "csutil/parray.h"
00029
00030 struct iTextureHandle;
00031 struct iTextureManager;
00032
00038 class csWSTexture
00039 {
00040
00041 int RefCount;
00042
00043 csRef<iImage> Image;
00044
00045 int Flags;
00046
00047 uint8 tr, tg, tb;
00048
00049 bool HasKey;
00050
00051 bool KeyChanged;
00052
00053 csRef<iTextureHandle> Handle;
00054
00055 char *Name;
00056
00057 char *FileName;
00058
00059 public:
00061 csWSTexture (const char *iName, iImage *Image, int iFlags);
00063 ~csWSTexture ();
00065 void SetKeyColor (int iR, int iG, int iB);
00067 void SetKeyColor (bool iEnable);
00069 void GetKeyColor (int &oR, int &oG, int &oB)
00070 { oR = tr; oG = tg; oB = tb; }
00072 bool HasKeyColor ()
00073 { return HasKey; }
00075 void Register (iTextureManager *iTexMan);
00077 void Unregister ();
00079 void Refresh ();
00081 void SetName (const char *iName);
00083 const char *GetName () const
00084 { return Name; }
00086 iTextureHandle *GetHandle ()
00087 { return Handle; }
00089 void IncRef ()
00090 { RefCount++; }
00092 void DecRef ()
00093 { RefCount--; }
00095 int GetRefCount () const
00096 { return RefCount; }
00098 const char *GetFileName () const
00099 { return FileName; }
00101 void SetFileName (const char *iFileName);
00103 void FixKeyColor ();
00105 void DontFixKeyColor ()
00106 { KeyChanged = false; }
00108 int GetWidth ();
00110 int GetHeight ();
00111 };
00112
00114 class csWSTexVector : public csPDelArray<csWSTexture>
00115 {
00116 public:
00118 csWSTexVector ();
00120 static int CompareKey (csWSTexture* const& Item, void* Key);
00122 csWSTexture *FindTexture (const char *name)
00123 {
00124 int idx = FindKey ((void*)name, CompareKey);
00125 return idx >= 0 ? Get (idx) : (csWSTexture*)0;
00126 }
00127 };
00128
00131 #endif // __CS_CSWSTEX_H__