X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fengineer%2Fengineer.cpp;h=dfc677d46410fcf33f3de7f9e0dfd746470e2d07;hb=4236c30c0a7a48854e9634e9ad7d8d6e0fd243a3;hp=8aea6f68ace07ad70360cd27bdb3fd874ccd913a;hpb=3c04e77e639e7b7fff995ceb9cc8c00da622d26e;p=r2c2.git diff --git a/source/engineer/engineer.cpp b/source/engineer/engineer.cpp index 8aea6f6..dfc677d 100644 --- a/source/engineer/engineer.cpp +++ b/source/engineer/engineer.cpp @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of R²C² -Copyright © 2006-2011 Mikkosoft Productions, Mikko Rasa -Distributed under the GPL -*/ - #include #include #include @@ -13,8 +6,8 @@ Distributed under the GPL #include #include #include -#include -#include +#include +#include #include #include #include @@ -23,7 +16,7 @@ Distributed under the GPL #include #include #include -#include +#include #include #include #include "libr2c2/driver.h" @@ -82,9 +75,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,7 +94,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, "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)); @@ -114,6 +108,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 @@ -379,9 +376,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()) { @@ -401,19 +396,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 &blocks = layout.get_blocks(); - for(set::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();