#include <cmath>
#include <msp/core/algorithm.h>
#include <msp/core/maputils.h>
+#include <msp/core/raii.h>
+#include "animate.h"
#include "fadeoverlay.h"
#include "sequencer.h"
#include "stage.h"
using namespace std;
-using namespace Msp;
+
+namespace Msp {
+namespace DemoScene {
Sequencer::Sequencer(float bpm):
started(false),
{
set_beats_per_minute(bpm);
+ register_action_type<Animate>("animate");
register_action_type<FadeOverlay::Fade>("fade");
register_action_type<Stage::UseInView>("use_stage");
+ register_action_type<Stage::SetCamera>("set_camera");
}
void Sequencer::set_beats_per_minute(float bpm)
Sequencer::Loader::Loader(Sequencer &s, Demo &d):
DataFile::ObjectLoader<Sequencer>(s),
- demo(d)
+ demo(d),
+ base_beat(0.0f)
{
+ add("base", &Loader::base);
add("define_action", &Loader::define_action);
add("instant", &Loader::instant);
+ add("repeat", &Loader::repeat);
add("segment", &Loader::segment);
}
+void Sequencer::Loader::base(float b)
+{
+ SetForScope<float> set_base(base_beat, base_beat+b);
+ load_sub_with(*this);
+}
+
void Sequencer::Loader::define_action(const string &n)
{
ActionDefLoader ldr(obj, demo);
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, start, end);
+ SegmentLoader ldr(obj, base_beat+start, base_beat+end, demo);
load_sub_with(ldr);
}
demo(d)
{
for(const auto &t: obj.action_types)
- add(t.first, t.second->get_loader_func());
+ add(t.first, t.second->get_def_loader_func());
}
void Sequencer::ActionDefLoader::finished()
}
-Sequencer::SegmentLoader::SegmentLoader(Sequencer &s, float b, float e):
+Sequencer::SegmentLoader::SegmentLoader(Sequencer &s, float b, float e, Demo &d):
ObjectLoader<Sequencer>(s),
start_beat(b),
- end_beat(e)
+ end_beat(e),
+ demo(d)
{
add("apply", &SegmentLoader::apply);
+ for(const auto &t: obj.action_types)
+ add(t.first, t.second->get_loader_func());
}
void Sequencer::SegmentLoader::apply(const string &n)
{
obj.add_action(*get_item(obj.named_actions, n), start_beat, end_beat);
}
+
+} // namespace DemoScene
+} // namespace Msp