From: Mikko Rasa Date: Sun, 23 Jun 2019 19:36:36 +0000 (+0300) Subject: Allow stages to define actions X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;ds=sidebyside;p=libs%2Fdemoscene.git Allow stages to define actions --- diff --git a/source/demo.cpp b/source/demo.cpp index c15d513..6579b8c 100644 --- a/source/demo.cpp +++ b/source/demo.cpp @@ -33,7 +33,9 @@ Demo::~Demo() void Demo::add_stage(const std::string &name, Stage &stage) { things[name] = &stage; - stage.add_things(things, name+"."); + string prefix = name+"."; + stage.add_things(things, prefix); + stage.define_actions(sequencer, prefix); } void Demo::set_fixed_framerate(float fps) diff --git a/source/sequencer.cpp b/source/sequencer.cpp index 25182b8..6a0ab2e 100644 --- a/source/sequencer.cpp +++ b/source/sequencer.cpp @@ -25,6 +25,11 @@ Sequencer::Sequencer(float bpm): register_action_type("set_camera"); } +void Sequencer::define_action(const string &name, Action &act) +{ + named_actions[name] = &act; +} + void Sequencer::set_beats_per_minute(float bpm) { secs_per_beat = Time::min/bpm; diff --git a/source/sequencer.h b/source/sequencer.h index d01ee68..d2a7869 100644 --- a/source/sequencer.h +++ b/source/sequencer.h @@ -108,6 +108,7 @@ public: template void register_action_type(const std::string &); + void define_action(const std::string &, Action &); void set_beats_per_minute(float); float get_beats_per_minute() const { return Msp::Time::min/secs_per_beat; } diff --git a/source/stage.h b/source/stage.h index 1d20bda..9026d03 100644 --- a/source/stage.h +++ b/source/stage.h @@ -74,6 +74,7 @@ public: ~Stage(); virtual void add_things(Demo::ThingMap &, const std::string &); + virtual void define_actions(Sequencer &, const std::string &) { } void set_camera(const Msp::GL::Camera &); Msp::GL::Camera &get_camera() { return camera; }