]> git.tdb.fi Git - libs/demoscene.git/blobdiff - source/sequencer.cpp
Use LoadableTypeRegistry to manage action types in Sequencer
[libs/demoscene.git] / source / sequencer.cpp
index 19c4041ab2f1d954a8ff7720d739019c6811a460..25182b8ef6ee7f4e623b83cfc942f8fe17339e86 100644 (file)
@@ -147,6 +147,7 @@ Sequencer::Loader::Loader(Sequencer &s, Demo &d):
        add("base", &Loader::base);
        add("define_action", &Loader::define_action);
        add("instant", &Loader::instant);
+       add("repeat", &Loader::repeat);
        add("segment", &Loader::segment);
 }
 
@@ -168,6 +169,15 @@ void Sequencer::Loader::instant(float beat)
        segment(beat, beat);
 }
 
+void Sequencer::Loader::repeat(float b, float d, unsigned n)
+{
+       for(unsigned i=0; i<n; ++i)
+       {
+               SetForScope<float> set_base(base_beat, base_beat+b+i*d);
+               load_sub_with(*this);
+       }
+}
+
 void Sequencer::Loader::segment(float start, float end)
 {
        SegmentLoader ldr(obj, base_beat+start, base_beat+end, demo);
@@ -179,26 +189,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)