summaryrefslogtreecommitdiffstats
path: root/pokescripting/MapWrapper.h
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-08-04 23:06:44 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-08-04 23:06:44 +0000
commit56b91df6010a9f3d304438cf95816399a6e46622 (patch)
tree4fc79267d86ebca445c91e00630cb29cfc5c1da4 /pokescripting/MapWrapper.h
parentc014db49f5044f15e7ad0236437ac9ae4aa3b23f (diff)
downloadsigen-56b91df6010a9f3d304438cf95816399a6e46622.tar.gz
sigen-56b91df6010a9f3d304438cf95816399a6e46622.tar.xz
sigen-56b91df6010a9f3d304438cf95816399a6e46622.zip
[FIX] SoundUI widget has a better layout
[FIX] Sound playback works in SoundUI [FIX] SoundWrapper returns a Phonon object for playback in scripts now [FIX] Wrapper classes now won't be duplicated (persistent storage is possible now) [FIX] Linking to libraries is fixed for RPM [FIX] Pokemod Macros.h is hidden if not compiling pokemod [FIX] make-tarball script is simpler now (and works as upstream, not local copy) [FIX] Cleaned up spec file per review request for Fedora git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@236 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokescripting/MapWrapper.h')
-rw-r--r--pokescripting/MapWrapper.h44
1 files changed, 25 insertions, 19 deletions
diff --git a/pokescripting/MapWrapper.h b/pokescripting/MapWrapper.h
index 7221b1cc..50cd207b 100644
--- a/pokescripting/MapWrapper.h
+++ b/pokescripting/MapWrapper.h
@@ -36,19 +36,25 @@ class POKESCRIPTING_EXPORT MapWrapper : public ObjectWrapper
Q_OBJECT
public:
- MapWrapper(const Pokemod::Map* map, QObject* parent);
+ static MapWrapper* create(const Pokemod::Map* map, QObject* parent)
+ {
+ if (!m_instances.contains(map->id()))
+ m_instances[map->id()] = new MapWrapper(map, parent);
+ return qobject_cast<MapWrapper*>(m_instances[map->id()]);
+ }
public slots:
QString name() const;
- const MapWarpWrapper* flyWarp() const;
+ MapWarpWrapper* flyWarp();
int type() const;
- const TileWrapper* tile(const int row, const int column) const;
+ TileWrapper* tile(const int row, const int column);
QPoint mapSize() const;
- const MapEffectWrapper* effect(const QString& name) const;
- const MapTrainerWrapper* trainer(const QString& name) const;
- const MapWarpWrapper* warp(const QString& name) const;
- const MapWildListWrapper* wildList(const QString& name) const;
+ MapEffectWrapper* effect(const QString& name);
+ MapTrainerWrapper* trainer(const QString& name);
+ MapWarpWrapper* warp(const QString& name);
+ MapWildListWrapper* wildList(const QString& name);
private:
+ MapWrapper(const Pokemod::Map* map, QObject* parent);
MapWrapper& operator=(const MapWrapper& rhs);
const Pokemod::Map* m_map;
@@ -65,9 +71,9 @@ inline QString MapWrapper::name() const
return m_map->name();
}
-inline const MapWarpWrapper* MapWrapper::flyWarp() const
+inline MapWarpWrapper* MapWrapper::flyWarp()
{
- return new MapWarpWrapper(m_map->warpById(m_map->flyWarp()), const_cast<MapWrapper*>(this));
+ return MapWarpWrapper::create(m_map->warpById(m_map->flyWarp()), this);
}
inline int MapWrapper::type() const
@@ -75,9 +81,9 @@ inline int MapWrapper::type() const
return m_map->type();
}
-inline const TileWrapper* MapWrapper::tile(const int row, const int column) const
+inline TileWrapper* MapWrapper::tile(const int row, const int column)
{
- return new TileWrapper(pokemod()->tileById(m_map->tile(row, column)), const_cast<MapWrapper*>(this));
+ return TileWrapper::create(pokemod()->tileById(m_map->tile(row, column)), this);
}
inline QPoint MapWrapper::mapSize() const
@@ -85,42 +91,42 @@ inline QPoint MapWrapper::mapSize() const
return m_map->size();
}
-inline const MapEffectWrapper* MapWrapper::effect(const QString& name) const
+inline MapEffectWrapper* MapWrapper::effect(const QString& name)
{
for (int i = 0; i < m_map->effectCount(); ++i)
{
if (m_map->effect(i)->name() == name)
- return new MapEffectWrapper(m_map->effect(i), const_cast<MapWrapper*>(this));
+ return MapEffectWrapper::create(m_map->effect(i), this);
}
return NULL;
}
-inline const MapTrainerWrapper* MapWrapper::trainer(const QString& name) const
+inline MapTrainerWrapper* MapWrapper::trainer(const QString& name)
{
for (int i = 0; i < m_map->trainerCount(); ++i)
{
if (m_map->trainer(i)->name() == name)
- return new MapTrainerWrapper(m_map->trainer(i), const_cast<MapWrapper*>(this));
+ return MapTrainerWrapper::create(m_map->trainer(i), this);
}
return NULL;
}
-inline const MapWarpWrapper* MapWrapper::warp(const QString& name) const
+inline MapWarpWrapper* MapWrapper::warp(const QString& name)
{
for (int i = 0; i < m_map->warpCount(); ++i)
{
if (m_map->warp(i)->name() == name)
- return new MapWarpWrapper(m_map->warp(i), const_cast<MapWrapper*>(this));
+ return MapWarpWrapper::create(m_map->warp(i), this);
}
return NULL;
}
-inline const MapWildListWrapper* MapWrapper::wildList(const QString& name) const
+inline MapWildListWrapper* MapWrapper::wildList(const QString& name)
{
for (int i = 0; i < m_map->wildListCount(); ++i)
{
if (m_map->wildList(i)->name() == name)
- return new MapWildListWrapper(m_map->wildList(i), const_cast<MapWrapper*>(this));
+ return MapWildListWrapper::create(m_map->wildList(i), this);
}
return NULL;
}