]> git.tdb.fi Git - r2c2.git/blobdiff - source/engineer/trainpanel.cpp
Major architecture rework
[r2c2.git] / source / engineer / trainpanel.cpp
index 339f4eca669f7e9d4337dd25ab674c4937a260c7..24a182b05c9328caca4efc318c14b7d309831ebc 100644 (file)
@@ -1,13 +1,13 @@
 /* $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
 */
 
 #include <msp/gltk/button.h>
 #include <msp/strings/formatter.h>
-#include "libmarklin/locomotive.h"
+#include "libmarklin/locotype.h"
 #include "engineer.h"
 #include "routeselect.h"
 #include "trainpanel.h"
@@ -25,7 +25,7 @@ TrainPanel::TrainPanel(Engineer &e, const GLtk::Resources &r, Train &t):
 {
        set_size(200, 170);
 
-       add(*(lbl_addr=new GLtk::Label(res, format("%2d", train.get_locomotive().get_address()))));
+       add(*(lbl_addr=new GLtk::Label(res, format("%2d", train.get_address()))));
        lbl_addr->set_style("digital");
        lbl_addr->set_geometry(GLtk::Geometry(10, geom.h-34, 35, 24));
 
@@ -34,7 +34,7 @@ TrainPanel::TrainPanel(Engineer &e, const GLtk::Resources &r, Train &t):
        lbl_name->set_geometry(GLtk::Geometry(45, geom.h-34, geom.w-55, 24));
        train.signal_name_changed.connect(sigc::mem_fun(lbl_name, &GLtk::Label::set_text));
 
-       add(*(lbl_speed=new GLtk::Label(res, format("%2d", train.get_locomotive().get_speed()))));
+       add(*(lbl_speed=new GLtk::Label(res, format("%2d", train.get_speed()))));
        lbl_speed->set_style("digital");
        lbl_speed->set_geometry(GLtk::Geometry(10, geom.h-58, 35, 24));
        train.signal_target_speed_changed.connect(sigc::mem_fun(this, &TrainPanel::train_speed_changed));
@@ -48,9 +48,9 @@ TrainPanel::TrainPanel(Engineer &e, const GLtk::Resources &r, Train &t):
        add(*(tgl_forward=new GLtk::Toggle(res)));
        tgl_forward->set_text("Fwd");
        tgl_forward->set_geometry(GLtk::Geometry(geom.w-30, geom.h-59, 20, 27));
-       tgl_forward->set_value(!train.get_locomotive().get_reverse());
+       tgl_forward->set_value(!train.get_reverse());
        tgl_forward->signal_toggled.connect(sigc::mem_fun(this, &TrainPanel::forward_toggled));
-       train.get_locomotive().signal_reverse_changed.connect(sigc::mem_fun(this, &TrainPanel::train_reverse_changed));
+       train.signal_reverse_changed.connect(sigc::mem_fun(this, &TrainPanel::train_reverse_changed));
 
        const Route *route = train.get_route();
        add(*(lbl_route=new GLtk::Label(res, (route ? route->get_name() : "Free run"))));
@@ -63,7 +63,7 @@ TrainPanel::TrainPanel(Engineer &e, const GLtk::Resources &r, Train &t):
        lbl_status->set_geometry(GLtk::Geometry(10, 34, geom.w-20, 24));
        train.signal_status_changed.connect(sigc::mem_fun(this, &TrainPanel::train_status_changed));
 
-       const map<unsigned, string> &funcs = train.get_locomotive().get_type().get_functions();
+       const map<unsigned, string> &funcs = train.get_locomotive_type().get_functions();
        unsigned x = 10;
        for(map<unsigned, string>::const_iterator i=funcs.begin(); i!=funcs.end(); ++i, x+=36)
        {
@@ -73,12 +73,12 @@ TrainPanel::TrainPanel(Engineer &e, const GLtk::Resources &r, Train &t):
                add(*(tgl=new GLtk::Toggle(res)));
                tgl->set_text(fname);
                tgl->set_geometry(GLtk::Geometry(x, geom.h-85, 36, 27));
-               tgl->set_value(train.get_locomotive().get_function(i->first));
+               tgl->set_value(train.get_function(i->first));
                tgl->signal_toggled.connect(sigc::bind(sigc::mem_fun(this, &TrainPanel::func_toggled), i->first));
 
                tgl_funcs[i->first] = tgl;
        }
-       train.get_locomotive().signal_function_changed.connect(sigc::mem_fun(this, &TrainPanel::loco_function_changed));
+       train.signal_function_changed.connect(sigc::mem_fun(this, &TrainPanel::train_function_changed));
 
        GLtk::Button *btn;
 
@@ -114,7 +114,7 @@ void TrainPanel::train_reverse_changed(bool reverse)
        tgl_forward->set_value(!reverse);
 }
 
-void TrainPanel::loco_function_changed(unsigned func, bool value)
+void TrainPanel::train_function_changed(unsigned func, bool value)
 {
        map<unsigned, GLtk::Toggle *>::iterator i = tgl_funcs.find(func);
        if(i!=tgl_funcs.end())
@@ -162,5 +162,5 @@ void TrainPanel::forward_toggled(bool value)
 
 void TrainPanel::func_toggled(bool value, unsigned func)
 {
-       train.get_locomotive().set_function(func, value);
+       train.set_function(func, value);
 }