X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fengineer%2Ftrainpanel.cpp;h=e239b1e7a9dfdb15431f128111eb9d1ab780ba94;hb=d2dfed1a38c5e8487532e9055fad464cf54efd83;hp=51e7a88fe8e820f54b76e03a1a0f94749c170365;hpb=34f8bf04e4bdffefeceea59b186386b51c542b9d;p=r2c2.git diff --git a/source/engineer/trainpanel.cpp b/source/engineer/trainpanel.cpp index 51e7a88..e239b1e 100644 --- a/source/engineer/trainpanel.cpp +++ b/source/engineer/trainpanel.cpp @@ -1,19 +1,11 @@ -/* $Id$ - -This file is part of R²C² -Copyright © 2006-2011 Mikkosoft Productions, Mikko Rasa -Distributed under the GPL -*/ - #include -#include +#include #include "libr2c2/aicontrol.h" -#include "libr2c2/timetable.h" #include "libr2c2/trackiter.h" +#include "libr2c2/trainrouter.h" #include "libr2c2/vehicletype.h" #include "engineer.h" #include "routeselect.h" -#include "timetabledialog.h" #include "trainpanel.h" #include "trainproperties.h" #include "trainview.h" @@ -72,20 +64,24 @@ TrainPanel::TrainPanel(Engineer &e, Train &t): pnl_extra->set_geometry(GLtk::Geometry(0, 10, geom.w, 135)); pnl_extra->set_visible(false); - const Route *route = train.get_route(); + TrainRouter *router = train.get_ai_of_type(); + if(!router) + router = new TrainRouter(train); + + const Route *route = router->get_route(); pnl_extra->add(*(lbl_route = new GLtk::Label((route ? route->get_name() : "Free run")))); lbl_route->set_style("digital"); lbl_route->set_geometry(GLtk::Geometry(10, 85, geom.w-20, 20)); - train.signal_route_changed.connect(sigc::mem_fun(this, &TrainPanel::train_route_changed)); + router->signal_route_changed.connect(sigc::mem_fun(this, &TrainPanel::train_route_changed)); pnl_extra->add(*(lbl_status = new GLtk::Label(status.get_status()))); lbl_status->set_style("digital"); lbl_status->set_geometry(GLtk::Geometry(10, 60, geom.w-20, 20)); status.signal_changed.connect(sigc::mem_fun(this, &TrainPanel::train_status_changed)); - const map &funcs = train.get_locomotive_type().get_functions(); + const VehicleType::FunctionMap &funcs = train.get_locomotive_type().get_functions(); unsigned x = 10; - for(map::const_iterator i=funcs.begin(); i!=funcs.end(); ++i, x+=36) + for(VehicleType::FunctionMap::const_iterator i=funcs.begin(); i!=funcs.end(); ++i, x+=36) { string fname = i->second; fname[0] = toupper(fname[0]); @@ -122,10 +118,6 @@ TrainPanel::TrainPanel(Engineer &e, Train &t): btn->set_geometry(GLtk::Geometry(100, 30, 36, 25)); btn->signal_clicked.connect(sigc::mem_fun(this, &TrainPanel::route_clicked)); - pnl_extra->add(*(btn = new GLtk::Button("TTbl"))); - btn->set_geometry(GLtk::Geometry(46, 30, 36, 25)); - btn->signal_clicked.connect(sigc::mem_fun(this, &TrainPanel::timetable_clicked)); - pnl_extra->add(*(btn = new GLtk::Button("View"))); btn->set_geometry(GLtk::Geometry(geom.w-46, 30, 36, 25)); btn->signal_clicked.connect(sigc::mem_fun(this, &TrainPanel::view_clicked)); @@ -212,20 +204,6 @@ void TrainPanel::goto_clicked() pick_conn = engineer.signal_pick_done.connect(sigc::mem_fun(this, &TrainPanel::go_to)); } -void TrainPanel::timetable_clicked() -{ - Timetable *timetable = dynamic_cast(train.get_tagged_ai("timetable")); - if(!timetable) - { - timetable = new Timetable(train); - timetable->set_tag("timetable"); - } - - TimetableDialog *dialog = new TimetableDialog(*timetable); - engineer.get_root().add(*dialog); - dialog->set_position(geom.x+geom.w, geom.y+geom.h-dialog->get_geometry().h); -} - void TrainPanel::view_clicked() { TrainView *dialog = new TrainView(engineer, train); @@ -258,31 +236,16 @@ void TrainPanel::place(Track *track, unsigned ep) { pick_conn.disconnect(); - Block &block = track->get_block(); - TrackIter iter(track, ep); - - while(block.has_track(*iter)) - { - const vector &eps = block.get_endpoints(); - bool ok = false; - for(unsigned i=0; (!ok && i(); + if(router) + router->set_destination(track->get_block()); }