X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fsequencer.cpp;h=917108b7878753a987e88d7c931a6e6a69760586;hb=2a957e891f86cc692ddbb80f71b1478ea03d5a4f;hp=d9d35614dbf4ed9fd897b60e5c5df67ee68d5f11;hpb=8ffa42fba0e6a13286b465473fd399cac7c77dcf;p=libs%2Fdemoscene.git diff --git a/source/sequencer.cpp b/source/sequencer.cpp index d9d3561..917108b 100644 --- a/source/sequencer.cpp +++ b/source/sequencer.cpp @@ -1,6 +1,6 @@ #include #include -#include "action.h" +#include #include "sequencer.h" using namespace std; @@ -126,3 +126,60 @@ void Sequencer::update_next_event() if(i->end_beat>beat) next_event = min(next_event, i->end_beat); } + + +Sequencer::Loader::Loader(Sequencer &s, Demo &d): + DataFile::ObjectLoader(s), + demo(d) +{ + add("define_action", &Loader::define_action); + add("instant", &Loader::instant); + add("segment", &Loader::segment); +} + +void Sequencer::Loader::define_action(const string &n) +{ + ActionDefLoader ldr(obj, demo); + load_sub_with(ldr); + obj.named_actions[n] = ldr.get_action(); +} + +void Sequencer::Loader::instant(float beat) +{ + segment(beat, beat); +} + +void Sequencer::Loader::segment(float start, float end) +{ + SegmentLoader ldr(obj, start, end); + load_sub_with(ldr); +} + + +Sequencer::ActionDefLoader::ActionDefLoader(Sequencer &s, Demo &d): + DataFile::ObjectLoader(s), + demo(d) +{ + for(const auto &t: obj.action_types) + add(t.first, t.second->get_loader_func()); +} + +void Sequencer::ActionDefLoader::finished() +{ + if(action) + action->validate(); +} + + +Sequencer::SegmentLoader::SegmentLoader(Sequencer &s, float b, float e): + ObjectLoader(s), + start_beat(b), + end_beat(e) +{ + add("apply", &SegmentLoader::apply); +} + +void Sequencer::SegmentLoader::apply(const string &n) +{ + obj.add_action(*get_item(obj.named_actions, n), start_beat, end_beat); +}