#ifndef MSP_DEMOSCENE_DEMO_H_
#define MSP_DEMOSCENE_DEMO_H_
+#include <map>
+#include <string>
#include <sigc++/signal.h>
#include <msp/al/sounddecoder.h>
#include <msp/al/source.h>
#include <msp/al/streamer.h>
#include <msp/datafile/collection.h>
+#include <msp/gl/animationplayer.h>
#include <msp/gl/windowview.h>
+#include "action.h"
#include "sequencer.h"
+namespace Msp {
+namespace DemoScene {
+
+class Stage;
+
class Demo
{
+private:
+ class AnimationAction: public Action
+ {
+ private:
+ Msp::GL::AnimationPlayer &player;
+
+ public:
+ AnimationAction(Msp::GL::AnimationPlayer &);
+
+ virtual void validate() const { }
+
+ virtual void tick(float, float);
+ };
+
public:
+ typedef std::map<std::string, Msp::Variant> ThingMap;
+
sigc::signal<void> signal_finished;
protected:
Sequencer sequencer;
Msp::DataFile::Collection &resources;
Msp::GL::WindowView view;
+ Msp::GL::AnimationPlayer anim_player;
+ AnimationAction anim_action;
Msp::AL::Source *music_source;
Msp::AL::Streamer *streamer;
Msp::IO::Seekable *music_io;
Msp::Time::TimeStamp last_tick;
Msp::Time::TimeStamp next_frame;
+ ThingMap things;
+
Demo(Msp::Graphics::Window &, Msp::Graphics::GLContext &, Msp::DataFile::Collection &);
public:
virtual ~Demo();
+ Msp::DataFile::Collection &get_resources() const { return resources; }
+ Msp::GL::AnimationPlayer &get_animation_player() { return anim_player; }
+
+protected:
+ void add_stage(const std::string &, Stage &);
+public:
+ template<typename T>
+ T &get_thing(const std::string &);
+
void set_fixed_framerate(float);
const Msp::Time::TimeStamp &get_next_frame_time() const { return next_frame; }
void enable_music();
void seek(const Msp::Time::TimeDelta &);
};
+template<typename T>
+T &Demo::get_thing(const std::string &name)
+{
+ return *get_item(things, name).value<T *>();
+}
+
+} // namespace DemoScene
+} // namespace Msp
#endif