X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fengineer%2Ftrainproperties.cpp;h=96c8313d4800d2809cf5da62021d5f1d9a4ab5a8;hb=dc3b2bce73df40ea885a1960a825e5cd3a33c045;hp=8780dc4ab1cd66c8ead2a755d0cdd307ba29243e;hpb=651698847d5293cfb15b6fb23a394701388c0151;p=r2c2.git diff --git a/source/engineer/trainproperties.cpp b/source/engineer/trainproperties.cpp index 8780dc4..96c8313 100644 --- a/source/engineer/trainproperties.cpp +++ b/source/engineer/trainproperties.cpp @@ -35,10 +35,13 @@ TrainProperties::TrainProperties(Engineer &e, const GLtk::Resources &r, Train *t add(*(drp_type=new GLtk::Dropdown(res))); drp_type->set_geometry(GLtk::Geometry(60, geom.h-50, geom.w-70, 20)); - const map &locos = engineer.get_catalogue().get_locomotives(); + const map &vehs = engineer.get_catalogue().get_vehicles(); unsigned n = 0; - for(map::const_iterator i=locos.begin(); i!=locos.end(); ++i, ++n) + for(map::const_iterator i=vehs.begin(); i!=vehs.end(); ++i, ++n) { + if(!dynamic_cast(i->second)) + continue; + drp_type->append(format("%d %s", i->second->get_article_number(), i->second->get_name())); if(train && i->second==&train->get_locomotive_type()) drp_type->set_selected_index(n); @@ -60,13 +63,20 @@ void TrainProperties::on_ok_clicked() { if(!train) { - const map &locos = engineer.get_catalogue().get_locomotives(); - map::const_iterator i = locos.begin(); - advance(i, drp_type->get_selected_index()); + const map &vehs = engineer.get_catalogue().get_vehicles(); + map::const_iterator i = vehs.begin(); + unsigned n = drp_type->get_selected_index(); + while(!dynamic_cast(i->second)) + ++i; + while(n) + { + if(dynamic_cast(i->second)) + --n; + ++i; + } unsigned addr = lexical_cast(ent_addr->get_text()); - train = new Train(engineer.get_layout(), *i->second, addr); - engineer.place_train(*train); + train = new Train(engineer.get_layout(), *dynamic_cast(i->second), addr); } train->set_name(ent_name->get_text());