summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-08-26 18:23:31 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-08-26 18:23:31 +0000
commit940e5d4b55bbd1261bf0ccb3a915b79cf2a240c8 (patch)
tree68d3ebfe3f0763d4dbcd7e642b065f6cde73fb8c
parentaa5ecfc2ac5c1b9c250159d01f1e83799e88eb45 (diff)
downloadsigen-940e5d4b55bbd1261bf0ccb3a915b79cf2a240c8.tar.gz
sigen-940e5d4b55bbd1261bf0ccb3a915b79cf2a240c8.tar.xz
sigen-940e5d4b55bbd1261bf0ccb3a915b79cf2a240c8.zip
[FIX] Fixed some minor typos
[FIX] Abstracted validation out to ValidationDialog [FIX] Added stat and Direction getters for Pokemod git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@244 6ecfd1a5-f3ed-3746-8530-beee90d26b22
-rw-r--r--Changelog9
-rw-r--r--pokemod/Global.h7
-rw-r--r--pokemod/Macros.h22
-rw-r--r--pokemod/Tile.cpp2
-rw-r--r--pokemodr/CMakeLists.txt2
-rw-r--r--pokemodr/FractionWidget.cpp4
-rw-r--r--pokemodr/ObjectUI.cpp89
-rw-r--r--pokemodr/ObjectUI.h12
-rw-r--r--pokemodr/ValidationDialog.cpp107
-rw-r--r--pokemodr/ValidationDialog.h59
-rw-r--r--pokemodr/gui/move.ui2
-rw-r--r--pokescripting/PokemodWrapper.cpp38
-rw-r--r--pokescripting/PokemodWrapper.h3
-rw-r--r--pokescripting/TileWrapper.cpp5
14 files changed, 251 insertions, 110 deletions
diff --git a/Changelog b/Changelog
index a3552d85..080e9d6d 100644
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,13 @@
-----------------
+Rev: 244
+Date: 26 August 2008
+User: MathStuf
+-----------------
+[FIX] Fixed some minor typos
+[FIX] Abstracted validation out to ValidationDialog
+[FIX] Added stat and Direction getters for Pokemod
+
+-----------------
Rev: 243
Date: 21 August 2008
User: MathStuf
diff --git a/pokemod/Global.h b/pokemod/Global.h
index 86db8b66..b5ef146c 100644
--- a/pokemod/Global.h
+++ b/pokemod/Global.h
@@ -43,6 +43,8 @@ namespace Pokemod
{
enum Stat
{
+ ST_Invalid = -1,
+
ST_HP = 0,
ST_No_HP_Start = 1,
ST_Attack = 1,
@@ -62,13 +64,14 @@ const QStringList StatGSCStr = QStringList() << "HP" << "Attack" << "Defense" <<
enum Direction
{
+ D_Invalid = -1,
+
D_Up = 0,
D_Down = 1,
D_Left = 2,
D_Right = 3,
D_End = 4,
- D_None = 4,
- D_End_None = 5
+ D_None = 4
};
const QStringList DirectionStr = QStringList() << "Up" << "Down" << "Left" << "Right" << "None";
diff --git a/pokemod/Macros.h b/pokemod/Macros.h
index fb4613d1..bfd4f6c6 100644
--- a/pokemod/Macros.h
+++ b/pokemod/Macros.h
@@ -45,7 +45,7 @@
QDomElement xml = QDomDocument().createElement(className()); \
xml.setAttribute("id", id())
#define SAVE(variable) xml.appendChild(saveValue(#variable, m_##variable))
-#define SAVE_ARRAY(variable) xml.appendChild(saveArray(QString(#variable), m_##variable))
+#define SAVE_ARRAY(variable) xml.appendChild(saveArray(#variable, m_##variable))
#define SAVE_LIST(variable) xml.appendChild(saveList(#variable, m_##variable))
#define SAVE_MATRIX(variable) xml.appendChild(saveMatrix(#variable, m_##variable))
#define SAVE_Rules(variable) xml.appendChild(m_##variable->save())
@@ -60,13 +60,13 @@
m_##variable.append(new class(*subclass, this, subclass->id()))
#define TEST_BEGIN() \
- connect(this, SIGNAL(warning(const QString&)), SIGNAL(valWarning(const QString&))); \
- connect(this, SIGNAL(error(const QString&)), SIGNAL(valError(const QString&))); \
+ connect(this, SIGNAL(warning(QString)), SIGNAL(valWarning(QString))); \
+ connect(this, SIGNAL(error(QString)), SIGNAL(valError(QString))); \
emit(valMessage(QString("++%1 (%2)").arg(className()).arg(id())))
#define TEST_END() \
emit(valMessage(QString("--%1 (%2)").arg(className()).arg(id()))); \
- disconnect(this, SIGNAL(warning(const QString&)), this, SIGNAL(valWarning(const QString&))); \
- disconnect(this, SIGNAL(error(const QString&)), this, SIGNAL(valError(const QString&)))
+ disconnect(this, SIGNAL(warning(QString)), this, SIGNAL(valWarning(QString))); \
+ disconnect(this, SIGNAL(error(QString)), this, SIGNAL(valError(QString)))
#define TEST(setter, variable) setter(m_##variable)
#define TEST_ARRAY(setter, variable, size) \
for (int i = 0; i < size; ++i) \
@@ -81,13 +81,13 @@
setter(i, j, m_##variable(i, j)); \
}
#define TEST_CHILD(object) \
- connect(object, SIGNAL(valMessage(const QString&)), this, SIGNAL(valMessage(const QString&))); \
- connect(object, SIGNAL(valWarning(const QString&)), this, SIGNAL(valWarning(const QString&))); \
- connect(object, SIGNAL(valError(const QString&)), this, SIGNAL(valError(const QString&))); \
+ connect(object, SIGNAL(valMessage(QString)), this, SIGNAL(valMessage(QString))); \
+ connect(object, SIGNAL(valWarning(QString)), this, SIGNAL(valWarning(QString))); \
+ connect(object, SIGNAL(valError(QString)), this, SIGNAL(valError(QString))); \
object->validate(); \
- disconnect(object, SIGNAL(valMessage(const QString&)), this, SIGNAL(valMessage(const QString&))); \
- disconnect(object, SIGNAL(valWarning(const QString&)), this, SIGNAL(valWarning(const QString&))); \
- disconnect(object, SIGNAL(valError(const QString&)), this, SIGNAL(valError(const QString&)))
+ disconnect(object, SIGNAL(valMessage(QString)), this, SIGNAL(valMessage(QString))); \
+ disconnect(object, SIGNAL(valWarning(QString)), this, SIGNAL(valWarning(QString))); \
+ disconnect(object, SIGNAL(valError(QString)), this, SIGNAL(valError(QString)))
#define TEST_SUB_BEGIN(type, variable) \
foreach (type* object, m_##variable) \
{ \
diff --git a/pokemod/Tile.cpp b/pokemod/Tile.cpp
index bacefad1..c58f7e01 100644
--- a/pokemod/Tile.cpp
+++ b/pokemod/Tile.cpp
@@ -90,7 +90,7 @@ void Pokemod::Tile::setSprite(const int sprite)
{
if (qobject_cast<const Pokemod*>(pokemod())->spriteIndex(sprite) == INT_MAX)
emit(error(bounds("sprite")));
- // TODO: remove if doing collaging
+ // FIXME: 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
diff --git a/pokemodr/CMakeLists.txt b/pokemodr/CMakeLists.txt
index dc6a3837..b08e03fc 100644
--- a/pokemodr/CMakeLists.txt
+++ b/pokemodr/CMakeLists.txt
@@ -174,6 +174,7 @@ SET(pokemodr_MAIN_HEADERS
ScriptWidget.h
TilemapModel.h
TypechartModel.h
+ ValidationDialog.h
)
SET(pokemodr_MOC_HEADERS
${pokemodr_WIDGET_HEADERS}
@@ -308,6 +309,7 @@ SET(pokemodr_SRCS
PokemodrPreferences.cpp
PokemodrUI.cpp
ScriptWidget.cpp
+ ValidationDialog.cpp
)
SET(pokemodr_RC_FILES
pokemodrui.rc
diff --git a/pokemodr/FractionWidget.cpp b/pokemodr/FractionWidget.cpp
index cdeb2278..bd136456 100644
--- a/pokemodr/FractionWidget.cpp
+++ b/pokemodr/FractionWidget.cpp
@@ -24,8 +24,8 @@ Pokemodr::FractionWidget::FractionWidget(QWidget* parent, const Pokemod::Fractio
m_value(value)
{
setupUi(this);
- connect(this, SIGNAL(valueChanged(const Pokemod::Fraction&)), SLOT(updateValue()));
- connect(this, SIGNAL(valueChanged(const Pokemod::Fraction&)), SLOT(resetRanges()));
+ connect(this, SIGNAL(valueChanged(Pokemod::Fraction)), SLOT(updateValue()));
+ connect(this, SIGNAL(valueChanged(Pokemod::Fraction)), SLOT(resetRanges()));
connect(this, SIGNAL(behaviorChanged(const Behavior)), SLOT(resetRanges()));
resetRanges();
}
diff --git a/pokemodr/ObjectUI.cpp b/pokemodr/ObjectUI.cpp
index 2cc7db2f..0cc5609b 100644
--- a/pokemodr/ObjectUI.cpp
+++ b/pokemodr/ObjectUI.cpp
@@ -18,33 +18,28 @@
// Header include
#include "ObjectUI.h"
+// Pokemodr includes
+#include "ValidationDialog.h"
+
// Pokemod includes
#include "../pokemod/Object.h"
#include "../pokemod/Pokemod.h"
-// Qt includes
-#include <QtGui/QLabel>
-#include <QtGui/QTreeWidget>
-#include <QtGui/QVBoxLayout>
-
// KDE includes
#include <KAction>
-#include <KColorScheme>
#include <KDialog>
#include <KMenu>
#include <KMessageBox>
-#include <KProgressDialog>
Pokemodr::ObjectUI::ObjectUI(QWidget* parent) :
QWidget(parent),
m_changed(false),
m_object(NULL),
- m_object_mod(NULL),
- m_valTree(NULL)
+ m_object_mod(NULL)
{
setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, SIGNAL(changed(bool)), SLOT(setChanged(bool)));
- connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), SLOT(contextMenu(const QPoint&)));
+ connect(this, SIGNAL(customContextMenuRequested(QPoint)), SLOT(contextMenu(QPoint)));
}
Pokemodr::ObjectUI::~ObjectUI()
@@ -126,73 +121,7 @@ void Pokemodr::ObjectUI::contextMenu(const QPoint& pos)
void Pokemodr::ObjectUI::validate()
{
- KProgressDialog* progress = new KProgressDialog(this, "Validating", "Please wait");
- progress->progressBar()->setRange(0, 0);
- progress->setAllowCancel(false);
- progress->setModal(true);
- progress->show();
- if (!m_valTree)
- m_valTree = new QTreeWidget;
- m_valTree->setHeaderHidden(true);
- m_parents.clear();
- m_warnings = 0;
- m_errors = 0;
- m_valTree->clear();
- connect(m_object, SIGNAL(valMessage(const QString&)), this, SLOT(addMessage(const QString&)));
- connect(m_object, SIGNAL(valWarning(const QString&)), this, SLOT(addWarning(const QString&)));
- connect(m_object, SIGNAL(valError(const QString&)), this, SLOT(addError(const QString&)));
- m_object->validate();
- delete progress;
- KDialog* dialog = new KDialog(this);
- dialog->setCaption("Validation Messages");
- dialog->setButtons(KDialog::Ok);
- QWidget* widget = new QWidget(this);
- QVBoxLayout* layout = new QVBoxLayout(widget);
- layout->addWidget(new QLabel(QString("Warnings: %1\nErrors: %2").arg(m_warnings).arg(m_errors), widget));
- layout->addWidget(m_valTree);
- dialog->setMainWidget(widget);
- dialog->exec();
- delete dialog;
- m_valTree = NULL;
- disconnect(m_object, SIGNAL(valMessage(const QString&)), this, SLOT(addMessage(const QString&)));
- disconnect(m_object, SIGNAL(valWarning(const QString&)), this, SLOT(addWarning(const QString&)));
- disconnect(m_object, SIGNAL(valError(const QString&)), this, SLOT(addError(const QString&)));
-}
-
-void Pokemodr::ObjectUI::addMessage(const QString& msg)
-{
- QTreeWidgetItem* item;
- if (msg.startsWith("++"))
- {
- if (m_parents.size())
- item = new QTreeWidgetItem(m_parents.top(), QStringList(msg.mid(2)));
- else
- item = new QTreeWidgetItem(m_valTree, QStringList(msg.mid(2)));
- m_parents.push(item);
- }
- else if (msg.startsWith("--"))
- m_parents.pop();
- else
- {
- item = new QTreeWidgetItem(m_parents.top(), QStringList(msg));
- item->setBackground(0, KStatefulBrush(KColorScheme::View, KColorScheme::PositiveBackground).brush(QPalette::Normal));
- }
-}
-
-void Pokemodr::ObjectUI::addWarning(const QString& msg)
-{
- ++m_warnings;
- QTreeWidgetItem* item;
- item = new QTreeWidgetItem(m_parents.top(), QStringList(msg));
- item->setBackground(0, KStatefulBrush(KColorScheme::View, KColorScheme::NeutralBackground).brush(QPalette::Normal));
-}
-
-void Pokemodr::ObjectUI::addError(const QString& msg)
-{
- ++m_errors;
- QTreeWidgetItem* item;
- item = new QTreeWidgetItem(m_parents.top(), QStringList(msg));
- item->setBackground(0, KStatefulBrush(KColorScheme::View, KColorScheme::NegativeBackground).brush(QPalette::Normal));
+ new ValidationDialog(m_object, this);
}
void Pokemodr::ObjectUI::setObjects(Pokemod::Object* original, Pokemod::Object* modified)
@@ -201,9 +130,9 @@ void Pokemodr::ObjectUI::setObjects(Pokemod::Object* original, Pokemod::Object*
m_object_mod = modified;
connect(m_object_mod, SIGNAL(changed()), this, SIGNAL(changed()));
connect(m_object_mod, SIGNAL(changed()), this, SLOT(setGui()));
- connect(m_object_mod, SIGNAL(error(const QString&)), this, SLOT(setGui()));
- connect(m_object_mod, SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&)));
- connect(m_object_mod, SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&)));
+ connect(m_object_mod, SIGNAL(error(QString)), this, SLOT(setGui()));
+ connect(m_object_mod, SIGNAL(error(QString)), this, SLOT(errorMessage(QString)));
+ connect(m_object_mod, SIGNAL(warning(QString)), this, SLOT(warningMessage(QString)));
init();
}
diff --git a/pokemodr/ObjectUI.h b/pokemodr/ObjectUI.h
index cacfbd39..f2259fee 100644
--- a/pokemodr/ObjectUI.h
+++ b/pokemodr/ObjectUI.h
@@ -19,13 +19,9 @@
#define __POKEMODR_OBJECTUI__
// Qt includes
-#include <QtCore/QStack>
#include <QtGui/QWidget>
// Forward declarations
-class QCloseEvent;
-class QTreeWidget;
-class QTreeWidgetItem;
namespace Pokemod
{
class Object;
@@ -69,9 +65,6 @@ class ObjectUI : public QWidget
void contextMenu(const QPoint& pos);
void validate();
- void addMessage(const QString& msg);
- void addWarning(const QString& msg);
- void addError(const QString& msg);
protected:
void setObjects(Pokemod::Object* original, Pokemod::Object* modified);
@@ -81,11 +74,6 @@ class ObjectUI : public QWidget
Pokemod::Object* m_object;
Pokemod::Object* m_object_mod;
-
- QStack<QTreeWidgetItem*> m_parents;
- QTreeWidget* m_valTree;
- int m_errors;
- int m_warnings;
};
}
diff --git a/pokemodr/ValidationDialog.cpp b/pokemodr/ValidationDialog.cpp
new file mode 100644
index 00000000..a9310c7e
--- /dev/null
+++ b/pokemodr/ValidationDialog.cpp
@@ -0,0 +1,107 @@
+/*
+ * Copyright 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 "ValidationDialog.h"
+
+// Pokemod includes
+#include "../pokemod/Object.h"
+
+// Qt includes
+#include <QtGui/QLabel>
+#include <QtGui/QTreeWidget>
+#include <QtGui/QVBoxLayout>
+
+// KDE includes
+#include <KColorScheme>
+#include <KMessageBox>
+#include <KProgressDialog>
+
+Pokemodr::ValidationDialog::ValidationDialog(Pokemod::Object* object, QWidget* parent) :
+ QWidget(parent),
+ m_valTree(new QTreeWidget),
+ m_errors(0),
+ m_warnings(0)
+{
+ KProgressDialog* progress = new KProgressDialog(this, "Validating", "Please wait");
+ progress->progressBar()->setRange(0, 0);
+ progress->setAllowCancel(false);
+ progress->setModal(true);
+ progress->show();
+ m_valTree->setHeaderHidden(true);
+ m_parents.push(ObjectErrorCount(m_valTree->invisibleRootItem(), 0));
+ connect(object, SIGNAL(valMessage(QString)), this, SLOT(addMessage(QString)));
+ connect(object, SIGNAL(valWarning(QString)), this, SLOT(addWarning(QString)));
+ connect(object, SIGNAL(valError(QString)), this, SLOT(addError(QString)));
+ object->validate();
+ delete progress;
+ if (m_parents.top().second)
+ {
+ m_valTree->addTopLevelItem(m_parents.top().first);
+ KDialog* dialog = new KDialog(this);
+ dialog->setCaption("Validation Messages");
+ dialog->setButtons(KDialog::Ok);
+ QWidget* widget = new QWidget(this);
+ QVBoxLayout* layout = new QVBoxLayout(widget);
+ layout->addWidget(new QLabel(QString("Warnings: %1\nErrors: %2").arg(m_warnings).arg(m_errors), widget));
+ layout->addWidget(m_valTree);
+ dialog->setMainWidget(widget);
+ dialog->exec();
+ delete dialog;
+ }
+ else
+ KMessageBox::information(this, "No messages", "Validation");
+ disconnect(object, SIGNAL(valMessage(QString)), this, SLOT(addMessage(QString)));
+ disconnect(object, SIGNAL(valWarning(QString)), this, SLOT(addWarning(QString)));
+ disconnect(object, SIGNAL(valError(QString)), this, SLOT(addError(QString)));
+}
+
+void Pokemodr::ValidationDialog::insertMessage(const QString& msg, const QBrush& brush)
+{
+ ++m_parents.top().second;
+ QTreeWidgetItem* item = new QTreeWidgetItem(m_parents.top().first, QStringList(msg));
+ item->setBackground(0, brush);
+}
+
+void Pokemodr::ValidationDialog::addMessage(const QString& msg)
+{
+ if (msg.startsWith("++"))
+ m_parents.push(ObjectErrorCount(new QTreeWidgetItem(QStringList(msg.mid(2))), 0));
+ else if (msg.startsWith("--"))
+ {
+ ObjectErrorCount count = m_parents.pop();
+ if (count.second)
+ {
+ m_parents.top().first->addChild(count.first);
+ ++m_parents.top().second;
+ }
+ }
+ else
+ insertMessage(msg, KStatefulBrush(KColorScheme::View, KColorScheme::PositiveBackground).brush(QPalette::Normal));
+}
+
+void Pokemodr::ValidationDialog::addError(const QString& msg)
+{
+ insertMessage(msg, KStatefulBrush(KColorScheme::View, KColorScheme::NegativeBackground).brush(QPalette::Normal));
+ ++m_errors;
+}
+
+void Pokemodr::ValidationDialog::addWarning(const QString& msg)
+{
+ insertMessage(msg, KStatefulBrush(KColorScheme::View, KColorScheme::NeutralBackground).brush(QPalette::Normal));
+ ++m_warnings;
+}
diff --git a/pokemodr/ValidationDialog.h b/pokemodr/ValidationDialog.h
new file mode 100644
index 00000000..a0be6685
--- /dev/null
+++ b/pokemodr/ValidationDialog.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright 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/>.
+ */
+
+#ifndef __POKEMODR_VALIDATIONDIALOG__
+#define __POKEMODR_VALIDATIONDIALOG__
+
+// Qt includes
+#include <QtCore/QPair>
+#include <QtCore/QStack>
+#include <QtGui/QWidget>
+
+// Forward declarations
+class QBrush;
+class QTreeWidget;
+class QTreeWidgetItem;
+namespace Pokemod
+{
+class Object;
+}
+
+namespace Pokemodr
+{
+class ValidationDialog : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ ValidationDialog(Pokemod::Object* object, QWidget* parent);
+
+ typedef QPair<QTreeWidgetItem*, int> ObjectErrorCount;
+ protected:
+ void insertMessage(const QString& msg, const QBrush& brush);
+ public slots:
+ void addMessage(const QString& msg);
+ void addWarning(const QString& msg);
+ void addError(const QString& msg);
+ private:
+ QStack<ObjectErrorCount> m_parents;
+ QTreeWidget* m_valTree;
+ int m_errors;
+ int m_warnings;
+};
+}
+
+#endif
diff --git a/pokemodr/gui/move.ui b/pokemodr/gui/move.ui
index 47d77adc..fa83035b 100644
--- a/pokemodr/gui/move.ui
+++ b/pokemodr/gui/move.ui
@@ -215,7 +215,7 @@
<item>
<widget class="QGroupBox" name="boxWorldScript" >
<property name="title" >
- <string>WorldScript</string>
+ <string>World Script</string>
</property>
<property name="toolTip" >
<string>The script that controls the move when used in the overworld</string>
diff --git a/pokescripting/PokemodWrapper.cpp b/pokescripting/PokemodWrapper.cpp
index 65befc51..149cd283 100644
--- a/pokescripting/PokemodWrapper.cpp
+++ b/pokescripting/PokemodWrapper.cpp
@@ -171,6 +171,44 @@ Pokescripting::WeatherWrapper* Pokescripting::PokemodWrapper::weather(const int
return WeatherWrapper::create(m_pokemod->weatherById(id), this);
}
+Pokemod::Stat Pokescripting::PokemodWrapper::stat(const QString& name) const
+{
+ if (name == "HP")
+ return Pokemod::ST_HP;
+ else if (name == "Attack")
+ return Pokemod::ST_Attack;
+ else if (name == "Defense")
+ return Pokemod::ST_Defense;
+ else if (name == "Speed")
+ return Pokemod::ST_Speed;
+ else if (name == "Special")
+ return Pokemod::ST_Special;
+ else if (name == "Special Attack")
+ return Pokemod::ST_SpecialAttack;
+ else if (name == "Special Defense")
+ return Pokemod::ST_SpecialAttack;
+ else if (name == "Accuracy")
+ return Pokemod::ST_Accuracy;
+ else if (name == "Evasion")
+ return Pokemod::ST_Evasion;
+ return Pokemod::ST_Invalid;
+}
+
+Pokemod::Direction Pokescripting::PokemodWrapper::direction(const QString& name) const
+{
+ if (name == "Up")
+ return Pokemod::D_Up;
+ else if (name == "Down")
+ return Pokemod::D_Down;
+ else if (name == "Left")
+ return Pokemod::D_Left;
+ else if (name == "Right")
+ return Pokemod::D_Right;
+ else if (name == "None")
+ return Pokemod::D_None;
+ return Pokemod::D_Invalid;
+}
+
QString Pokescripting::PokemodWrapper::title() const
{
return m_pokemod->title();
diff --git a/pokescripting/PokemodWrapper.h b/pokescripting/PokemodWrapper.h
index f782fdb5..cf97c60c 100644
--- a/pokescripting/PokemodWrapper.h
+++ b/pokescripting/PokemodWrapper.h
@@ -85,6 +85,9 @@ class POKESCRIPTING_EXPORT PokemodWrapper : public ObjectWrapper
TypeWrapper* type(const int id);
WeatherWrapper* weather(const int id);
+ Q_SCRIPTABLE Pokemod::Stat stat(const QString& name) const;
+ Q_SCRIPTABLE Pokemod::Direction direction(const QString& direction) const;
+
Q_SCRIPTABLE QString title() const;
Q_SCRIPTABLE QString version() const;
Q_SCRIPTABLE QString description() const;
diff --git a/pokescripting/TileWrapper.cpp b/pokescripting/TileWrapper.cpp
index 8cec95f5..648bd39d 100644
--- a/pokescripting/TileWrapper.cpp
+++ b/pokescripting/TileWrapper.cpp
@@ -20,6 +20,7 @@
// Pokescripting includes
#include "PokemodWrapper.h"
+#include "SpriteWrapper.h"
Pokescripting::TileWrapper* Pokescripting::TileWrapper::create(const Pokemod::Tile* tile, PokemodWrapper* parent)
{
@@ -43,7 +44,9 @@ Pokescripting::SpriteWrapper* Pokescripting::TileWrapper::sprite()
{
if (value("sprite").canConvert<QString>())
{
- // TODO: Check sprite dimensions
+ SpriteWrapper* sprite = pokemod()->sprite(value("sprite").toString());
+ if (sprite && sprite->sprite().size() == QSize(64, 64))
+ return sprite;
}
return pokemod()->sprite(m_tile->sprite());
}