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_MANAGER_H_
00029 #define _PATCH_MANAGER_H_
00030
00032
00033 #include <list>
00034 #include <map>
00035 #include <vector>
00036
00037 class CPatchType;
00038 class CPatch;
00039 class CFile;
00040
00041
00042 class CPatchManager
00043 {
00044 public:
00048 CPatchManager();
00049
00053 ~CPatchManager();
00054
00058 CPatch *add(const std::string &typeName, int x, int y);
00059
00063 void remove(CPatch *patch);
00064
00068 void move(CPatch *patch, int x, int y);
00069
00073 void moveToTop(CPatch *patch);
00074
00078 void moveToBottom(CPatch *patch);
00079
00083 CPatch *getPatch(int x, int y, int *xOffset = NULL, int *yOffset = NULL) const;
00084
00088 std::list<CPatch *> getPatches() const;
00089
00093 std::vector<std::string> getPatchTypeNames() const;
00094
00098 void load();
00099
00103 void loadAll();
00104
00108 void clear();
00109
00114 CPatchType *newPatchType(const std::string &name, const std::string &file,
00115 int tileWidth, int tileHeight, int *flags);
00116
00121 CPatchType *newPatchType(const std::string &name, const std::string &file,
00122 int tileWidth, int tileHeight, unsigned short *flags);
00123
00127 CPatchType *getPatchType(const std::string &name);
00128
00132 std::string savePatches(bool patchesOnly = false) const;
00133
00137 std::string savePatchType(CPatchType *patchType) const;
00138
00139 private:
00140 void updateMapFlags(int x1, int y1, int x2, int y2);
00141
00142 std::list<CPatch *> patches;
00143 std::map<std::string, CPatchType *> patchTypesMap;
00144
00145 std::list<CPatch *> removedPatches;
00146
00147 bool loadedAll;
00148 };
00149
00151
00152 #endif
00153