X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fengineer%2Frouteselect.cpp;h=770a455a4130b7406e22a6f348c38b680b757626;hb=ca9d278f9472206ad9a01190dcef9f0eb1bcc274;hp=0e191499a0541d89478de35c94b44e7522329163;hpb=62ce775d9af8f3321dbdebd6243b551fbbb0b976;p=r2c2.git diff --git a/source/engineer/routeselect.cpp b/source/engineer/routeselect.cpp index 0e19149..770a455 100644 --- a/source/engineer/routeselect.cpp +++ b/source/engineer/routeselect.cpp @@ -1,18 +1,12 @@ -/* $Id$ - -This file is part of the MSP Märklin suite -Copyright © 2009 Mikkosoft Productions, Mikko Rasa -Distributed under the GPL -*/ - #include #include "engineer.h" -#include "libmarklin/route.h" +#include "libr2c2/route.h" +#include "libr2c2/trainrouter.h" #include "routeselect.h" using namespace std; using namespace Msp; -using namespace Marklin; +using namespace R2C2; RouteSelect::RouteSelect(Engineer &e, Train &t): engineer(e), @@ -28,13 +22,18 @@ RouteSelect::RouteSelect(Engineer &e, Train &t): drp_route->set_geometry(GLtk::Geometry(10, geom.h-50, geom.w-20, 20)); drp_route->append("(none)"); drp_route->set_selected_index(0); + + const Route *current_route = 0; + if(TrainRouter *router = train.get_ai_of_type()) + current_route = router->get_route(); + const set &routes = engineer.get_layout().get_routes(); unsigned n = 1; for(set::const_iterator i=routes.begin(); i!=routes.end(); ++i) if(!(*i)->is_temporary()) { drp_route->append((*i)->get_name()); - if(*i==train.get_route()) + if(*i==current_route) drp_route->set_selected_index(n); ++n; } @@ -57,10 +56,9 @@ void RouteSelect::on_ok_clicked() } ++i; } - - if(!train.set_route(*i)) - engineer.set_status("Could not set route"); + + train.ai_message(TrainAI::Message("set-route", *i)); } else - train.set_route(0); + train.ai_message(TrainAI::Message("clear-route")); }