mirror of
https://github.com/libAthena/athena.git
synced 2025-12-09 05:27:50 +00:00
* Major rewrite
This commit is contained in:
280
include/Athena/SpriteFile.hpp
Normal file
280
include/Athena/SpriteFile.hpp
Normal file
@@ -0,0 +1,280 @@
|
||||
// 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 SSPRITEFILE_HPP
|
||||
#define SSPRITEFILE_HPP
|
||||
|
||||
#ifndef LIBZELDA_USE_QT
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#else
|
||||
#include <QObject>
|
||||
#include <QMap>
|
||||
#include <QList>
|
||||
#include <QSize>
|
||||
#include <QPoint>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include "Athena/Global.hpp"
|
||||
|
||||
namespace Athena
|
||||
{
|
||||
namespace Sakura
|
||||
{
|
||||
struct STexture
|
||||
{
|
||||
std::string Filepath;
|
||||
bool Preload;
|
||||
};
|
||||
|
||||
class Sprite;
|
||||
#ifndef LIBZELDA_USE_QT
|
||||
class SpriteFile
|
||||
{
|
||||
#else
|
||||
class SpriteFile : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
#endif
|
||||
public:
|
||||
/*!
|
||||
* \brief Major
|
||||
*/
|
||||
static const Uint32 Major;
|
||||
|
||||
/*!
|
||||
* \brief Minor
|
||||
*/
|
||||
static const Uint32 Minor;
|
||||
|
||||
/*!
|
||||
* \brief Revision
|
||||
*/
|
||||
static const Uint32 Revision;
|
||||
|
||||
/*!
|
||||
* \brief Patch
|
||||
*/
|
||||
static const Uint32 Build;
|
||||
|
||||
/*!
|
||||
* \brief Version
|
||||
*/
|
||||
static const Uint32 Version;
|
||||
|
||||
/*!
|
||||
* \brief Magic
|
||||
*/
|
||||
static const Uint32 Magic;
|
||||
|
||||
/*!
|
||||
* \brief SSprite
|
||||
*/
|
||||
SpriteFile();
|
||||
|
||||
/*!
|
||||
* \brief SSpriteFile
|
||||
* \param width
|
||||
* \param height
|
||||
* \param originX
|
||||
* \param originY
|
||||
*/
|
||||
SpriteFile(Uint32 width, Uint32 height, float originX, float originY);
|
||||
|
||||
/*!
|
||||
* \brief SSpriteFile
|
||||
* \param size
|
||||
* \param origin
|
||||
*/
|
||||
#ifndef LIBZELDA_USE_QT
|
||||
SpriteFile(const Vector2Di& size, const Vector2Df& origin);
|
||||
#else
|
||||
SpriteFile(const QSize& size, const QPoint& origin);
|
||||
#endif
|
||||
|
||||
~SpriteFile();
|
||||
|
||||
#ifndef LIBZELDA_USE_QT
|
||||
public:
|
||||
#else
|
||||
public slots:
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* \brief setSize
|
||||
* \param width
|
||||
* \param height
|
||||
*/
|
||||
void setSize(Uint32 width, Uint32 height);
|
||||
|
||||
/*!
|
||||
* \brief setSize
|
||||
* \param size
|
||||
*/
|
||||
#ifndef LIBZELDA_USE_QT
|
||||
void setSize(const Vector2Di& size);
|
||||
#else
|
||||
void setSize(const QSize& size);
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* \brief size
|
||||
* \return
|
||||
*/
|
||||
#ifndef LIBZELDA_USE_QT
|
||||
Vector2Di size() const;
|
||||
#else
|
||||
QSize size() const;
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* \brief width
|
||||
* \return
|
||||
*/
|
||||
Uint32 width() const;
|
||||
|
||||
/*!
|
||||
* \brief height
|
||||
* \return
|
||||
*/
|
||||
Uint32 height() const;
|
||||
|
||||
/*!
|
||||
* \brief setOrigin
|
||||
* \param x
|
||||
* \param y
|
||||
*/
|
||||
void setOrigin(const float x, const float y);
|
||||
|
||||
/*!
|
||||
* \brief setOrigin
|
||||
* \param origin
|
||||
*/
|
||||
#ifndef LIBZELDA_USE_QT
|
||||
void setOrigin(const Vector2Df& origin);
|
||||
#else
|
||||
void setOrigin(const QPoint& origin);
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* \brief origin
|
||||
* \return
|
||||
*/
|
||||
#ifndef LIBZELDA_USE_QT
|
||||
Vector2Df origin() const;
|
||||
#else
|
||||
QPoint origin() const;
|
||||
#endif
|
||||
|
||||
|
||||
/*!
|
||||
* \brief originX
|
||||
* \return
|
||||
*/
|
||||
float originX() const;
|
||||
|
||||
/*!
|
||||
* \brief originY
|
||||
* \return
|
||||
*/
|
||||
float originY() const;
|
||||
|
||||
/*!
|
||||
* \brief addTexture
|
||||
* \param texture
|
||||
*/
|
||||
bool addTexture(STexture* texture);
|
||||
|
||||
/*!
|
||||
* \brief removeTexture
|
||||
* \param id
|
||||
*/
|
||||
void removeTexture(int id);
|
||||
|
||||
/*!
|
||||
* \brief texture
|
||||
* \param id
|
||||
* \return
|
||||
*/
|
||||
STexture* texture(Uint32 id);
|
||||
|
||||
#ifndef LIBZELDA_USE_QT
|
||||
std::vector<STexture*> textures() const;
|
||||
#else
|
||||
QList<STexture*> textures() const;
|
||||
#endif
|
||||
Uint32 textureCount() const;
|
||||
/*!
|
||||
* \brief setTextures
|
||||
* \param textures
|
||||
*/
|
||||
|
||||
#ifndef LIBZELDA_USE_QT
|
||||
void setTextures(std::vector<STexture*> textures);
|
||||
#else
|
||||
void setTextures(QList<STexture*> textures);
|
||||
#endif
|
||||
|
||||
void addSprite(Sprite* sprite);
|
||||
|
||||
#ifndef LIBZELDA_USE_QT
|
||||
void removeSprite(const std::string& name);
|
||||
#else
|
||||
void removeSprite(const QString& name);
|
||||
#endif
|
||||
void removeSprite(Sprite* sprite);
|
||||
|
||||
#ifndef LIBZELDA_USE_QT
|
||||
void setSprites(std::unordered_map<std::string, Sprite*> sprites);
|
||||
#else
|
||||
void setSprites(QMap<QString, Sprite*> sprites);
|
||||
#endif
|
||||
#ifndef LIBZELDA_USE_QT
|
||||
Sprite* sprite(const std::string& name);
|
||||
std::unordered_map<std::string, Sprite*> sprites() const;
|
||||
#else
|
||||
Sprite* sprite(const QString& name);
|
||||
QMap<QString, Sprite*> sprites() const;
|
||||
#endif
|
||||
|
||||
Uint32 spriteCount() const;
|
||||
|
||||
#ifdef LIBZELDA_USE_QT
|
||||
signals:
|
||||
void originChanged(QPoint);
|
||||
void sizeChanged(QSize);
|
||||
#endif
|
||||
private:
|
||||
#ifndef LIBZELDA_USE_QT
|
||||
std::vector<STexture*> m_textures;
|
||||
Vector2Di m_size;
|
||||
Vector2Df m_origin;
|
||||
std::unordered_map<std::string, Sprite*> m_sprites;
|
||||
#else
|
||||
QList<STexture*> m_textures;
|
||||
QSize m_size;
|
||||
QPoint m_origin;
|
||||
QMap<QString, Sprite*> m_sprites;
|
||||
#endif
|
||||
};
|
||||
} // Sakura
|
||||
} // Zelda
|
||||
|
||||
#ifdef LIBZELDA_USE_QT
|
||||
Q_DECLARE_METATYPE(zelda::Sakura::SpriteFile*)
|
||||
Q_DECLARE_METATYPE(zelda::Sakura::STexture*)
|
||||
#endif
|
||||
#endif // SSPRITE_HPP
|
||||
Reference in New Issue
Block a user