client.send(pkt);
}
+float NetTrain::get_control(const string &c) const
+{
+ map<string, float>::const_iterator i = controls.find(c);
+ return i!=controls.end() ? i->second : 0;
+}
+
void NetTrain::set_function(unsigned i, bool set)
{
TrainFunctionPacket pkt;
{
if(control=="speed")
{
- // XXX It would be better to make the LocoType give us the catalogue
- scl_speed->set_value(abs(value)*3.6/remote.get_catalogue().get_scale());
- chk_reverse->set_active(value<0);
+ // XXX It would be better to make the VehicleType give us the catalogue
+ scl_speed->set_value(value*3.6/remote.get_catalogue().get_scale());
}
+ else if(control=="reverse")
+ chk_reverse->set_active(value);
}
void TrainPanel::function_changed(unsigned func, bool set)
void TrainPanel::ui_speed_changed()
{
float speed = scl_speed->get_value()/3.6*remote.get_catalogue().get_scale();
- if(chk_reverse->get_active())
- speed = -speed;
train.set_control("speed", speed);
}
void TrainPanel::ui_reverse_changed()
{
- train.set_control("speed", 0);
+ if(train.get_control("speed"))
+ {
+ train.set_control("speed", 0);
+ chk_reverse->set_active(train.get_control("reverse"));
+ }
+ else
+ train.set_control("reverse", chk_reverse->get_active());
}
void TrainPanel::ui_function_changed(unsigned func)