summaryrefslogtreecommitdiffstats
path: root/pokescripting
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-08-04 17:44:07 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-08-04 17:44:07 +0000
commitc014db49f5044f15e7ad0236437ac9ae4aa3b23f (patch)
treeba9b1fe82b1a43155b99259d324ff444f1cdcf14 /pokescripting
parent38b4604019a93ecd053939e8e722fd36b8d7236d (diff)
downloadsigen-c014db49f5044f15e7ad0236437ac9ae4aa3b23f.tar.gz
sigen-c014db49f5044f15e7ad0236437ac9ae4aa3b23f.tar.xz
sigen-c014db49f5044f15e7ad0236437ac9ae4aa3b23f.zip
[FIX] Move no longer uses the overworld flag (will just check to see if the worldScript is empty)
[FIX] TeamMember now inherits from Config [FIX] Wrapper now inherit from Config git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@235 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokescripting')
-rw-r--r--pokescripting/AbilityWrapper.h1
-rw-r--r--pokescripting/Config.cpp30
-rw-r--r--pokescripting/Config.h11
-rw-r--r--pokescripting/MoveWrapper.h6
-rw-r--r--pokescripting/ObjectWrapper.h6
-rw-r--r--pokescripting/TODO1
6 files changed, 43 insertions, 12 deletions
diff --git a/pokescripting/AbilityWrapper.h b/pokescripting/AbilityWrapper.h
index 68c918af..aa749e66 100644
--- a/pokescripting/AbilityWrapper.h
+++ b/pokescripting/AbilityWrapper.h
@@ -29,6 +29,7 @@ namespace Pokescripting
class POKESCRIPTING_EXPORT AbilityWrapper : public ObjectWrapper
{
Q_OBJECT
+
public:
AbilityWrapper(const Pokemod::Ability* ability, QObject* parent);
public slots:
diff --git a/pokescripting/Config.cpp b/pokescripting/Config.cpp
index 8e429fb8..3e2e3adc 100644
--- a/pokescripting/Config.cpp
+++ b/pokescripting/Config.cpp
@@ -34,9 +34,37 @@ void Pokescripting::Config::setValue(const QString& name, const QVariant& value)
m_values[name] = value;
}
-QVariant Pokescripting::Config::value(const QString& name)
+void Pokescripting::Config::removeValue(const QString& name)
+{
+ m_values.remove(name);
+}
+
+QVariant Pokescripting::Config::value(const QString& name, const bool recursive) const
{
if (m_values.contains(name))
return m_values[name];
+ if (recursive)
+ {
+ QObject* par = parent();
+ while (par)
+ {
+ if (qobject_cast<Config*>(par) && qobject_cast<Config*>(par)->hasValue(name))
+ return qobject_cast<Config*>(par)->value(name);
+ par = par->parent();
+ }
+ }
return QVariant();
}
+
+bool Pokescripting::Config::hasValue(const QString& name, const bool recursive) const
+{
+ if (m_values.contains(name))
+ return true;
+ if (recursive && qobject_cast<Config*>(parent()))
+ return qobject_cast<Config*>(parent())->hasValue(name, true);
+ return false;
+}
+
+void Pokescripting::Config::writeBack()
+{
+}
diff --git a/pokescripting/Config.h b/pokescripting/Config.h
index 21dab83f..338c4bb6 100644
--- a/pokescripting/Config.h
+++ b/pokescripting/Config.h
@@ -18,6 +18,9 @@
#ifndef __POKESCRIPTING_CONFIG__
#define __POKESCRIPTING_CONFIG__
+// Pokescripting includes
+#include "Global.h"
+
// Qt includes
#include <QtCore/QMap>
#include <QtCore/QObject>
@@ -32,7 +35,7 @@ class Pokemod;
namespace Pokescripting
{
-class Config : public QObject
+class POKESCRIPTING_EXPORT Config : public QObject
{
Q_OBJECT
@@ -41,7 +44,11 @@ class Config : public QObject
public slots:
void addValue(const QString& name, const QVariant& value);
void setValue(const QString& name, const QVariant& value);
- QVariant value(const QString& name);
+ void removeValue(const QString& name);
+ QVariant value(const QString& name, const bool recursive = true) const;
+ bool hasValue(const QString& name, const bool recursive = false) const;
+
+ virtual void writeBack();
private:
QMap<QString, QVariant> m_values;
};
diff --git a/pokescripting/MoveWrapper.h b/pokescripting/MoveWrapper.h
index eab6d53f..7dbb48cf 100644
--- a/pokescripting/MoveWrapper.h
+++ b/pokescripting/MoveWrapper.h
@@ -39,7 +39,6 @@ class POKESCRIPTING_EXPORT MoveWrapper : public ObjectWrapper
int power() const;
const TypeWrapper* type() const;
bool special() const;
- bool overworld() const;
int powerPoints() const;
int priority() const;
QString description() const;
@@ -80,11 +79,6 @@ inline bool MoveWrapper::special() const
return m_move->special();
}
-inline bool MoveWrapper::overworld() const
-{
- return m_move->overworld();
-}
-
inline int MoveWrapper::powerPoints() const
{
return m_move->powerPoints();
diff --git a/pokescripting/ObjectWrapper.h b/pokescripting/ObjectWrapper.h
index 5c26f6dc..8b3aee29 100644
--- a/pokescripting/ObjectWrapper.h
+++ b/pokescripting/ObjectWrapper.h
@@ -19,7 +19,7 @@
#define __POKESCRIPTING_OBJECTWRAPPER__
// Pokescripting includes
-#include "Global.h"
+#include "Config.h"
// Pokemod includes
#include "../pokemod/Object.h"
@@ -30,7 +30,7 @@
namespace Pokescripting
{
-class POKESCRIPTING_EXPORT ObjectWrapper : public QObject
+class POKESCRIPTING_EXPORT ObjectWrapper : public Config
{
Q_OBJECT
Q_PROPERTY(int id READ id)
@@ -45,7 +45,7 @@ class POKESCRIPTING_EXPORT ObjectWrapper : public QObject
};
inline ObjectWrapper::ObjectWrapper(const Pokemod::Object* object, QObject* parent) :
- QObject(parent),
+ Config(parent),
m_object(object)
{
}
diff --git a/pokescripting/TODO b/pokescripting/TODO
new file mode 100644
index 00000000..eafd89bb
--- /dev/null
+++ b/pokescripting/TODO
@@ -0,0 +1 @@
+Make it a mirror (dont create another Wrapper instance if one has already been created)