00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __CSWSTEX_H__
00021 #define __CSWSTEX_H__
00022
00023 #include "csgfx/csimage.h"
00024 #include "csutil/csvector.h"
00025
00026 struct iTextureHandle;
00027 struct iTextureManager;
00028
00034 class csWSTexture
00035 {
00036
00037 int RefCount;
00038
00039 iImage *Image;
00040
00041 int Flags;
00042
00043 UByte tr, tg, tb;
00044
00045 bool HasKey;
00046
00047 bool KeyChanged;
00048
00049 iTextureHandle *Handle;
00050
00051 char *Name;
00052
00053 char *FileName;
00054
00055 public:
00057 csWSTexture (const char *iName, iImage *Image, int iFlags);
00059 ~csWSTexture ();
00061 void SetKeyColor (int iR, int iG, int iB);
00063 void SetKeyColor (bool iEnable);
00065 void GetKeyColor (int &oR, int &oG, int &oB)
00066 { oR = tr; oG = tg; oB = tb; }
00068 bool HasKeyColor ()
00069 { return HasKey; }
00071 void Register (iTextureManager *iTexMan);
00073 void Unregister ();
00075 void Refresh ();
00077 void SetName (const char *iName);
00079 const char *GetName ()
00080 { return Name; }
00082 iTextureHandle *GetHandle ()
00083 { return Handle; }
00085 void IncRef ()
00086 { RefCount++; }
00088 void DecRef ()
00089 { RefCount--; }
00091 int GetRefCount () const
00092 { return RefCount; }
00094 const char *GetFileName () const
00095 { return FileName; }
00097 void SetFileName (const char *iFileName);
00099 void FixKeyColor ();
00101 void DontFixKeyColor ()
00102 { KeyChanged = false; }
00104 int GetWidth ();
00106 int GetHeight ();
00107 };
00108
00110 class csWSTexVector : public csVector
00111 {
00112 public:
00114 csWSTexVector ();
00116 virtual ~csWSTexVector ();
00118 virtual bool FreeItem (csSome Item);
00120 virtual int CompareKey (csSome Item, csConstSome Key, int Mode) const;
00122 csWSTexture *Get (int idx)
00123 { return (csWSTexture *)csVector::Get (idx); }
00125 csWSTexture *FindTexture (const char *iName)
00126 {
00127 int idx = FindKey (iName);
00128 return idx >= 0 ? (csWSTexture *)Get (idx) : (csWSTexture*)NULL;
00129 }
00130 };
00131
00132 #endif // __CSWSTEX_H__