music_io(0),
music_decoder(0)
{
+ things["window"] = static_cast<GL::View *>(&view);
+
sequencer.signal_finished.connect(signal_finished);
}
#include <msp/datafile/collection.h>
#include <msp/gl/renderer.h>
#include <msp/gl/texture2d.h>
+#include "demo.h"
#include "fadeoverlay.h"
using namespace Msp;
+using namespace std;
FadeOverlay::FadeOverlay(DataFile::Collection &resources):
mesh(get_fullscreen_quad()),
}
+FadeOverlay::Fade::Fade():
+ ColorFadeAction(GL::Color(0.0f, 0.0f, 0.0f, 0.0f)),
+ overlay(0)
+{ }
+
FadeOverlay::Fade::Fade(FadeOverlay &o, const GL::Color &c):
ColorFadeAction(c),
- overlay(o)
+ overlay(&o)
{ }
+
+void FadeOverlay::Fade::validate() const
+{
+ if(!overlay)
+ throw logic_error("null overlay");
+}
+
+
+FadeOverlay::Fade::Loader::Loader(Fade &f, Demo &d):
+ DataFile::DerivedObjectLoader<Fade, Action::Loader>(f, d)
+{
+ add("overlay", &Loader::overlay);
+ add("color", &Loader::color);
+}
+
+void FadeOverlay::Fade::Loader::overlay(const string &n)
+{
+ obj.overlay = &demo.get_thing<FadeOverlay>(n);
+}
+
+void FadeOverlay::Fade::Loader::color(float r, float g, float b, float a)
+{
+ obj.end_color = GL::Color(r, g, b, a);
+}
public:
class Fade: public ColorFadeAction
{
+ public:
+ class Loader: public Msp::DataFile::DerivedObjectLoader<Fade, Action::Loader>
+ {
+ public:
+ Loader(Fade &, Demo &);
+
+ private:
+ void overlay(const std::string &);
+ void color(float, float, float, float);
+ };
+
private:
- FadeOverlay &overlay;
+ FadeOverlay *overlay;
public:
+ Fade();
Fade(FadeOverlay &, const Msp::GL::Color &);
- virtual void validate() const { }
+ virtual void validate() const;
- virtual const Msp::GL::Color &get_color() const { return overlay.color; }
- virtual void set_color(const Msp::GL::Color &c) { overlay.set_color(c); }
+ virtual const Msp::GL::Color &get_color() const { return overlay->color; }
+ virtual void set_color(const Msp::GL::Color &c) { overlay->set_color(c); }
};
private:
#include <cmath>
#include <msp/core/algorithm.h>
#include <msp/core/maputils.h>
+#include "fadeoverlay.h"
#include "sequencer.h"
+#include "stage.h"
using namespace std;
using namespace Msp;
next_event(0)
{
set_beats_per_minute(bpm);
+
+ register_action_type<FadeOverlay::Fade>("fade");
+ register_action_type<Stage::UseInView>("use_stage");
}
void Sequencer::set_beats_per_minute(float bpm)
#include <msp/gl/view.h>
+#include "demo.h"
#include "stage.h"
+using namespace std;
using namespace Msp;
Stage::Stage():
}
+Stage::UseInView::UseInView():
+ view(0),
+ stage(0)
+{ }
+
Stage::UseInView::UseInView(GL::View &v, Stage &s):
- view(v),
- stage(s)
+ view(&v),
+ stage(&s)
{ }
+void Stage::UseInView::validate() const
+{
+ if(!view)
+ throw logic_error("null view");
+ if(!stage)
+ throw logic_error("null stage");
+}
+
void Stage::UseInView::start(float, float)
{
- view.set_camera(&stage.camera_control.get_camera());
- view.set_content(stage.pipeline);
+ view->set_camera(&stage->camera_control.get_camera());
+ view->set_content(stage->pipeline);
+}
+
+
+Stage::UseInView::Loader::Loader(UseInView &u, Demo &d):
+ DataFile::DerivedObjectLoader<UseInView, Action::Loader>(u, d)
+{
+ add("view", &Loader::view);
+ add("stage", &Loader::stage);
+}
+
+void Stage::UseInView::Loader::view(const string &n)
+{
+ obj.view = &demo.get_thing<GL::View>(n);
+}
+
+void Stage::UseInView::Loader::stage(const string &n)
+{
+ obj.stage = &demo.get_thing<Stage>(n);
}
{
class UseInView: public Action
{
+ public:
+ class Loader: public Msp::DataFile::DerivedObjectLoader<UseInView, Action::Loader>
+ {
+ public:
+ Loader(UseInView &, Demo &);
+
+ private:
+ void view(const std::string &);
+ void stage(const std::string &);
+ };
+
private:
- Msp::GL::View &view;
- Stage &stage;
+ Msp::GL::View *view;
+ Stage *stage;
public:
+ UseInView();
UseInView(Msp::GL::View &, Stage &);
- virtual void validate() const { }
+ virtual void validate() const;
virtual void start(float, float);
};