summaryrefslogtreecommitdiffstats
path: root/pokescripting/MapTrainerWrapper.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/MapTrainerWrapper.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/MapTrainerWrapper.h')
-rw-r--r--pokescripting/MapTrainerWrapper.h24
1 files changed, 15 insertions, 9 deletions
diff --git a/pokescripting/MapTrainerWrapper.h b/pokescripting/MapTrainerWrapper.h
index c6554d55..1e558a04 100644
--- a/pokescripting/MapTrainerWrapper.h
+++ b/pokescripting/MapTrainerWrapper.h
@@ -33,16 +33,22 @@ class POKESCRIPTING_EXPORT MapTrainerWrapper : public ObjectWrapper
Q_OBJECT
public:
- MapTrainerWrapper(const Pokemod::MapTrainer* trainer, QObject* parent);
+ static MapTrainerWrapper* create(const Pokemod::MapTrainer* trainer, QObject* parent)
+ {
+ if (!m_instances.contains(trainer->id()))
+ m_instances[trainer->id()] = new MapTrainerWrapper(trainer, parent);
+ return qobject_cast<MapTrainerWrapper*>(m_instances[trainer->id()]);
+ }
public slots:
QString name() const;
- const TrainerWrapper* trainerClass() const;
+ TrainerWrapper* trainerClass();
int numberFight() const;
- const MapTrainerTeamMemberWrapper* leadTeamMember() const;
+ MapTrainerTeamMemberWrapper* leadTeamMember();
- const MapTrainerTeamMemberWrapper* teamMember(const int index) const;
+ MapTrainerTeamMemberWrapper* teamMember(const int index);
int teamMemberCount() const;
private:
+ MapTrainerWrapper(const Pokemod::MapTrainer* trainer, QObject* parent);
MapTrainerWrapper& operator=(const MapTrainerWrapper& rhs);
const Pokemod::MapTrainer* m_trainer;
@@ -59,9 +65,9 @@ inline QString MapTrainerWrapper::name() const
return m_trainer->name();
}
-inline const TrainerWrapper* MapTrainerWrapper::trainerClass() const
+inline TrainerWrapper* MapTrainerWrapper::trainerClass()
{
- return new TrainerWrapper(pokemod()->trainerById(m_trainer->trainerClass()), const_cast<MapTrainerWrapper*>(this));
+ return TrainerWrapper::create(pokemod()->trainerById(m_trainer->trainerClass()), this);
}
inline int MapTrainerWrapper::numberFight() const
@@ -69,14 +75,14 @@ inline int MapTrainerWrapper::numberFight() const
return m_trainer->numberFight();
}
-inline const MapTrainerTeamMemberWrapper* MapTrainerWrapper::leadTeamMember() const
+inline MapTrainerTeamMemberWrapper* MapTrainerWrapper::leadTeamMember()
{
return teamMember(m_trainer->leadTeamMember());
}
-inline const MapTrainerTeamMemberWrapper* MapTrainerWrapper::teamMember(const int index) const
+inline MapTrainerTeamMemberWrapper* MapTrainerWrapper::teamMember(const int index)
{
- return new MapTrainerTeamMemberWrapper(m_trainer->teamMember(index), const_cast<MapTrainerWrapper*>(this));
+ return MapTrainerTeamMemberWrapper::create(m_trainer->teamMember(index), this);
}
inline int MapTrainerWrapper::teamMemberCount() const