X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdemo.h;h=35be62454e0c70100b13f392f560ef8784446a07;hb=e2032cbdb8d2ae52e42d400c5cc90ddad844f665;hp=2f40cf8df577e4f8796a1f53401d46de9ae7cd2e;hpb=35332818fc6bad98fe77831de2c51a11326e31aa;p=libs%2Fdemoscene.git diff --git a/source/demo.h b/source/demo.h index 2f40cf8..35be624 100644 --- a/source/demo.h +++ b/source/demo.h @@ -1,23 +1,47 @@ #ifndef MSP_DEMOSCENE_DEMO_H_ #define MSP_DEMOSCENE_DEMO_H_ +#include +#include #include #include #include #include #include +#include #include +#include "action.h" #include "sequencer.h" +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 ThingMap; + sigc::signal 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; @@ -26,10 +50,21 @@ protected: 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 + 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(); @@ -38,5 +73,10 @@ public: void seek(const Msp::Time::TimeDelta &); }; +template +T &Demo::get_thing(const std::string &name) +{ + return *get_item(things, name).value(); +} #endif