]> git.tdb.fi Git - r2c2.git/blobdiff - source/engineer/engineer.cpp
Fix remaining exception class names
[r2c2.git] / source / engineer / engineer.cpp
index 32b23ab900aa16ea6ab7009081d911ec8801a73a..b9e252301b5adbd1b3d77bc0ec6f068ba85239d9 100644 (file)
@@ -1,20 +1,12 @@
-/* $Id$
-
-This file is part of R²C²
-Copyright © 2006-2011 Mikkosoft Productions, Mikko Rasa
-Distributed under the GPL
-*/
-
 #include <algorithm>
 #include <cmath>
 #include <cstdlib>
 #include <limits>
 #include <signal.h>
-#include <msp/core/except.h>
 #include <msp/fs/stat.h>
 #include <msp/fs/utils.h>
-#include <msp/gbase/display.h>
-#include <msp/gbase/window.h>
+#include <msp/graphics/display.h>
+#include <msp/graphics/window.h>
 #include <msp/gl/blend.h>
 #include <msp/gl/framebuffer.h>
 #include <msp/gl/matrix.h>
@@ -23,7 +15,7 @@ Distributed under the GPL
 #include <msp/gl/tests.h>
 #include <msp/gl/transform.h>
 #include <msp/io/print.h>
-#include <msp/strings/formatter.h>
+#include <msp/strings/format.h>
 #include <msp/time/units.h>
 #include <msp/time/utils.h>
 #include "libr2c2/driver.h"
@@ -73,7 +65,7 @@ Engineer::Engineer(int argc, char **argv):
        main_panel->set_position(0, window.get_height()-main_panel->get_geometry().h);
        main_panel->set_visible(true);
 
-       overlay = new Overlay3D(window, camera, ui_res.get_default_font());
+       overlay = new Overlay3D(ui_res.get_default_font());
 
        // Setup railroad control
        DataFile::load(catalogue, "tracks.dat");
@@ -82,9 +74,10 @@ Engineer::Engineer(int argc, char **argv):
        DataFile::load(layout, options.layout_fn);
 
        layout.signal_train_added.connect(sigc::mem_fun(this, &Engineer::train_added));
-       layout.signal_block_reserved.connect(sigc::mem_fun(this, &Engineer::block_reserved));
+       layout.signal_block_reserved.connect(sigc::hide<1>(sigc::mem_fun(this, &Engineer::reset_block_color)));
+       layout.signal_block_state_changed.connect(sigc::hide<1>(sigc::mem_fun(this, &Engineer::reset_block_color)));
        layout.signal_emergency.connect(sigc::mem_fun(this, &Engineer::set_status));
-       layout.get_driver().signal_sensor.connect(sigc::mem_fun(this, &Engineer::sensor_event));
+
        if(FS::exists(options.state_fn))
                DataFile::load(layout, options.state_fn);
 
@@ -100,6 +93,7 @@ Engineer::Engineer(int argc, char **argv):
        pipeline.set_camera(&camera);
        pipeline.add_renderable_for_pass(layout_3d.get_scene(), 0);
        pipeline.add_renderable_for_pass(layout_3d.get_path_scene(), "unlit");
+       pipeline.add_renderable_for_pass(*overlay, "overlay");
 
        light.set_position(GL::Vector4(0, -0.259, 0.966, 0));
        light.set_diffuse(GL::Color(0.9));
@@ -113,6 +107,9 @@ Engineer::Engineer(int argc, char **argv):
        pass = &pipeline.add_pass("unlit");
        pass->depth_test = &GL::DepthTest::lequal();
 
+       pass = &pipeline.add_pass("overlay");
+       pass->blend = &GL::Blend::alpha();
+
        view_all();
 
        // Catch various signals so we can stop the trains in case we get terminated
@@ -202,10 +199,6 @@ void Engineer::tick()
        GL::Framebuffer::system().clear(GL::COLOR_BUFFER_BIT|GL::DEPTH_BUFFER_BIT);
 
        pipeline.render_all();
-       {
-               GL::Bind blend(GL::Blend::alpha());
-               overlay->render(0);
-       }
 
        if(pointer_moved)
        {
@@ -382,9 +375,7 @@ void Engineer::set_block_color(const Block &block, const GL::Color &color)
 
 void Engineer::reset_block_color(const Block &block)
 {
-       bool active = false;
-       if(unsigned sid=block.get_sensor_id())
-               active = layout.get_driver().get_sensor(sid);
+       bool active = block.get_state()>Block::INACTIVE;
 
        if(block.get_train())
        {
@@ -404,19 +395,6 @@ void Engineer::reset_block_color(const Block &block)
                set_block_color(block, GL::Color(1));
 }
 
-void Engineer::sensor_event(unsigned addr, bool)
-{
-       const set<Block *> &blocks = layout.get_blocks();
-       for(set<Block *>::const_iterator i=blocks.begin(); i!=blocks.end(); ++i)
-               if((*i)->get_sensor_id()==addr)
-                       reset_block_color(**i);
-}
-
-void Engineer::block_reserved(const Block &block, const Train *)
-{
-       reset_block_color(block);
-}
-
 Track *Engineer::pick_track(int x, int y)
 {
        const GL::Vector3 &start = camera.get_position();