From c1793a87ebea8c8e1bb2d5d1a409d105bfae3871 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 18 Aug 2008 18:51:31 +0000 Subject: [FIX] Script to make a tarball now defaults to HEAD for the revision [FIX] Enumeration types used to help remove some checks [FIX] Macro code moved to static members of Object (not all though) [FIX] Scripting wrappers now share information by keeping track of already-created instances of the wrapper [FIX] Scripting methods are now Q_SCRIPTABLE and not slots git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@239 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- pokescripting/SpeciesWrapper.cpp | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'pokescripting/SpeciesWrapper.cpp') diff --git a/pokescripting/SpeciesWrapper.cpp b/pokescripting/SpeciesWrapper.cpp index 9c2737e4..23f76082 100644 --- a/pokescripting/SpeciesWrapper.cpp +++ b/pokescripting/SpeciesWrapper.cpp @@ -19,17 +19,19 @@ #include "SpeciesWrapper.h" // Pokescripting includes -#include "AbilityWrapper.h" -#include "EggGroupWrapper.h" -#include "ItemWrapper.h" -#include "SkinWrapper.h" +#include "PokemodWrapper.h" #include "SpeciesAbilityWrapper.h" #include "SpeciesItemWrapper.h" #include "SpeciesMoveWrapper.h" -#include "SpriteWrapper.h" -#include "TypeWrapper.h" -Pokescripting::SpeciesWrapper::SpeciesWrapper(const Pokemod::Species* species, QObject* parent) : +Pokescripting::SpeciesWrapper* Pokescripting::SpeciesWrapper::create(const Pokemod::Species* species, PokemodWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, species->id()))) + m_instances[Signiture(parent, species->id())] = new SpeciesWrapper(species, parent); + return qobject_cast(m_instances[Signiture(parent, species->id())]); +} + +Pokescripting::SpeciesWrapper::SpeciesWrapper(const Pokemod::Species* species, PokemodWrapper* parent) : ObjectWrapper(species, parent), m_species(species) { @@ -56,17 +58,17 @@ QString Pokescripting::SpeciesWrapper::name() const return m_species->name(); } -int Pokescripting::SpeciesWrapper::baseStat(const int stat) const +int Pokescripting::SpeciesWrapper::baseStat(const Pokemod::Stat stat) const { return m_species->baseStat(stat); } -int Pokescripting::SpeciesWrapper::effortValue(const int stat) const +int Pokescripting::SpeciesWrapper::effortValue(const Pokemod::Stat stat) const { return m_species->effortValue(stat); } -int Pokescripting::SpeciesWrapper::growth() const +Pokemod::Species::Style Pokescripting::SpeciesWrapper::growth() const { return m_species->growth(); } @@ -124,27 +126,27 @@ QString Pokescripting::SpeciesWrapper::pokedexEntry() const Pokescripting::SpriteWrapper* Pokescripting::SpeciesWrapper::frontMaleSprite() { - return SpriteWrapper::create(pokemod()->spriteById(m_species->frontMaleSprite()), this); + return pokemod()->sprite(m_species->frontMaleSprite()); } Pokescripting::SpriteWrapper* Pokescripting::SpeciesWrapper::backMaleSprite() { - return SpriteWrapper::create(pokemod()->spriteById(m_species->backMaleSprite()), this); + return pokemod()->sprite(m_species->backMaleSprite()); } Pokescripting::SpriteWrapper* Pokescripting::SpeciesWrapper::frontFemaleSprite() { - return SpriteWrapper::create(pokemod()->spriteById(m_species->frontFemaleSprite()), this); + return pokemod()->sprite(m_species->frontFemaleSprite()); } Pokescripting::SpriteWrapper* Pokescripting::SpeciesWrapper::backFemaleSprite() { - return SpriteWrapper::create(pokemod()->spriteById(m_species->backFemaleSprite()), this); + return pokemod()->sprite(m_species->backFemaleSprite()); } Pokescripting::SkinWrapper* Pokescripting::SpeciesWrapper::skin() { - return SkinWrapper::create(pokemod()->skinById(m_species->skin()), this); + return pokemod()->skin(m_species->skin()); } Pokemod::Fraction Pokescripting::SpeciesWrapper::genderFactor() const @@ -169,7 +171,7 @@ QList Pokescripting::SpeciesWrapper::types() QList typeIds = m_species->types(); QList types; foreach (int id, typeIds) - types.append(TypeWrapper::create(pokemod()->typeById(id), this)); + types.append(pokemod()->type(id)); return types; } @@ -178,7 +180,7 @@ QList Pokescripting::SpeciesWrapper::eggGroups( QList eggGroupIds = m_species->eggGroups(); QList eggGroups; foreach (int id, eggGroupIds) - eggGroups.append(EggGroupWrapper::create(pokemod()->eggGroupById(id), this)); + eggGroups.append(pokemod()->eggGroup(id)); return eggGroups; } -- cgit