Athena IO Library
SpritePart.hpp
1 #ifndef SSPRITEPART_HPP
2 #define SSPRITEPART_HPP
3 
4 #include "athena/SakuraGlobal.hpp"
5 #ifndef ATHENA_USE_QT
6 # include <vector>
7 #else
8 # include <QObject>
9 # include <QPoint>
10 # include <QSize>
11 # include <QString>
12 #endif
13 
14 #include <string>
15 
16 namespace athena
17 {
18 namespace Sakura
19 {
20 class SpriteFrame;
21 
22 #ifndef ATHENA_USE_QT
24 {
25 #else
26 class SpritePart : public QObject
27 {
28  Q_OBJECT
29  Q_PROPERTY(QString name READ name WRITE setName)
30  Q_PROPERTY(bool hasCollision READ hasCollision WRITE setCollision)
32  Q_PROPERTY(bool flippedVertically READ flippedVertically WRITE setFlippedVertically)
33  Q_PROPERTY(QPoint offset READ offset WRITE setOffset)
34  Q_PROPERTY(QPoint textureOffset READ textureOffset WRITE setTextureOffset)
35  Q_PROPERTY(QSize size READ size WRITE setSize)
36 #endif
37 public:
38  SpritePart(SpriteFrame* root);
39  SpritePart(SpriteFrame* root, const std::string& name, bool hasCollision = false);
40  virtual ~SpritePart();
41 
42 
43 #ifndef ATHENA_USE_QT
44  void setName(const std::string& name);
45  std::string name() const;
46 #else
47  void setName(const QString& name);
48  QString name() const;
49 #endif
50 
51  void setCollision(bool col);
52  bool hasCollision() const;
53 
59  void setOffset(float x, float y);
60 
65 #ifndef ATHENA_USE_QT
66  void setOffset(const Vector2Df& offset);
67 #else
68  void setOffset(const QPoint& offset);
69 #endif
70 
75 #ifndef ATHENA_USE_QT
76  Vector2Df offset() const;
77 #else
78  QPoint offset() const;
79 #endif
80 
86  void setTextureOffset(float x, float y);
87 
92 #ifndef ATHENA_USE_QT
93  void setTextureOffset(const Vector2Df& offset);
94 #else
95  void setTextureOffset(const QPoint& offset);
96 #endif
97 
102 #ifndef ATHENA_USE_QT
103  Vector2Df textureOffset() const;
104 #else
105  QPoint textureOffset() const;
106 #endif
107 
113  void setSize(atUint32 width, atUint32 height);
114 
119 #ifndef ATHENA_USE_QT
120  void setSize(const Vector2Di& size);
121 #else
122  void setSize(const QSize& size);
123 #endif
124 
129 #ifndef ATHENA_USE_QT
130  Vector2Di size() const;
131 #else
132  QSize size() const;
133 #endif
134 
139  void setFlippedHorizontally(const bool val);
140 
145  bool flippedHorizontally() const;
146 
151  void setFlippedVertically(const bool val);
152 
157  bool flippedVertically() const;
158 
159  void setRoot(SpriteFrame* root);
160  SpriteFrame* root() const;
161 
162 #ifdef ATHENA_USE_QT
163 signals:
164  void nameChanged(QString);
165  void orientationChanged(bool, bool);
166  void offsetChanged(QPoint);
167  void textureOffsetChanged(QPoint);
168  void sizeChanged(QSize);
169  void collisionChanged(bool);
170 #endif
171 
172 private:
173  SpriteFrame* m_root;
174 #ifndef ATHENA_USE_QT
175  std::string m_name;
176 #else
177  QString m_name;
178 #endif
179  bool m_hasCollision;
180 #ifndef ATHENA_USE_QT
181  Vector2Df m_offset;
182  Vector2Df m_textureOffset;
183  Vector2Di m_size;
184 #else
185  QPoint m_offset;
186  QPoint m_textureOffset;
187  QSize m_size;
188 #endif
189  bool m_flippedH;
190  bool m_flippedV;
191  atUint32 m_frameIndex;
192 };
193 
194 }
195 }
196 #ifdef ATHENA_USE_QT
197 Q_DECLARE_METATYPE(athena::Sakura::SpritePart*)
198 #endif
199 
200 #endif // SSPRITEPART_HPP
void setTextureOffset(float x, float y)
setTextureOffset
Vector2Di size() const
size
void setSize(atUint32 width, atUint32 height)
setSize
bool flippedVertically() const
flippedVertically
Vector2Df offset() const
offset
bool flippedHorizontally() const
flippedHorizontally
Vector2Df textureOffset() const
textureOffset
void setFlippedVertically(const bool val)
setFlippedVertically
void setFlippedHorizontally(const bool val)
setFlippedHorizontally
void setOffset(float x, float y)
setOffset