summaryrefslogtreecommitdiffstats
path: root/pokescripting/MapWrapper.h
diff options
context:
space:
mode:
Diffstat (limited to 'pokescripting/MapWrapper.h')
-rw-r--r--pokescripting/MapWrapper.h130
1 files changed, 130 insertions, 0 deletions
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 <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 "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<MapWrapper*>(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<MapWrapper*>(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<MapWrapper*>(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<MapWrapper*>(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<MapWrapper*>(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<MapWrapper*>(this));
+ }
+ return NULL;
+}
+
+}
+
+#endif