|
mkRPG
|
00001 #ifndef MAP_H 00002 #define MAP_H 00003 00004 #include "object.h" 00005 #include <QMutex> 00006 #include <QMutexLocker> 00007 00016 class CellType; 00020 class CellType : public Type<CellType> 00021 { 00022 public: 00023 TypeName(CellType) 00024 CellType(CellType &ancestor); 00025 CellType(DefaultTypes &parent); 00026 00027 inline Image* image() const{return aImage ? aImage : aTypedAncestor ? aTypedAncestor->image() : nullptr;} 00028 inline void setImage(Image* im){aImage = im; touch();} 00029 00030 00031 C0(Flag,w,W,alkable) 00032 private: 00033 Image * aImage; 00034 00035 }; 00036 00037 00038 00039 00040 00041 00045 class Cell : public TypedObject<CellType> 00046 { 00047 public: 00048 TypeName(Cell) 00049 Cell(CellType &type, GameObject &parent); 00050 00051 bool isSelected() const; 00052 void setSelected(bool s = true); 00053 void invertSelected(); 00054 00055 00056 void addSelection(); 00057 bool isPreSelected() const; 00058 void confirmPreSelection(bool add = true); 00059 void clearPreSelection(); 00060 00061 CellType &cellType(); 00062 void setCellType(CellType &type); 00063 00064 void operator=(Cell &c); 00065 00066 C0(Flag, a,A,ccessible) 00067 00068 //ObjectListD(o,O,bject,,s,Object) 00069 00070 // ObjectsMap(c,o,O,bject,,s) 00071 00072 // TODO destruction 00073 static Cell* cellArray(CellType &type, GameObject &parent, int n); 00074 private: 00075 Cell(); 00076 bool select; 00077 int nbSel; 00078 bool selectMod; 00079 00080 static QMutex sync; 00081 static CellType *defaultCellType; 00082 static GameObject *defaultParent; 00083 }; 00084 00085 /*class MapType; 00086 class MapType : public Type<MapType> 00087 { 00088 00089 };*/ 00090 00091 00092 00093 00094 class MapType; 00098 class MapType : public Type<MapType> 00099 { 00100 public: 00101 TypeName(MapType) 00102 MapType(MapType &ancestor); 00103 MapType(DefaultTypes &parent); 00104 C0(Param,a,A,ngleX) 00105 C0(Param,a,A,ngleY) 00106 }; 00107 00108 00109 00110 00114 #define forCells(i) int nbCell = width()*height(); for(int i(0); i<nbCell; ++i) 00115 00119 class Map : public TypedObject<MapType> 00120 { 00121 public: 00122 TypeName(Map) 00123 Map(MapType &type, GameObject &parent); 00124 ~Map(); 00125 00126 int width() const; 00127 int height() const; 00128 QSize size() const{return QSize(width(),height());} 00129 void setWidth(int w); 00130 void setHeight(int h); 00131 void resize(int w, int h, int xOffset = 0, int yOffset = 0); 00132 void resize(const QRect &newSize); 00133 C0(Param,a,A,ngleX) 00134 C0(Param,a,A,ngleY) 00135 Cell& cell(int i, int j) const; 00138 Cell& cell(const QPoint &p) const; 00141 void selectAll(); 00146 void unSelectAll(); 00154 void confirmPreSelection(bool add = true); 00159 void clearPreSelection(); 00164 QList<GameObject*> children() const; 00173 MapType &mapType(); 00174 void setMapType(MapType &type); 00175 private: 00176 Cell* cells; 00177 int wi,he; 00178 00179 }; 00180 00181 00182 00183 00184 00185 00186 #endif // MAP_H
1.7.6.1