summaryrefslogtreecommitdiffstats
path: root/sigworld
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-11-09 18:53:21 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-11-09 18:53:21 +0000
commite965d4f6d7cd33c3901a61d9b798dcc5593534c7 (patch)
tree9d12f796894eabd820a8d2b68462b7123808293b /sigworld
parentc54d318ae9b4efa57938e29eac7f13ae75e799e5 (diff)
downloadsigen-e965d4f6d7cd33c3901a61d9b798dcc5593534c7.tar.gz
sigen-e965d4f6d7cd33c3901a61d9b798dcc5593534c7.tar.xz
sigen-e965d4f6d7cd33c3901a61d9b798dcc5593534c7.zip
[FIX] Starting the sigworld library
[FIX] Tile has walkable flag on it git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@310 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'sigworld')
-rw-r--r--sigworld/CMakeLists.txt49
-rw-r--r--sigworld/Global.h37
-rw-r--r--sigworld/MapScene.cpp37
-rw-r--r--sigworld/MapScene.h55
-rw-r--r--sigworld/TileGraphicsItem.cpp62
-rw-r--r--sigworld/TileGraphicsItem.h57
-rw-r--r--sigworld/TrainerGraphicsItem.cpp0
-rw-r--r--sigworld/TrainerGraphicsItem.h52
-rw-r--r--sigworld/WarpGraphicsItem.cpp0
-rw-r--r--sigworld/WarpGraphicsItem.h28
10 files changed, 377 insertions, 0 deletions
diff --git a/sigworld/CMakeLists.txt b/sigworld/CMakeLists.txt
new file mode 100644
index 00000000..2d528346
--- /dev/null
+++ b/sigworld/CMakeLists.txt
@@ -0,0 +1,49 @@
+PROJECT(sigworld)
+
+IF (NOT SIGEN_VERSION)
+ MESSAGE(FATAL_ERROR "Sigen version is not defined")
+ENDIF (NOT SIGEN_VERSION)
+
+SET(sigworld_HEADERS
+ Global.h
+ MapScene.h
+ TileGraphicsItem.h
+ TrainerGraphicsItem.h
+ WarpGraphicsItem.h
+)
+SET(sigworld_SRCS
+ MapScene.cpp
+ TileGraphicsItem.cpp
+ TrainerGraphicsItem.cpp
+ WarpGraphicsItem.cpp
+)
+
+KDE4_ADD_LIBRARY(sigworld
+ SHARED
+ ${sigworld_SRCS}
+)
+SET_TARGET_PROPERTIES(sigworld
+ PROPERTIES
+ VERSION ${SIGEN_VERSION}
+ SOVERSION ${SIGEN_SOVERSION}
+ LINK_INTERFACE_LIBRARIES ""
+)
+TARGET_LINK_LIBRARIES(sigworld
+ ${QT_QTCORE_LIBRARY}
+ ${QT_QTGUI_LIBRARY}
+ ${KDE4_KROSSCORE_LIBRARY}
+ sigcore
+ sigscript
+)
+
+INSTALL(
+ TARGETS sigworld
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}
+ COMPONENT runtime
+)
+
+INSTALL(
+ FILES ${sigworld_HEADERS}
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/${CMAKE_PROJECT_NAME}/${PROJECT_NAME}
+ COMPONENT development
+)
diff --git a/sigworld/Global.h b/sigworld/Global.h
new file mode 100644
index 00000000..c50c5c40
--- /dev/null
+++ b/sigworld/Global.h
@@ -0,0 +1,37 @@
+/*
+ * 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 SIGWORLD_GLOBAL
+#define SIGWORLD_GLOBAL
+
+// KDE includes
+#include <kdemacros.h>
+
+#ifndef SIGWORLD_EXPORT
+# ifdef MAKE_SIGWORLD_LIB
+# define SIGWORLD_EXPORT KDE_EXPORT
+# else
+# define SIGWORLD_EXPORT KDE_IMPORT
+# endif
+# define SIGWORLD_IMPORT KDE_IMPORT
+#endif
+
+#ifndef SIGWORLD_EXPORT_DEPRECATED
+# define SIGWORLD_EXPORT_DEPRECATED KDE_DEPRECATED SIGWORLD_EXPORT
+#endif
+
+#endif
diff --git a/sigworld/MapScene.cpp b/sigworld/MapScene.cpp
new file mode 100644
index 00000000..2a9467ce
--- /dev/null
+++ b/sigworld/MapScene.cpp
@@ -0,0 +1,37 @@
+/*
+ * 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 "MapScene.h"
+
+Sigworld::MapScene::MapScene(Sigscript::MapWrapper* map, QObject* parent) :
+ QGraphicsScene(parent),
+ m_map(map)
+{
+ // TODO: add all of the items to the map
+ // TODO: make the collection
+}
+
+QString Sigworld::MapScene::makeTileName(const int id) const
+{
+ return QString("tile-%1").arg(id);
+}
+
+Kross::ActionCollection* Sigworld::MapScene::collection()
+{
+ return m_collection;
+}
diff --git a/sigworld/MapScene.h b/sigworld/MapScene.h
new file mode 100644
index 00000000..b9fd5c4d
--- /dev/null
+++ b/sigworld/MapScene.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 SIGWORLD_MAPSCENE
+#define SIGWORLD_MAPSCENE
+
+// Sigworld includes
+#include "Global.h"
+
+// Qt includes
+#include <QtGui/QGraphicsScene>
+
+// Forward declarations
+namespace Kross
+{
+class ActionCollection;
+}
+namespace Sigscript
+{
+class MapWrapper;
+}
+
+namespace Sigworld
+{
+class SIGWORLD_EXPORT MapScene : public QGraphicsScene
+{
+ Q_OBJECT
+
+ public:
+ MapScene(Sigscript::MapWrapper* map, QObject* parent);
+
+ QString makeTileName(const int id) const;
+
+ Kross::ActionCollection* collection();
+ private:
+ Sigscript::MapWrapper* m_map;
+ Kross::ActionCollection* m_collection;
+};
+}
+
+#endif
diff --git a/sigworld/TileGraphicsItem.cpp b/sigworld/TileGraphicsItem.cpp
new file mode 100644
index 00000000..8ffac8d4
--- /dev/null
+++ b/sigworld/TileGraphicsItem.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 "TileGraphicsItem.h"
+
+// Sigworld includes
+#include "MapScene.h"
+
+// Sigscript includes
+#include "../sigscript/MapTileWrapper.h"
+#include "../sigscript/SigmodWrapper.h"
+#include "../sigscript/SpriteWrapper.h"
+#include "../sigscript/TileWrapper.h"
+
+// KDE includes
+#include <kross/core/action.h>
+#include <kross/core/actioncollection.h>
+
+Sigworld::TileGraphicsItem::TileGraphicsItem(Sigscript::MapTileWrapper* tile, MapScene* scene) :
+ QObject(scene),
+ m_tile(tile)
+{
+ setPos(m_tile->position());
+ Sigcore::Script script = m_tile->tile()->script();
+ Kross::Action* action = new Kross::Action(scene->collection(), scene->makeTileName(m_tile->id()));
+ action->addObject(this, "tile");
+ action->setInterpreter(script.interpreter());
+ action->setCode(script.script().toUtf8());
+ action->trigger();
+}
+
+QPainterPath Sigworld::TileGraphicsItem::shape() const
+{
+ if (m_tile->tile()->walkable())
+ return QPainterPath();
+ return QGraphicsPixmapItem::shape();
+}
+
+void Sigworld::TileGraphicsItem::moveBy(qreal dx, qreal dy)
+{
+ QGraphicsPixmapItem::moveBy(dx, dy);
+}
+
+void Sigworld::TileGraphicsItem::setSprite(const int spriteId)
+{
+ setPixmap(m_tile->sigmod()->sprite(spriteId)->sprite());
+}
diff --git a/sigworld/TileGraphicsItem.h b/sigworld/TileGraphicsItem.h
new file mode 100644
index 00000000..29ba58e5
--- /dev/null
+++ b/sigworld/TileGraphicsItem.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 SIGWORLD_TILEGRAPHICSITEM
+#define SIGWORLD_TILEGRAPHICSITEM
+
+// Sigworld includes
+#include "Global.h"
+
+// Qt includes
+#include <QtCore/QObject>
+#include <QtGui/QGraphicsPixmapItem>
+
+// Forward declarations
+namespace Sigscript
+{
+class MapTileWrapper;
+}
+
+namespace Sigworld
+{
+class MapScene;
+
+class SIGWORLD_EXPORT TileGraphicsItem : public QObject, public QGraphicsPixmapItem
+{
+ Q_OBJECT
+
+ public:
+ TileGraphicsItem(Sigscript::MapTileWrapper* tile, MapScene* scene);
+
+ QPainterPath shape() const;
+ public slots:
+ void moveBy(qreal dx, qreal dy);
+
+ void setSprite(const int spriteId);
+ signals:
+ void playerEntered();
+ private:
+ Sigscript::MapTileWrapper* m_tile;
+};
+}
+
+#endif
diff --git a/sigworld/TrainerGraphicsItem.cpp b/sigworld/TrainerGraphicsItem.cpp
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/sigworld/TrainerGraphicsItem.cpp
diff --git a/sigworld/TrainerGraphicsItem.h b/sigworld/TrainerGraphicsItem.h
new file mode 100644
index 00000000..920409ed
--- /dev/null
+++ b/sigworld/TrainerGraphicsItem.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 SIGWORLD_TRAINERGRAPHICSITEM
+#define SIGWORLD_TRAINERGRAPHICSITEM
+
+// Sigworld includes
+#include "Global.h"
+
+// Qt includes
+#include <QtCore/QObject>
+#include <QtGui/QGraphicsPixmapItem>
+
+// Forward declarations
+namespace Sigscript
+{
+class MapTrainerWrapper;
+}
+
+namespace Sigworld
+{
+class MapScene;
+
+class SIGWORLD_EXPORT TrainerGraphicsItem : public QObject, public QGraphicsPixmapItem
+{
+ Q_OBJECT
+
+ public:
+ TrainerGraphicsItem(Sigscript::MapTrainerWrapper* tile, MapScene* scene);
+
+ QRect boundingRect() const;
+ QPainterPath shape() const;
+ public slots:
+
+};
+}
+
+#endif
diff --git a/sigworld/WarpGraphicsItem.cpp b/sigworld/WarpGraphicsItem.cpp
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/sigworld/WarpGraphicsItem.cpp
diff --git a/sigworld/WarpGraphicsItem.h b/sigworld/WarpGraphicsItem.h
new file mode 100644
index 00000000..bf52ebe0
--- /dev/null
+++ b/sigworld/WarpGraphicsItem.h
@@ -0,0 +1,28 @@
+/*
+ * 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 SIGWORLD_WARPGRAPHICSITEM
+#define SIGWORLD_WARPGRAPHICSITEM
+
+// Sigworld includes
+#include "Global.h"
+
+namespace Sigworld
+{
+}
+
+#endif