X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fengineer%2Fengineer.cpp;h=e1268c63f25323f55a9b002589989a419a3c573a;hb=4086edbfae9a04da491cdb349a3bef6af5c132d9;hp=365fee0d6333d02c65875c518fcb7fe1042bf9a5;hpb=ec1f75d72e5c4f7f7c9dafdf80f58c30ffb1a855;p=r2c2.git diff --git a/source/engineer/engineer.cpp b/source/engineer/engineer.cpp index 365fee0..e1268c6 100644 --- a/source/engineer/engineer.cpp +++ b/source/engineer/engineer.cpp @@ -37,6 +37,7 @@ Engineer::Engineer(int argc, char **argv): window(options.screen_w, options.screen_h, options.fullscreen), keyboard(window), mouse(window), + ui_res("r2c2.res"), layout(catalogue, (options.driver.empty() ? 0 : Driver::create(options.driver))), layout_3d(layout), server(0), @@ -51,7 +52,6 @@ Engineer::Engineer(int argc, char **argv): window.set_title("Railroad Engineer"); window.signal_close.connect(sigc::bind(sigc::mem_fun(this, &Engineer::exit), 0)); - DataFile::load(ui_res, "r2c2.res"); root = new GLtk::Root(ui_res, window); mouse.signal_button_press.connect(sigc::mem_fun(this, &Engineer::button_press)); mouse.signal_axis_motion.connect(sigc::mem_fun(this, &Engineer::axis_motion)); @@ -181,6 +181,10 @@ void Engineer::tick() { window.get_display().tick(); + for(list::iterator i=new_trains.begin(); i!=new_trains.end(); ++i) + process_new_train(**i); + new_trains.clear(); + layout.tick(); event_disp.tick(Time::zero); @@ -224,6 +228,7 @@ void Engineer::tick() if(picking && picking_track && picking_entry>=0) { + camera.apply(); GL::MatrixStack::Push push_mat(GL::MatrixStack::modelview()); float rot = picking_track->get_endpoint_direction(picking_entry); @@ -391,7 +396,7 @@ Track *Engineer::pick_track(const Vector &p) return layout.pick_track(Vector(start.x, start.y, start.z), Vector(ray.x, ray.y, ray.z)); } -void Engineer::train_added(Train &train) +void Engineer::process_new_train(Train &train) { TrainPanel *tpanel = new TrainPanel(*this, train); root->add(*tpanel); @@ -401,15 +406,21 @@ void Engineer::train_added(Train &train) Vehicle3D &loco3d = layout_3d.get_vehicle(train.get_vehicle(0)); overlay->set_label(loco3d, train.get_name()); train.signal_name_changed.connect(sigc::bind<0>(sigc::mem_fun(overlay, &Overlay3D::set_label), sigc::ref(loco3d))); +} + +void Engineer::train_added(Train &train) +{ + new_trains.push_back(&train); GL::Color best_color; float best_d_sq = 0; for(unsigned i=0; i<10; ++i) { GL::Color color; - color.r = rand()*1.0/RAND_MAX; - color.g = rand()*1.0/RAND_MAX; - color.b = rand()*1.0/RAND_MAX; + unsigned h = rand()%3; + color.r = (h==0 ? 0.0 : rand()*1.0/RAND_MAX); + color.g = (h==1 ? 0.0 : rand()*1.0/RAND_MAX); + color.b = (h==2 ? 0.0 : rand()*1.0/RAND_MAX); color = color*(1/max(max(color.r, color.g), color.b)); float min_d_sq = 3; for(map::const_iterator j=train_colors.begin(); j!=train_colors.end(); ++j)