summaryrefslogtreecommitdiffstats
path: root/examples/statemachine
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>2009-05-12 14:40:44 (GMT)
committerEskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>2009-05-12 14:42:26 (GMT)
commitd26a56e2d94bea2b5a1135b8336bbeefebf3ba1c (patch)
treec4a6497357266aa6f8bca69aef985a0f4ac5779d /examples/statemachine
parentcb516fd65149991a2105c545192a52f26a6ab67d (diff)
downloadQt-d26a56e2d94bea2b5a1135b8336bbeefebf3ba1c.zip
Qt-d26a56e2d94bea2b5a1135b8336bbeefebf3ba1c.tar.gz
Qt-d26a56e2d94bea2b5a1135b8336bbeefebf3ba1c.tar.bz2
Change name of "errorstate" example to "tankgame"
The error state is not a big enough part of the example to justify naming it after it.
Diffstat (limited to 'examples/statemachine')
-rw-r--r--examples/statemachine/errorstateplugins/errorstateplugins.pro11
-rw-r--r--examples/statemachine/statemachine.pro4
-rw-r--r--examples/statemachine/tankgame/gameitem.cpp (renamed from examples/statemachine/errorstate/gameitem.cpp)0
-rw-r--r--examples/statemachine/tankgame/gameitem.h (renamed from examples/statemachine/errorstate/gameitem.h)0
-rw-r--r--examples/statemachine/tankgame/main.cpp (renamed from examples/statemachine/errorstate/main.cpp)0
-rw-r--r--examples/statemachine/tankgame/mainwindow.cpp (renamed from examples/statemachine/errorstate/mainwindow.cpp)7
-rw-r--r--examples/statemachine/tankgame/mainwindow.h (renamed from examples/statemachine/errorstate/mainwindow.h)0
-rw-r--r--examples/statemachine/tankgame/plugin.h (renamed from examples/statemachine/errorstate/plugin.h)0
-rw-r--r--examples/statemachine/tankgame/rocketitem.cpp (renamed from examples/statemachine/errorstate/rocketitem.cpp)0
-rw-r--r--examples/statemachine/tankgame/rocketitem.h (renamed from examples/statemachine/errorstate/rocketitem.h)0
-rw-r--r--examples/statemachine/tankgame/tankgame.pro (renamed from examples/statemachine/errorstate/errorstate.pro)2
-rw-r--r--examples/statemachine/tankgame/tankitem.cpp (renamed from examples/statemachine/errorstate/tankitem.cpp)0
-rw-r--r--examples/statemachine/tankgame/tankitem.h (renamed from examples/statemachine/errorstate/tankitem.h)2
-rw-r--r--examples/statemachine/tankgameplugins/random_ai/random_ai.pro (renamed from examples/statemachine/errorstateplugins/random_ai/random_ai.pro)6
-rw-r--r--examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.cpp (renamed from examples/statemachine/errorstateplugins/random_ai/random_ai_plugin.cpp)0
-rw-r--r--examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.h (renamed from examples/statemachine/errorstateplugins/random_ai/random_ai_plugin.h)2
-rw-r--r--examples/statemachine/tankgameplugins/seek_ai/seek_ai.cpp (renamed from examples/statemachine/errorstateplugins/seek_ai/seek_ai.cpp)0
-rw-r--r--examples/statemachine/tankgameplugins/seek_ai/seek_ai.h (renamed from examples/statemachine/errorstateplugins/seek_ai/seek_ai.h)2
-rw-r--r--examples/statemachine/tankgameplugins/seek_ai/seek_ai.pro (renamed from examples/statemachine/errorstateplugins/seek_ai/seek_ai.pro)6
-rw-r--r--examples/statemachine/tankgameplugins/spin_ai/spin_ai.cpp (renamed from examples/statemachine/errorstateplugins/spin_ai/spin_ai.cpp)0
-rw-r--r--examples/statemachine/tankgameplugins/spin_ai/spin_ai.h (renamed from examples/statemachine/errorstateplugins/spin_ai/spin_ai.h)2
-rw-r--r--examples/statemachine/tankgameplugins/spin_ai/spin_ai.pro (renamed from examples/statemachine/errorstateplugins/spin_ai/spin_ai.pro)6
-rw-r--r--examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.cpp (renamed from examples/statemachine/errorstateplugins/spin_ai_with_error/spin_ai_with_error.cpp)0
-rw-r--r--examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.h (renamed from examples/statemachine/errorstateplugins/spin_ai_with_error/spin_ai_with_error.h)2
-rw-r--r--examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.pro (renamed from examples/statemachine/errorstateplugins/spin_ai_with_error/spin_ai_with_error.pro)6
-rw-r--r--examples/statemachine/tankgameplugins/tankgameplugins.pro11
26 files changed, 40 insertions, 29 deletions
diff --git a/examples/statemachine/errorstateplugins/errorstateplugins.pro b/examples/statemachine/errorstateplugins/errorstateplugins.pro
deleted file mode 100644
index 5b6b758..0000000
--- a/examples/statemachine/errorstateplugins/errorstateplugins.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS = random_ai \
- spin_ai_with_error \
- spin_ai \
- seek_ai
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/errorstateplugins
-sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS errorstateplugins.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/statemachine/errorstateplugins
-INSTALLS += target sources
diff --git a/examples/statemachine/statemachine.pro b/examples/statemachine/statemachine.pro
index ea3e7a8..5074a3c 100644
--- a/examples/statemachine/statemachine.pro
+++ b/examples/statemachine/statemachine.pro
@@ -4,7 +4,9 @@ SUBDIRS = \
factorial \
pingpong \
trafficlight \
- twowaybutton
+ twowaybutton \
+ tankgame \
+ tankgameplugins
# install
target.path = $$[QT_INSTALL_EXAMPLES]/statemachine
diff --git a/examples/statemachine/errorstate/gameitem.cpp b/examples/statemachine/tankgame/gameitem.cpp
index 1a2af71..1a2af71 100644
--- a/examples/statemachine/errorstate/gameitem.cpp
+++ b/examples/statemachine/tankgame/gameitem.cpp
diff --git a/examples/statemachine/errorstate/gameitem.h b/examples/statemachine/tankgame/gameitem.h
index 43b8785..43b8785 100644
--- a/examples/statemachine/errorstate/gameitem.h
+++ b/examples/statemachine/tankgame/gameitem.h
diff --git a/examples/statemachine/errorstate/main.cpp b/examples/statemachine/tankgame/main.cpp
index 26fc1bb..26fc1bb 100644
--- a/examples/statemachine/errorstate/main.cpp
+++ b/examples/statemachine/tankgame/main.cpp
diff --git a/examples/statemachine/errorstate/mainwindow.cpp b/examples/statemachine/tankgame/mainwindow.cpp
index 07719bc..3bc9bbe 100644
--- a/examples/statemachine/errorstate/mainwindow.cpp
+++ b/examples/statemachine/tankgame/mainwindow.cpp
@@ -140,7 +140,9 @@ void MainWindow::init()
stoppedState->setInitialState(hs);
+//! [0]
m_runningState = new QState(QState::ParallelStates, m_machine->rootState());
+//! [0]
m_runningState->setObjectName("runningState");
m_runningState->assignProperty(addTankAction, "enabled", false);
m_runningState->assignProperty(runGameAction, "enabled", false);
@@ -231,8 +233,10 @@ void MainWindow::addTank()
}
bool ok;
+//! [1]
QString selectedName = QInputDialog::getItem(this, "Select a tank type", "Tank types",
itemNames, 0, false, &ok);
+//! [1]
if (ok && !selectedName.isEmpty()) {
int idx = itemNames.indexOf(selectedName);
@@ -244,9 +248,12 @@ void MainWindow::addTank()
emit mapFull();
QState *region = new QState(m_runningState);
+//! [2]
QState *pluginState = plugin->create(region, tankItem);
+//! [2]
region->setInitialState(pluginState);
+
// If the plugin has an error it is disabled
QState *errorState = new QState(region);
errorState->assignProperty(tankItem, "enabled", false);
diff --git a/examples/statemachine/errorstate/mainwindow.h b/examples/statemachine/tankgame/mainwindow.h
index 622dabe..622dabe 100644
--- a/examples/statemachine/errorstate/mainwindow.h
+++ b/examples/statemachine/tankgame/mainwindow.h
diff --git a/examples/statemachine/errorstate/plugin.h b/examples/statemachine/tankgame/plugin.h
index 2b48d43..2b48d43 100644
--- a/examples/statemachine/errorstate/plugin.h
+++ b/examples/statemachine/tankgame/plugin.h
diff --git a/examples/statemachine/errorstate/rocketitem.cpp b/examples/statemachine/tankgame/rocketitem.cpp
index c324980..c324980 100644
--- a/examples/statemachine/errorstate/rocketitem.cpp
+++ b/examples/statemachine/tankgame/rocketitem.cpp
diff --git a/examples/statemachine/errorstate/rocketitem.h b/examples/statemachine/tankgame/rocketitem.h
index 189a1dd..189a1dd 100644
--- a/examples/statemachine/errorstate/rocketitem.h
+++ b/examples/statemachine/tankgame/rocketitem.h
diff --git a/examples/statemachine/errorstate/errorstate.pro b/examples/statemachine/tankgame/tankgame.pro
index b93a691..f7b0760 100644
--- a/examples/statemachine/errorstate/errorstate.pro
+++ b/examples/statemachine/tankgame/tankgame.pro
@@ -5,7 +5,7 @@
TEMPLATE = app
TARGET =
DEPENDPATH += .
-INCLUDEPATH += C:/dev/kinetic/examples/statemachine/errorstate/. .
+INCLUDEPATH += C:/dev/kinetic/examples/statemachine/tankgame/. .
# Input
HEADERS += mainwindow.h plugin.h tankitem.h rocketitem.h gameitem.h
diff --git a/examples/statemachine/errorstate/tankitem.cpp b/examples/statemachine/tankgame/tankitem.cpp
index 5506a7e..5506a7e 100644
--- a/examples/statemachine/errorstate/tankitem.cpp
+++ b/examples/statemachine/tankgame/tankitem.cpp
diff --git a/examples/statemachine/errorstate/tankitem.h b/examples/statemachine/tankgame/tankitem.h
index cefed69..66f05aa 100644
--- a/examples/statemachine/errorstate/tankitem.h
+++ b/examples/statemachine/tankgame/tankitem.h
@@ -35,6 +35,7 @@ public:
qreal distanceToObstacle() const;
qreal distanceToObstacle(QGraphicsItem **item) const;
+//! [0]
signals:
void tankSpotted(qreal direction, qreal distance);
void collision(const QLineF &collidedLine);
@@ -48,6 +49,7 @@ public slots:
void turnTo(qreal degrees = 0.0);
void stop();
void fireCannon();
+//! [0]
protected:
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
diff --git a/examples/statemachine/errorstateplugins/random_ai/random_ai.pro b/examples/statemachine/tankgameplugins/random_ai/random_ai.pro
index f290250..5bc0b26 100644
--- a/examples/statemachine/errorstateplugins/random_ai/random_ai.pro
+++ b/examples/statemachine/tankgameplugins/random_ai/random_ai.pro
@@ -4,10 +4,10 @@ INCLUDEPATH += ../..
HEADERS = random_ai_plugin.h
SOURCES = random_ai_plugin.cpp
TARGET = $$qtLibraryTarget(random_ai)
-DESTDIR = ../../errorstate/plugins
+DESTDIR = ../../tankgame/plugins
#! [0]
# install
-target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/errorstate/plugins
+target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgame/plugins
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS random_ai.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/statemachine/errorstateplugins/random_ai \ No newline at end of file
+sources.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgameplugins/random_ai \ No newline at end of file
diff --git a/examples/statemachine/errorstateplugins/random_ai/random_ai_plugin.cpp b/examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.cpp
index c196247..c196247 100644
--- a/examples/statemachine/errorstateplugins/random_ai/random_ai_plugin.cpp
+++ b/examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.cpp
diff --git a/examples/statemachine/errorstateplugins/random_ai/random_ai_plugin.h b/examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.h
index 10e6f48..f5e3b6f 100644
--- a/examples/statemachine/errorstateplugins/random_ai/random_ai_plugin.h
+++ b/examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.h
@@ -4,7 +4,7 @@
#include <QObject>
#include <QState>
-#include <errorstate/plugin.h>
+#include <tankgame/plugin.h>
class SelectActionState: public QState
{
diff --git a/examples/statemachine/errorstateplugins/seek_ai/seek_ai.cpp b/examples/statemachine/tankgameplugins/seek_ai/seek_ai.cpp
index 2fb05d4..2fb05d4 100644
--- a/examples/statemachine/errorstateplugins/seek_ai/seek_ai.cpp
+++ b/examples/statemachine/tankgameplugins/seek_ai/seek_ai.cpp
diff --git a/examples/statemachine/errorstateplugins/seek_ai/seek_ai.h b/examples/statemachine/tankgameplugins/seek_ai/seek_ai.h
index a1b5749..2835988 100644
--- a/examples/statemachine/errorstateplugins/seek_ai/seek_ai.h
+++ b/examples/statemachine/tankgameplugins/seek_ai/seek_ai.h
@@ -1,7 +1,7 @@
#ifndef SEEK_AI_H
#define SEEK_AI_H
-#include <errorstate/plugin.h>
+#include <tankgame/plugin.h>
#include <QState>
#include <QFinalState>
diff --git a/examples/statemachine/errorstateplugins/seek_ai/seek_ai.pro b/examples/statemachine/tankgameplugins/seek_ai/seek_ai.pro
index 11bd242..0d8bf2e 100644
--- a/examples/statemachine/errorstateplugins/seek_ai/seek_ai.pro
+++ b/examples/statemachine/tankgameplugins/seek_ai/seek_ai.pro
@@ -4,10 +4,10 @@ INCLUDEPATH += ../..
HEADERS = seek_ai.h
SOURCES = seek_ai.cpp
TARGET = $$qtLibraryTarget(seek_ai)
-DESTDIR = ../../errorstate/plugins
+DESTDIR = ../../tankgame/plugins
#! [0]
# install
-target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/errorstate/plugins
+target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgame/plugins
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS seek_ai.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/statemachine/errorstateplugins/seek_ai \ No newline at end of file
+sources.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgameplugins/seek_ai \ No newline at end of file
diff --git a/examples/statemachine/errorstateplugins/spin_ai/spin_ai.cpp b/examples/statemachine/tankgameplugins/spin_ai/spin_ai.cpp
index de95f41..de95f41 100644
--- a/examples/statemachine/errorstateplugins/spin_ai/spin_ai.cpp
+++ b/examples/statemachine/tankgameplugins/spin_ai/spin_ai.cpp
diff --git a/examples/statemachine/errorstateplugins/spin_ai/spin_ai.h b/examples/statemachine/tankgameplugins/spin_ai/spin_ai.h
index 6e220ed..a331a3e 100644
--- a/examples/statemachine/errorstateplugins/spin_ai/spin_ai.h
+++ b/examples/statemachine/tankgameplugins/spin_ai/spin_ai.h
@@ -1,7 +1,7 @@
#ifndef SPIN_AI_H
#define SPIN_AI_H
-#include <errorstate/plugin.h>
+#include <tankgame/plugin.h>
#include <QObject>
#include <QState>
diff --git a/examples/statemachine/errorstateplugins/spin_ai/spin_ai.pro b/examples/statemachine/tankgameplugins/spin_ai/spin_ai.pro
index c2fd937..8ab4da0 100644
--- a/examples/statemachine/errorstateplugins/spin_ai/spin_ai.pro
+++ b/examples/statemachine/tankgameplugins/spin_ai/spin_ai.pro
@@ -4,10 +4,10 @@ INCLUDEPATH += ../..
HEADERS = spin_ai.h
SOURCES = spin_ai.cpp
TARGET = $$qtLibraryTarget(spin_ai)
-DESTDIR = ../../errorstate/plugins
+DESTDIR = ../../tankgame/plugins
#! [0]
# install
-target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/errorstate/plugins
+target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgame/plugins
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS spin_ai.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/statemachine/errorstateplugins/spin_ai \ No newline at end of file
+sources.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgameplugins/spin_ai \ No newline at end of file
diff --git a/examples/statemachine/errorstateplugins/spin_ai_with_error/spin_ai_with_error.cpp b/examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.cpp
index 5499ba3..5499ba3 100644
--- a/examples/statemachine/errorstateplugins/spin_ai_with_error/spin_ai_with_error.cpp
+++ b/examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.cpp
diff --git a/examples/statemachine/errorstateplugins/spin_ai_with_error/spin_ai_with_error.h b/examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.h
index d520455..5cfb364 100644
--- a/examples/statemachine/errorstateplugins/spin_ai_with_error/spin_ai_with_error.h
+++ b/examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.h
@@ -1,7 +1,7 @@
#ifndef SPIN_AI_WITH_ERROR_H
#define SPIN_AI_WITH_ERROR_H
-#include <errorstate/plugin.h>
+#include <tankgame/plugin.h>
#include <QObject>
#include <QState>
diff --git a/examples/statemachine/errorstateplugins/spin_ai_with_error/spin_ai_with_error.pro b/examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.pro
index 31f4c7f..124cf98 100644
--- a/examples/statemachine/errorstateplugins/spin_ai_with_error/spin_ai_with_error.pro
+++ b/examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.pro
@@ -4,10 +4,10 @@ INCLUDEPATH += ../..
HEADERS = spin_ai_with_error.h
SOURCES = spin_ai_with_error.cpp
TARGET = $$qtLibraryTarget(spin_ai_with_error)
-DESTDIR = ../../errorstate/plugins
+DESTDIR = ../../tankgame/plugins
#! [0]
# install
-target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/errorstate/plugins
+target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgame/plugins
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS spin_ai_with_error.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/statemachine/errorstateplugins/spin_ai_with_error \ No newline at end of file
+sources.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgameplugins/spin_ai_with_error \ No newline at end of file
diff --git a/examples/statemachine/tankgameplugins/tankgameplugins.pro b/examples/statemachine/tankgameplugins/tankgameplugins.pro
new file mode 100644
index 0000000..a098e03
--- /dev/null
+++ b/examples/statemachine/tankgameplugins/tankgameplugins.pro
@@ -0,0 +1,11 @@
+TEMPLATE = subdirs
+SUBDIRS = random_ai \
+ spin_ai_with_error \
+ spin_ai \
+ seek_ai
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgameplugins
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS tankgameplugins.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgameplugins
+INSTALLS += target sources