3 This file is part of R²C²
4 Copyright © 2009 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
8 #include <msp/gltk/label.h>
10 #include "libr2c2/route.h"
11 #include "routeselect.h"
17 RouteSelect::RouteSelect(Engineer &e, Train &t):
24 add(*(label = new GLtk::Label("Select route")));
25 label->set_geometry(GLtk::Geometry(10, geom.h-25, geom.w-20, 20));
27 add(*(drp_route = new GLtk::Dropdown));
28 drp_route->set_geometry(GLtk::Geometry(10, geom.h-50, geom.w-20, 20));
29 drp_route->append("(none)");
30 drp_route->set_selected_index(0);
31 const set<Route *> &routes = engineer.get_layout().get_routes();
33 for(set<Route *>::const_iterator i=routes.begin(); i!=routes.end(); ++i)
34 if(!(*i)->is_temporary())
36 drp_route->append((*i)->get_name());
37 if(*i==train.get_route())
38 drp_route->set_selected_index(n);
43 void RouteSelect::on_ok_clicked()
45 if(drp_route->get_selected_index()>0)
47 const set<Route *> &routes = engineer.get_layout().get_routes();
48 set<Route *>::const_iterator i = routes.begin();
49 unsigned n = drp_route->get_selected_index()-1;
50 while(i!=routes.end())
52 if(!(*i)->is_temporary())
61 if(!train.set_route(*i))
62 engineer.set_status("Could not set route");