summaryrefslogtreecommitdiff
path: root/application/main.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-03-08 20:03:40 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-03-08 20:03:40 +0000
commita32a8447028798ef05af33230fbcfa3195ab430c (patch)
treeb311ea9623ac1816f48bdc1cd1f9a8f1d78091a4 /application/main.cpp
parentShut up cppcheck, an STL implementation of that would be stupid (diff)
downloadilt-a32a8447028798ef05af33230fbcfa3195ab430c.tar.bz2
ilt-a32a8447028798ef05af33230fbcfa3195ab430c.tar.xz
ilt-a32a8447028798ef05af33230fbcfa3195ab430c.zip
Initial commit of the orders/activities system
Has the main window provide some control over our test train
Diffstat (limited to 'application/main.cpp')
-rw-r--r--application/main.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/application/main.cpp b/application/main.cpp
index c9caf74..1d961a0 100644
--- a/application/main.cpp
+++ b/application/main.cpp
@@ -2,6 +2,9 @@
#include <array>
#include <chrono>
#include <collection.hpp>
+#include <game/activities/go.h>
+#include <game/activities/idle.h>
+#include <game/activity.h>
#include <game/network/link.h>
#include <game/network/rail.h>
#include <game/terrain.h>
@@ -49,6 +52,7 @@ public:
NO_COPY(SDL_Application);
NO_MOVE(SDL_Application);
+ std::shared_ptr<Train> train;
bool
handleInput(SDL_Event & e) override
{
@@ -56,6 +60,18 @@ public:
case SDL_QUIT:
isRunning = false;
return true;
+ case SDL_KEYUP:
+ switch (e.key.keysym.scancode) {
+ case SDL_SCANCODE_G:
+ train->currentActivity = std::make_unique<Go>();
+ break;
+ case SDL_SCANCODE_I:
+ train->currentActivity = std::make_unique<Idle>();
+ break;
+ default:
+ return false;
+ }
+ return true;
}
return false;
}
@@ -81,7 +97,7 @@ public:
rl->addLinksBetween(e1, j);
auto e2 = rl->addLinksBetween(e, {-925, 10, -1075})->ends[0].first->pos;
rl->addLinksBetween(e2, j);
- const auto & train = world.create<Train>(l3);
+ train = world.create<Train>(l3);
auto b47 = std::make_shared<RailVehicleClass>("brush47");
for (int n = 0; n < 6; n++) {
train->create<RailVehicle>(b47);