2014-01-26 04:56:04 +00:00
|
|
|
#ifndef SSPRITEPART_HPP
|
|
|
|
#define SSPRITEPART_HPP
|
|
|
|
|
2015-09-03 19:37:45 +00:00
|
|
|
#include "Athena/SakuraGlobal.hpp"
|
2014-04-20 10:28:28 +00:00
|
|
|
#ifndef ATHENA_USE_QT
|
2014-02-27 05:47:39 +00:00
|
|
|
# include <vector>
|
|
|
|
#else
|
|
|
|
# include <QObject>
|
|
|
|
# include <QPoint>
|
|
|
|
# include <QSize>
|
|
|
|
# include <QString>
|
|
|
|
#endif
|
|
|
|
|
2014-01-26 04:56:04 +00:00
|
|
|
#include <string>
|
|
|
|
|
2014-04-20 09:14:15 +00:00
|
|
|
namespace Athena
|
2014-01-26 04:56:04 +00:00
|
|
|
{
|
|
|
|
namespace Sakura
|
|
|
|
{
|
|
|
|
class SpriteFrame;
|
|
|
|
|
2014-04-20 10:28:28 +00:00
|
|
|
#ifndef ATHENA_USE_QT
|
2014-01-26 04:56:04 +00:00
|
|
|
class SpritePart
|
|
|
|
{
|
2014-02-27 05:47:39 +00:00
|
|
|
#else
|
|
|
|
class SpritePart : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(QString name READ name WRITE setName)
|
|
|
|
Q_PROPERTY(bool hasCollision READ hasCollision WRITE setCollision)
|
|
|
|
Q_PROPERTY(bool flippedHorizontally READ flippedHorizontally WRITE setFlippedHorizontally)
|
|
|
|
Q_PROPERTY(bool flippedVertically READ flippedVertically WRITE setFlippedVertically)
|
|
|
|
Q_PROPERTY(QPoint offset READ offset WRITE setOffset)
|
|
|
|
Q_PROPERTY(QPoint textureOffset READ textureOffset WRITE setTextureOffset)
|
|
|
|
Q_PROPERTY(QSize size READ size WRITE setSize)
|
|
|
|
#endif
|
2014-01-26 04:56:04 +00:00
|
|
|
public:
|
2014-02-27 05:47:39 +00:00
|
|
|
SpritePart(SpriteFrame* root);
|
|
|
|
SpritePart(SpriteFrame* root, const std::string& name, bool hasCollision = false);
|
2014-01-26 04:56:04 +00:00
|
|
|
virtual ~SpritePart();
|
|
|
|
|
2014-02-27 05:47:39 +00:00
|
|
|
|
2014-04-20 10:28:28 +00:00
|
|
|
#ifndef ATHENA_USE_QT
|
2014-01-26 04:56:04 +00:00
|
|
|
void setName(const std::string& name);
|
|
|
|
std::string name() const;
|
2014-02-27 05:47:39 +00:00
|
|
|
#else
|
|
|
|
void setName(const QString& name);
|
|
|
|
QString name() const;
|
|
|
|
#endif
|
2014-01-26 04:56:04 +00:00
|
|
|
|
|
|
|
void setCollision(bool col);
|
|
|
|
bool hasCollision() const;
|
|
|
|
|
2014-02-27 05:47:39 +00:00
|
|
|
/*!
|
|
|
|
* \brief setOffset
|
|
|
|
* \param x
|
|
|
|
* \param y
|
|
|
|
*/
|
|
|
|
void setOffset(float x, float y);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief setOffset
|
|
|
|
* \param offset
|
|
|
|
*/
|
2014-04-20 10:28:28 +00:00
|
|
|
#ifndef ATHENA_USE_QT
|
2014-02-27 05:47:39 +00:00
|
|
|
void setOffset(const Vector2Df& offset);
|
|
|
|
#else
|
|
|
|
void setOffset(const QPoint& offset);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief offset
|
|
|
|
* \return
|
|
|
|
*/
|
2014-04-20 10:28:28 +00:00
|
|
|
#ifndef ATHENA_USE_QT
|
2014-02-27 05:47:39 +00:00
|
|
|
Vector2Df offset() const;
|
|
|
|
#else
|
|
|
|
QPoint offset() const;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief setTextureOffset
|
|
|
|
* \param x
|
|
|
|
* \param y
|
|
|
|
*/
|
|
|
|
void setTextureOffset(float x, float y);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief setTextureOffset
|
|
|
|
* \param texOff
|
|
|
|
*/
|
2014-04-20 10:28:28 +00:00
|
|
|
#ifndef ATHENA_USE_QT
|
2014-02-27 05:47:39 +00:00
|
|
|
void setTextureOffset(const Vector2Df& offset);
|
|
|
|
#else
|
|
|
|
void setTextureOffset(const QPoint& offset);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief textureOffset
|
|
|
|
* \return
|
|
|
|
*/
|
2014-04-20 10:28:28 +00:00
|
|
|
#ifndef ATHENA_USE_QT
|
2014-02-27 05:47:39 +00:00
|
|
|
Vector2Df textureOffset() const;
|
|
|
|
#else
|
|
|
|
QPoint textureOffset() const;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief setSize
|
|
|
|
* \param width
|
|
|
|
* \param height
|
|
|
|
*/
|
2014-06-18 04:51:18 +00:00
|
|
|
void setSize(atUint32 width, atUint32 height);
|
2014-01-26 04:56:04 +00:00
|
|
|
|
2014-02-27 05:47:39 +00:00
|
|
|
/*!
|
|
|
|
* \brief setSize
|
|
|
|
* \param size
|
|
|
|
*/
|
2014-04-20 10:28:28 +00:00
|
|
|
#ifndef ATHENA_USE_QT
|
2014-02-27 05:47:39 +00:00
|
|
|
void setSize(const Vector2Di& size);
|
|
|
|
#else
|
|
|
|
void setSize(const QSize& size);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief size
|
|
|
|
* \return
|
|
|
|
*/
|
2014-04-20 10:28:28 +00:00
|
|
|
#ifndef ATHENA_USE_QT
|
2014-02-27 05:47:39 +00:00
|
|
|
Vector2Di size() const;
|
|
|
|
#else
|
|
|
|
QSize size() const;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief setFlippedHorizontally
|
|
|
|
* \param val
|
|
|
|
*/
|
|
|
|
void setFlippedHorizontally(const bool val);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief flippedHorizontally
|
|
|
|
* \return
|
|
|
|
*/
|
|
|
|
bool flippedHorizontally() const;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief setFlippedVertically
|
|
|
|
* \param val
|
|
|
|
*/
|
|
|
|
void setFlippedVertically(const bool val);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief flippedVertically
|
|
|
|
* \return
|
|
|
|
*/
|
|
|
|
bool flippedVertically() const;
|
|
|
|
|
|
|
|
void setRoot(SpriteFrame* root);
|
|
|
|
SpriteFrame* root() const;
|
|
|
|
|
2014-04-20 10:28:28 +00:00
|
|
|
#ifdef ATHENA_USE_QT
|
2014-02-27 05:47:39 +00:00
|
|
|
signals:
|
|
|
|
void nameChanged(QString);
|
2015-05-19 03:24:56 +00:00
|
|
|
void orientationChanged(bool, bool);
|
2014-02-27 05:47:39 +00:00
|
|
|
void offsetChanged(QPoint);
|
|
|
|
void textureOffsetChanged(QPoint);
|
|
|
|
void sizeChanged(QSize);
|
|
|
|
void collisionChanged(bool);
|
|
|
|
#endif
|
2014-01-26 04:56:04 +00:00
|
|
|
|
|
|
|
private:
|
2014-02-27 05:47:39 +00:00
|
|
|
SpriteFrame* m_root;
|
2014-04-20 10:28:28 +00:00
|
|
|
#ifndef ATHENA_USE_QT
|
2014-01-26 04:56:04 +00:00
|
|
|
std::string m_name;
|
2014-02-27 05:47:39 +00:00
|
|
|
#else
|
|
|
|
QString m_name;
|
|
|
|
#endif
|
2014-01-26 04:56:04 +00:00
|
|
|
bool m_hasCollision;
|
2014-04-20 10:28:28 +00:00
|
|
|
#ifndef ATHENA_USE_QT
|
2014-02-27 05:47:39 +00:00
|
|
|
Vector2Df m_offset;
|
|
|
|
Vector2Df m_textureOffset;
|
|
|
|
Vector2Di m_size;
|
|
|
|
#else
|
|
|
|
QPoint m_offset;
|
|
|
|
QPoint m_textureOffset;
|
|
|
|
QSize m_size;
|
|
|
|
#endif
|
|
|
|
bool m_flippedH;
|
|
|
|
bool m_flippedV;
|
2014-06-18 04:51:18 +00:00
|
|
|
atUint32 m_frameIndex;
|
2014-01-26 04:56:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2014-04-20 10:28:28 +00:00
|
|
|
#ifdef ATHENA_USE_QT
|
|
|
|
Q_DECLARE_METATYPE(Athena::Sakura::SpritePart*)
|
2014-02-27 05:47:39 +00:00
|
|
|
#endif
|
2014-01-26 04:56:04 +00:00
|
|
|
|
2014-02-27 05:47:39 +00:00
|
|
|
#endif // SSPRITEPART_HPP
|