From e2032cbdb8d2ae52e42d400c5cc90ddad844f665 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 24 May 2019 22:29:04 +0300 Subject: [PATCH] Make it possible for Stages to add things to the Demo This is much more flexible than exposing everything so Demo can add them. --- source/demo.cpp | 2 +- source/demo.h | 4 +++- source/stage.cpp | 5 +++++ source/stage.h | 2 ++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/source/demo.cpp b/source/demo.cpp index 4cd66bd..c545685 100644 --- a/source/demo.cpp +++ b/source/demo.cpp @@ -31,7 +31,7 @@ Demo::~Demo() void Demo::add_stage(const std::string &name, Stage &stage) { things[name] = &stage; - things[name+".camera"] = static_cast(&stage.get_camera()); + stage.add_things(things, name+"."); } void Demo::set_fixed_framerate(float fps) diff --git a/source/demo.h b/source/demo.h index e2dfd6e..35be624 100644 --- a/source/demo.h +++ b/source/demo.h @@ -32,6 +32,8 @@ private: }; public: + typedef std::map ThingMap; + sigc::signal signal_finished; protected: @@ -48,7 +50,7 @@ protected: Msp::Time::TimeStamp last_tick; Msp::Time::TimeStamp next_frame; - std::map things; + ThingMap things; Demo(Msp::Graphics::Window &, Msp::Graphics::GLContext &, Msp::DataFile::Collection &); public: diff --git a/source/stage.cpp b/source/stage.cpp index 267afe3..e1ce352 100644 --- a/source/stage.cpp +++ b/source/stage.cpp @@ -14,6 +14,11 @@ Stage::~Stage() delete pipeline; } +void Stage::add_things(Demo::ThingMap &things, const string &prefix) +{ + things[prefix+"camera"] = static_cast(&camera); +} + void Stage::add_postprocessor(GL::PostProcessor &pp) { pipeline->add_postprocessor(pp); diff --git a/source/stage.h b/source/stage.h index 4937177..c108f6f 100644 --- a/source/stage.h +++ b/source/stage.h @@ -4,6 +4,7 @@ #include #include #include "action.h" +#include "demo.h" class Stage { @@ -68,6 +69,7 @@ public: Stage(); ~Stage(); + virtual void add_things(Demo::ThingMap &, const std::string &); void add_postprocessor(Msp::GL::PostProcessor &); void set_camera(const Msp::GL::Camera &); Msp::GL::Camera &get_camera() { return camera; } -- 2.45.2