]> git.tdb.fi Git - libs/demoscene.git/blobdiff - source/sequencer.cpp
Allow stages to define actions
[libs/demoscene.git] / source / sequencer.cpp
index b4969bb30337182b35500b7ec378797bd8c1e86c..6a0ab2ef7f655d46109f8252ec4bfae1376908ba 100644 (file)
@@ -25,6 +25,11 @@ Sequencer::Sequencer(float bpm):
        register_action_type<Stage::SetCamera>("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;
@@ -189,26 +194,22 @@ Sequencer::ActionDefLoader::ActionDefLoader(Sequencer &s, Demo &d):
        DataFile::ObjectLoader<Sequencer>(s),
        demo(d)
 {
-       for(const auto &t: obj.action_types)
-               add(t.first, t.second->get_def_loader_func());
-}
-
-void Sequencer::ActionDefLoader::finished()
-{
-       if(action)
-               action->validate();
+       obj.action_registry.add_all(*this);
 }
 
 
 Sequencer::SegmentLoader::SegmentLoader(Sequencer &s, float b, float e, Demo &d):
-       ObjectLoader<Sequencer>(s),
+       ActionDefLoader(s, d),
        start_beat(b),
-       end_beat(e),
-       demo(d)
+       end_beat(e)
 {
        add("apply", &SegmentLoader::apply);
-       for(const auto &t: obj.action_types)
-               add(t.first, t.second->get_loader_func());
+}
+
+void Sequencer::SegmentLoader::action_loaded()
+{
+       obj.add_action(*action, start_beat, end_beat);
+       obj.anonymous_actions.push_back(action.release());
 }
 
 void Sequencer::SegmentLoader::apply(const string &n)