summaryrefslogtreecommitdiffstats
path: root/pokemod/Sprite.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'pokemod/Sprite.cpp')
-rw-r--r--pokemod/Sprite.cpp105
1 files changed, 105 insertions, 0 deletions
diff --git a/pokemod/Sprite.cpp b/pokemod/Sprite.cpp
new file mode 100644
index 00000000..df3c5bd5
--- /dev/null
+++ b/pokemod/Sprite.cpp
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2007-2008 Ben Boeckel <MathStuf@gmail.com>
+ *
+ * This program 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.
+ *
+ * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+// Header include
+#include "Sprite.h"
+
+// Pokemod includes
+#include "Pokemod.h"
+
+// Qt includes
+#include <QBuffer>
+
+Sprite::Sprite(const Sprite& sprite) :
+ Object("Sprite", sprite.parent(), sprite.id())
+{
+ *this = sprite;
+}
+
+Sprite::Sprite(const Pokemod* parent, const int id) :
+ Object("Sprite", parent, id),
+ m_name(""),
+ m_sprite()
+{
+}
+
+Sprite::Sprite(const Sprite& sprite, const Pokemod* parent, const int id) :
+ Object("Sprite", parent, id)
+{
+ *this = sprite;
+}
+
+Sprite::Sprite(const QDomElement& xml, const Pokemod* parent, const int id) :
+ Object("Sprite", parent, id)
+{
+ load(xml, id);
+}
+
+Sprite::~Sprite()
+{
+}
+
+void Sprite::validate()
+{
+ if (m_name.isEmpty())
+ emit(error("Name is empty"));
+}
+
+void Sprite::load(const QDomElement& xml, int id)
+{
+ LOAD_ID();
+ LOAD(QString, name);
+ LOAD(QPixmap, sprite);
+}
+
+QDomElement Sprite::save() const
+{
+ SAVE_CREATE();
+ SAVE(QString, name);
+ SAVE(QPixmap, sprite);
+ return xml;
+}
+
+void Sprite::setName(const QString& name)
+{
+ CHECK(name);
+}
+
+void Sprite::setSprite(const QPixmap& sprite)
+{
+ m_sprite = sprite;
+ emit(changed());
+}
+
+QString Sprite::name() const
+{
+ return m_name;
+}
+
+QPixmap Sprite::sprite() const
+{
+ return m_sprite;
+}
+
+Sprite& Sprite::operator=(const Sprite& rhs)
+{
+ if (this == &rhs)
+ return *this;
+ COPY(name);
+ COPY(sprite);
+ return *this;
+}