3 This file is part of R²C²
4 Copyright © 2011 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
8 #include <msp/strings/formatter.h>
12 #include "trainstatus.h"
17 #include <msp/io/print.h>
21 TrainStatus::TrainStatus(Train &t):
28 void TrainStatus::tick(const Time::TimeStamp &, const Time::TimeDelta &)
33 void TrainStatus::check()
35 float scale = train.get_layout().get_catalogue().get_scale();
36 int s = static_cast<int>(train.get_quantized_speed()*3.6/scale+0.5);
37 if(s==0 && train.is_active())
44 status = format("Traveling %d kmh", s);
45 if(unsigned step = train.get_speed_step())
46 status += format(" (%d)", step);
50 else if(!train.get_vehicle(0).get_track())
57 signal_changed.emit(status);
58 signal_event.emit(Message("status-changed", status));