00001 #ifndef ARENAELEMENT_H 00002 #define ARENAELEMENT_H 00003 00004 #include <QObject> 00005 #include <QPoint> 00006 #include <QDomNode> 00007 #include <QXmlStreamWriter> 00008 00009 #include "xmlloadingexception.h" 00010 00011 class Arena; 00012 class ArenaElementType; 00013 00014 class ArenaElement : public QObject 00015 { 00016 Q_OBJECT 00017 00018 friend class ArenaElementType; 00019 00020 public: 00022 QPoint pos() const { return m_pos; } 00024 void setPos(QPoint pos); 00026 int rotation() const { return m_rotation; } 00028 void setRotation(int rotation); 00029 00031 void load(const QDomElement& node) throw (XmlLoadingException); 00033 void save(QXmlStreamWriter& writer); 00035 void saveWorld(QXmlStreamWriter& writer); 00036 void saveWorldSdf(QXmlStreamWriter& writer); 00037 00039 void setArena(Arena *arena) { m_arena = arena; } 00040 00043 ArenaElementType const * type() const { return m_type; } 00044 00046 bool isWall() const; 00048 bool isFloor() const; 00050 bool isMountableItem() const; 00052 bool isItem() const; 00053 00055 QPointF itemOffset() const { return m_itemOffset; } 00057 void setItemOffset(const QPointF &offset); 00058 00062 int itemMountPoint() const { return m_itemMountPoint; } 00063 00065 void setItemMountPoint(int mountPoint); 00066 00067 signals: 00070 void posChanged(ArenaElement *element, QPoint pos); 00073 void rotationChanged(ArenaElement *element, int rotation); 00076 void modified(ArenaElement *element); 00077 00078 private: 00080 explicit ArenaElement(const ArenaElementType * const type, int id); 00081 00083 Arena *m_arena; 00084 00085 const ArenaElementType * const m_type; 00086 QPoint m_pos; 00088 QPointF m_itemOffset; 00090 int m_rotation; 00093 int m_itemMountPoint; 00095 const int m_instanceId; 00096 }; 00097 00098 #endif // ARENAELEMENT_H