diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-08-04 03:27:13 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-08-04 03:27:13 +0000 |
| commit | 373e686bf4ecaaabcf80544e74f017eebe05213f (patch) | |
| tree | cddf7a223f16944b0380386e568f2606f634c366 /pokemod/Tile.cpp | |
| parent | 63417b1c5057d22bd853e92cd3a25aa812b8d917 (diff) | |
[FIX] Cleaned up the RC file
[FIX] Script editing is getting there (still a little weird...)
[FIX] Cleaned up the main file a bit
[FIX] Added the Skin class
[FIX] All sprites and skins are internally linked now
[FIX] No more image restraints (tiles are still enforced so that map editing works)
[FIX] Cleaned up checking for valid values when setting in pokemod
[FIX] Removed FileDialog files
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@233 6ecfd1a5-f3ed-3746-8530-beee90d26b22
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; } |
