00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _PATCH_TYPE_H_
00029 #define _PATCH_TYPE_H_
00030
00032
00033 #include "video.h"
00034
00035
00036 class CPatchType
00037 {
00038 public:
00042 CPatchType(const std::string &name, const std::string &file,
00043 int tileWidth, int tileHeight, unsigned short *flags) :
00044 name(name), file(file), graphic(NULL), tileWidth(tileWidth), tileHeight(tileHeight)
00045 {
00046 this->flags = new unsigned short[this->tileWidth * this->tileHeight];
00047 memcpy(this->flags, flags, this->tileWidth * this->tileHeight * sizeof(unsigned short));
00048 }
00049
00053 ~CPatchType()
00054 {
00055 CGraphic::Free(this->graphic);
00056 delete[] this->flags;
00057 }
00058
00062 void load()
00063 {
00064 if (!this->graphic) {
00065 this->graphic = CGraphic::New(this->file);
00066 this->graphic->Load();
00067 }
00068 }
00069
00073 void clean()
00074 {
00075 CGraphic::Free(this->graphic);
00076 this->graphic = NULL;
00077 }
00078
00082 inline const std::string &getName() const { return this->name; }
00083
00087 inline const std::string &getFile() const { return this->file; }
00088
00092 inline const CGraphic *getGraphic() const { return this->graphic; }
00093
00097 inline int getTileWidth() const { return this->tileWidth; }
00098
00102 inline int getTileHeight() const { return this->tileHeight; }
00103
00107 unsigned short getFlag(int x, int y) const
00108 {
00109 Assert(0 <= x && x < this->tileWidth && 0 <= y && y < this->tileHeight);
00110 return flags[y * this->tileWidth + x];
00111 }
00112
00116 void setFlag(int x, int y, unsigned short flag)
00117 {
00118 Assert(0 <= x && x < this->tileWidth && 0 <= y && y < this->tileHeight);
00119 flags[y * this->tileWidth + x] = flag;
00120 }
00121
00125 inline unsigned short *getFlags()
00126 {
00127 return this->flags;
00128 }
00129
00130 private:
00131 std::string name;
00132 std::string file;
00133 CGraphic *graphic;
00134 int tileWidth;
00135 int tileHeight;
00136 unsigned short *flags;
00137 };
00138
00140
00141 #endif
00142