summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 5b6b758871..0000000000
--- 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 ea3e7a809b..5074a3ca8d 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 1a2af710c9..1a2af710c9 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 43b8785f16..43b8785f16 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 26fc1bbd4c..26fc1bbd4c 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 07719bca45..3bc9bbe0ee 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 622dabe75e..622dabe75e 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 2b48d4309f..2b48d4309f 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 c324980176..c324980176 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 189a1dda31..189a1dda31 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 b93a6919ea..f7b0760b29 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 5506a7ec0b..5506a7ec0b 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 cefed69b35..66f05aa1c4 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 f290250289..5bc0b26a04 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 c196247b01..c196247b01 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 10e6f48f31..f5e3b6f373 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 2fb05d431c..2fb05d431c 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 a1b5749b31..2835988799 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 11bd242b12..0d8bf2e9a1 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 de95f41283..de95f41283 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 6e220ed602..a331a3e283 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 c2fd937956..8ab4da05fb 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 5499ba308a..5499ba308a 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 d5204553cc..5cfb3649c8 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 31f4c7fac0..124cf98d16 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 0000000000..a098e03c8d
--- /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