X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fengineer%2Ftrainproperties.cpp;h=eaddc8bb1c47a38a2ca94c5944deef0592b14773;hb=9b05c573a38639827697fe393d55b7c76f5bde45;hp=bf0b270ca3de41556e3219fd81ea3ee73f70dc71;hpb=62ce775d9af8f3321dbdebd6243b551fbbb0b976;p=r2c2.git diff --git a/source/engineer/trainproperties.cpp b/source/engineer/trainproperties.cpp index bf0b270..eaddc8b 100644 --- a/source/engineer/trainproperties.cpp +++ b/source/engineer/trainproperties.cpp @@ -8,6 +8,7 @@ Distributed under the GPL #include #include #include +#include "libmarklin/driver.h" #include "libmarklin/vehicle.h" #include "libmarklin/vehicletype.h" #include "engineer.h" @@ -30,8 +31,19 @@ TrainProperties::TrainProperties(Engineer &e, Train *t): add(*(ent_addr = new GLtk::Entry)); ent_addr->set_geometry(GLtk::Geometry(10, geom.h-50, 40, 20)); + add(*(drp_protocol = new GLtk::Dropdown)); + drp_protocol->set_geometry(GLtk::Geometry(60, geom.h-50, 60, 20)); + for(unsigned i=0;; ++i) + { + if(const char *proto = engineer.get_layout().get_driver().enumerate_protocols(i)) + drp_protocol->append(proto); + else + break; + } + drp_protocol->set_selected_index(0); + add(*(drp_type = new GLtk::Dropdown)); - drp_type->set_geometry(GLtk::Geometry(60, geom.h-50, geom.w-70, 20)); + drp_type->set_geometry(GLtk::Geometry(130, geom.h-50, geom.w-140, 20)); const Catalogue::VehicleMap &vehs = engineer.get_catalogue().get_vehicles(); unsigned n = 0; @@ -106,7 +118,7 @@ void TrainProperties::on_ok_clicked() { const VehicleType &type = get_vehicle_type(drp_type->get_selected_index(), true); unsigned addr = lexical_cast(ent_addr->get_text()); - train = new Train(engineer.get_layout(), type, addr); + train = new Train(engineer.get_layout(), type, addr, drp_protocol->get_selected()); } train->set_name(ent_name->get_text()); @@ -139,7 +151,7 @@ void TrainProperties::remove_vehicle_clicked() lst_vehicles->remove(selected); - unsigned n_vehicles = train->get_n_vehicles()-rem_vehicles.size(); + unsigned n_vehicles = (train ? train->get_n_vehicles()-rem_vehicles.size() : 0); if(static_cast(selected)>=n_vehicles) add_vehicles.erase(add_vehicles.begin()+(selected-n_vehicles)); else