]> git.tdb.fi Git - libs/demoscene.git/blobdiff - source/stage.cpp
Make some simple actions loadable
[libs/demoscene.git] / source / stage.cpp
index ef5cac44ca5bbdcf8429350e4f98cb35afff7bdb..cbe576fa24ba566d2e33bcb2e04201c8c40be027 100644 (file)
@@ -1,6 +1,8 @@
 #include <msp/gl/view.h>
+#include "demo.h"
 #include "stage.h"
 
+using namespace std;
 using namespace Msp;
 
 Stage::Stage():
@@ -13,13 +15,44 @@ 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);
 }