athena/include/Athena/SpritePart.hpp

216 lines
4.6 KiB
C++
Raw Normal View History

2014-04-20 09:14:15 +00:00
// This file is part of libAthena.
//
// libAthena is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// libAthena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with libAthena. If not, see <http://www.gnu.org/licenses/>
#ifndef SSPRITEPART_HPP
#define SSPRITEPART_HPP
2014-04-20 09:14:15 +00:00
#include "Athena/Global.hpp"
#ifndef ATHENA_USE_QT
2014-02-27 05:47:39 +00:00
# include <vector>
#else
# include <QObject>
# include <QPoint>
# include <QSize>
# include <QString>
#endif
#include <string>
2014-04-20 09:14:15 +00:00
namespace Athena
{
namespace Sakura
{
class SpriteFrame;
#ifndef ATHENA_USE_QT
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
public:
2014-02-27 05:47:39 +00:00
SpritePart(SpriteFrame* root);
SpritePart(SpriteFrame* root, const std::string& name, bool hasCollision = false);
virtual ~SpritePart();
2014-02-27 05:47:39 +00:00
#ifndef ATHENA_USE_QT
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
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
*/
#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
*/
#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
*/
#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
*/
#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
*/
void setSize(atUint32 width, atUint32 height);
2014-02-27 05:47:39 +00:00
/*!
* \brief setSize
* \param size
*/
#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
*/
#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;
#ifdef ATHENA_USE_QT
2014-02-27 05:47:39 +00:00
signals:
void nameChanged(QString);
void orientationChanged(bool,bool);
void offsetChanged(QPoint);
void textureOffsetChanged(QPoint);
void sizeChanged(QSize);
void collisionChanged(bool);
#endif
private:
2014-02-27 05:47:39 +00:00
SpriteFrame* m_root;
#ifndef ATHENA_USE_QT
std::string m_name;
2014-02-27 05:47:39 +00:00
#else
QString m_name;
#endif
bool m_hasCollision;
#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;
atUint32 m_frameIndex;
};
}
}
#ifdef ATHENA_USE_QT
Q_DECLARE_METATYPE(Athena::Sakura::SpritePart*)
2014-02-27 05:47:39 +00:00
#endif
2014-02-27 05:47:39 +00:00
#endif // SSPRITEPART_HPP