]> git.tdb.fi Git - libs/demoscene.git/commitdiff
Add statement for easily offsetting a group of segments
authorMikko Rasa <tdb@tdb.fi>
Sat, 8 Jun 2019 15:53:50 +0000 (18:53 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 8 Jun 2019 15:53:50 +0000 (18:53 +0300)
source/sequencer.cpp
source/sequencer.h

index 5aa0823897749227b0a51b08bb44454da752fccb..19c4041ab2f1d954a8ff7720d739019c6811a460 100644 (file)
@@ -1,6 +1,7 @@
 #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"
@@ -140,13 +141,21 @@ void Sequencer::update_next_event()
 
 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("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);
@@ -161,7 +170,7 @@ void Sequencer::Loader::instant(float beat)
 
 void Sequencer::Loader::segment(float start, float end)
 {
-       SegmentLoader ldr(obj, start, end, demo);
+       SegmentLoader ldr(obj, base_beat+start, base_beat+end, demo);
        load_sub_with(ldr);
 }
 
index 6e984025a0f27d21405185332c550952fe9ffd25..1cd1ebc8f139bc9c1ad6b5af2d1e0bfa79da0615 100644 (file)
@@ -22,11 +22,13 @@ public:
        {
        private:
                Demo &demo;
+               float base_beat;
 
        public:
                Loader(Sequencer &, Demo &);
 
        private:
+               void base(float);
                void define_action(const std::string &);
                void instant(float);
                void segment(float, float);