]> git.tdb.fi Git - libs/demoscene.git/blobdiff - source/demo.cpp
Allow stages to define actions
[libs/demoscene.git] / source / demo.cpp
index 08a92b4f0d6bd925709de855a30cec20201adcf2..6579b8cb7b3b6a905e053266177f4b15e5c2a4c0 100644 (file)
@@ -1,8 +1,11 @@
 #include <msp/time/utils.h>
 #include "demo.h"
+#include "stage.h"
 
 using namespace std;
-using namespace Msp;
+
+namespace Msp {
+namespace DemoScene {
 
 Demo::Demo(Graphics::Window &window, Graphics::GLContext &gl_ctx, DataFile::Collection &r):
        resources(r),
@@ -27,6 +30,14 @@ Demo::~Demo()
        delete music_source;
 }
 
+void Demo::add_stage(const std::string &name, Stage &stage)
+{
+       things[name] = &stage;
+       string prefix = name+".";
+       stage.add_things(things, prefix);
+       stage.define_actions(sequencer, prefix);
+}
+
 void Demo::set_fixed_framerate(float fps)
 {
        frame_interval = Time::sec/fps;
@@ -89,3 +100,6 @@ void Demo::AnimationAction::tick(float, float d)
 {
        player.tick(d*Time::sec);
 }
+
+} // namespace DemoScene
+} // namespace Msp