]> git.tdb.fi Git - r2c2.git/blobdiff - source/engineer/trainproperties.cpp
Major architecture rework
[r2c2.git] / source / engineer / trainproperties.cpp
index 004747cdd1224456ecf0493e1d175e64823160ed..8780dc4ab1cd66c8ead2a755d0cdd307ba29243e 100644 (file)
@@ -1,7 +1,7 @@
 /* $Id$
 
 This file is part of the MSP Märklin suite
-Copyright © 2006-2009 Mikkosoft Productions, Mikko Rasa
+Copyright © 2006-2010  Mikkosoft Productions, Mikko Rasa
 Distributed under the GPL
 */
 
@@ -9,6 +9,7 @@ Distributed under the GPL
 #include <msp/gltk/label.h>
 #include <msp/strings/formatter.h>
 #include <msp/strings/lexicalcast.h>
+#include "libmarklin/locotype.h"
 #include "engineer.h"
 #include "trainproperties.h"
 
@@ -39,7 +40,7 @@ TrainProperties::TrainProperties(Engineer &e, const GLtk::Resources &r, Train *t
        for(map<unsigned, LocoType *>::const_iterator i=locos.begin(); i!=locos.end(); ++i, ++n)
        {
                drp_type->append(format("%d %s", i->second->get_article_number(), i->second->get_name()));
-               if(train && i->second==&train->get_locomotive().get_type())
+               if(train && i->second==&train->get_locomotive_type())
                        drp_type->set_selected_index(n);
        }
 
@@ -48,11 +49,11 @@ TrainProperties::TrainProperties(Engineer &e, const GLtk::Resources &r, Train *t
 
        if(train)
        {
-               ent_addr->set_text(lexical_cast(train->get_locomotive().get_address()));
+               ent_addr->set_text(lexical_cast(train->get_address()));
                ent_name->set_text(train->get_name());
        }
        else
-               ent_name->set_text(format("Train %d", engineer.get_traffic_manager().get_trains().size()+1));
+               ent_name->set_text(format("Train %d", engineer.get_layout().get_trains().size()+1));
 }
 
 void TrainProperties::on_ok_clicked()
@@ -64,8 +65,7 @@ void TrainProperties::on_ok_clicked()
                advance(i, drp_type->get_selected_index());
 
                unsigned addr = lexical_cast<unsigned>(ent_addr->get_text());
-               Locomotive *loco = new Locomotive(*i->second, engineer.get_control(), addr);
-               train = new Train(engineer.get_traffic_manager(), *loco);
+               train = new Train(engineer.get_layout(), *i->second, addr);
                engineer.place_train(*train);
        }