2015-09-03 19:37:45 +00:00
|
|
|
|
#ifndef SSPRITEFILE_HPP
|
2014-01-26 04:56:04 +00:00
|
|
|
|
#define SSPRITEFILE_HPP
|
|
|
|
|
|
2014-04-20 10:28:28 +00:00
|
|
|
|
#ifndef ATHENA_USE_QT
|
2014-01-26 04:56:04 +00:00
|
|
|
|
#include <vector>
|
|
|
|
|
#include <unordered_map>
|
2014-02-27 05:47:39 +00:00
|
|
|
|
#else
|
|
|
|
|
#include <QObject>
|
|
|
|
|
#include <QMap>
|
|
|
|
|
#include <QList>
|
|
|
|
|
#include <QSize>
|
|
|
|
|
#include <QPoint>
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-01-26 04:56:04 +00:00
|
|
|
|
#include <string>
|
2015-09-03 19:37:45 +00:00
|
|
|
|
#include "Athena/SakuraGlobal.hpp"
|
2014-01-26 04:56:04 +00:00
|
|
|
|
|
2014-04-20 09:14:15 +00:00
|
|
|
|
namespace Athena
|
2014-01-26 04:56:04 +00:00
|
|
|
|
{
|
|
|
|
|
namespace Sakura
|
|
|
|
|
{
|
|
|
|
|
struct STexture
|
|
|
|
|
{
|
|
|
|
|
std::string Filepath;
|
|
|
|
|
bool Preload;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class Sprite;
|
2014-04-20 10:28:28 +00:00
|
|
|
|
#ifndef ATHENA_USE_QT
|
2014-01-26 04:56:04 +00:00
|
|
|
|
class SpriteFile
|
|
|
|
|
{
|
2014-02-27 05:47:39 +00:00
|
|
|
|
#else
|
|
|
|
|
class SpriteFile : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
#endif
|
2014-01-26 04:56:04 +00:00
|
|
|
|
public:
|
|
|
|
|
/*!
|
|
|
|
|
* \brief Major
|
|
|
|
|
*/
|
2014-06-18 04:51:18 +00:00
|
|
|
|
static const atUint32 Major;
|
2014-01-26 04:56:04 +00:00
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief Minor
|
|
|
|
|
*/
|
2014-06-18 04:51:18 +00:00
|
|
|
|
static const atUint32 Minor;
|
2014-01-26 04:56:04 +00:00
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief Revision
|
|
|
|
|
*/
|
2014-06-18 04:51:18 +00:00
|
|
|
|
static const atUint32 Revision;
|
2014-01-26 04:56:04 +00:00
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief Patch
|
|
|
|
|
*/
|
2014-06-18 04:51:18 +00:00
|
|
|
|
static const atUint32 Build;
|
2014-01-26 04:56:04 +00:00
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief Version
|
|
|
|
|
*/
|
2014-06-18 04:51:18 +00:00
|
|
|
|
static const atUint32 Version;
|
2014-01-26 04:56:04 +00:00
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief Magic
|
|
|
|
|
*/
|
2014-06-18 04:51:18 +00:00
|
|
|
|
static const atUint32 Magic;
|
2014-01-26 04:56:04 +00:00
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief SSprite
|
|
|
|
|
*/
|
|
|
|
|
SpriteFile();
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief SSpriteFile
|
|
|
|
|
* \param width
|
|
|
|
|
* \param height
|
|
|
|
|
* \param originX
|
|
|
|
|
* \param originY
|
|
|
|
|
*/
|
2014-06-18 04:51:18 +00:00
|
|
|
|
SpriteFile(atUint32 width, atUint32 height, float originX, float originY);
|
2014-01-26 04:56:04 +00:00
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief SSpriteFile
|
|
|
|
|
* \param size
|
|
|
|
|
* \param origin
|
|
|
|
|
*/
|
2014-04-20 10:28:28 +00:00
|
|
|
|
#ifndef ATHENA_USE_QT
|
2014-01-26 04:56:04 +00:00
|
|
|
|
SpriteFile(const Vector2Di& size, const Vector2Df& origin);
|
2014-02-27 05:47:39 +00:00
|
|
|
|
#else
|
|
|
|
|
SpriteFile(const QSize& size, const QPoint& origin);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
~SpriteFile();
|
|
|
|
|
|
2014-04-20 10:28:28 +00:00
|
|
|
|
#ifndef ATHENA_USE_QT
|
2014-02-27 05:47:39 +00:00
|
|
|
|
public:
|
|
|
|
|
#else
|
|
|
|
|
public slots:
|
|
|
|
|
#endif
|
2014-01-26 04:56:04 +00:00
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \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
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief setSize
|
|
|
|
|
* \param size
|
|
|
|
|
*/
|
2014-04-20 10:28:28 +00:00
|
|
|
|
#ifndef ATHENA_USE_QT
|
2014-01-26 04:56:04 +00:00
|
|
|
|
void setSize(const Vector2Di& size);
|
2014-02-27 05:47:39 +00:00
|
|
|
|
#else
|
|
|
|
|
void setSize(const QSize& size);
|
|
|
|
|
#endif
|
2014-01-26 04:56:04 +00:00
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief size
|
|
|
|
|
* \return
|
|
|
|
|
*/
|
2014-04-20 10:28:28 +00:00
|
|
|
|
#ifndef ATHENA_USE_QT
|
2014-01-26 04:56:04 +00:00
|
|
|
|
Vector2Di size() const;
|
2014-02-27 05:47:39 +00:00
|
|
|
|
#else
|
|
|
|
|
QSize size() const;
|
|
|
|
|
#endif
|
2014-01-26 04:56:04 +00:00
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief width
|
|
|
|
|
* \return
|
|
|
|
|
*/
|
2014-06-18 04:51:18 +00:00
|
|
|
|
atUint32 width() const;
|
2014-01-26 04:56:04 +00:00
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief height
|
|
|
|
|
* \return
|
|
|
|
|
*/
|
2014-06-18 04:51:18 +00:00
|
|
|
|
atUint32 height() const;
|
2014-01-26 04:56:04 +00:00
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief setOrigin
|
|
|
|
|
* \param x
|
|
|
|
|
* \param y
|
|
|
|
|
*/
|
|
|
|
|
void setOrigin(const float x, const float y);
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief setOrigin
|
|
|
|
|
* \param origin
|
|
|
|
|
*/
|
2014-04-20 10:28:28 +00:00
|
|
|
|
#ifndef ATHENA_USE_QT
|
2014-03-22 02:27:29 +00:00
|
|
|
|
void setOrigin(const Vector2Df& origin);
|
2014-02-27 05:47:39 +00:00
|
|
|
|
#else
|
|
|
|
|
void setOrigin(const QPoint& origin);
|
|
|
|
|
#endif
|
2014-01-26 04:56:04 +00:00
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief origin
|
|
|
|
|
* \return
|
|
|
|
|
*/
|
2014-04-20 10:28:28 +00:00
|
|
|
|
#ifndef ATHENA_USE_QT
|
2014-01-26 04:56:04 +00:00
|
|
|
|
Vector2Df origin() const;
|
2014-02-27 05:47:39 +00:00
|
|
|
|
#else
|
|
|
|
|
QPoint origin() const;
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-01-26 04:56:04 +00:00
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief originX
|
|
|
|
|
* \return
|
|
|
|
|
*/
|
|
|
|
|
float originX() const;
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief originY
|
|
|
|
|
* \return
|
|
|
|
|
*/
|
|
|
|
|
float originY() const;
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief addTexture
|
|
|
|
|
* \param texture
|
|
|
|
|
*/
|
2014-02-27 05:47:39 +00:00
|
|
|
|
bool addTexture(STexture* texture);
|
2014-01-26 04:56:04 +00:00
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief removeTexture
|
|
|
|
|
* \param id
|
|
|
|
|
*/
|
|
|
|
|
void removeTexture(int id);
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief texture
|
|
|
|
|
* \param id
|
|
|
|
|
* \return
|
|
|
|
|
*/
|
2014-06-18 04:51:18 +00:00
|
|
|
|
STexture* texture(atUint32 id);
|
2014-01-26 04:56:04 +00:00
|
|
|
|
|
2014-04-20 10:28:28 +00:00
|
|
|
|
#ifndef ATHENA_USE_QT
|
2014-01-26 04:56:04 +00:00
|
|
|
|
std::vector<STexture*> textures() const;
|
2014-02-27 05:47:39 +00:00
|
|
|
|
#else
|
|
|
|
|
QList<STexture*> textures() const;
|
|
|
|
|
#endif
|
2014-06-18 04:51:18 +00:00
|
|
|
|
atUint32 textureCount() const;
|
2014-01-26 04:56:04 +00:00
|
|
|
|
/*!
|
|
|
|
|
* \brief setTextures
|
|
|
|
|
* \param textures
|
|
|
|
|
*/
|
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 setTextures(std::vector<STexture*> textures);
|
2014-02-27 05:47:39 +00:00
|
|
|
|
#else
|
|
|
|
|
void setTextures(QList<STexture*> textures);
|
|
|
|
|
#endif
|
2014-01-26 04:56:04 +00:00
|
|
|
|
|
|
|
|
|
void addSprite(Sprite* sprite);
|
|
|
|
|
|
2014-04-20 10:28:28 +00:00
|
|
|
|
#ifndef ATHENA_USE_QT
|
2014-02-27 05:47:39 +00:00
|
|
|
|
void removeSprite(const std::string& name);
|
|
|
|
|
#else
|
|
|
|
|
void removeSprite(const QString& name);
|
|
|
|
|
#endif
|
|
|
|
|
void removeSprite(Sprite* sprite);
|
2014-01-26 04:56:04 +00:00
|
|
|
|
|
2014-04-20 10:28:28 +00:00
|
|
|
|
#ifndef ATHENA_USE_QT
|
2014-02-27 05:47:39 +00:00
|
|
|
|
void setSprites(std::unordered_map<std::string, Sprite*> sprites);
|
|
|
|
|
#else
|
|
|
|
|
void setSprites(QMap<QString, Sprite*> sprites);
|
|
|
|
|
#endif
|
2014-04-20 10:28:28 +00:00
|
|
|
|
#ifndef ATHENA_USE_QT
|
2014-01-26 04:56:04 +00:00
|
|
|
|
Sprite* sprite(const std::string& name);
|
|
|
|
|
std::unordered_map<std::string, Sprite*> sprites() const;
|
2014-02-27 05:47:39 +00:00
|
|
|
|
#else
|
|
|
|
|
Sprite* sprite(const QString& name);
|
|
|
|
|
QMap<QString, Sprite*> sprites() const;
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-06-18 04:51:18 +00:00
|
|
|
|
atUint32 spriteCount() const;
|
2014-01-26 04:56:04 +00:00
|
|
|
|
|
2014-04-20 10:28:28 +00:00
|
|
|
|
#ifdef ATHENA_USE_QT
|
2014-02-27 05:47:39 +00:00
|
|
|
|
signals:
|
|
|
|
|
void originChanged(QPoint);
|
|
|
|
|
void sizeChanged(QSize);
|
|
|
|
|
#endif
|
2015-05-19 03:24:56 +00:00
|
|
|
|
private:
|
|
|
|
|
#ifndef ATHENA_USE_QT
|
|
|
|
|
std::vector<STexture*> m_textures;
|
2014-01-26 04:56:04 +00:00
|
|
|
|
Vector2Di m_size;
|
|
|
|
|
Vector2Df m_origin;
|
|
|
|
|
std::unordered_map<std::string, Sprite*> m_sprites;
|
2014-02-27 05:47:39 +00:00
|
|
|
|
#else
|
|
|
|
|
QList<STexture*> m_textures;
|
|
|
|
|
QSize m_size;
|
|
|
|
|
QPoint m_origin;
|
|
|
|
|
QMap<QString, Sprite*> m_sprites;
|
|
|
|
|
#endif
|
2014-01-26 04:56:04 +00:00
|
|
|
|
};
|
|
|
|
|
} // Sakura
|
|
|
|
|
} // Zelda
|
|
|
|
|
|
2014-04-20 10:28:28 +00:00
|
|
|
|
#ifdef ATHENA_USE_QT
|
|
|
|
|
Q_DECLARE_METATYPE(Athena::Sakura::SpriteFile*)
|
|
|
|
|
Q_DECLARE_METATYPE(Athena::Sakura::STexture*)
|
2014-02-27 05:47:39 +00:00
|
|
|
|
#endif
|
2014-01-26 04:56:04 +00:00
|
|
|
|
#endif // SSPRITE_HPP
|