diff options
Diffstat (limited to 'pokemod/Tile.cpp')
| -rw-r--r-- | pokemod/Tile.cpp | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/pokemod/Tile.cpp b/pokemod/Tile.cpp index fb0d328e..4e52a11f 100644 --- a/pokemod/Tile.cpp +++ b/pokemod/Tile.cpp @@ -21,6 +21,7 @@ // Pokemod includes #include "Macros.h" #include "Pokemod.h" +#include "Sprite.h" Pokemod::Tile::Tile(const Tile& tile) : Object(tile.parent(), tile.id()) @@ -31,7 +32,7 @@ Pokemod::Tile::Tile(const Tile& tile) : Pokemod::Tile::Tile(const Pokemod* parent, const int id) : Object(parent, id), m_name(""), - m_sprite(64, 64), + m_sprite(-1), m_script("", "") { for (int i = 0; i < D_End; ++i) @@ -64,7 +65,7 @@ void Pokemod::Tile::load(const QDomElement& xml) { LOAD_BEGIN(); LOAD(QString, name); - LOAD(QPixmap, sprite); + LOAD(int, sprite); LOAD_ARRAY(bool, from, D_End); LOAD(Script, script); } @@ -73,7 +74,7 @@ QDomElement Pokemod::Tile::save() const { SAVE_CREATE(); SAVE(QString, name); - SAVE(QPixmap, sprite); + SAVE(int, sprite); SAVE_ARRAY(bool, from, D_End); SAVE(Script, script); return xml; @@ -84,25 +85,23 @@ void Pokemod::Tile::setName(const QString& name) CHECK(name); } -void Pokemod::Tile::setSprite(const QPixmap& sprite) +void Pokemod::Tile::setSprite(const int sprite) { - if (sprite.size() != QSize(64, 64)) - { - emit(error(size("sprite"))); - return; - } - m_sprite = sprite; - emit(changed()); + if (qobject_cast<const Pokemod*>(pokemod())->spriteIndex(sprite) == INT_MAX) + emit(error(bounds("sprite"))); + // TODO: remove if doing collaging + else if (qobject_cast<const Pokemod*>(pokemod())->spriteById(sprite)->sprite().size() != QSize(64, 64)) + emit(error("Sprite is the wrong dimensions")); + else + CHECK(sprite); } void Pokemod::Tile::setFrom(const int direction, const bool state) { if (D_End <= direction) - { emit(error(bounds("direction"))); - return; - } - CHECK_ARRAY(from[direction], state); + else + CHECK_ARRAY(from[direction], state); } void Pokemod::Tile::setScript(const Script& script) @@ -115,7 +114,7 @@ QString Pokemod::Tile::name() const return m_name; } -QPixmap Pokemod::Tile::sprite() const +int Pokemod::Tile::sprite() const { return m_sprite; } |
