X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fengineer%2Ftrainproperties.cpp;h=9686dee485527574cd2b1f78b3c111f3b46a1f09;hb=1ff06c5bc46a677fa389ef86c6b26664368f1653;hp=bf0b270ca3de41556e3219fd81ea3ee73f70dc71;hpb=62ce775d9af8f3321dbdebd6243b551fbbb0b976;p=r2c2.git diff --git a/source/engineer/trainproperties.cpp b/source/engineer/trainproperties.cpp index bf0b270..9686dee 100644 --- a/source/engineer/trainproperties.cpp +++ b/source/engineer/trainproperties.cpp @@ -1,6 +1,6 @@ /* $Id$ -This file is part of the MSP Märklin suite +This file is part of R²C² Copyright © 2006-2010 Mikkosoft Productions, Mikko Rasa Distributed under the GPL */ @@ -8,14 +8,15 @@ Distributed under the GPL #include #include #include -#include "libmarklin/vehicle.h" -#include "libmarklin/vehicletype.h" +#include "libr2c2/driver.h" +#include "libr2c2/vehicle.h" +#include "libr2c2/vehicletype.h" #include "engineer.h" #include "trainproperties.h" using namespace std; using namespace Msp; -using namespace Marklin; +using namespace R2C2; TrainProperties::TrainProperties(Engineer &e, Train *t): engineer(e), @@ -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