]> git.tdb.fi Git - r2c2.git/commitdiff
Set speed slider range from the advertised top speed of the train
authorMikko Rasa <tdb@tdb.fi>
Wed, 9 Apr 2014 21:23:42 +0000 (00:23 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 9 Apr 2014 21:23:42 +0000 (00:23 +0300)
source/engineer/traindialog.cpp

index f202377f0cddea3dba3cb0cdfb31fa576eba6462..432f3dd22c99b98f7ea8d212b2dfeb73db861b9c 100644 (file)
@@ -33,6 +33,9 @@ TrainDialog::TrainDialog(Engineer &e, R2C2::Train &t):
        btn_expand->signal_clicked.connect(sigc::mem_fun(this, &TrainDialog::expand_clicked));
        lbl_speed = dynamic_cast<GLtk::Label *>(get_item(widgets, "lbl_speed"));
        sld_speed = dynamic_cast<GLtk::Slider *>(get_item(widgets, "sld_speed"));
+       float max_speed = train.get_maximum_speed();
+       if(max_speed>0)
+               sld_speed->set_range(0, max_speed*3.6/train.get_layout().get_catalogue().get_scale());
        sld_speed->signal_value_changed.connect(sigc::mem_fun(this, &TrainDialog::ui_speed_changed));
        tgl_forward = dynamic_cast<GLtk::Toggle *>(get_item(widgets, "tgl_forward"));
        tgl_forward->signal_toggled.connect(sigc::mem_fun(this, &TrainDialog::ui_forward_toggled));