From ac55d15e484e2357954af3a6a3573c79fbbd88d8 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 12 Jul 2008 01:44:23 +0000 Subject: [FIX] Actually added the Wrapper classes (again :( ) git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@226 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- pokescripting/MapWrapper.h | 130 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 pokescripting/MapWrapper.h (limited to 'pokescripting/MapWrapper.h') diff --git a/pokescripting/MapWrapper.h b/pokescripting/MapWrapper.h new file mode 100644 index 00000000..7221b1cc --- /dev/null +++ b/pokescripting/MapWrapper.h @@ -0,0 +1,130 @@ +/* + * Copyright 2008 Ben Boeckel + * + * 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 . + */ + +#ifndef __POKESCRIPTING_MAPWRAPPER__ +#define __POKESCRIPTING_MAPWRAPPER__ + +// Pokescripting includes +#include "MapEffectWrapper.h" +#include "MapTrainerWrapper.h" +#include "MapWarpWrapper.h" +#include "MapWildListWrapper.h" +#include "ObjectWrapper.h" +#include "TileWrapper.h" + +// Pokemod includes +#include "../pokemod/Map.h" + +namespace Pokescripting +{ +class POKESCRIPTING_EXPORT MapWrapper : public ObjectWrapper +{ + Q_OBJECT + + public: + MapWrapper(const Pokemod::Map* map, QObject* parent); + public slots: + QString name() const; + const MapWarpWrapper* flyWarp() const; + int type() const; + const TileWrapper* tile(const int row, const int column) const; + QPoint mapSize() const; + + const MapEffectWrapper* effect(const QString& name) const; + const MapTrainerWrapper* trainer(const QString& name) const; + const MapWarpWrapper* warp(const QString& name) const; + const MapWildListWrapper* wildList(const QString& name) const; + private: + MapWrapper& operator=(const MapWrapper& rhs); + + const Pokemod::Map* m_map; +}; + +inline MapWrapper::MapWrapper(const Pokemod::Map* map, QObject* parent) : + ObjectWrapper(map, parent), + m_map(map) +{ +} + +inline QString MapWrapper::name() const +{ + return m_map->name(); +} + +inline const MapWarpWrapper* MapWrapper::flyWarp() const +{ + return new MapWarpWrapper(m_map->warpById(m_map->flyWarp()), const_cast(this)); +} + +inline int MapWrapper::type() const +{ + return m_map->type(); +} + +inline const TileWrapper* MapWrapper::tile(const int row, const int column) const +{ + return new TileWrapper(pokemod()->tileById(m_map->tile(row, column)), const_cast(this)); +} + +inline QPoint MapWrapper::mapSize() const +{ + return m_map->size(); +} + +inline const MapEffectWrapper* MapWrapper::effect(const QString& name) const +{ + for (int i = 0; i < m_map->effectCount(); ++i) + { + if (m_map->effect(i)->name() == name) + return new MapEffectWrapper(m_map->effect(i), const_cast(this)); + } + return NULL; +} + +inline const MapTrainerWrapper* MapWrapper::trainer(const QString& name) const +{ + for (int i = 0; i < m_map->trainerCount(); ++i) + { + if (m_map->trainer(i)->name() == name) + return new MapTrainerWrapper(m_map->trainer(i), const_cast(this)); + } + return NULL; +} + +inline const MapWarpWrapper* MapWrapper::warp(const QString& name) const +{ + for (int i = 0; i < m_map->warpCount(); ++i) + { + if (m_map->warp(i)->name() == name) + return new MapWarpWrapper(m_map->warp(i), const_cast(this)); + } + return NULL; +} + +inline const MapWildListWrapper* MapWrapper::wildList(const QString& name) const +{ + for (int i = 0; i < m_map->wildListCount(); ++i) + { + if (m_map->wildList(i)->name() == name) + return new MapWildListWrapper(m_map->wildList(i), const_cast(this)); + } + return NULL; +} + +} + +#endif -- cgit