arenaelement.h
Go to the documentation of this file.
1 #ifndef ARENAELEMENT_H
2 #define ARENAELEMENT_H
3 
4 #include <QObject>
5 #include <QPoint>
6 #include <QDomNode>
7 #include <QXmlStreamWriter>
8 
9 #include "xmlloadingexception.h"
10 
11 class Arena;
12 class ArenaElementType;
13 
14 class ArenaElement : public QObject
15 {
16  Q_OBJECT
17 
18  friend class ArenaElementType;
19 
20 public:
22  QPoint pos() const { return m_pos; }
24  void setPos(QPoint pos);
26  int rotation() const { return m_rotation; }
28  void setRotation(int rotation);
29 
31  void load(const QDomElement& node);
33  void save(QXmlStreamWriter& writer);
35  void saveWorld(QXmlStreamWriter& writer);
36  void saveWorldSdf(QXmlStreamWriter& writer);
37 
39  void setArena(Arena *arena) { m_arena = arena; }
40 
43  ArenaElementType const * type() const { return m_type; }
44 
46  bool isWall() const;
48  bool isFloor() const;
50  bool isMountableItem() const;
52  bool isItem() const;
53 
55  QPointF itemOffset() const { return m_itemOffset; }
57  void setItemOffset(const QPointF &offset);
58 
62  int itemMountPoint() const { return m_itemMountPoint; }
63 
65  void setItemMountPoint(int mountPoint);
66 
67 signals:
70  void posChanged(ArenaElement *element, QPoint pos);
73  void rotationChanged(ArenaElement *element, int rotation);
76  void modified(ArenaElement *element);
77 
78 private:
80  explicit ArenaElement(const ArenaElementType * const type, int id);
81 
84 
85  const ArenaElementType * const m_type;
86  QPoint m_pos;
88  QPointF m_itemOffset;
95  const int m_instanceId;
96 };
97 
98 #endif // ARENAELEMENT_H
void saveWorld(QXmlStreamWriter &writer)
Writes .world format-compliant XML.
void saveWorldSdf(QXmlStreamWriter &writer)
ArenaElementType const * type() const
Definition: arenaelement.h:43
int m_itemMountPoint
Definition: arenaelement.h:93
Arena * m_arena
Arena this element currently belongs to (exactly one)
Definition: arenaelement.h:83
void setItemMountPoint(int mountPoint)
See itemMountPoint(). Use -1 to set index to "unspecified".
QPoint m_pos
Definition: arenaelement.h:86
int itemMountPoint() const
Definition: arenaelement.h:62
void setArena(Arena *arena)
Called from Arena::addElement()
Definition: arenaelement.h:39
void setItemOffset(const QPointF &offset)
See itemOffset()
bool isItem() const
Convenience method returning true iff. this is an item element (freely movable)
QPointF m_itemOffset
See itemOffset()
Definition: arenaelement.h:88
Definition: arena.h:10
QPointF itemOffset() const
Returns the item&#39;s offset from the grid point with 0 <= x,y <= 1 ( (0,0) is bottom left) ...
Definition: arenaelement.h:55
int rotation() const
Returns the rotation in degrees.
Definition: arenaelement.h:26
void save(QXmlStreamWriter &writer)
Serializes this element in XML.
int m_rotation
rotation in degrees (only multiples of 90 degrees)
Definition: arenaelement.h:90
void load(const QDomElement &node)
Deserializes this element from XML.
void setRotation(int rotation)
Sets the rotation in degrees.
ArenaElement(const ArenaElementType *const type, int id)
Only meant for use by ArenaElementType::createInstance()
QPoint pos() const
Returns the position in arena coordinates.
Definition: arenaelement.h:22
void setPos(QPoint pos)
Sets the position in arena coordinates.
void rotationChanged(ArenaElement *element, int rotation)
void posChanged(ArenaElement *element, QPoint pos)
bool isFloor() const
Convenience method returning true iff. this is a floor element.
bool isMountableItem() const
Convenience method returning true iff. this is a mountable-item element.
const int m_instanceId
Unique ID set by ArenaElementType.
Definition: arenaelement.h:95
bool isWall() const
Convenience method returning true iff. this is a wall element.
void modified(ArenaElement *element)
const ArenaElementType *const m_type
Definition: arenaelement.h:85


hector_nist_arena_designer
Author(s): Stefan Kohlbrecher , Johannes Simon
autogenerated on Fri Aug 21 2020 10:45:27