From 56b91df6010a9f3d304438cf95816399a6e46622 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 4 Aug 2008 23:06:44 +0000 Subject: [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 --- pokescripting/MapTrainerWrapper.h | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'pokescripting/MapTrainerWrapper.h') 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(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(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(this)); + return MapTrainerTeamMemberWrapper::create(m_trainer->teamMember(index), this); } inline int MapTrainerWrapper::teamMemberCount() const -- cgit