X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fengineer%2Fengineer.cpp;h=8b0c6b72bd2d1cf2b50e896ae4437f6e164e4640;hb=ff6a2d7146e9e8981ae0f53815b71aabec31f063;hp=32b23ab900aa16ea6ab7009081d911ec8801a73a;hpb=277e8e7e4230aa8867f507ace62476afe575cff1;p=r2c2.git diff --git a/source/engineer/engineer.cpp b/source/engineer/engineer.cpp index 32b23ab..8b0c6b7 100644 --- a/source/engineer/engineer.cpp +++ b/source/engineer/engineer.cpp @@ -1,20 +1,12 @@ -/* $Id$ - -This file is part of R²C² -Copyright © 2006-2011 Mikkosoft Productions, Mikko Rasa -Distributed under the GPL -*/ - #include #include #include #include #include -#include #include #include -#include -#include +#include +#include #include #include #include @@ -23,7 +15,7 @@ Distributed under the GPL #include #include #include -#include +#include #include #include #include "libr2c2/driver.h" @@ -41,8 +33,6 @@ using namespace std; using namespace R2C2; using namespace Msp; -Application::RegApp Engineer::reg; - Engineer::Engineer(int argc, char **argv): options(argc, argv), window(options.screen_w, options.screen_h, options.fullscreen), @@ -73,7 +63,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 +72,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,18 +91,22 @@ 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)); lighting.set_ambient(GL::Color(0.4)); lighting.attach(0, light); - GL::PipelinePass *pass = &pipeline.add_pass(0); - pass->depth_test = &GL::DepthTest::lequal(); - pass->lighting = &lighting; + GL::Pipeline::Pass *pass = &pipeline.add_pass(0); + pass->set_depth_test(&GL::DepthTest::lequal()); + pass->set_lighting(&lighting); pass = &pipeline.add_pass("unlit"); - pass->depth_test = &GL::DepthTest::lequal(); + pass->set_depth_test(&GL::DepthTest::lequal()); + + pass = &pipeline.add_pass("overlay"); + pass->set_blend(&GL::Blend::alpha()); view_all(); @@ -201,11 +196,7 @@ 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); - } + pipeline.render(); if(pointer_moved) { @@ -382,9 +373,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 +393,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();