diff options
author | Ben Boeckel <MathStuf@gmail.com> | 2008-09-05 20:41:05 +0000 |
---|---|---|
committer | Ben Boeckel <MathStuf@gmail.com> | 2008-09-05 20:41:05 +0000 |
commit | b81f5bffa2772eb9bd3c67fb35485ab1ee2d96e7 (patch) | |
tree | 6609f31b1635d948cf7a216c7fea72cfb3c905a0 /sigscript | |
parent | b99ffef4aa68dd5f0af64de9aec0f610e267d8cc (diff) | |
download | sigen-b81f5bffa2772eb9bd3c67fb35485ab1ee2d96e7.tar.gz sigen-b81f5bffa2772eb9bd3c67fb35485ab1ee2d96e7.tar.xz sigen-b81f5bffa2772eb9bd3c67fb35485ab1ee2d96e7.zip |
[FIX] Moving stuff for the move to the new name, Sigma Game Engine (sigen for short)
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@249 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'sigscript')
75 files changed, 5139 insertions, 0 deletions
diff --git a/sigscript/AbilityWrapper.cpp b/sigscript/AbilityWrapper.cpp new file mode 100644 index 00000000..c7641c87 --- /dev/null +++ b/sigscript/AbilityWrapper.cpp @@ -0,0 +1,62 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// header include +#include "AbilityWrapper.h" + +// Pokescripting includes +#include "PokemodWrapper.h" + +Pokescripting::AbilityWrapper* Pokescripting::AbilityWrapper::create(const Pokemod::Ability* ability, PokemodWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, ability->id()))) + m_instances[Signiture(parent, ability->id())] = new AbilityWrapper(ability, parent); + return qobject_cast<AbilityWrapper*>(m_instances[Signiture(parent, ability->id())]); +} + +Pokescripting::AbilityWrapper::AbilityWrapper(const Pokemod::Ability* ability, PokemodWrapper* parent) : + ObjectWrapper(ability, parent), + m_ability(ability) +{ +} + +QString Pokescripting::AbilityWrapper::name() const +{ + return m_ability->name(); +} + +int Pokescripting::AbilityWrapper::priority() const +{ + if (value("priority").canConvert<int>()) + return value("priority").toInt(); + return m_ability->priority(); +} + +QString Pokescripting::AbilityWrapper::description() const +{ + return m_ability->description(); +} + +Pokemod::Script Pokescripting::AbilityWrapper::battleScript() const +{ + return m_ability->battleScript(); +} + +Pokemod::Script Pokescripting::AbilityWrapper::worldScript() const +{ + return m_ability->worldScript(); +} diff --git a/sigscript/AbilityWrapper.h b/sigscript/AbilityWrapper.h new file mode 100644 index 00000000..1b1f040b --- /dev/null +++ b/sigscript/AbilityWrapper.h @@ -0,0 +1,50 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_ABILITYWRAPPER__ +#define __POKESCRIPTING_ABILITYWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/Ability.h" + +namespace Pokescripting +{ +class POKESCRIPTING_EXPORT AbilityWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static AbilityWrapper* create(const Pokemod::Ability* ability, PokemodWrapper* parent); + + Q_SCRIPTABLE QString name() const; + Q_SCRIPTABLE int priority() const; + Q_SCRIPTABLE QString description() const; + Q_SCRIPTABLE Pokemod::Script battleScript() const; + Q_SCRIPTABLE Pokemod::Script worldScript() const; + private: + AbilityWrapper(const Pokemod::Ability* ability, PokemodWrapper* parent); + AbilityWrapper& operator=(const AbilityWrapper& rhs); + + const Pokemod::Ability* m_ability; +}; +} +Q_DECLARE_METATYPE(Pokescripting::AbilityWrapper*) + +#endif diff --git a/sigscript/AuthorWrapper.cpp b/sigscript/AuthorWrapper.cpp new file mode 100644 index 00000000..53834074 --- /dev/null +++ b/sigscript/AuthorWrapper.cpp @@ -0,0 +1,50 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "AuthorWrapper.h" + +// Pokescripting includes +#include "PokemodWrapper.h" + +Pokescripting::AuthorWrapper* Pokescripting::AuthorWrapper::create(const Pokemod::Author* author, PokemodWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, author->id()))) + m_instances[Signiture(parent, author->id())] = new AuthorWrapper(author, parent); + return qobject_cast<AuthorWrapper*>(m_instances[Signiture(parent, author->id())]); +} + +Pokescripting::AuthorWrapper::AuthorWrapper(const Pokemod::Author* author, PokemodWrapper* parent) : + ObjectWrapper(author, parent), + m_author(author) +{ +} + +QString Pokescripting::AuthorWrapper::name() const +{ + return m_author->name(); +} + +QString Pokescripting::AuthorWrapper::email() const +{ + return m_author->email(); +} + +QString Pokescripting::AuthorWrapper::role() const +{ + return m_author->role(); +} diff --git a/sigscript/AuthorWrapper.h b/sigscript/AuthorWrapper.h new file mode 100644 index 00000000..706f2d07 --- /dev/null +++ b/sigscript/AuthorWrapper.h @@ -0,0 +1,48 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_AUTHORWRAPPER__ +#define __POKESCRIPTING_AUTHORWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/Author.h" + +namespace Pokescripting +{ +class POKESCRIPTING_EXPORT AuthorWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static AuthorWrapper* create(const Pokemod::Author* author, PokemodWrapper* parent); + + Q_SCRIPTABLE QString name() const; + Q_SCRIPTABLE QString email() const; + Q_SCRIPTABLE QString role() const; + private: + AuthorWrapper(const Pokemod::Author* author, PokemodWrapper* parent); + AuthorWrapper& operator=(const AuthorWrapper& rhs); + + const Pokemod::Author* m_author; +}; +} +Q_DECLARE_METATYPE(Pokescripting::AuthorWrapper*) + +#endif diff --git a/sigscript/BadgeWrapper.cpp b/sigscript/BadgeWrapper.cpp new file mode 100644 index 00000000..0d495a15 --- /dev/null +++ b/sigscript/BadgeWrapper.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "BadgeWrapper.h" + +// Pokescripting includes +#include "PokemodWrapper.h" + +Pokescripting::BadgeWrapper* Pokescripting::BadgeWrapper::create(const Pokemod::Badge* badge, PokemodWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, badge->id()))) + m_instances[Signiture(parent, badge->id())] = new BadgeWrapper(badge, parent); + return qobject_cast<BadgeWrapper*>(m_instances[Signiture(parent, badge->id())]); +} + +Pokescripting::BadgeWrapper::BadgeWrapper(const Pokemod::Badge* badge, PokemodWrapper* parent) : + ObjectWrapper(badge, parent), + m_badge(badge) +{ +} + +QString Pokescripting::BadgeWrapper::name() const +{ + return m_badge->name(); +} + +Pokescripting::SpriteWrapper* Pokescripting::BadgeWrapper::face() +{ + return pokemod()->sprite(m_badge->face()); +} + +Pokescripting::SpriteWrapper* Pokescripting::BadgeWrapper::badge() +{ + return pokemod()->sprite(m_badge->badge()); +} + +int Pokescripting::BadgeWrapper::obey() const +{ + return m_badge->obey(); +} + +Pokemod::Fraction Pokescripting::BadgeWrapper::stat(const Pokemod::Stat stat) const +{ + return m_badge->stat(stat); +} diff --git a/sigscript/BadgeWrapper.h b/sigscript/BadgeWrapper.h new file mode 100644 index 00000000..1feeb6e9 --- /dev/null +++ b/sigscript/BadgeWrapper.h @@ -0,0 +1,53 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_BADGEWRAPPER__ +#define __POKESCRIPTING_BADGEWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/Badge.h" + +namespace Pokescripting +{ +// Forward declarations +class SpriteWrapper; + +class POKESCRIPTING_EXPORT BadgeWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static BadgeWrapper* create(const Pokemod::Badge* badge, PokemodWrapper* parent); + + Q_SCRIPTABLE QString name() const; + Q_SCRIPTABLE SpriteWrapper* face(); + Q_SCRIPTABLE SpriteWrapper* badge(); + Q_SCRIPTABLE int obey() const; + Q_SCRIPTABLE Pokemod::Fraction stat(const Pokemod::Stat stat) const; + private: + BadgeWrapper(const Pokemod::Badge* badge, PokemodWrapper* parent); + BadgeWrapper& operator=(const BadgeWrapper& rhs); + + const Pokemod::Badge* m_badge; +}; +} +Q_DECLARE_METATYPE(Pokescripting::BadgeWrapper*) + +#endif diff --git a/sigscript/CMakeLists.txt b/sigscript/CMakeLists.txt new file mode 100644 index 00000000..81308327 --- /dev/null +++ b/sigscript/CMakeLists.txt @@ -0,0 +1,120 @@ +PROJECT(pokescripting) + +IF(NOT BUILT_FROM_ROOT) + MESSAGE(FATAL_ERROR "Not built from source root") +ENDIF(NOT BUILT_FROM_ROOT) + +ADD_DEFINITIONS(-DMAKE_POKESCRIPTING_LIB) + +SET(pokescripting_MOC_HEADERS + Config.h + AbilityWrapper.h + AuthorWrapper.h + BadgeWrapper.h + CoinListWrapper.h + CoinListObjectWrapper.h + EggGroupWrapper.h + GlobalScriptWrapper.h + ItemWrapper.h + ItemTypeWrapper.h + MapWrapper.h + MapEffectWrapper.h + MapTrainerWrapper.h + MapTrainerTeamMemberWrapper.h + MapWarpWrapper.h + MapWildListWrapper.h + MapWildListEncounterWrapper.h + MoveWrapper.h + NatureWrapper.h + ObjectWrapper.h + PokemodWrapper.h + RulesWrapper.h + SkinWrapper.h + SoundWrapper.h + SpeciesWrapper.h + SpeciesAbilityWrapper.h + SpeciesItemWrapper.h + SpeciesMoveWrapper.h + SpriteWrapper.h + StatusWrapper.h + StoreWrapper.h + TileWrapper.h + TimeWrapper.h + TrainerWrapper.h + TypeWrapper.h + WeatherWrapper.h +) +QT4_WRAP_CPP(pokescripting_MOC_SRCS ${pokescripting_MOC_HEADERS}) +SET(pokescripting_HEADERS +) +SET(pokescripting_DEVEL + ${pokescripting_HEADERS} + ${pokescripting_MOC_HEADERS} +) +SET(pokescripting_SRCS + Config.cpp + AbilityWrapper.cpp + AuthorWrapper.cpp + BadgeWrapper.cpp + CoinListWrapper.cpp + CoinListObjectWrapper.cpp + EggGroupWrapper.cpp + GlobalScriptWrapper.cpp + ItemWrapper.cpp + ItemTypeWrapper.cpp + MapWrapper.cpp + MapEffectWrapper.cpp + MapTrainerWrapper.cpp + MapTrainerTeamMemberWrapper.cpp + MapWarpWrapper.cpp + MapWildListWrapper.cpp + MapWildListEncounterWrapper.cpp + MoveWrapper.cpp + NatureWrapper.cpp + ObjectWrapper.cpp + PokemodWrapper.cpp + RulesWrapper.cpp + SkinWrapper.cpp + SoundWrapper.cpp + SpeciesWrapper.cpp + SpeciesAbilityWrapper.cpp + SpeciesItemWrapper.cpp + SpeciesMoveWrapper.cpp + SpriteWrapper.cpp + StatusWrapper.cpp + StoreWrapper.cpp + TileWrapper.cpp + TimeWrapper.cpp + TrainerWrapper.cpp + TypeWrapper.cpp + WeatherWrapper.cpp +) + +ADD_LIBRARY(pokescripting + ${pokescripting_SRCS} + ${pokescripting_MOC_SRCS} +) +SET_TARGET_PROPERTIES(pokescripting + PROPERTIES + VERSION ${POKEGEN_VERSION} + SOVERSION ${POKEGEN_SOVERSION} + LINK_INTERFACE_LIBRARIES "" +) +TARGET_LINK_LIBRARIES(pokescripting + ${QT_QTCORE_LIBRARY} + ${QT_QTGUI_LIBRARY} + ${PHONON_LIBRARY} + pokemod +) + +INSTALL( + TARGETS pokescripting + DESTINATION ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX} + COMPONENT runtime +) + +INSTALL( + FILES ${pokescripting_DEVEL} + DESTINATION ${CMAKE_INSTALL_PREFIX}/include/${CMAKE_PROJECT_NAME}/${PROJECT_NAME} + COMPONENT development +) diff --git a/sigscript/CoinListObjectWrapper.cpp b/sigscript/CoinListObjectWrapper.cpp new file mode 100644 index 00000000..9ebff168 --- /dev/null +++ b/sigscript/CoinListObjectWrapper.cpp @@ -0,0 +1,78 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "CoinListObjectWrapper.h" + +// Pokescripting includes +#include "CoinListWrapper.h" +#include "PokemodWrapper.h" + +Pokescripting::CoinListObjectWrapper* Pokescripting::CoinListObjectWrapper::create(const Pokemod::CoinListObject* object, CoinListWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, object->id()))) + m_instances[Signiture(parent, object->id())] = new CoinListObjectWrapper(object, parent); + return qobject_cast<CoinListObjectWrapper*>(m_instances[Signiture(parent, object->id())]); +} + +Pokescripting::CoinListObjectWrapper::CoinListObjectWrapper(const Pokemod::CoinListObject* object, CoinListWrapper* parent) : + ObjectWrapper(object, parent), + m_object(object) +{ +} + +Pokemod::CoinListObject::Type Pokescripting::CoinListObjectWrapper::type(const QString& name) const +{ + if (name == "Item") + return Pokemod::CoinListObject::Item; + else if (name == "Species") + return Pokemod::CoinListObject::Species; + return QVariant(-1).value<Pokemod::CoinListObject::Type>(); +} + +Pokemod::CoinListObject::Type Pokescripting::CoinListObjectWrapper::type() const +{ + return m_object->type(); +} + +Pokescripting::ItemWrapper* Pokescripting::CoinListObjectWrapper::itemObject() +{ + if (m_object->type() == Pokemod::CoinListObject::Item) + return pokemod()->item(m_object->object()); + return NULL; +} + +Pokescripting::SpeciesWrapper* Pokescripting::CoinListObjectWrapper::speciesObject() +{ + if (m_object->type() == Pokemod::CoinListObject::Species) + return pokemod()->species(m_object->object()); + return NULL; +} + +int Pokescripting::CoinListObjectWrapper::amount() const +{ + if (value("amount").canConvert<int>()) + return value("amount").toInt(); + return m_object->amount(); +} + +int Pokescripting::CoinListObjectWrapper::cost() const +{ + if (value("cost").canConvert<int>()) + return value("cost").toInt(); + return m_object->cost(); +} diff --git a/sigscript/CoinListObjectWrapper.h b/sigscript/CoinListObjectWrapper.h new file mode 100644 index 00000000..57a2330d --- /dev/null +++ b/sigscript/CoinListObjectWrapper.h @@ -0,0 +1,57 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_COINLISTOBJECTWRAPPER__ +#define __POKESCRIPTING_COINLISTOBJECTWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/CoinListObject.h" + +namespace Pokescripting +{ +// Forward declarations +class CoinListWrapper; +class ItemWrapper; +class SpeciesWrapper; + +class POKESCRIPTING_EXPORT CoinListObjectWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static CoinListObjectWrapper* create(const Pokemod::CoinListObject* object, CoinListWrapper* parent); + + Q_SCRIPTABLE Pokemod::CoinListObject::Type type(const QString& name) const; + + Q_SCRIPTABLE Pokemod::CoinListObject::Type type() const; + Q_SCRIPTABLE ItemWrapper* itemObject(); + Q_SCRIPTABLE SpeciesWrapper* speciesObject(); + Q_SCRIPTABLE int amount() const; + Q_SCRIPTABLE int cost() const; + private: + CoinListObjectWrapper(const Pokemod::CoinListObject* object, CoinListWrapper* parent); + CoinListObjectWrapper& operator=(const CoinListObjectWrapper& rhs); + + const Pokemod::CoinListObject* m_object; +}; +} +Q_DECLARE_METATYPE(Pokescripting::CoinListObjectWrapper*) + +#endif diff --git a/sigscript/CoinListWrapper.cpp b/sigscript/CoinListWrapper.cpp new file mode 100644 index 00000000..38807810 --- /dev/null +++ b/sigscript/CoinListWrapper.cpp @@ -0,0 +1,56 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "CoinListWrapper.h" + +// Pokescripting includes +#include "CoinListObjectWrapper.h" +#include "PokemodWrapper.h" + +Pokescripting::CoinListWrapper* Pokescripting::CoinListWrapper::create(const Pokemod::CoinList* coinList, PokemodWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, coinList->id()))) + m_instances[Signiture(parent, coinList->id())] = new CoinListWrapper(coinList, parent); + return qobject_cast<CoinListWrapper*>(m_instances[Signiture(parent, coinList->id())]); +} + +Pokescripting::CoinListWrapper::CoinListWrapper(const Pokemod::CoinList* coinList, PokemodWrapper* parent) : + ObjectWrapper(coinList, parent), + m_coinList(coinList) +{ +} + +QString Pokescripting::CoinListWrapper::name() const +{ + return m_coinList->name(); +} + +Pokemod::Script Pokescripting::CoinListWrapper::script() const +{ + return m_coinList->script(); +} + +Pokescripting::CoinListObjectWrapper* Pokescripting::CoinListWrapper::object(const int index) +{ + return CoinListObjectWrapper::create(m_coinList->object(index), this); +} + +int Pokescripting::CoinListWrapper::objectCount() const +{ + return m_coinList->objectCount(); +} diff --git a/sigscript/CoinListWrapper.h b/sigscript/CoinListWrapper.h new file mode 100644 index 00000000..819a817e --- /dev/null +++ b/sigscript/CoinListWrapper.h @@ -0,0 +1,54 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_COINLISTWRAPPER__ +#define __POKESCRIPTING_COINLISTWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/CoinList.h" + +namespace Pokescripting +{ +// Forward declarations +class CoinListObjectWrapper; +class PokemodWrapper; + +class POKESCRIPTING_EXPORT CoinListWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static CoinListWrapper* create(const Pokemod::CoinList* coinList, PokemodWrapper* parent); + + Q_SCRIPTABLE QString name() const; + Q_SCRIPTABLE Pokemod::Script script() const; + + Q_SCRIPTABLE CoinListObjectWrapper* object(const int index); + Q_SCRIPTABLE int objectCount() const; + private: + CoinListWrapper(const Pokemod::CoinList* coinList, PokemodWrapper* parent); + CoinListWrapper& operator=(const CoinListWrapper& rhs); + + const Pokemod::CoinList* m_coinList; +}; +} +Q_DECLARE_METATYPE(Pokescripting::CoinListWrapper*) + +#endif diff --git a/sigscript/Config.cpp b/sigscript/Config.cpp new file mode 100644 index 00000000..a0739591 --- /dev/null +++ b/sigscript/Config.cpp @@ -0,0 +1,90 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "Config.h" + +Pokescripting::Config::Config(QObject* parent) : + QObject(parent) +{ +} + +void Pokescripting::Config::addValue(const QString& name, const QVariant& value, const bool temporary) +{ + if (!m_values.contains(name)) + { + setValue(name, value, temporary); + emit(valueAdded(name, value)); + } +} + +void Pokescripting::Config::setValue(const QString& name, const QVariant& value, const bool temporary) +{ + const QVariant& oldValue = m_values[name]; + m_values[name] = value; + if (temporary) + { + if (m_temporaries.contains(name)) + m_temporaries.append(name); + } + else + m_temporaries.removeAll(name); + emit(valueChanged(name, oldValue, value)); +} + +void Pokescripting::Config::removeValue(const QString& name) +{ + m_values.remove(name); + m_temporaries.removeAll(name); + emit(valueRemoved(name)); +} + +QVariant Pokescripting::Config::value(const QString& name, const bool recursive) const +{ + if (m_values.contains(name)) + return m_values[name]; + if (recursive) + { + QObject* par = parent(); + while (par) + { + if (qobject_cast<Config*>(par) && qobject_cast<Config*>(par)->hasValue(name)) + return qobject_cast<Config*>(par)->value(name); + par = par->parent(); + } + } + return QVariant(); +} + +bool Pokescripting::Config::hasValue(const QString& name, const bool recursive) const +{ + if (m_values.contains(name)) + return true; + if (recursive && qobject_cast<Config*>(parent())) + return qobject_cast<Config*>(parent())->hasValue(name, true); + return false; +} + +void Pokescripting::Config::clearTemporary() +{ + while (m_temporaries.size()) + removeValue(m_temporaries[0]); +} + +void Pokescripting::Config::writeBack() +{ +} diff --git a/sigscript/Config.h b/sigscript/Config.h new file mode 100644 index 00000000..16be5ade --- /dev/null +++ b/sigscript/Config.h @@ -0,0 +1,67 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_CONFIG__ +#define __POKESCRIPTING_CONFIG__ + +// Pokescripting includes +#include "Global.h" + +// Qt includes +#include <QtCore/QList> +#include <QtCore/QMap> +#include <QtCore/QObject> +#include <QtCore/QString> +#include <QtCore/QVariant> + +// Forward declarations +namespace Pokemod +{ +class Pokemod; +} + +namespace Pokescripting +{ +class POKESCRIPTING_EXPORT Config : public QObject +{ + Q_OBJECT + + public: + Config(QObject* parent); + + Q_SCRIPTABLE QVariant value(const QString& name, const bool recursive = true) const; + Q_SCRIPTABLE bool hasValue(const QString& name, const bool recursive = false) const; + signals: + void valueAdded(const QString& name, const QVariant& value); + void valueChanged(const QString& name, const QVariant& oldValue, const QVariant& newValue); + void valueRemoved(const QString& name); + public slots: + void addValue(const QString& name, const QVariant& value, const bool temporary = false); + void setValue(const QString& name, const QVariant& value, const bool temporary = false); + void removeValue(const QString& name); + + void clearTemporary(); + + virtual void writeBack(); + private: + QMap<QString, QVariant> m_values; + QList<QString> m_temporaries; +}; +} +Q_DECLARE_METATYPE(Pokescripting::Config*) + +#endif diff --git a/sigscript/EggGroupWrapper.cpp b/sigscript/EggGroupWrapper.cpp new file mode 100644 index 00000000..2f3f9051 --- /dev/null +++ b/sigscript/EggGroupWrapper.cpp @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "EggGroupWrapper.h" + +// Pokescripting includes +#include "PokemodWrapper.h" + +Pokescripting::EggGroupWrapper* Pokescripting::EggGroupWrapper::create(const Pokemod::EggGroup* eggGroup, PokemodWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, eggGroup->id()))) + m_instances[Signiture(parent, eggGroup->id())] = new EggGroupWrapper(eggGroup, parent); + return qobject_cast<EggGroupWrapper*>(m_instances[Signiture(parent, eggGroup->id())]); +} + +Pokescripting::EggGroupWrapper::EggGroupWrapper(const Pokemod::EggGroup* eggGroup, PokemodWrapper* parent) : + ObjectWrapper(eggGroup, parent), + m_eggGroup(eggGroup) +{ +} + +QString Pokescripting::EggGroupWrapper::name() const +{ + return m_eggGroup->name(); +} diff --git a/sigscript/EggGroupWrapper.h b/sigscript/EggGroupWrapper.h new file mode 100644 index 00000000..6c139c1e --- /dev/null +++ b/sigscript/EggGroupWrapper.h @@ -0,0 +1,46 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_EGGGROUPWRAPPER__ +#define __POKESCRIPTING_EGGGROUPWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/EggGroup.h" + +namespace Pokescripting +{ +class POKESCRIPTING_EXPORT EggGroupWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static EggGroupWrapper* create(const Pokemod::EggGroup* eggGroup, PokemodWrapper* parent); + + Q_SCRIPTABLE QString name() const; + private: + EggGroupWrapper(const Pokemod::EggGroup* eggGroup, PokemodWrapper* parent); + EggGroupWrapper& operator=(const EggGroupWrapper& rhs); + + const Pokemod::EggGroup* m_eggGroup; +}; +} +Q_DECLARE_METATYPE(Pokescripting::EggGroupWrapper*) + +#endif diff --git a/sigscript/Global.h b/sigscript/Global.h new file mode 100644 index 00000000..d77ef326 --- /dev/null +++ b/sigscript/Global.h @@ -0,0 +1,38 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_GLOBAL__ +#define __POKESCRIPTING_GLOBAL__ + +// KDE includes +#include <kdemacros.h> + +#ifndef POKESCRIPTING_EXPORT +# ifdef MAKE_POKESCRIPTING_LIB + /* We are building this library */ +# define POKESCRIPTING_EXPORT KDE_EXPORT +# else + /* We are using this library */ +# define POKESCRIPTING_EXPORT KDE_IMPORT +# endif +#endif + +# ifndef POKESCRIPTING_EXPORT_DEPRECATED +# define POKESCRIPTING_EXPORT_DEPRECATED KDE_DEPRECATED POKESCRIPTING_EXPORT +# endif + +#endif diff --git a/sigscript/GlobalScriptWrapper.cpp b/sigscript/GlobalScriptWrapper.cpp new file mode 100644 index 00000000..34a3fa62 --- /dev/null +++ b/sigscript/GlobalScriptWrapper.cpp @@ -0,0 +1,45 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "GlobalScriptWrapper.h" + +// Pokescripting includes +#include "PokemodWrapper.h" + +Pokescripting::GlobalScriptWrapper* Pokescripting::GlobalScriptWrapper::create(const Pokemod::GlobalScript* globalScript, PokemodWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, globalScript->id()))) + m_instances[Signiture(parent, globalScript->id())] = new GlobalScriptWrapper(globalScript, parent); + return qobject_cast<GlobalScriptWrapper*>(m_instances[Signiture(parent, globalScript->id())]); +} + +Pokescripting::GlobalScriptWrapper::GlobalScriptWrapper(const Pokemod::GlobalScript* globalScript, PokemodWrapper* parent) : + ObjectWrapper(globalScript, parent), + m_globalScript(globalScript) +{ +} + +QString Pokescripting::GlobalScriptWrapper::name() const +{ + return m_globalScript->name(); +} + +Pokemod::Script Pokescripting::GlobalScriptWrapper::script() const +{ + return m_globalScript->script(); +} diff --git a/sigscript/GlobalScriptWrapper.h b/sigscript/GlobalScriptWrapper.h new file mode 100644 index 00000000..dd5f3e36 --- /dev/null +++ b/sigscript/GlobalScriptWrapper.h @@ -0,0 +1,47 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_GLOBALSCRIPTWRAPPER__ +#define __POKESCRIPTING_GLOBALSCRIPTWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/GlobalScript.h" + +namespace Pokescripting +{ +class POKESCRIPTING_EXPORT GlobalScriptWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static GlobalScriptWrapper* create(const Pokemod::GlobalScript* globalScript, PokemodWrapper* parent); + + Q_SCRIPTABLE QString name() const; + Q_SCRIPTABLE Pokemod::Script script() const; + private: + GlobalScriptWrapper(const Pokemod::GlobalScript* globalScript, PokemodWrapper* parent); + GlobalScriptWrapper& operator=(const GlobalScriptWrapper& rhs); + + const Pokemod::GlobalScript* m_globalScript; +}; +} +Q_DECLARE_METATYPE(Pokescripting::GlobalScriptWrapper*) + +#endif diff --git a/sigscript/ItemTypeWrapper.cpp b/sigscript/ItemTypeWrapper.cpp new file mode 100644 index 00000000..f9111db2 --- /dev/null +++ b/sigscript/ItemTypeWrapper.cpp @@ -0,0 +1,64 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "ItemTypeWrapper.h" + +// Pokescripting includes +#include "PokemodWrapper.h" + +Pokescripting::ItemTypeWrapper* Pokescripting::ItemTypeWrapper::create(const Pokemod::ItemType* itemType, PokemodWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, itemType->id()))) + m_instances[Signiture(parent, itemType->id())] = new ItemTypeWrapper(itemType, parent); + return qobject_cast<ItemTypeWrapper*>(m_instances[Signiture(parent, itemType->id())]); +} + +Pokescripting::ItemTypeWrapper::ItemTypeWrapper(const Pokemod::ItemType* itemType, PokemodWrapper* parent) : + ObjectWrapper(itemType, parent), + m_itemType(itemType) +{ +} + +Pokemod::ItemType::Count Pokescripting::ItemTypeWrapper::count(const QString& name) const +{ + if (name == "Distinct") + return Pokemod::ItemType::Distinct; + else if (name == "Total") + return Pokemod::ItemType::Total; + return QVariant(-1).value<Pokemod::ItemType::Count>(); +} + +QString Pokescripting::ItemTypeWrapper::name() const +{ + return m_itemType->name(); +} + +int Pokescripting::ItemTypeWrapper::computer() const +{ + return m_itemType->computer(); +} + +int Pokescripting::ItemTypeWrapper::player() const +{ + return m_itemType->player(); +} + +int Pokescripting::ItemTypeWrapper::count() const +{ + return m_itemType->count(); +} diff --git a/sigscript/ItemTypeWrapper.h b/sigscript/ItemTypeWrapper.h new file mode 100644 index 00000000..f9e61ccc --- /dev/null +++ b/sigscript/ItemTypeWrapper.h @@ -0,0 +1,51 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_ITEMTYPEWRAPPER__ +#define __POKESCRIPTING_ITEMTYPEWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/ItemType.h" + +namespace Pokescripting +{ +class POKESCRIPTING_EXPORT ItemTypeWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static ItemTypeWrapper* create(const Pokemod::ItemType* itemType, PokemodWrapper* parent); + + Q_SCRIPTABLE Pokemod::ItemType::Count count(const QString& name) const; + + Q_SCRIPTABLE QString name() const; + Q_SCRIPTABLE int computer() const; + Q_SCRIPTABLE int player() const; + Q_SCRIPTABLE int count() const; + private: + ItemTypeWrapper(const Pokemod::ItemType* itemType, PokemodWrapper* parent); + ItemTypeWrapper& operator=(const ItemTypeWrapper& rhs); + + const Pokemod::ItemType* m_itemType; +}; +} +Q_DECLARE_METATYPE(Pokescripting::ItemTypeWrapper*) + +#endif diff --git a/sigscript/ItemWrapper.cpp b/sigscript/ItemWrapper.cpp new file mode 100644 index 00000000..002efea6 --- /dev/null +++ b/sigscript/ItemWrapper.cpp @@ -0,0 +1,67 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "ItemWrapper.h" + +// Pokescripting includes +#include "PokemodWrapper.h" + +Pokescripting::ItemWrapper* Pokescripting::ItemWrapper::create(const Pokemod::Item* item, PokemodWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, item->id()))) + m_instances[Signiture(parent, item->id())] = new ItemWrapper(item, parent); + return qobject_cast<ItemWrapper*>(m_instances[Signiture(parent, item->id())]); +} + +Pokescripting::ItemWrapper::ItemWrapper(const Pokemod::Item* item, PokemodWrapper* parent) : + ObjectWrapper(item, parent), + m_item(item) +{ +} + +QString Pokescripting::ItemWrapper::name() const +{ + return m_item->name(); +} + +bool Pokescripting::ItemWrapper::sellable() const +{ + return m_item->sellable(); +} + +Pokescripting::ItemTypeWrapper* Pokescripting::ItemWrapper::type() +{ + return pokemod()->itemType(m_item->type()); +} + +int Pokescripting::ItemWrapper::price() const +{ + if (value("price").canConvert<int>()) + return value("price").toInt(); + return m_item->price(); +} + +QString Pokescripting::ItemWrapper::description() const +{ + return m_item->description(); +} + +Pokemod::Script Pokescripting::ItemWrapper::script() const +{ + return m_item->script(); +} diff --git a/sigscript/ItemWrapper.h b/sigscript/ItemWrapper.h new file mode 100644 index 00000000..1550c2f9 --- /dev/null +++ b/sigscript/ItemWrapper.h @@ -0,0 +1,54 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_ITEMWRAPPER__ +#define __POKESCRIPTING_ITEMWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/Item.h" + +namespace Pokescripting +{ +// Forward declarations +class ItemTypeWrapper; + +class POKESCRIPTING_EXPORT ItemWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static ItemWrapper* create(const Pokemod::Item* item, PokemodWrapper* parent); + + Q_SCRIPTABLE QString name() const; + Q_SCRIPTABLE bool sellable() const; + Q_SCRIPTABLE ItemTypeWrapper* type(); + Q_SCRIPTABLE int price() const; + Q_SCRIPTABLE QString description() const; + Q_SCRIPTABLE Pokemod::Script script() const; + private: + ItemWrapper(const Pokemod::Item* item, PokemodWrapper* parent); + ItemWrapper& operator=(const ItemWrapper& rhs); + + const Pokemod::Item* m_item; +}; +} +Q_DECLARE_METATYPE(Pokescripting::ItemWrapper*) + +#endif diff --git a/sigscript/MapEffectWrapper.cpp b/sigscript/MapEffectWrapper.cpp new file mode 100644 index 00000000..ac1d7c41 --- /dev/null +++ b/sigscript/MapEffectWrapper.cpp @@ -0,0 +1,65 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "MapEffectWrapper.h" + +// Pokescripting includes +#include "MapWrapper.h" +#include "PokemodWrapper.h" + +Pokescripting::MapEffectWrapper* Pokescripting::MapEffectWrapper::create(const Pokemod::MapEffect* effect, MapWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, effect->id()))) + m_instances[Signiture(parent, effect->id())] = new MapEffectWrapper(effect, parent); + return qobject_cast<MapEffectWrapper*>(m_instances[Signiture(parent, effect->id())]); +} + +Pokescripting::MapEffectWrapper::MapEffectWrapper(const Pokemod::MapEffect* effect, MapWrapper* parent) : + ObjectWrapper(effect, parent), + m_effect(effect) +{ +} + +QString Pokescripting::MapEffectWrapper::name() const +{ + return m_effect->name(); +} + +QPoint Pokescripting::MapEffectWrapper::coordinate() const +{ + if (value("coordinate").canConvert<QPoint>()) + return value("coordinate").toPoint(); + return m_effect->coordinate(); +} + +Pokescripting::SkinWrapper* Pokescripting::MapEffectWrapper::skin() +{ + return pokemod()->skin(m_effect->skin()); +} + +bool Pokescripting::MapEffectWrapper::isGhost() const +{ + if (value("ghost").canConvert<bool>()) + return value("ghost").toBool(); + return m_effect->isGhost(); +} + +Pokemod::Script Pokescripting::MapEffectWrapper::script() const +{ + return m_effect->script(); +} diff --git a/sigscript/MapEffectWrapper.h b/sigscript/MapEffectWrapper.h new file mode 100644 index 00000000..8ccb2781 --- /dev/null +++ b/sigscript/MapEffectWrapper.h @@ -0,0 +1,54 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_MAPEFFECTWRAPPER__ +#define __POKESCRIPTING_MAPEFFECTWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/MapEffect.h" + +namespace Pokescripting +{ +// Forward declarations +class MapWrapper; +class SkinWrapper; + +class POKESCRIPTING_EXPORT MapEffectWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static MapEffectWrapper* create(const Pokemod::MapEffect* effect, MapWrapper* parent); + + Q_SCRIPTABLE QString name() const; + Q_SCRIPTABLE QPoint coordinate() const; + Q_SCRIPTABLE SkinWrapper* skin(); + Q_SCRIPTABLE bool isGhost() const; + Q_SCRIPTABLE Pokemod::Script script() const; + private: + MapEffectWrapper(const Pokemod::MapEffect* effect, MapWrapper* parent); + MapEffectWrapper& operator=(const MapEffectWrapper& rhs); + + const Pokemod::MapEffect* m_effect; +}; +} +Q_DECLARE_METATYPE(Pokescripting::MapEffectWrapper*) + +#endif diff --git a/sigscript/MapTrainerTeamMemberWrapper.cpp b/sigscript/MapTrainerTeamMemberWrapper.cpp new file mode 100644 index 00000000..a7b52c35 --- /dev/null +++ b/sigscript/MapTrainerTeamMemberWrapper.cpp @@ -0,0 +1,84 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "MapTrainerTeamMemberWrapper.h" + +// Pokescripting includes +#include "MapTrainerWrapper.h" +#include "PokemodWrapper.h" + +Pokescripting::MapTrainerTeamMemberWrapper* Pokescripting::MapTrainerTeamMemberWrapper::create(const Pokemod::MapTrainerTeamMember* teamMember, MapTrainerWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, teamMember->id()))) + m_instances[Signiture(parent, teamMember->id())] = new MapTrainerTeamMemberWrapper(teamMember, parent); + return qobject_cast<MapTrainerTeamMemberWrapper*>(m_instances[Signiture(parent, teamMember->id())]); +} + +Pokescripting::MapTrainerTeamMemberWrapper::MapTrainerTeamMemberWrapper(const Pokemod::MapTrainerTeamMember* teamMember, MapTrainerWrapper* parent) : + ObjectWrapper(teamMember, parent), + m_teamMember(teamMember) +{ +} + +Pokescripting::SpeciesWrapper* Pokescripting::MapTrainerTeamMemberWrapper::species() +{ + return pokemod()->species(m_teamMember->species()); +} + +int Pokescripting::MapTrainerTeamMemberWrapper::level() const +{ + if (value("level").canConvert<int>()) + return value("level").toInt(); + return m_teamMember->level(); +} + +QList<Pokescripting::AbilityWrapper*> Pokescripting::MapTrainerTeamMemberWrapper::abilities() +{ + QList<int> abilityIds = m_teamMember->abilities(); + QList<AbilityWrapper*> abilities; + foreach (int id, abilityIds) + abilities.append(pokemod()->ability(id)); + return abilities; +} + +QList<Pokescripting::ItemWrapper*> Pokescripting::MapTrainerTeamMemberWrapper::items() +{ + QList<int> itemIds = m_teamMember->items(); + QList<ItemWrapper*> items; + foreach (int id, itemIds) + items.append(pokemod()->item(id)); + return items; +} + +QList<Pokescripting::MoveWrapper*> Pokescripting::MapTrainerTeamMemberWrapper::moves() +{ + QList<int> moveIds = m_teamMember->moves(); + QList<MoveWrapper*> moves; + foreach (int id, moveIds) + moves.append(pokemod()->move(id)); + return moves; +} + +QList<Pokescripting::NatureWrapper*> Pokescripting::MapTrainerTeamMemberWrapper::natures() +{ + QList<int> natureIds = m_teamMember->natures(); + QList<NatureWrapper*> natures; + foreach (int id, natureIds) + natures.append(pokemod()->nature(id)); + return natures; +} diff --git a/sigscript/MapTrainerTeamMemberWrapper.h b/sigscript/MapTrainerTeamMemberWrapper.h new file mode 100644 index 00000000..313fe3f2 --- /dev/null +++ b/sigscript/MapTrainerTeamMemberWrapper.h @@ -0,0 +1,59 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_MAPTRAINERTEAMMEMBERWRAPPER__ +#define __POKESCRIPTING_MAPTRAINERTEAMMEMBERWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/MapTrainerTeamMember.h" + +namespace Pokescripting +{ +// Forward declarations +class AbilityWrapper; +class ItemWrapper; +class MapTrainerWrapper; +class MoveWrapper; +class NatureWrapper; +class SpeciesWrapper; + +class POKESCRIPTING_EXPORT MapTrainerTeamMemberWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static MapTrainerTeamMemberWrapper* create(const Pokemod::MapTrainerTeamMember* teamMember, MapTrainerWrapper* parent); + + Q_SCRIPTABLE SpeciesWrapper* species(); + Q_SCRIPTABLE int level() const; + Q_SCRIPTABLE QList<AbilityWrapper*> abilities(); + Q_SCRIPTABLE QList<ItemWrapper*> items(); + Q_SCRIPTABLE QList<MoveWrapper*> moves(); + Q_SCRIPTABLE QList<NatureWrapper*> natures(); + private: + MapTrainerTeamMemberWrapper(const Pokemod::MapTrainerTeamMember* teamMember, MapTrainerWrapper* parent); + MapTrainerTeamMemberWrapper& operator=(const MapTrainerTeamMemberWrapper& rhs); + + const Pokemod::MapTrainerTeamMember* m_teamMember; +}; +} +Q_DECLARE_METATYPE(Pokescripting::MapTrainerTeamMemberWrapper*) + +#endif diff --git a/sigscript/MapTrainerWrapper.cpp b/sigscript/MapTrainerWrapper.cpp new file mode 100644 index 00000000..a3ac6050 --- /dev/null +++ b/sigscript/MapTrainerWrapper.cpp @@ -0,0 +1,72 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "MapTrainerWrapper.h" + +// Pokescripting includes +#include "MapWrapper.h" +#include "MapTrainerTeamMemberWrapper.h" +#include "PokemodWrapper.h" + +Pokescripting::MapTrainerWrapper* Pokescripting::MapTrainerWrapper::create(const Pokemod::MapTrainer* trainer, MapWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, trainer->id()))) + m_instances[Signiture(parent, trainer->id())] = new MapTrainerWrapper(trainer, parent); + return qobject_cast<MapTrainerWrapper*>(m_instances[Signiture(parent, trainer->id())]); +} + +Pokescripting::MapTrainerWrapper::MapTrainerWrapper(const Pokemod::MapTrainer* trainer, MapWrapper* parent) : + ObjectWrapper(trainer, parent), + m_trainer(trainer) +{ +} + +QString Pokescripting::MapTrainerWrapper::name() const +{ + return m_trainer->name(); +} + +Pokescripting::TrainerWrapper* Pokescripting::MapTrainerWrapper::trainerClass() +{ + return pokemod()->trainer(m_trainer->trainerClass()); +} + +int Pokescripting::MapTrainerWrapper::numberFight() const +{ + return m_trainer->numberFight(); +} + +Pokescripting::MapTrainerTeamMemberWrapper* Pokescripting::MapTrainerWrapper::leadTeamMember() +{ + return teamMember(m_trainer->leadTeamMember()); +} + +Pokemod::Script Pokescripting::MapTrainerWrapper::script() const +{ + return m_trainer->script(); +} + +Pokescripting::MapTrainerTeamMemberWrapper* Pokescripting::MapTrainerWrapper::teamMember(const int index) +{ + return MapTrainerTeamMemberWrapper::create(m_trainer->teamMember(index), this); +} + +int Pokescripting::MapTrainerWrapper::teamMemberCount() const +{ + return m_trainer->teamMemberCount(); +} diff --git a/sigscript/MapTrainerWrapper.h b/sigscript/MapTrainerWrapper.h new file mode 100644 index 00000000..0c65b186 --- /dev/null +++ b/sigscript/MapTrainerWrapper.h @@ -0,0 +1,58 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_MAPTRAINERWRAPPER__ +#define __POKESCRIPTING_MAPTRAINERWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/MapTrainer.h" + +namespace Pokescripting +{ +// Forward declarations +class MapWrapper; +class MapTrainerTeamMemberWrapper; +class TrainerWrapper; + +class POKESCRIPTING_EXPORT MapTrainerWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static MapTrainerWrapper* create(const Pokemod::MapTrainer* trainer, MapWrapper* parent); + + Q_SCRIPTABLE QString name() const; + Q_SCRIPTABLE TrainerWrapper* trainerClass(); + Q_SCRIPTABLE int numberFight() const; + Q_SCRIPTABLE MapTrainerTeamMemberWrapper* leadTeamMember(); + Q_SCRIPTABLE Pokemod::Script script() const; + + Q_SCRIPTABLE MapTrainerTeamMemberWrapper* teamMember(const int index); + Q_SCRIPTABLE int teamMemberCount() const; + private: + MapTrainerWrapper(const Pokemod::MapTrainer* trainer, MapWrapper* parent); + MapTrainerWrapper& operator=(const MapTrainerWrapper& rhs); + + const Pokemod::MapTrainer* m_trainer; +}; +} +Q_DECLARE_METATYPE(Pokescripting::MapTrainerWrapper*) + +#endif diff --git a/sigscript/MapWarpWrapper.cpp b/sigscript/MapWarpWrapper.cpp new file mode 100644 index 00000000..370ad6f5 --- /dev/null +++ b/sigscript/MapWarpWrapper.cpp @@ -0,0 +1,76 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "MapWarpWrapper.h" + +// Pokescripting includes +#include "MapWrapper.h" +#include "PokemodWrapper.h" + +Pokescripting::MapWarpWrapper* Pokescripting::MapWarpWrapper::create(const Pokemod::MapWarp* warp, MapWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, warp->id()))) + m_instances[Signiture(parent, warp->id())] = new MapWarpWrapper(warp, parent); + return qobject_cast<MapWarpWrapper*>(m_instances[Signiture(parent, warp->id())]); +} + +Pokescripting::MapWarpWrapper::MapWarpWrapper(const Pokemod::MapWarp* warp, MapWrapper* parent) : + ObjectWrapper(warp, parent), + m_warp(warp) +{ +} + +Pokemod::MapWarp::Type Pokescripting::MapWarpWrapper::type(const QString& name) const +{ + if (name == "Door") + return Pokemod::MapWarp::Door; + else if (name == "Warp") + return Pokemod::MapWarp::Warp; + else if (name == "Hole") + return Pokemod::MapWarp::Hole; + else if (name == "Boundary") + return Pokemod::MapWarp::Boundary; + return QVariant(-1).value<Pokemod::MapWarp::Type>(); +} + +QString Pokescripting::MapWarpWrapper::name() const +{ + return m_warp->name(); +} + +QPoint Pokescripting::MapWarpWrapper::coordinate() const +{ + if (value("coordinate").canConvert<QPoint>()) + return value("coordinate").toPoint(); + return m_warp->coordinate(); +} + +Pokemod::MapWarp::Type Pokescripting::MapWarpWrapper::type() const +{ + return m_warp->type(); +} + +Pokescripting::MapWarpWrapper* Pokescripting::MapWarpWrapper::toWarp() +{ + return pokemod()->map(m_warp->toMap())->warp(m_warp->toWarp()); +} + +Pokemod::Script Pokescripting::MapWarpWrapper::script() const +{ + return m_warp->script(); +} diff --git a/sigscript/MapWarpWrapper.h b/sigscript/MapWarpWrapper.h new file mode 100644 index 00000000..ac894b04 --- /dev/null +++ b/sigscript/MapWarpWrapper.h @@ -0,0 +1,55 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_MAPWARPWRAPPER__ +#define __POKESCRIPTING_MAPWARPWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/MapWarp.h" + +namespace Pokescripting +{ +// Forward declartions +class MapWrapper; + +class POKESCRIPTING_EXPORT MapWarpWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static MapWarpWrapper* create(const Pokemod::MapWarp* warp, MapWrapper* parent); + + Q_SCRIPTABLE Pokemod::MapWarp::Type type(const QString& name) const; + + Q_SCRIPTABLE QString name() const; + Q_SCRIPTABLE QPoint coordinate() const; + Q_SCRIPTABLE Pokemod::MapWarp::Type type() const; + Q_SCRIPTABLE MapWarpWrapper* toWarp(); + Q_SCRIPTABLE Pokemod::Script script() const; + private: + MapWarpWrapper(const Pokemod::MapWarp* warp, MapWrapper* parent); + MapWarpWrapper& operator=(const MapWarpWrapper& rhs); + + const Pokemod::MapWarp* m_warp; +}; +} +Q_DECLARE_METATYPE(Pokescripting::MapWarpWrapper*) + +#endif diff --git a/sigscript/MapWildListEncounterWrapper.cpp b/sigscript/MapWildListEncounterWrapper.cpp new file mode 100644 index 00000000..6d37d5ae --- /dev/null +++ b/sigscript/MapWildListEncounterWrapper.cpp @@ -0,0 +1,55 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "MapWildListEncounterWrapper.h" + +// Pokescripting includes +#include "MapWildListWrapper.h" +#include "PokemodWrapper.h" + +Pokescripting::MapWildListEncounterWrapper* Pokescripting::MapWildListEncounterWrapper::create(const Pokemod::MapWildListEncounter* encounter, MapWildListWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, encounter->id()))) + m_instances[Signiture(parent, encounter->id())] = new MapWildListEncounterWrapper(encounter, parent); + return qobject_cast<MapWildListEncounterWrapper*>(m_instances[Signiture(parent, encounter->id())]); +} + +Pokescripting::MapWildListEncounterWrapper::MapWildListEncounterWrapper(const Pokemod::MapWildListEncounter* encounter, MapWildListWrapper* parent) : + ObjectWrapper(encounter, parent), + m_encounter(encounter) +{ +} + +Pokescripting::SpeciesWrapper* Pokescripting::MapWildListEncounterWrapper::species() +{ + return pokemod()->species(m_encounter->species()); +} + +int Pokescripting::MapWildListEncounterWrapper::level() const +{ + if (value("level").canConvert<int>()) + return value("level").toInt(); + return m_encounter->level(); +} + +int Pokescripting::MapWildListEncounterWrapper::weight() const +{ + if (value("weight").canConvert<int>()) + return value("weight").toInt(); + return m_encounter->weight(); +} diff --git a/sigscript/MapWildListEncounterWrapper.h b/sigscript/MapWildListEncounterWrapper.h new file mode 100644 index 00000000..c9459430 --- /dev/null +++ b/sigscript/MapWildListEncounterWrapper.h @@ -0,0 +1,52 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_MAPWILDLISTENCOUNTERWRAPPER__ +#define __POKESCRIPTING_MAPWILDLISTENCOUNTERWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/MapWildListEncounter.h" + +namespace Pokescripting +{ +// Forward declarations +class MapWildListWrapper; +class SpeciesWrapper; + +class POKESCRIPTING_EXPORT MapWildListEncounterWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static MapWildListEncounterWrapper* create(const Pokemod::MapWildListEncounter* encounter, MapWildListWrapper* parent); + + Q_SCRIPTABLE SpeciesWrapper* species(); + Q_SCRIPTABLE int level() const; + Q_SCRIPTABLE int weight() const; + private: + MapWildListEncounterWrapper(const Pokemod::MapWildListEncounter* encounter, MapWildListWrapper* parent); + MapWildListEncounterWrapper& operator=(const MapWildListEncounterWrapper& rhs); + + const Pokemod::MapWildListEncounter* m_encounter; +}; +} +Q_DECLARE_METATYPE(Pokescripting::MapWildListEncounterWrapper*) + +#endif diff --git a/sigscript/MapWildListWrapper.cpp b/sigscript/MapWildListWrapper.cpp new file mode 100644 index 00000000..3b725b34 --- /dev/null +++ b/sigscript/MapWildListWrapper.cpp @@ -0,0 +1,59 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "MapWildListWrapper.h" + +// Pokescripting includes +#include "MapWrapper.h" +#include "MapWildListEncounterWrapper.h" + +Pokescripting::MapWildListWrapper* Pokescripting::MapWildListWrapper::create(const Pokemod::MapWildList* wildList, MapWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, wildList->id()))) + m_instances[Signiture(parent, wildList->id())] = new MapWildListWrapper(wildList, parent); + return qobject_cast<MapWildListWrapper*>(m_instances[Signiture(parent, wildList->id())]); +} + +Pokescripting::MapWildListWrapper::MapWildListWrapper(const Pokemod::MapWildList* wildList, MapWrapper* parent) : + ObjectWrapper(wildList, parent), + m_wildList(wildList) +{ +} + +Pokemod::Hat<Pokescripting::MapWildListEncounterWrapper*> Pokescripting::MapWildListWrapper::encounterHat() +{ + Pokemod::Hat<MapWildListEncounterWrapper*> hat; + for (int i = 0; i < encounterCount(); ++i) + hat.add(encounter(i), encounter(i)->weight()); + return hat; +} + +QString Pokescripting::MapWildListWrapper::name() const +{ + return m_wildList->name(); +} + +Pokescripting::MapWildListEncounterWrapper* Pokescripting::MapWildListWrapper::encounter(const int index) +{ + return MapWildListEncounterWrapper::create(m_wildList->encounter(index), this); +} + +int Pokescripting::MapWildListWrapper::encounterCount() const +{ + return m_wildList->encounterCount(); +} diff --git a/sigscript/MapWildListWrapper.h b/sigscript/MapWildListWrapper.h new file mode 100644 index 00000000..661a3ef7 --- /dev/null +++ b/sigscript/MapWildListWrapper.h @@ -0,0 +1,56 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_MAPWILDLISTWRAPPER__ +#define __POKESCRIPTING_MAPWILDLISTWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/Hat.h" +#include "../pokemod/MapWildList.h" + +namespace Pokescripting +{ +// Forward declarations +class MapWrapper; +class MapWildListEncounterWrapper; + +class POKESCRIPTING_EXPORT MapWildListWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static MapWildListWrapper* create(const Pokemod::MapWildList* wildList, MapWrapper* parent); + + Pokemod::Hat<MapWildListEncounterWrapper*> encounterHat(); + + Q_SCRIPTABLE QString name() const; + + Q_SCRIPTABLE MapWildListEncounterWrapper* encounter(const int index); + Q_SCRIPTABLE int encounterCount() const; + private: + MapWildListWrapper(const Pokemod::MapWildList* wildList, MapWrapper* parent); + MapWildListWrapper& operator=(const MapWildListWrapper& rhs); + + const Pokemod::MapWildList* m_wildList; +}; +} +Q_DECLARE_METATYPE(Pokescripting::MapWildListWrapper*) + +#endif diff --git a/sigscript/MapWrapper.cpp b/sigscript/MapWrapper.cpp new file mode 100644 index 00000000..ebd37ceb --- /dev/null +++ b/sigscript/MapWrapper.cpp @@ -0,0 +1,135 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "MapWrapper.h" + +// Pokescripting includes +#include "MapEffectWrapper.h" +#include "MapTrainerWrapper.h" +#include "MapWarpWrapper.h" +#include "MapWildListWrapper.h" +#include "PokemodWrapper.h" + +Pokescripting::MapWrapper* Pokescripting::MapWrapper::create(const Pokemod::Map* map, PokemodWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, map->id()))) + m_instances[Signiture(parent, map->id())] = new MapWrapper(map, parent); + return qobject_cast<MapWrapper*>(m_instances[Signiture(parent, map->id())]); +} + +Pokescripting::MapWrapper::MapWrapper(const Pokemod::Map* map, PokemodWrapper* parent) : + ObjectWrapper(map, parent), + m_map(map) +{ +} + +Pokescripting::MapEffectWrapper* Pokescripting::MapWrapper::effect(const int id) +{ + return MapEffectWrapper::create(m_map->effectById(id), this); +} + +Pokescripting::MapTrainerWrapper* Pokescripting::MapWrapper::trainer(const int id) +{ + return MapTrainerWrapper::create(m_map->trainerById(id), this); +} + +Pokescripting::MapWarpWrapper* Pokescripting::MapWrapper::warp(const int id) +{ + return MapWarpWrapper::create(m_map->warpById(id), this); +} + +Pokescripting::MapWildListWrapper* Pokescripting::MapWrapper::wildList(const int id) +{ + return MapWildListWrapper::create(m_map->wildListById(id), this); +} + +Pokemod::Map::Type Pokescripting::MapWrapper::type(const QString& name) const +{ + if (name == "Outdoor") + return Pokemod::Map::Outdoor; + else if (name == "Dungeon") + return Pokemod::Map::Dungeon; + else if (name == "Building") + return Pokemod::Map::Building; + return QVariant(-1).value<Pokemod::Map::Type>(); +} + +QString Pokescripting::MapWrapper::name() const +{ + return m_map->name(); +} + +Pokescripting::MapWarpWrapper* Pokescripting::MapWrapper::flyWarp() +{ + return MapWarpWrapper::create(m_map->warpById(m_map->flyWarp()), this); +} + +Pokemod::Map::Type Pokescripting::MapWrapper::type() const +{ + return m_map->type(); +} + +Pokescripting::TileWrapper* Pokescripting::MapWrapper::tile(const int row, const int column) +{ + return pokemod()->tile(m_map->tile(row, column)); +} + +QPoint Pokescripting::MapWrapper::mapSize() const +{ + return m_map->size(); +} + +Pokescripting::MapEffectWrapper* Pokescripting::MapWrapper::effect(const QString& name) +{ + for (int i = 0; i < m_map->effectCount(); ++i) + { + if (m_map->effect(i)->name() == name) + return MapEffectWrapper::create(m_map->effect(i), this); + } + return NULL; +} + +Pokescripting::MapTrainerWrapper* Pokescripting::MapWrapper::trainer(const QString& name) +{ + for (int i = 0; i < m_map->trainerCount(); ++i) + { + if (m_map->trainer(i)->name() == name) + return MapTrainerWrapper::create(m_map->trainer(i), this); + } + return NULL; +} + +Pokescripting::MapWarpWrapper* Pokescripting::MapWrapper::warp(const QString& name) +{ + for (int i = 0; i < m_map->warpCount(); ++i) + { + if (m_map->warp(i)->name() == name) + return MapWarpWrapper::create(m_map->warp(i), this); + } + return NULL; +} + +Pokescripting::MapWildListWrapper* Pokescripting::MapWrapper::wildList(const QString& name) +{ + for (int i = 0; i < m_map->wildListCount(); ++i) + { + if (m_map->wildList(i)->name() == name) + return MapWildListWrapper::create(m_map->wildList(i), this); + } + return NULL; +} diff --git a/sigscript/MapWrapper.h b/sigscript/MapWrapper.h new file mode 100644 index 00000000..f0f8980f --- /dev/null +++ b/sigscript/MapWrapper.h @@ -0,0 +1,69 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_MAPWRAPPER__ +#define __POKESCRIPTING_MAPWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/Map.h" + +namespace Pokescripting +{ +// Forward declarations +class MapEffectWrapper; +class MapTrainerWrapper; +class MapWarpWrapper; +class MapWildListWrapper; +class TileWrapper; + +class POKESCRIPTING_EXPORT MapWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static MapWrapper* create(const Pokemod::Map* map, PokemodWrapper* parent); + + MapEffectWrapper* effect(const int id); + MapTrainerWrapper* trainer(const int id); + MapWarpWrapper* warp(const int id); + MapWildListWrapper* wildList(const int id); + + Q_SCRIPTABLE Pokemod::Map::Type type(const QString& name) const; + + Q_SCRIPTABLE QString name() const; + Q_SCRIPTABLE MapWarpWrapper* flyWarp(); + Q_SCRIPTABLE Pokemod::Map::Type type() const; + Q_SCRIPTABLE TileWrapper* tile(const int row, const int column); + Q_SCRIPTABLE QPoint mapSize() const; + + Q_SCRIPTABLE MapEffectWrapper* effect(const QString& name); + Q_SCRIPTABLE MapTrainerWrapper* trainer(const QString& name); + Q_SCRIPTABLE MapWarpWrapper* warp(const QString& name); + Q_SCRIPTABLE MapWildListWrapper* wildList(const QString& name); + private: + MapWrapper(const Pokemod::Map* map, PokemodWrapper* parent); + MapWrapper& operator=(const MapWrapper& rhs); + + const Pokemod::Map* m_map; +}; +} +Q_DECLARE_METATYPE(Pokescripting::MapWrapper*) + +#endif diff --git a/sigscript/MoveWrapper.cpp b/sigscript/MoveWrapper.cpp new file mode 100644 index 00000000..1bf5d3f8 --- /dev/null +++ b/sigscript/MoveWrapper.cpp @@ -0,0 +1,91 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "MoveWrapper.h" + +// Pokescripting includes +#include "PokemodWrapper.h" + +Pokescripting::MoveWrapper* Pokescripting::MoveWrapper::create(const Pokemod::Move* move, PokemodWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, move->id()))) + m_instances[Signiture(parent, move->id())] = new MoveWrapper(move, parent); + return qobject_cast<MoveWrapper*>(m_instances[Signiture(parent, move->id())]); +} + +Pokescripting::MoveWrapper::MoveWrapper(const Pokemod::Move* move, PokemodWrapper* parent) : + ObjectWrapper(move, parent), + m_move(move) +{ +} + +QString Pokescripting::MoveWrapper::name() const +{ + return m_move->name(); +} + +Pokemod::Fraction Pokescripting::MoveWrapper::accuracy() const +{ + if (value("accuracy").canConvert<Pokemod::Fraction>()) + return value("accuracy").value<Pokemod::Fraction>(); + return m_move->accuracy(); +} + +int Pokescripting::MoveWrapper::power() const +{ + if (value("power").canConvert<int>()) + return value("power").toInt(); + return m_move->power(); +} + +Pokescripting::TypeWrapper* Pokescripting::MoveWrapper::type() +{ + return pokemod()->type(m_move->type()); +} + +bool Pokescripting::MoveWrapper::special() const +{ + return m_move->special(); +} + +int Pokescripting::MoveWrapper::powerPoints() const +{ + return m_move->powerPoints(); +} + +int Pokescripting::MoveWrapper::priority() const +{ + if (value("priority").canConvert<int>()) + return value("priority").toInt(); + return m_move->priority(); +} + +QString Pokescripting::MoveWrapper::description() const +{ + return m_move->description(); +} + +Pokemod::Script Pokescripting::MoveWrapper::battleScript() const +{ + return m_move->battleScript(); +} + +Pokemod::Script Pokescripting::MoveWrapper::worldScript() const +{ + return m_move->worldScript(); +} diff --git a/sigscript/MoveWrapper.h b/sigscript/MoveWrapper.h new file mode 100644 index 00000000..37a7192f --- /dev/null +++ b/sigscript/MoveWrapper.h @@ -0,0 +1,58 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_MOVEWRAPPER__ +#define __POKESCRIPTING_MOVEWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/Move.h" + +namespace Pokescripting +{ +// Forward declarations +class TypeWrapper; + +class POKESCRIPTING_EXPORT MoveWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static MoveWrapper* create(const Pokemod::Move* move, PokemodWrapper* parent); + + Q_SCRIPTABLE QString name() const; + Q_SCRIPTABLE Pokemod::Fraction accuracy() const; + Q_SCRIPTABLE int power() const; + Q_SCRIPTABLE TypeWrapper* type(); + Q_SCRIPTABLE bool special() const; + Q_SCRIPTABLE int powerPoints() const; + Q_SCRIPTABLE int priority() const; + Q_SCRIPTABLE QString description() const; + Q_SCRIPTABLE Pokemod::Script battleScript() const; + Q_SCRIPTABLE Pokemod::Script worldScript() const; + private: + MoveWrapper(const Pokemod::Move* move, PokemodWrapper* parent); + MoveWrapper& operator=(const MoveWrapper& rhs); + + const Pokemod::Move* m_move; +}; +} +Q_DECLARE_METATYPE(Pokescripting::MoveWrapper*) + +#endif diff --git a/sigscript/NatureWrapper.cpp b/sigscript/NatureWrapper.cpp new file mode 100644 index 00000000..fa9f1c06 --- /dev/null +++ b/sigscript/NatureWrapper.cpp @@ -0,0 +1,50 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "NatureWrapper.h" + +// Pokescripting includes +#include "PokemodWrapper.h" + +Pokescripting::NatureWrapper* Pokescripting::NatureWrapper::create(const Pokemod::Nature* nature, PokemodWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, nature->id()))) + m_instances[Signiture(parent, nature->id())] = new NatureWrapper(nature, parent); + return qobject_cast<NatureWrapper*>(m_instances[Signiture(parent, nature->id())]); +} + +Pokescripting::NatureWrapper::NatureWrapper(const Pokemod::Nature* nature, PokemodWrapper* parent) : + ObjectWrapper(nature, parent), + m_nature(nature) +{ +} + +QString Pokescripting::NatureWrapper::name() const +{ + return m_nature->name(); +} + +Pokemod::Fraction Pokescripting::NatureWrapper::stat(const Pokemod::Stat stat) const +{ + return m_nature->stat(stat); +} + +int Pokescripting::NatureWrapper::weight() const +{ + return m_nature->weight(); +} diff --git a/sigscript/NatureWrapper.h b/sigscript/NatureWrapper.h new file mode 100644 index 00000000..037a014c --- /dev/null +++ b/sigscript/NatureWrapper.h @@ -0,0 +1,48 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_NATUREWRAPPER__ +#define __POKESCRIPTING_NATUREWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/Nature.h" + +namespace Pokescripting +{ +class POKESCRIPTING_EXPORT NatureWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static NatureWrapper* create(const Pokemod::Nature* nature, PokemodWrapper* parent); + + Q_SCRIPTABLE QString name() const; + Q_SCRIPTABLE Pokemod::Fraction stat(const Pokemod::Stat stat) const; + Q_SCRIPTABLE int weight() const; + private: + NatureWrapper(const Pokemod::Nature* nature, PokemodWrapper* parent); + NatureWrapper& operator=(const NatureWrapper& rhs); + + const Pokemod::Nature* m_nature; +}; +} +Q_DECLARE_METATYPE(Pokescripting::NatureWrapper*) + +#endif diff --git a/sigscript/ObjectWrapper.cpp b/sigscript/ObjectWrapper.cpp new file mode 100644 index 00000000..d1af3220 --- /dev/null +++ b/sigscript/ObjectWrapper.cpp @@ -0,0 +1,59 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "ObjectWrapper.h" + +// Pokescripting includes +#include "PokemodWrapper.h" + +QMap<Pokescripting::ObjectWrapper::Signiture, Pokescripting::ObjectWrapper*> Pokescripting::ObjectWrapper::m_instances; + +Pokescripting::ObjectWrapper::ObjectWrapper(const Pokemod::Object* object, ObjectWrapper* parent) : + Config(parent), + m_object(object) +{ +} + +int Pokescripting::ObjectWrapper::id() const +{ + return m_object->id(); +} + +const Pokescripting::ObjectWrapper* Pokescripting::ObjectWrapper::parent() const +{ + return m_parent; +} + +Pokescripting::ObjectWrapper* Pokescripting::ObjectWrapper::parent() +{ + return m_parent; +} + +const Pokescripting::PokemodWrapper* Pokescripting::ObjectWrapper::pokemod() const +{ + if (m_parent) + return m_parent->pokemod(); + return qobject_cast<const PokemodWrapper*>(m_parent); +} + +Pokescripting::PokemodWrapper* Pokescripting::ObjectWrapper::pokemod() +{ + if (m_parent) + return m_parent->pokemod(); + return qobject_cast<PokemodWrapper*>(m_parent); +} diff --git a/sigscript/ObjectWrapper.h b/sigscript/ObjectWrapper.h new file mode 100644 index 00000000..648b693b --- /dev/null +++ b/sigscript/ObjectWrapper.h @@ -0,0 +1,63 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_OBJECTWRAPPER__ +#define __POKESCRIPTING_OBJECTWRAPPER__ + +// Pokescripting includes +#include "Config.h" + +// Pokemod includes +#include "../pokemod/Object.h" +#include "../pokemod/Pokemod.h" + +// Qt includes +#include <QtCore/QMap> +#include <QtCore/QObject> +#include <QtCore/QPair> + +namespace Pokescripting +{ +// Forward declarations +class PokemodWrapper; + +class POKESCRIPTING_EXPORT ObjectWrapper : public Config +{ + Q_OBJECT + Q_PROPERTY(int id READ id) + + public: + typedef QPair<ObjectWrapper*, int> Signiture; + + ObjectWrapper(const Pokemod::Object* object, ObjectWrapper* parent); + + int id() const; + + const ObjectWrapper* parent() const; + ObjectWrapper* parent(); + + const PokemodWrapper* pokemod() const; + PokemodWrapper* pokemod(); + protected: + static QMap<Signiture, ObjectWrapper*> m_instances; + private: + ObjectWrapper* m_parent; + const Pokemod::Object* m_object; +}; +} + +#endif diff --git a/sigscript/PokemodWrapper.cpp b/sigscript/PokemodWrapper.cpp new file mode 100644 index 00000000..247fb409 --- /dev/null +++ b/sigscript/PokemodWrapper.cpp @@ -0,0 +1,460 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "PokemodWrapper.h" + +// Pokescripting includes +#include "AbilityWrapper.h" +#include "AuthorWrapper.h" +#include "BadgeWrapper.h" +#include "CoinListWrapper.h" +#include "EggGroupWrapper.h" +#include "GlobalScriptWrapper.h" +#include "ItemWrapper.h" +#include "ItemTypeWrapper.h" +#include "MapWrapper.h" +#include "MapWarpWrapper.h" +#include "MoveWrapper.h" +#include "NatureWrapper.h" +#include "RulesWrapper.h" +#include "SkinWrapper.h" +#include "SoundWrapper.h" +#include "SpeciesWrapper.h" +#include "SpriteWrapper.h" +#include "StatusWrapper.h" +#include "StoreWrapper.h" +#include "TileWrapper.h" +#include "TimeWrapper.h" +#include "TrainerWrapper.h" +#include "TypeWrapper.h" +#include "WeatherWrapper.h" + +Pokescripting::PokemodWrapper::PokemodWrapper(const Pokemod::Pokemod* pokemod) : + ObjectWrapper(pokemod, NULL), + m_pokemod(pokemod) +{ +} + +Pokemod::Hat<Pokescripting::NatureWrapper*> Pokescripting::PokemodWrapper::natureHat() +{ + Pokemod::Hat<NatureWrapper*> hat; + for (int i = 0; i < m_pokemod->natureCount(); ++i) + { + NatureWrapper* nature = NatureWrapper::create(m_pokemod->nature(i), this); + hat.add(nature, nature->weight()); + } + return hat; +} + +Pokescripting::AbilityWrapper* Pokescripting::PokemodWrapper::ability(const int id) +{ + return AbilityWrapper::create(m_pokemod->abilityById(id), this); +} + +Pokescripting::AuthorWrapper* Pokescripting::PokemodWrapper::author(const int id) +{ + return AuthorWrapper::create(m_pokemod->authorById(id), this); +} + +Pokescripting::BadgeWrapper* Pokescripting::PokemodWrapper::badge(const int id) +{ + return BadgeWrapper::create(m_pokemod->badgeById(id), this); +} + +Pokescripting::CoinListWrapper* Pokescripting::PokemodWrapper::coinList(const int id) +{ + return CoinListWrapper::create(m_pokemod->coinListById(id), this); +} + +Pokescripting::EggGroupWrapper* Pokescripting::PokemodWrapper::eggGroup(const int id) +{ + return EggGroupWrapper::create(m_pokemod->eggGroupById(id), this); +} + +Pokescripting::GlobalScriptWrapper* Pokescripting::PokemodWrapper::globalScript(const int id) +{ + return GlobalScriptWrapper::create(m_pokemod->globalScriptById(id), this); +} + +Pokescripting::ItemWrapper* Pokescripting::PokemodWrapper::item(const int id) +{ + return ItemWrapper::create(m_pokemod->itemById(id), this); +} + +Pokescripting::ItemTypeWrapper* Pokescripting::PokemodWrapper::itemType(const int id) +{ + return ItemTypeWrapper::create(m_pokemod->itemTypeById(id), this); +} + +Pokescripting::MapWrapper* Pokescripting::PokemodWrapper::map(const int id) +{ + return MapWrapper::create(m_pokemod->mapById(id), this); +} + +Pokescripting::MoveWrapper* Pokescripting::PokemodWrapper::move(const int id) +{ + return MoveWrapper::create(m_pokemod->moveById(id), this); +} + +Pokescripting::NatureWrapper* Pokescripting::PokemodWrapper::nature(const int id) +{ + return NatureWrapper::create(m_pokemod->natureById(id), this); +} + +Pokescripting::SkinWrapper* Pokescripting::PokemodWrapper::skin(const int id) +{ + return SkinWrapper::create(m_pokemod->skinById(id), this); +} + +Pokescripting::SoundWrapper* Pokescripting::PokemodWrapper::sound(const int id) +{ + return SoundWrapper::create(m_pokemod->soundById(id), this); +} + +Pokescripting::SpeciesWrapper* Pokescripting::PokemodWrapper::species(const int id) +{ + return SpeciesWrapper::create(m_pokemod->speciesById(id), this); +} + +Pokescripting::SpriteWrapper* Pokescripting::PokemodWrapper::sprite(const int id) +{ + return SpriteWrapper::create(m_pokemod->spriteById(id), this); +} + +Pokescripting::StatusWrapper* Pokescripting::PokemodWrapper::status(const int id) +{ + return StatusWrapper::create(m_pokemod->statusById(id), this); +} + +Pokescripting::StoreWrapper* Pokescripting::PokemodWrapper::store(const int id) +{ + return StoreWrapper::create(m_pokemod->storeById(id), this); +} + +Pokescripting::TileWrapper* Pokescripting::PokemodWrapper::tile(const int id) +{ + return TileWrapper::create(m_pokemod->tileById(id), this); +} + +Pokescripting::TimeWrapper* Pokescripting::PokemodWrapper::time(const int id) +{ + return TimeWrapper::create(m_pokemod->timeById(id), this); +} + +Pokescripting::TrainerWrapper* Pokescripting::PokemodWrapper::trainer(const int id) +{ + return TrainerWrapper::create(m_pokemod->trainerById(id), this); +} + +Pokescripting::TypeWrapper* Pokescripting::PokemodWrapper::type(const int id) +{ + return TypeWrapper::create(m_pokemod->typeById(id), this); +} + +Pokescripting::WeatherWrapper* Pokescripting::PokemodWrapper::weather(const int id) +{ + return WeatherWrapper::create(m_pokemod->weatherById(id), this); +} + +Pokemod::Stat Pokescripting::PokemodWrapper::stat(const QString& name) const +{ + if (name == "HP") + return Pokemod::ST_HP; + else if (name == "Attack") + return Pokemod::ST_Attack; + else if (name == "Defense") + return Pokemod::ST_Defense; + else if (name == "Speed") + return Pokemod::ST_Speed; + else if (name == "Special") + return Pokemod::ST_Special; + else if (name == "Special Attack") + return Pokemod::ST_SpecialAttack; + else if (name == "Special Defense") + return Pokemod::ST_SpecialAttack; + else if (name == "Accuracy") + return Pokemod::ST_Accuracy; + else if (name == "Evasion") + return Pokemod::ST_Evasion; + return QVariant(-1).value<Pokemod::Stat>(); +} + +Pokemod::Direction Pokescripting::PokemodWrapper::direction(const QString& name) const +{ + if (name == "Up") + return Pokemod::D_Up; + else if (name == "Down") + return Pokemod::D_Down; + else if (name == "Left") + return Pokemod::D_Left; + else if (name == "Right") + return Pokemod::D_Right; + else if (name == "None") + return Pokemod::D_None; + return QVariant(-1).value<Pokemod::Direction>(); +} + +QString Pokescripting::PokemodWrapper::title() const +{ + return m_pokemod->title(); +} + +QString Pokescripting::PokemodWrapper::version() const +{ + return m_pokemod->version(); +} + +QString Pokescripting::PokemodWrapper::description() const +{ + return m_pokemod->description(); +} + +Pokescripting::MapWarpWrapper* Pokescripting::PokemodWrapper::startWarp() +{ + return map(m_pokemod->startMap())->warp(m_pokemod->startWarp()); +} + +Pokemod::Fraction Pokescripting::PokemodWrapper::effectiveness(const TypeWrapper* attacker, const TypeWrapper* defender) const +{ + return m_pokemod->typechart(m_pokemod->typeIndex(attacker->id()), m_pokemod->typeIndex(defender->id())); +} + +Pokescripting::RulesWrapper* Pokescripting::PokemodWrapper::rules() +{ + return RulesWrapper::create(m_pokemod->rules(), this); +} + +Pokescripting::AbilityWrapper* Pokescripting::PokemodWrapper::ability(const QString& name) +{ + for (int i = 0; i < m_pokemod->abilityCount(); ++i) + { + if (m_pokemod->ability(i)->name() == name) + return AbilityWrapper::create(m_pokemod->ability(i), this); + } + return NULL; +} + +Pokescripting::AuthorWrapper* Pokescripting::PokemodWrapper::author(const QString& name) +{ + for (int i = 0; i < m_pokemod->authorCount(); ++i) + { + if (m_pokemod->author(i)->name() == name) + return AuthorWrapper::create(m_pokemod->author(i), this); + } + return NULL; +} + +Pokescripting::BadgeWrapper* Pokescripting::PokemodWrapper::badge(const QString& name) +{ + for (int i = 0; i < m_pokemod->badgeCount(); ++i) + { + if (m_pokemod->badge(i)->name() == name) + return BadgeWrapper::create(m_pokemod->badge(i), this); + } + return NULL; +} + +Pokescripting::CoinListWrapper* Pokescripting::PokemodWrapper::coinList(const QString& name) +{ + for (int i = 0; i < m_pokemod->coinListCount(); ++i) + { + if (m_pokemod->coinList(i)->name() == name) + return CoinListWrapper::create(m_pokemod->coinList(i), this); + } + return NULL; +} + +Pokescripting::EggGroupWrapper* Pokescripting::PokemodWrapper::eggGroup(const QString& name) +{ + for (int i = 0; i < m_pokemod->eggGroupCount(); ++i) + { + if (m_pokemod->eggGroup(i)->name() == name) + return EggGroupWrapper::create(m_pokemod->eggGroup(i), this); + } + return NULL; +} + +Pokescripting::GlobalScriptWrapper* Pokescripting::PokemodWrapper::globalScript(const QString& name) +{ + for (int i = 0; i < m_pokemod->globalScriptCount(); ++i) + { + if (m_pokemod->globalScript(i)->name() == name) + return GlobalScriptWrapper::create(m_pokemod->globalScript(i), this); + } + return NULL; +} + +Pokescripting::ItemWrapper* Pokescripting::PokemodWrapper::item(const QString& name) +{ + for (int i = 0; i < m_pokemod->itemCount(); ++i) + { + if (m_pokemod->item(i)->name() == name) + return ItemWrapper::create(m_pokemod->item(i), this); + } + return NULL; +} + +Pokescripting::ItemTypeWrapper* Pokescripting::PokemodWrapper::itemType(const QString& name) +{ + for (int i = 0; i < m_pokemod->itemTypeCount(); ++i) + { + if (m_pokemod->itemType(i)->name() == name) + return ItemTypeWrapper::create(m_pokemod->itemType(i), this); + } + return NULL; +} + +Pokescripting::MapWrapper* Pokescripting::PokemodWrapper::map(const QString& name) +{ + for (int i = 0; i < m_pokemod->mapCount(); ++i) + { + if (m_pokemod->map(i)->name() == name) + return MapWrapper::create(m_pokemod->map(i), this); + } + return NULL; +} + +Pokescripting::MoveWrapper* Pokescripting::PokemodWrapper::move(const QString& name) +{ + for (int i = 0; i < m_pokemod->moveCount(); ++i) + { + if (m_pokemod->move(i)->name() == name) + return MoveWrapper::create(m_pokemod->move(i), this); + } + return NULL; +} + +Pokescripting::NatureWrapper* Pokescripting::PokemodWrapper::nature(const QString& name) +{ + for (int i = 0; i < m_pokemod->natureCount(); ++i) + { + if (m_pokemod->nature(i)->name() == name) + return NatureWrapper::create(m_pokemod->nature(i), this); + } + return NULL; +} + +Pokescripting::SkinWrapper* Pokescripting::PokemodWrapper::skin(const QString& name) +{ + for (int i = 0; i < m_pokemod->skinCount(); ++i) + { + if (m_pokemod->skin(i)->name() == name) + return SkinWrapper::create(m_pokemod->skin(i), this); + } + return NULL; +} + +Pokescripting::SoundWrapper* Pokescripting::PokemodWrapper::sound(const QString& name) +{ + for (int i = 0; i < m_pokemod->soundCount(); ++i) + { + if (m_pokemod->sound(i)->name() == name) + return SoundWrapper::create(m_pokemod->sound(i), this); + } + return NULL; +} + +Pokescripting::SpeciesWrapper* Pokescripting::PokemodWrapper::species(const QString& name) +{ + for (int i = 0; i < m_pokemod->speciesCount(); ++i) + { + if (m_pokemod->species(i)->name() == name) + return SpeciesWrapper::create(m_pokemod->species(i), this); + } + return NULL; +} + +Pokescripting::SpriteWrapper* Pokescripting::PokemodWrapper::sprite(const QString& name) +{ + for (int i = 0; i < m_pokemod->spriteCount(); ++i) + { + if (m_pokemod->sprite(i)->name() == name) + return SpriteWrapper::create(m_pokemod->sprite(i), this); + } + return NULL; +} + +Pokescripting::StatusWrapper* Pokescripting::PokemodWrapper::status(const QString& name) +{ + for (int i = 0; i < m_pokemod->statusCount(); ++i) + { + if (m_pokemod->status(i)->name() == name) + return StatusWrapper::create(m_pokemod->status(i), this); + } + return NULL; +} + +Pokescripting::StoreWrapper* Pokescripting::PokemodWrapper::store(const QString& name) +{ + for (int i = 0; i < m_pokemod->storeCount(); ++i) + { + if (m_pokemod->store(i)->name() == name) + return StoreWrapper::create(m_pokemod->store(i), this); + } + return NULL; +} + +Pokescripting::TileWrapper* Pokescripting::PokemodWrapper::tile(const QString& name) +{ + for (int i = 0; i < m_pokemod->tileCount(); ++i) + { + if (m_pokemod->tile(i)->name() == name) + return TileWrapper::create(m_pokemod->tile(i), this); + } + return NULL; +} + +Pokescripting::TimeWrapper* Pokescripting::PokemodWrapper::time(const QString& name) +{ + for (int i = 0; i < m_pokemod->timeCount(); ++i) + { + if (m_pokemod->time(i)->name() == name) + return TimeWrapper::create(m_pokemod->time(i), this); + } + return NULL; +} + +Pokescripting::TrainerWrapper* Pokescripting::PokemodWrapper::trainer(const QString& name) +{ + for (int i = 0; i < m_pokemod->trainerCount(); ++i) + { + if (m_pokemod->trainer(i)->name() == name) + return TrainerWrapper::create(m_pokemod->trainer(i), this); + } + return NULL; +} + +Pokescripting::TypeWrapper* Pokescripting::PokemodWrapper::type(const QString& name) +{ + for (int i = 0; i < m_pokemod->typeCount(); ++i) + { + if (m_pokemod->type(i)->name() == name) + return TypeWrapper::create(m_pokemod->type(i), this); + } + return NULL; +} + +Pokescripting::WeatherWrapper* Pokescripting::PokemodWrapper::weather(const QString& name) +{ + for (int i = 0; i < m_pokemod->weatherCount(); ++i) + { + if (m_pokemod->weather(i)->name() == name) + return WeatherWrapper::create(m_pokemod->weather(i), this); + } + return NULL; +} diff --git a/sigscript/PokemodWrapper.h b/sigscript/PokemodWrapper.h new file mode 100644 index 00000000..cf97c60c --- /dev/null +++ b/sigscript/PokemodWrapper.h @@ -0,0 +1,128 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_POKEMODWRAPPER__ +#define __POKESCRIPTING_POKEMODWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/Hat.h" +#include "../pokemod/Pokemod.h" + +namespace Pokescripting +{ +// Forward declarations +class AbilityWrapper; +class AuthorWrapper; +class BadgeWrapper; +class CoinListWrapper; +class EggGroupWrapper; +class GlobalScriptWrapper; +class ItemWrapper; +class ItemTypeWrapper; +class MapWrapper; +class MapWarpWrapper; +class MoveWrapper; +class NatureWrapper; +class RulesWrapper; +class SkinWrapper; +class SoundWrapper; +class SpeciesWrapper; +class SpriteWrapper; +class StatusWrapper; +class StoreWrapper; +class TileWrapper; +class TimeWrapper; +class TrainerWrapper; +class TypeWrapper; +class WeatherWrapper; + +class POKESCRIPTING_EXPORT PokemodWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + PokemodWrapper(const Pokemod::Pokemod* pokemod); + + Pokemod::Hat<NatureWrapper*> natureHat(); + + AbilityWrapper* ability(const int id); + AuthorWrapper* author(const int id); + BadgeWrapper* badge(const int id); + CoinListWrapper* coinList(const int id); + EggGroupWrapper* eggGroup(const int id); + GlobalScriptWrapper* globalScript(const int id); + ItemWrapper* item(const int id); + ItemTypeWrapper* itemType(const int id); + MapWrapper* map(const int id); + MoveWrapper* move(const int id); + NatureWrapper* nature(const int id); + SkinWrapper* skin(const int id); + SoundWrapper* sound(const int id); + SpeciesWrapper* species(const int id); + SpriteWrapper* sprite(const int id); + StatusWrapper* status(const int id); + StoreWrapper* store(const int id); + TileWrapper* tile(const int id); + TimeWrapper* time(const int id); + TrainerWrapper* trainer(const int id); + TypeWrapper* type(const int id); + WeatherWrapper* weather(const int id); + + Q_SCRIPTABLE Pokemod::Stat stat(const QString& name) const; + Q_SCRIPTABLE Pokemod::Direction direction(const QString& direction) const; + + Q_SCRIPTABLE QString title() const; + Q_SCRIPTABLE QString version() const; + Q_SCRIPTABLE QString description() const; + Q_SCRIPTABLE MapWarpWrapper* startWarp(); + Q_SCRIPTABLE Pokemod::Fraction effectiveness(const TypeWrapper* attacker, const TypeWrapper* defender) const; + Q_SCRIPTABLE RulesWrapper* rules(); + + Q_SCRIPTABLE AbilityWrapper* ability(const QString& name); + Q_SCRIPTABLE AuthorWrapper* author(const QString& name); + Q_SCRIPTABLE BadgeWrapper* badge(const QString& name); + Q_SCRIPTABLE CoinListWrapper* coinList(const QString& name); + Q_SCRIPTABLE EggGroupWrapper* eggGroup(const QString& name); + Q_SCRIPTABLE GlobalScriptWrapper* globalScript(const QString& name); + Q_SCRIPTABLE ItemWrapper* item(const QString& name); + Q_SCRIPTABLE ItemTypeWrapper* itemType(const QString& name); + Q_SCRIPTABLE MapWrapper* map(const QString& name); + Q_SCRIPTABLE MoveWrapper* move(const QString& name); + Q_SCRIPTABLE NatureWrapper* nature(const QString& name); + Q_SCRIPTABLE SkinWrapper* skin(const QString& name); + Q_SCRIPTABLE SoundWrapper* sound(const QString& name); + Q_SCRIPTABLE SpeciesWrapper* species(const QString& name); + Q_SCRIPTABLE SpriteWrapper* sprite(const QString& name); + Q_SCRIPTABLE StatusWrapper* status(const QString& name); + Q_SCRIPTABLE StoreWrapper* store(const QString& name); + Q_SCRIPTABLE TileWrapper* tile(const QString& name); + Q_SCRIPTABLE TimeWrapper* time(const QString& name); + Q_SCRIPTABLE TrainerWrapper* trainer(const QString& name); + Q_SCRIPTABLE TypeWrapper* type(const QString& name); + Q_SCRIPTABLE WeatherWrapper* weather(const QString& name); + private: + PokemodWrapper& operator=(const PokemodWrapper& rhs); + + const Pokemod::Pokemod* m_pokemod; +}; +} +Q_DECLARE_METATYPE(Pokescripting::PokemodWrapper*) + +#endif diff --git a/sigscript/RulesWrapper.cpp b/sigscript/RulesWrapper.cpp new file mode 100644 index 00000000..e70e4af0 --- /dev/null +++ b/sigscript/RulesWrapper.cpp @@ -0,0 +1,176 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "RulesWrapper.h" + +// Pokescripting includes +#include "PokemodWrapper.h" + +Pokescripting::RulesWrapper* Pokescripting::RulesWrapper::create(const Pokemod::Rules* rules, PokemodWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, rules->id()))) + m_instances[Signiture(parent, rules->id())] = new RulesWrapper(rules, parent); + return qobject_cast<RulesWrapper*>(m_instances[Signiture(parent, rules->id())]); +} + +Pokescripting::RulesWrapper::RulesWrapper(const Pokemod::Rules* rules, PokemodWrapper* parent) : + ObjectWrapper(rules, parent), + m_rules(rules) +{ +} + +bool Pokescripting::RulesWrapper::genderAllowed() const +{ + return m_rules->genderAllowed(); +} + +bool Pokescripting::RulesWrapper::breedingAllowed() const +{ + return m_rules->breedingAllowed(); +} + +bool Pokescripting::RulesWrapper::criticalDomains() const +{ + return m_rules->criticalDomains(); +} + +bool Pokescripting::RulesWrapper::useTurns() const +{ + return m_rules->useTurns(); +} + +int Pokescripting::RulesWrapper::numBoxes() const +{ + if (value("numBoxes").canConvert<int>()) + return value("numBoxes").toInt(); + return m_rules->numBoxes(); +} + +int Pokescripting::RulesWrapper::boxSize() const +{ + if (value("boxSize").canConvert<int>()) + return value("boxSize").toInt(); + return m_rules->boxSize(); +} + +int Pokescripting::RulesWrapper::maxParty() const +{ + if (value("maxParty").canConvert<int>()) + return value("maxParty").toInt(); + return m_rules->maxParty(); +} + +int Pokescripting::RulesWrapper::maxFight() const +{ + if (value("maxFight").canConvert<int>()) + return value("maxFight").toInt(); + return m_rules->maxFight(); +} + +int Pokescripting::RulesWrapper::maxPlayers() const +{ + if (value("maxFight").canConvert<int>()) + return value("maxFight").toInt(); + return m_rules->maxPlayers(); +} + +int Pokescripting::RulesWrapper::maxHeldItems() const +{ + if (value("maxHeldItems").canConvert<int>()) + return value("maxHeldItems").toInt(); + return m_rules->maxHeldItems(); +} + +int Pokescripting::RulesWrapper::maxAbilities() const +{ + return m_rules->maxAbilities(); +} + +int Pokescripting::RulesWrapper::maxNatures() const +{ + return m_rules->maxNatures(); +} + +int Pokescripting::RulesWrapper::maxMoves() const +{ + if (value("maxMoves").canConvert<int>()) + return value("maxMoves").toInt(); + return m_rules->maxMoves(); +} + +int Pokescripting::RulesWrapper::maxLevel() const +{ + if (value("maxLevel").canConvert<int>()) + return value("maxLevel").toInt(); + return m_rules->maxLevel(); +} + +int Pokescripting::RulesWrapper::maxStages() const +{ + if (value("maxStages").canConvert<int>()) + return value("maxStages").toInt(); + return m_rules->maxStages(); +} + +int Pokescripting::RulesWrapper::maxMoney() const +{ + if (value("maxMoney").canConvert<int>()) + return value("maxMoney").toInt(); + return m_rules->maxMoney(); +} + +bool Pokescripting::RulesWrapper::hardCash() const +{ + return m_rules->hardCash(); +} + +bool Pokescripting::RulesWrapper::allowSwitchStyle() const +{ + if (value("allowSwitchStyle").canConvert<bool>()) + return value("allowSwitchStyle").toBool(); + return m_rules->allowSwitchStyle(); +} + +bool Pokescripting::RulesWrapper::specialSplit() const +{ + return m_rules->specialSplit(); +} + +bool Pokescripting::RulesWrapper::specialDVSplit() const +{ + return m_rules->specialDVSplit(); +} + +bool Pokescripting::RulesWrapper::effortValuesAllowed() const +{ + return m_rules->effortValuesAllowed(); +} + +int Pokescripting::RulesWrapper::maxTotalEV() const +{ + if (value("maxTotalEV").canConvert<int>()) + return value("maxTotalEV").toInt(); + return m_rules->maxTotalEV(); +} + +int Pokescripting::RulesWrapper::maxEVPerStat() const +{ + if (value("maxEVPerStat").canConvert<int>()) + return value("maxEVPerStat").toInt(); + return m_rules->maxEVPerStat(); +} diff --git a/sigscript/RulesWrapper.h b/sigscript/RulesWrapper.h new file mode 100644 index 00000000..a4492022 --- /dev/null +++ b/sigscript/RulesWrapper.h @@ -0,0 +1,68 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_RULESWRAPPER__ +#define __POKESCRIPTING_RULESWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/Rules.h" + +namespace Pokescripting +{ +class POKESCRIPTING_EXPORT RulesWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static RulesWrapper* create(const Pokemod::Rules* rules, PokemodWrapper* parent); + + Q_SCRIPTABLE bool genderAllowed() const; + Q_SCRIPTABLE bool breedingAllowed() const; + Q_SCRIPTABLE bool criticalDomains() const; + Q_SCRIPTABLE bool useTurns() const; + Q_SCRIPTABLE int numBoxes() const; + Q_SCRIPTABLE int boxSize() const; + Q_SCRIPTABLE int maxParty() const; + Q_SCRIPTABLE int maxFight() const; + Q_SCRIPTABLE int maxPlayers() const; + Q_SCRIPTABLE int maxHeldItems() const; + Q_SCRIPTABLE int maxAbilities() const; + Q_SCRIPTABLE int maxNatures() const; + Q_SCRIPTABLE int maxMoves() const; + Q_SCRIPTABLE int maxLevel() const; + Q_SCRIPTABLE int maxStages() const; + Q_SCRIPTABLE int maxMoney() const; + Q_SCRIPTABLE bool hardCash() const; + Q_SCRIPTABLE bool allowSwitchStyle() const; + Q_SCRIPTABLE bool specialSplit() const; + Q_SCRIPTABLE bool specialDVSplit() const; + Q_SCRIPTABLE bool effortValuesAllowed() const; + Q_SCRIPTABLE int maxTotalEV() const; + Q_SCRIPTABLE int maxEVPerStat() const; + private: + RulesWrapper(const Pokemod::Rules* rules, PokemodWrapper* parent); + RulesWrapper& operator=(const RulesWrapper& rhs); + + const Pokemod::Rules* m_rules; +}; +} +Q_DECLARE_METATYPE(Pokescripting::RulesWrapper*) + +#endif diff --git a/sigscript/SkinWrapper.cpp b/sigscript/SkinWrapper.cpp new file mode 100644 index 00000000..be19a8f1 --- /dev/null +++ b/sigscript/SkinWrapper.cpp @@ -0,0 +1,45 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "SkinWrapper.h" + +// Pokemod scripting +#include "PokemodWrapper.h" + +Pokescripting::SkinWrapper* Pokescripting::SkinWrapper::create(const Pokemod::Skin* skin, PokemodWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, skin->id()))) + m_instances[Signiture(parent, skin->id())] = new SkinWrapper(skin, parent); + return qobject_cast<SkinWrapper*>(m_instances[Signiture(parent, skin->id())]); +} + +Pokescripting::SkinWrapper::SkinWrapper(const Pokemod::Skin* skin, PokemodWrapper* parent) : + ObjectWrapper(skin, parent), + m_skin(skin) +{ +} + +QString Pokescripting::SkinWrapper::name() const +{ + return m_skin->name(); +} + +Pokemod::Script Pokescripting::SkinWrapper::script() const +{ + return m_skin->script(); +} diff --git a/sigscript/SkinWrapper.h b/sigscript/SkinWrapper.h new file mode 100644 index 00000000..1604d3f4 --- /dev/null +++ b/sigscript/SkinWrapper.h @@ -0,0 +1,47 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_SKINWRAPPER__ +#define __POKESCRIPTING_SKINWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/Skin.h" + +namespace Pokescripting +{ +class POKESCRIPTING_EXPORT SkinWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static SkinWrapper* create(const Pokemod::Skin* skin, PokemodWrapper* parent); + + Q_SCRIPTABLE QString name() const; + Q_SCRIPTABLE Pokemod::Script script() const; + private: + SkinWrapper(const Pokemod::Skin* skin, PokemodWrapper* parent); + SkinWrapper& operator=(const SkinWrapper& rhs); + + const Pokemod::Skin* m_skin; +}; +} +Q_DECLARE_METATYPE(Pokescripting::SkinWrapper*) + +#endif diff --git a/sigscript/SoundWrapper.cpp b/sigscript/SoundWrapper.cpp new file mode 100644 index 00000000..ebecdfc2 --- /dev/null +++ b/sigscript/SoundWrapper.cpp @@ -0,0 +1,70 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "SoundWrapper.h" + +// Pokescripting includes +#include "PokemodWrapper.h" + +// Qt includes +#include <QtCore/QBuffer> + +// Phonon includes +#include <Phonon/MediaObject> +#include <Phonon/MediaSource> + +Pokescripting::SoundWrapper* Pokescripting::SoundWrapper::create(const Pokemod::Sound* sound, PokemodWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, sound->id()))) + m_instances[Signiture(parent, sound->id())] = new SoundWrapper(sound, parent); + return qobject_cast<SoundWrapper*>(m_instances[Signiture(parent, sound->id())]); +} + +Pokescripting::SoundWrapper::SoundWrapper(const Pokemod::Sound* sound, PokemodWrapper* parent) : + ObjectWrapper(sound, parent), + m_sound(sound) +{ +} + +Pokemod::Sound::Type Pokescripting::SoundWrapper::type(const QString& name) const +{ + if (name == "Sound Effect") + return Pokemod::Sound::SoundEffect; + else if (name == "Music") + return Pokemod::Sound::Music; + return QVariant(-1).value<Pokemod::Sound::Type>(); +} + +QString Pokescripting::SoundWrapper::name() const +{ + return m_sound->name(); +} + +Pokemod::Sound::Type Pokescripting::SoundWrapper::type() const +{ + return m_sound->type(); +} + +Phonon::MediaObject* Pokescripting::SoundWrapper::audio() +{ + Phonon::MediaObject* media = new Phonon::MediaObject(this); + QBuffer* buffer = new QBuffer(media); + buffer->setData(m_sound->data()); + media->setCurrentSource(buffer); + return media; +} diff --git a/sigscript/SoundWrapper.h b/sigscript/SoundWrapper.h new file mode 100644 index 00000000..54ac3f38 --- /dev/null +++ b/sigscript/SoundWrapper.h @@ -0,0 +1,56 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_SOUNDWRAPPER__ +#define __POKESCRIPTING_SOUNDWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/Sound.h" + +// Forward declarations +namespace Phonon +{ +class MediaObject; +} + +namespace Pokescripting +{ +class POKESCRIPTING_EXPORT SoundWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static SoundWrapper* create(const Pokemod::Sound* sound, PokemodWrapper* parent); + + Q_SCRIPTABLE Pokemod::Sound::Type type(const QString& name) const; + + Q_SCRIPTABLE QString name() const; + Q_SCRIPTABLE Pokemod::Sound::Type type() const; + Q_SCRIPTABLE Phonon::MediaObject* audio(); + private: + SoundWrapper(const Pokemod::Sound* sound, PokemodWrapper* parent); + SoundWrapper& operator=(const SoundWrapper& rhs); + + const Pokemod::Sound* m_sound; +}; +} +Q_DECLARE_METATYPE(Pokescripting::SoundWrapper*) + +#endif diff --git a/sigscript/SpeciesAbilityWrapper.cpp b/sigscript/SpeciesAbilityWrapper.cpp new file mode 100644 index 00000000..fb392653 --- /dev/null +++ b/sigscript/SpeciesAbilityWrapper.cpp @@ -0,0 +1,46 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "SpeciesAbilityWrapper.h" + +// Pokescripting includes +#include "PokemodWrapper.h" +#include "SpeciesWrapper.h" + +Pokescripting::SpeciesAbilityWrapper* Pokescripting::SpeciesAbilityWrapper::create(const Pokemod::SpeciesAbility* ability, SpeciesWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, ability->id()))) + m_instances[Signiture(parent, ability->id())] = new SpeciesAbilityWrapper(ability, parent); + return qobject_cast<SpeciesAbilityWrapper*>(m_instances[Signiture(parent, ability->id())]); +} + +Pokescripting::SpeciesAbilityWrapper::SpeciesAbilityWrapper(const Pokemod::SpeciesAbility* ability, SpeciesWrapper* parent) : + ObjectWrapper(ability, parent), + m_ability(ability) +{ +} + +Pokescripting::AbilityWrapper* Pokescripting::SpeciesAbilityWrapper::ability() +{ + return pokemod()->ability(m_ability->ability()); +} + +int Pokescripting::SpeciesAbilityWrapper::weight() const +{ + return m_ability->weight(); +} diff --git a/sigscript/SpeciesAbilityWrapper.h b/sigscript/SpeciesAbilityWrapper.h new file mode 100644 index 00000000..dafe9dbe --- /dev/null +++ b/sigscript/SpeciesAbilityWrapper.h @@ -0,0 +1,51 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_SPECIESABILITYWRAPPER__ +#define __POKESCRIPTING_SPECIESABILITYWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/SpeciesAbility.h" + +namespace Pokescripting +{ +// Forward declarations +class AbilityWrapper; +class SpeciesWrapper; + +class POKESCRIPTING_EXPORT SpeciesAbilityWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static SpeciesAbilityWrapper* create(const Pokemod::SpeciesAbility* ability, SpeciesWrapper* parent); + + Q_SCRIPTABLE AbilityWrapper* ability(); + Q_SCRIPTABLE int weight() const; + private: + SpeciesAbilityWrapper(const Pokemod::SpeciesAbility* ability, SpeciesWrapper* parent); + SpeciesAbilityWrapper& operator=(const SpeciesAbilityWrapper& rhs); + + const Pokemod::SpeciesAbility* m_ability; +}; +} +Q_DECLARE_METATYPE(Pokescripting::SpeciesAbilityWrapper*) + +#endif diff --git a/sigscript/SpeciesItemWrapper.cpp b/sigscript/SpeciesItemWrapper.cpp new file mode 100644 index 00000000..23d4afa1 --- /dev/null +++ b/sigscript/SpeciesItemWrapper.cpp @@ -0,0 +1,48 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "SpeciesItemWrapper.h" + +// Pokescripting includes +#include "PokemodWrapper.h" +#include "SpeciesWrapper.h" + +Pokescripting::SpeciesItemWrapper* Pokescripting::SpeciesItemWrapper::create(const Pokemod::SpeciesItem* item, SpeciesWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, item->id()))) + m_instances[Signiture(parent, item->id())] = new SpeciesItemWrapper(item, parent); + return qobject_cast<SpeciesItemWrapper*>(m_instances[Signiture(parent, item->id())]); +} + +Pokescripting::SpeciesItemWrapper::SpeciesItemWrapper(const Pokemod::SpeciesItem* item, SpeciesWrapper* parent) : + ObjectWrapper(item, parent), + m_item(item) +{ +} + +Pokescripting::ItemWrapper* Pokescripting::SpeciesItemWrapper::item() +{ + return pokemod()->item(m_item->item()); +} + +int Pokescripting::SpeciesItemWrapper::weight() const +{ + if (value("weight").canConvert<int>()) + return value("weight").toInt(); + return m_item->weight(); +} diff --git a/sigscript/SpeciesItemWrapper.h b/sigscript/SpeciesItemWrapper.h new file mode 100644 index 00000000..b172b32f --- /dev/null +++ b/sigscript/SpeciesItemWrapper.h @@ -0,0 +1,51 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_SPECIESITEMWRAPPER__ +#define __POKESCRIPTING_SPECIESITEMWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/SpeciesItem.h" + +namespace Pokescripting +{ +// Forward declarations +class ItemWrapper; +class SpeciesWrapper; + +class POKESCRIPTING_EXPORT SpeciesItemWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static SpeciesItemWrapper* create(const Pokemod::SpeciesItem* item, SpeciesWrapper* parent); + + Q_SCRIPTABLE ItemWrapper* item(); + Q_SCRIPTABLE int weight() const; + private: + SpeciesItemWrapper(const Pokemod::SpeciesItem* item, SpeciesWrapper* parent); + SpeciesItemWrapper& operator=(const SpeciesItemWrapper& rhs); + + const Pokemod::SpeciesItem* m_item; +}; +} +Q_DECLARE_METATYPE(Pokescripting::SpeciesItemWrapper*) + +#endif diff --git a/sigscript/SpeciesMoveWrapper.cpp b/sigscript/SpeciesMoveWrapper.cpp new file mode 100644 index 00000000..d1c33864 --- /dev/null +++ b/sigscript/SpeciesMoveWrapper.cpp @@ -0,0 +1,51 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "SpeciesMoveWrapper.h" + +// Pokescripting includes +#include "PokemodWrapper.h" +#include "SpeciesWrapper.h" + +Pokescripting::SpeciesMoveWrapper* Pokescripting::SpeciesMoveWrapper::create(const Pokemod::SpeciesMove* move, SpeciesWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, move->id()))) + m_instances[Signiture(parent, move->id())] = new SpeciesMoveWrapper(move, parent); + return qobject_cast<SpeciesMoveWrapper*>(m_instances[Signiture(parent, move->id())]); +} + +Pokescripting::SpeciesMoveWrapper::SpeciesMoveWrapper(const Pokemod::SpeciesMove* move, SpeciesWrapper* parent) : + ObjectWrapper(move, parent), + m_move(move) +{ +} + +Pokescripting::MoveWrapper* Pokescripting::SpeciesMoveWrapper::move() +{ + return pokemod()->move(m_move->move()); +} + +int Pokescripting::SpeciesMoveWrapper::level() const +{ + return m_move->level(); +} + +int Pokescripting::SpeciesMoveWrapper::wild() const +{ + return m_move->wild(); +} diff --git a/sigscript/SpeciesMoveWrapper.h b/sigscript/SpeciesMoveWrapper.h new file mode 100644 index 00000000..6d575fda --- /dev/null +++ b/sigscript/SpeciesMoveWrapper.h @@ -0,0 +1,52 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_SPECIESMOVEWRAPPER__ +#define __POKESCRIPTING_SPECIESMOVEWRAPPER__ + +// Pokescripting includes +#include "MoveWrapper.h" +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/SpeciesMove.h" + +namespace Pokescripting +{ +// Forward declarations +class SpeciesWrapper; + +class POKESCRIPTING_EXPORT SpeciesMoveWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static SpeciesMoveWrapper* create(const Pokemod::SpeciesMove* move, SpeciesWrapper* parent); + + Q_SCRIPTABLE MoveWrapper* move(); + Q_SCRIPTABLE int level() const; + Q_SCRIPTABLE int wild() const; + private: + SpeciesMoveWrapper(const Pokemod::SpeciesMove* move, SpeciesWrapper* parent); + SpeciesMoveWrapper& operator=(const SpeciesMoveWrapper& rhs); + + const Pokemod::SpeciesMove* m_move; +}; +} +Q_DECLARE_METATYPE(Pokescripting::SpeciesMoveWrapper*) + +#endif diff --git a/sigscript/SpeciesWrapper.cpp b/sigscript/SpeciesWrapper.cpp new file mode 100644 index 00000000..e80c364d --- /dev/null +++ b/sigscript/SpeciesWrapper.cpp @@ -0,0 +1,237 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "SpeciesWrapper.h" + +// Pokescripting includes +#include "PokemodWrapper.h" +#include "SpeciesAbilityWrapper.h" +#include "SpeciesItemWrapper.h" +#include "SpeciesMoveWrapper.h" + +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<SpeciesWrapper*>(m_instances[Signiture(parent, species->id())]); +} + +Pokescripting::SpeciesWrapper::SpeciesWrapper(const Pokemod::Species* species, PokemodWrapper* parent) : + ObjectWrapper(species, parent), + m_species(species) +{ +} + +Pokemod::Hat<Pokescripting::AbilityWrapper*> Pokescripting::SpeciesWrapper::abilityHat() +{ + Pokemod::Hat<AbilityWrapper*> hat; + for (int i = 0; i < abilityCount(); ++i) + hat.add(ability(i)->ability(), ability(i)->weight()); + return hat; +} + +Pokemod::Hat<Pokescripting::ItemWrapper*> Pokescripting::SpeciesWrapper::itemHat() +{ + Pokemod::Hat<ItemWrapper*> hat; + for (int i = 0; i < itemCount(); ++i) + hat.add(item(i)->item(), item(i)->weight()); + return hat; +} + +Pokemod::Species::Style Pokescripting::SpeciesWrapper::growth(const QString& name) const +{ + if (name == "Fluctuating") + return Pokemod::Species::Fluctuating; + else if (name == "Fading") + return Pokemod::Species::Fading; + else if (name == "Slow") + return Pokemod::Species::Slow; + else if (name == "Normal") + return Pokemod::Species::Normal; + else if (name == "Fast") + return Pokemod::Species::Fast; + else if (name == "Erratic") + return Pokemod::Species::Erratic; + return QVariant(-1).value<Pokemod::Species::Style>(); +} + +QString Pokescripting::SpeciesWrapper::name() const +{ + return m_species->name(); +} + +int Pokescripting::SpeciesWrapper::baseStat(const Pokemod::Stat stat) const +{ + return m_species->baseStat(stat); +} + +int Pokescripting::SpeciesWrapper::effortValue(const Pokemod::Stat stat) const +{ + return m_species->effortValue(stat); +} + +Pokemod::Species::Style Pokescripting::SpeciesWrapper::growth() const +{ + return m_species->growth(); +} + +int Pokescripting::SpeciesWrapper::experienceValue() const +{ + return m_species->experienceValue(); +} + +int Pokescripting::SpeciesWrapper::catchValue() const +{ + return m_species->catchValue(); +} + +Pokemod::Fraction Pokescripting::SpeciesWrapper::runChance() const +{ + if (value("runChance").canConvert<Pokemod::Fraction>()) + return value("runChance").value<Pokemod::Fraction>(); + return m_species->runChance(); +} + +Pokemod::Fraction Pokescripting::SpeciesWrapper::fleeChance() const +{ + if (value("fleeChance").canConvert<Pokemod::Fraction>()) + return value("fleeChance").value<Pokemod::Fraction>(); + return m_species->fleeChance(); +} + +Pokemod::Fraction Pokescripting::SpeciesWrapper::itemChance() const +{ + if (value("itemChance").canConvert<Pokemod::Fraction>()) + return value("itemChance").value<Pokemod::Fraction>(); + return m_species->itemChance(); +} + +int Pokescripting::SpeciesWrapper::pokedexNumber() const +{ + return m_species->pokedexNumber(); +} + +int Pokescripting::SpeciesWrapper::weight() const +{ + return m_species->weight(); +} + +int Pokescripting::SpeciesWrapper::height() const +{ + return m_species->height(); +} + +QString Pokescripting::SpeciesWrapper::pokedexEntry() const +{ + return m_species->pokedexEntry(); +} + +Pokescripting::SpriteWrapper* Pokescripting::SpeciesWrapper::frontMaleSprite() +{ + return pokemod()->sprite(m_species->frontMaleSprite()); +} + +Pokescripting::SpriteWrapper* Pokescripting::SpeciesWrapper::backMaleSprite() +{ + return pokemod()->sprite(m_species->backMaleSprite()); +} + +Pokescripting::SpriteWrapper* Pokescripting::SpeciesWrapper::frontFemaleSprite() +{ + return pokemod()->sprite(m_species->frontFemaleSprite()); +} + +Pokescripting::SpriteWrapper* Pokescripting::SpeciesWrapper::backFemaleSprite() +{ + return pokemod()->sprite(m_species->backFemaleSprite()); +} + +Pokescripting::SkinWrapper* Pokescripting::SpeciesWrapper::skin() +{ + return pokemod()->skin(m_species->skin()); +} + +Pokemod::Fraction Pokescripting::SpeciesWrapper::genderFactor() const +{ + return m_species->genderFactor(); +} + +int Pokescripting::SpeciesWrapper::eggSpecies() const +{ + if (value("eggSpecies").canConvert<int>()) + return value("eggSpecies").toInt(); + return m_species->eggSpecies(); +} + +int Pokescripting::SpeciesWrapper::eggSteps() const +{ + return m_species->eggSteps(); +} + +QList<Pokescripting::TypeWrapper*> Pokescripting::SpeciesWrapper::types() +{ + QList<int> typeIds = m_species->types(); + QList<TypeWrapper*> types; + foreach (int id, typeIds) + types.append(pokemod()->type(id)); + return types; +} + +QList<Pokescripting::EggGroupWrapper*> Pokescripting::SpeciesWrapper::eggGroups() +{ + QList<int> eggGroupIds = m_species->eggGroups(); + QList<EggGroupWrapper*> eggGroups; + foreach (int id, eggGroupIds) + eggGroups.append(pokemod()->eggGroup(id)); + return eggGroups; +} + +Pokemod::Script Pokescripting::SpeciesWrapper::evolution() const +{ + return m_species->evolution(); +} + +Pokescripting::SpeciesAbilityWrapper* Pokescripting::SpeciesWrapper::ability(const int index) +{ + return SpeciesAbilityWrapper::create(m_species->ability(index), this); +} + +int Pokescripting::SpeciesWrapper::abilityCount() const +{ + return m_species->abilityCount(); +} + +Pokescripting::SpeciesItemWrapper* Pokescripting::SpeciesWrapper::item(const int index) +{ + return SpeciesItemWrapper::create(m_species->item(index), this); +} + +int Pokescripting::SpeciesWrapper::itemCount() const +{ + return m_species->itemCount(); +} + +Pokescripting::SpeciesMoveWrapper* Pokescripting::SpeciesWrapper::move(const int index) +{ + return SpeciesMoveWrapper::create(m_species->move(index), this); +} + +int Pokescripting::SpeciesWrapper::moveCount() const +{ + return m_species->moveCount(); +} diff --git a/sigscript/SpeciesWrapper.h b/sigscript/SpeciesWrapper.h new file mode 100644 index 00000000..f42e628d --- /dev/null +++ b/sigscript/SpeciesWrapper.h @@ -0,0 +1,95 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_SPECIESWRAPPER__ +#define __POKESCRIPTING_SPECIESWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/Hat.h" +#include "../pokemod/Species.h" + +namespace Pokescripting +{ +// Forward declarations +class AbilityWrapper; +class EggGroupWrapper; +class ItemWrapper; +class SkinWrapper; +class SpeciesAbilityWrapper; +class SpeciesItemWrapper; +class SpeciesMoveWrapper; +class SpriteWrapper; +class TypeWrapper; + +class POKESCRIPTING_EXPORT SpeciesWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static SpeciesWrapper* create(const Pokemod::Species* species, PokemodWrapper* parent); + + Pokemod::Hat<AbilityWrapper*> abilityHat(); + Pokemod::Hat<ItemWrapper*> itemHat(); + + Q_SCRIPTABLE Pokemod::Species::Style growth(const QString& name) const; + + Q_SCRIPTABLE QString name() const; + Q_SCRIPTABLE int baseStat(const Pokemod::Stat stat) const; + Q_SCRIPTABLE int effortValue(const Pokemod::Stat stat) const; + Q_SCRIPTABLE Pokemod::Species::Style growth() const; + Q_SCRIPTABLE int experienceValue() const; + Q_SCRIPTABLE int catchValue() const; + Q_SCRIPTABLE Pokemod::Fraction runChance() const; + Q_SCRIPTABLE Pokemod::Fraction fleeChance() const; + Q_SCRIPTABLE Pokemod::Fraction itemChance() const; + Q_SCRIPTABLE int pokedexNumber() const; + Q_SCRIPTABLE int weight() const; + Q_SCRIPTABLE int height() const; + Q_SCRIPTABLE QString pokedexEntry() const; + Q_SCRIPTABLE SpriteWrapper* frontMaleSprite(); + Q_SCRIPTABLE SpriteWrapper* backMaleSprite(); + Q_SCRIPTABLE SpriteWrapper* frontFemaleSprite(); + Q_SCRIPTABLE SpriteWrapper* backFemaleSprite(); + Q_SCRIPTABLE SkinWrapper* skin(); + Q_SCRIPTABLE Pokemod::Fraction genderFactor() const; + Q_SCRIPTABLE int eggSpecies() const; + Q_SCRIPTABLE int eggSteps() const; + Q_SCRIPTABLE QList<TypeWrapper*> types(); + Q_SCRIPTABLE QList<EggGroupWrapper*> eggGroups(); + Q_SCRIPTABLE Pokemod::Script evolution() const; + + Q_SCRIPTABLE SpeciesAbilityWrapper* ability(const int index); + Q_SCRIPTABLE int abilityCount() const; + + Q_SCRIPTABLE SpeciesItemWrapper* item(const int index); + Q_SCRIPTABLE int itemCount() const; + + Q_SCRIPTABLE SpeciesMoveWrapper* move(const int index); + Q_SCRIPTABLE int moveCount() const; + private: + SpeciesWrapper(const Pokemod::Species* species, PokemodWrapper* parent); + SpeciesWrapper& operator=(const SpeciesWrapper& rhs); + + const Pokemod::Species* m_species; +}; +} +Q_DECLARE_METATYPE(Pokescripting::SpeciesWrapper*) + +#endif diff --git a/sigscript/SpriteWrapper.cpp b/sigscript/SpriteWrapper.cpp new file mode 100644 index 00000000..0233e996 --- /dev/null +++ b/sigscript/SpriteWrapper.cpp @@ -0,0 +1,45 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "SpriteWrapper.h" + +// Pokescripting includes +#include "PokemodWrapper.h" + +Pokescripting::SpriteWrapper* Pokescripting::SpriteWrapper::create(const Pokemod::Sprite* sprite, PokemodWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, sprite->id()))) + m_instances[Signiture(parent, sprite->id())] = new SpriteWrapper(sprite, parent); + return qobject_cast<SpriteWrapper*>(m_instances[Signiture(parent, sprite->id())]); +} + +Pokescripting::SpriteWrapper::SpriteWrapper(const Pokemod::Sprite* sprite, PokemodWrapper* parent) : + ObjectWrapper(sprite, parent), + m_sprite(sprite) +{ +} + +QString Pokescripting::SpriteWrapper::name() const +{ + return m_sprite->name(); +} + +QImage Pokescripting::SpriteWrapper::sprite() const +{ + return m_sprite->sprite(); +} diff --git a/sigscript/SpriteWrapper.h b/sigscript/SpriteWrapper.h new file mode 100644 index 00000000..77db2e47 --- /dev/null +++ b/sigscript/SpriteWrapper.h @@ -0,0 +1,47 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_SPRITEWRAPPER__ +#define __POKESCRIPTING_SPRITEWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/Sprite.h" + +namespace Pokescripting +{ +class POKESCRIPTING_EXPORT SpriteWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static SpriteWrapper* create(const Pokemod::Sprite* sprite, PokemodWrapper* parent); + + Q_SCRIPTABLE QString name() const; + Q_SCRIPTABLE QImage sprite() const; + private: + SpriteWrapper(const Pokemod::Sprite* sprite, PokemodWrapper* parent); + SpriteWrapper& operator=(const SpriteWrapper& rhs); + + const Pokemod::Sprite* m_sprite; +}; +} +Q_DECLARE_METATYPE(Pokescripting::SpriteWrapper*) + +#endif diff --git a/sigscript/StatusWrapper.cpp b/sigscript/StatusWrapper.cpp new file mode 100644 index 00000000..4c5191ad --- /dev/null +++ b/sigscript/StatusWrapper.cpp @@ -0,0 +1,50 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "StatusWrapper.h" + +// Pokescripting includes +#include "PokemodWrapper.h" + +Pokescripting::StatusWrapper* Pokescripting::StatusWrapper::create(const Pokemod::Status* status, PokemodWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, status->id()))) + m_instances[Signiture(parent, status->id())] = new StatusWrapper(status, parent); + return qobject_cast<StatusWrapper*>(m_instances[Signiture(parent, status->id())]); +} + +Pokescripting::StatusWrapper::StatusWrapper(const Pokemod::Status* status, PokemodWrapper* parent) : + ObjectWrapper(status, parent), + m_status(status) +{ +} + +QString Pokescripting::StatusWrapper::name() const +{ + return m_status->name(); +} + +Pokemod::Script Pokescripting::StatusWrapper::battleScript() const +{ + return m_status->battleScript(); +} + +Pokemod::Script Pokescripting::StatusWrapper::worldScript() const +{ + return m_status->worldScript(); +} diff --git a/sigscript/StatusWrapper.h b/sigscript/StatusWrapper.h new file mode 100644 index 00000000..1a84e0a4 --- /dev/null +++ b/sigscript/StatusWrapper.h @@ -0,0 +1,48 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_STATUSWRAPPER__ +#define __POKESCRIPTING_STATUSWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/Status.h" + +namespace Pokescripting +{ +class POKESCRIPTING_EXPORT StatusWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static StatusWrapper* create(const Pokemod::Status* status, PokemodWrapper* parent); + + Q_SCRIPTABLE QString name() const; + Q_SCRIPTABLE Pokemod::Script battleScript() const; + Q_SCRIPTABLE Pokemod::Script worldScript() const; + private: + StatusWrapper(const Pokemod::Status* status, PokemodWrapper* parent); + StatusWrapper& operator=(const StatusWrapper& rhs); + + const Pokemod::Status* m_status; +}; +} +Q_DECLARE_METATYPE(Pokescripting::StatusWrapper*) + +#endif diff --git a/sigscript/StoreWrapper.cpp b/sigscript/StoreWrapper.cpp new file mode 100644 index 00000000..111d0bd0 --- /dev/null +++ b/sigscript/StoreWrapper.cpp @@ -0,0 +1,49 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "StoreWrapper.h" + +// Pokescripting includes +#include "PokemodWrapper.h" + +Pokescripting::StoreWrapper* Pokescripting::StoreWrapper::create(const Pokemod::Store* store, PokemodWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, store->id()))) + m_instances[Signiture(parent, store->id())] = new StoreWrapper(store, parent); + return qobject_cast<StoreWrapper*>(m_instances[Signiture(parent, store->id())]); +} + +Pokescripting::StoreWrapper::StoreWrapper(const Pokemod::Store* store, PokemodWrapper* parent) : + ObjectWrapper(store, parent), + m_store(store) +{ +} + +QString Pokescripting::StoreWrapper::name() const +{ + return m_store->name(); +} + +QList<Pokescripting::ItemWrapper*> Pokescripting::StoreWrapper::items() +{ + QList<int> itemIds = m_store->items(); + QList<ItemWrapper*> items; + foreach (int id, itemIds) + items.append(pokemod()->item(id)); + return items; +} diff --git a/sigscript/StoreWrapper.h b/sigscript/StoreWrapper.h new file mode 100644 index 00000000..18892e8f --- /dev/null +++ b/sigscript/StoreWrapper.h @@ -0,0 +1,50 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_STOREWRAPPER__ +#define __POKESCRIPTING_STOREWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/Store.h" + +namespace Pokescripting +{ +// Forward declarations +class ItemWrapper; + +class POKESCRIPTING_EXPORT StoreWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static StoreWrapper* create(const Pokemod::Store* store, PokemodWrapper* parent); + + Q_SCRIPTABLE QString name() const; + Q_SCRIPTABLE QList<ItemWrapper*> items(); + private: + StoreWrapper(const Pokemod::Store* store, PokemodWrapper* parent); + StoreWrapper& operator=(const StoreWrapper& rhs); + + const Pokemod::Store* m_store; +}; +} +Q_DECLARE_METATYPE(Pokescripting::StoreWrapper*) + +#endif diff --git a/sigscript/TODO b/sigscript/TODO new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/sigscript/TODO diff --git a/sigscript/TileWrapper.cpp b/sigscript/TileWrapper.cpp new file mode 100644 index 00000000..648bd39d --- /dev/null +++ b/sigscript/TileWrapper.cpp @@ -0,0 +1,64 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "TileWrapper.h" + +// Pokescripting includes +#include "PokemodWrapper.h" +#include "SpriteWrapper.h" + +Pokescripting::TileWrapper* Pokescripting::TileWrapper::create(const Pokemod::Tile* tile, PokemodWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, tile->id()))) + m_instances[Signiture(parent, tile->id())] = new TileWrapper(tile, parent); + return qobject_cast<TileWrapper*>(m_instances[Signiture(parent, tile->id())]); +} + +Pokescripting::TileWrapper::TileWrapper(const Pokemod::Tile* tile, PokemodWrapper* parent) : + ObjectWrapper(tile, parent), + m_tile(tile) +{ +} + +QString Pokescripting::TileWrapper::name() const +{ + return m_tile->name(); +} + +Pokescripting::SpriteWrapper* Pokescripting::TileWrapper::sprite() +{ + if (value("sprite").canConvert<QString>()) + { + SpriteWrapper* sprite = pokemod()->sprite(value("sprite").toString()); + if (sprite && sprite->sprite().size() == QSize(64, 64)) + return sprite; + } + return pokemod()->sprite(m_tile->sprite()); +} + +bool Pokescripting::TileWrapper::from(const Pokemod::Direction direction) const +{ + if (value(QString("direction-%1").arg(direction)).canConvert<bool>()) + return value(QString("direction-%1").arg(direction)).toBool(); + return m_tile->from(direction); +} + +Pokemod::Script Pokescripting::TileWrapper::script() const +{ + return m_tile->script(); +} diff --git a/sigscript/TileWrapper.h b/sigscript/TileWrapper.h new file mode 100644 index 00000000..a32d3594 --- /dev/null +++ b/sigscript/TileWrapper.h @@ -0,0 +1,52 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_TILEWRAPPER__ +#define __POKESCRIPTING_TILEWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/Tile.h" + +namespace Pokescripting +{ +// Forward declarations +class SpriteWrapper; + +class POKESCRIPTING_EXPORT TileWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static TileWrapper* create(const Pokemod::Tile* tile, PokemodWrapper* parent); + + Q_SCRIPTABLE QString name() const; + Q_SCRIPTABLE SpriteWrapper* sprite(); + Q_SCRIPTABLE bool from(const Pokemod::Direction direction) const; + Q_SCRIPTABLE Pokemod::Script script() const; + private: + TileWrapper(const Pokemod::Tile* tile, PokemodWrapper* parent); + TileWrapper& operator=(const TileWrapper& rhs); + + const Pokemod::Tile* m_tile; +}; +} +Q_DECLARE_METATYPE(Pokescripting::TileWrapper*) + +#endif diff --git a/sigscript/TimeWrapper.cpp b/sigscript/TimeWrapper.cpp new file mode 100644 index 00000000..1971582b --- /dev/null +++ b/sigscript/TimeWrapper.cpp @@ -0,0 +1,50 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "TimeWrapper.h" + +// Pokescripting includes +#include "PokemodWrapper.h" + +Pokescripting::TimeWrapper* Pokescripting::TimeWrapper::create(const Pokemod::Time* time, PokemodWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, time->id()))) + m_instances[Signiture(parent, time->id())] = new TimeWrapper(time, parent); + return qobject_cast<TimeWrapper*>(m_instances[Signiture(parent, time->id())]); +} + +Pokescripting::TimeWrapper::TimeWrapper(const Pokemod::Time* time, PokemodWrapper* parent) : + ObjectWrapper(time, parent), + m_time(time) +{ +} + +QString Pokescripting::TimeWrapper::TimeWrapper::name() const +{ + return m_time->name(); +} + +int Pokescripting::TimeWrapper::TimeWrapper::hour() const +{ + return m_time->hour(); +} + +int Pokescripting::TimeWrapper::TimeWrapper::minute() const +{ + return m_time->minute(); +} diff --git a/sigscript/TimeWrapper.h b/sigscript/TimeWrapper.h new file mode 100644 index 00000000..e7326cfb --- /dev/null +++ b/sigscript/TimeWrapper.h @@ -0,0 +1,48 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_TIMEWRAPPER__ +#define __POKESCRIPTING_TIMEWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/Time.h" + +namespace Pokescripting +{ +class POKESCRIPTING_EXPORT TimeWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static TimeWrapper* create(const Pokemod::Time* time, PokemodWrapper* parent); + + Q_SCRIPTABLE QString name() const; + Q_SCRIPTABLE int hour() const; + Q_SCRIPTABLE int minute() const; + private: + TimeWrapper(const Pokemod::Time* time, PokemodWrapper* parent); + TimeWrapper& operator=(const TimeWrapper& rhs); + + const Pokemod::Time* m_time; +}; +} +Q_DECLARE_METATYPE(Pokescripting::TimeWrapper*) + +#endif diff --git a/sigscript/TrainerWrapper.cpp b/sigscript/TrainerWrapper.cpp new file mode 100644 index 00000000..d552070b --- /dev/null +++ b/sigscript/TrainerWrapper.cpp @@ -0,0 +1,97 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "TrainerWrapper.h" + +// Pokescripting includes +#include "PokemodWrapper.h" + +Pokescripting::TrainerWrapper* Pokescripting::TrainerWrapper::create(const Pokemod::Trainer* trainer, PokemodWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, trainer->id()))) + m_instances[Signiture(parent, trainer->id())] = new TrainerWrapper(trainer, parent); + return qobject_cast<TrainerWrapper*>(m_instances[Signiture(parent, trainer->id())]); +} + +Pokescripting::TrainerWrapper::TrainerWrapper(const Pokemod::Trainer* trainer, PokemodWrapper* parent) : + ObjectWrapper(trainer, parent), + m_trainer(trainer) +{ +} + +Pokemod::Trainer::Intelligence Pokescripting::TrainerWrapper::intelligence(const QString& name) const +{ + if (name == "Ignorant") + return Pokemod::Trainer::Ignorant; + else if (name == "Determine") + return Pokemod::Trainer::Determine; + else if (name == "Remember") + return Pokemod::Trainer::Remember; + else if (name == "Cheating") + return Pokemod::Trainer::Cheating; + return QVariant(-1).value<Pokemod::Trainer::Intelligence>(); +} + +QString Pokescripting::TrainerWrapper::TrainerWrapper::name() const +{ + return m_trainer->name(); +} + +int Pokescripting::TrainerWrapper::TrainerWrapper::moneyFactor() const +{ + if (value("moneyFactor").canConvert<int>()) + return value("moneyFactor").toInt(); + return m_trainer->moneyFactor(); +} + +Pokescripting::SkinWrapper* Pokescripting::TrainerWrapper::TrainerWrapper::skin() +{ + return pokemod()->skin(m_trainer->skin()); +} + +int Pokescripting::TrainerWrapper::TrainerWrapper::depth() const +{ + if (value("depth").canConvert<int>()) + return value("depth").toInt(); + return m_trainer->depth(); +} + +Pokemod::Trainer::Intelligence Pokescripting::TrainerWrapper::TrainerWrapper::teamIntel() const +{ + return m_trainer->teamIntel(); +} + +Pokemod::Trainer::Intelligence Pokescripting::TrainerWrapper::TrainerWrapper::moveIntel() const +{ + return m_trainer->moveIntel(); +} + +Pokemod::Trainer::Intelligence Pokescripting::TrainerWrapper::TrainerWrapper::itemIntel() const +{ + return m_trainer->itemIntel(); +} + +Pokemod::Trainer::Intelligence Pokescripting::TrainerWrapper::TrainerWrapper::abilityIntel() const +{ + return m_trainer->abilityIntel(); +} + +Pokemod::Trainer::Intelligence Pokescripting::TrainerWrapper::TrainerWrapper::statIntel() const +{ + return m_trainer->statIntel(); +} diff --git a/sigscript/TrainerWrapper.h b/sigscript/TrainerWrapper.h new file mode 100644 index 00000000..c8ae6e85 --- /dev/null +++ b/sigscript/TrainerWrapper.h @@ -0,0 +1,59 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_TRAINERWRAPPER__ +#define __POKESCRIPTING_TRAINERWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/Trainer.h" + +namespace Pokescripting +{ +// Forward declarations +class SkinWrapper; + +class POKESCRIPTING_EXPORT TrainerWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static TrainerWrapper* create(const Pokemod::Trainer* trainer, PokemodWrapper* parent); + + Q_SCRIPTABLE Pokemod::Trainer::Intelligence intelligence(const QString& name) const; + + Q_SCRIPTABLE QString name() const; + Q_SCRIPTABLE int moneyFactor() const; + Q_SCRIPTABLE SkinWrapper* skin(); + Q_SCRIPTABLE int depth() const; + Q_SCRIPTABLE Pokemod::Trainer::Intelligence teamIntel() const; + Q_SCRIPTABLE Pokemod::Trainer::Intelligence moveIntel() const; + Q_SCRIPTABLE Pokemod::Trainer::Intelligence itemIntel() const; + Q_SCRIPTABLE Pokemod::Trainer::Intelligence abilityIntel() const; + Q_SCRIPTABLE Pokemod::Trainer::Intelligence statIntel() const; + private: + TrainerWrapper(const Pokemod::Trainer* trainer, PokemodWrapper* parent); + TrainerWrapper& operator=(const TrainerWrapper& rhs); + + const Pokemod::Trainer* m_trainer; +}; +} +Q_DECLARE_METATYPE(Pokescripting::TrainerWrapper*) + +#endif diff --git a/sigscript/TypeWrapper.cpp b/sigscript/TypeWrapper.cpp new file mode 100644 index 00000000..d752a9fa --- /dev/null +++ b/sigscript/TypeWrapper.cpp @@ -0,0 +1,45 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "TypeWrapper.h" + +// Pokescripting includes +#include "PokemodWrapper.h" + +Pokescripting::TypeWrapper* Pokescripting::TypeWrapper::create(const Pokemod::Type* type, PokemodWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, type->id()))) + m_instances[Signiture(parent, type->id())] = new TypeWrapper(type, parent); + return qobject_cast<TypeWrapper*>(m_instances[Signiture(parent, type->id())]); +} + +Pokescripting::TypeWrapper::TypeWrapper(const Pokemod::Type* type, PokemodWrapper* parent) : + ObjectWrapper(type, parent), + m_type(type) +{ +} + +QString Pokescripting::TypeWrapper::TypeWrapper::name() const +{ + return m_type->name(); +} + +Pokemod::Fraction Pokescripting::TypeWrapper::TypeWrapper::stab() const +{ + return m_type->stab(); +} diff --git a/sigscript/TypeWrapper.h b/sigscript/TypeWrapper.h new file mode 100644 index 00000000..02dba293 --- /dev/null +++ b/sigscript/TypeWrapper.h @@ -0,0 +1,47 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_TYPEWRAPPER__ +#define __POKESCRIPTING_TYPEWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/Type.h" + +namespace Pokescripting +{ +class POKESCRIPTING_EXPORT TypeWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static TypeWrapper* create(const Pokemod::Type* type, PokemodWrapper* parent); + + Q_SCRIPTABLE QString name() const; + Q_SCRIPTABLE Pokemod::Fraction stab() const; + private: + TypeWrapper(const Pokemod::Type* type, PokemodWrapper* parent); + TypeWrapper& operator=(const TypeWrapper& rhs); + + const Pokemod::Type* m_type; +}; +} +Q_DECLARE_METATYPE(Pokescripting::TypeWrapper*) + +#endif diff --git a/sigscript/WeatherWrapper.cpp b/sigscript/WeatherWrapper.cpp new file mode 100644 index 00000000..ad7bc990 --- /dev/null +++ b/sigscript/WeatherWrapper.cpp @@ -0,0 +1,45 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "WeatherWrapper.h" + +// Pokescripting includes +#include "PokemodWrapper.h" + +Pokescripting::WeatherWrapper* Pokescripting::WeatherWrapper::create(const Pokemod::Weather* weather, PokemodWrapper* parent) +{ + if (!m_instances.contains(Signiture(parent, weather->id()))) + m_instances[Signiture(parent, weather->id())] = new WeatherWrapper(weather, parent); + return qobject_cast<WeatherWrapper*>(m_instances[Signiture(parent, weather->id())]); +} + +Pokescripting::WeatherWrapper::WeatherWrapper(const Pokemod::Weather* weather, PokemodWrapper* parent) : + ObjectWrapper(weather, parent), + m_weather(weather) +{ +} + +QString Pokescripting::WeatherWrapper::name() const +{ + return m_weather->name(); +} + +Pokemod::Script Pokescripting::WeatherWrapper::script() const +{ + return m_weather->script(); +} diff --git a/sigscript/WeatherWrapper.h b/sigscript/WeatherWrapper.h new file mode 100644 index 00000000..4a915af2 --- /dev/null +++ b/sigscript/WeatherWrapper.h @@ -0,0 +1,47 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __POKESCRIPTING_WEATHERWRAPPER__ +#define __POKESCRIPTING_WEATHERWRAPPER__ + +// Pokescripting includes +#include "ObjectWrapper.h" + +// Pokemod includes +#include "../pokemod/Weather.h" + +namespace Pokescripting +{ +class POKESCRIPTING_EXPORT WeatherWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + static WeatherWrapper* create(const Pokemod::Weather* weather, PokemodWrapper* parent); + + Q_SCRIPTABLE QString name() const; + Q_SCRIPTABLE Pokemod::Script script() const; + private: + WeatherWrapper(const Pokemod::Weather* weather, PokemodWrapper* parent); + WeatherWrapper& operator=(const WeatherWrapper& rhs); + + const Pokemod::Weather* m_weather; +}; +} +Q_DECLARE_METATYPE(Pokescripting::WeatherWrapper*) + +#endif |