From: Mikko Rasa Date: Wed, 22 May 2019 20:43:34 +0000 (+0300) Subject: Add a helper function for registering a stage with the demo X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=bcee277ee013cb24cff047a5459774df67561f0c;p=libs%2Fdemoscene.git Add a helper function for registering a stage with the demo --- diff --git a/source/demo.cpp b/source/demo.cpp index 08a92b4..4cd66bd 100644 --- a/source/demo.cpp +++ b/source/demo.cpp @@ -1,5 +1,6 @@ #include #include "demo.h" +#include "stage.h" using namespace std; using namespace Msp; @@ -27,6 +28,12 @@ Demo::~Demo() delete music_source; } +void Demo::add_stage(const std::string &name, Stage &stage) +{ + things[name] = &stage; + things[name+".camera"] = static_cast(&stage.get_camera()); +} + void Demo::set_fixed_framerate(float fps) { frame_interval = Time::sec/fps; diff --git a/source/demo.h b/source/demo.h index e9d369b..e2dfd6e 100644 --- a/source/demo.h +++ b/source/demo.h @@ -13,6 +13,8 @@ #include "action.h" #include "sequencer.h" +class Stage; + class Demo { private: @@ -55,6 +57,9 @@ public: Msp::DataFile::Collection &get_resources() const { return resources; } Msp::GL::AnimationPlayer &get_animation_player() { return anim_player; } +protected: + void add_stage(const std::string &, Stage &); +public: template T &get_thing(const std::string &);