diff options
Diffstat (limited to 'pokescripting/MapWarpWrapper.h')
| -rw-r--r-- | pokescripting/MapWarpWrapper.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/pokescripting/MapWarpWrapper.h b/pokescripting/MapWarpWrapper.h index 5d1dd8ec..8bc3a7da 100644 --- a/pokescripting/MapWarpWrapper.h +++ b/pokescripting/MapWarpWrapper.h @@ -32,13 +32,19 @@ class POKESCRIPTING_EXPORT MapWarpWrapper : public ObjectWrapper Q_OBJECT public: - MapWarpWrapper(const Pokemod::MapWarp* warp, QObject* parent); + static MapWarpWrapper* create(const Pokemod::MapWarp* warp, QObject* parent) + { + if (!m_instances.contains(warp->id())) + m_instances[warp->id()] = new MapWarpWrapper(warp, parent); + return qobject_cast<MapWarpWrapper*>(m_instances[warp->id()]); + } public slots: QString name() const; QPoint coordinate() const; int type() const; - const MapWarpWrapper* toWarp() const; + MapWarpWrapper* toWarp(); private: + MapWarpWrapper(const Pokemod::MapWarp* warp, QObject* parent); MapWarpWrapper& operator=(const MapWarpWrapper& rhs); const Pokemod::MapWarp* m_warp; @@ -65,9 +71,9 @@ inline int MapWarpWrapper::type() const return m_warp->type(); } -inline const MapWarpWrapper* MapWarpWrapper::toWarp() const +inline MapWarpWrapper* MapWarpWrapper::toWarp() { - return new MapWarpWrapper(pokemod()->mapById(m_warp->toMap())->warpById(m_warp->toWarp()), const_cast<MapWarpWrapper*>(this)); + return new MapWarpWrapper(pokemod()->mapById(m_warp->toMap())->warpById(m_warp->toWarp()), this); } } |
