-/* $Id$
-
-This file is part of the MSP Märklin suite
-Copyright © 2006-2010 Mikkosoft Productions, Mikko Rasa
-Distributed under the GPL
-*/
-
#include <msp/gltk/label.h>
-#include <msp/strings/formatter.h>
+#include <msp/strings/format.h>
#include <msp/strings/lexicalcast.h>
-#include "libmarklin/driver.h"
-#include "libmarklin/vehicle.h"
-#include "libmarklin/vehicletype.h"
+#include "libr2c2/driver.h"
+#include "libr2c2/trainrouter.h"
+#include "libr2c2/vehicle.h"
+#include "libr2c2/vehicletype.h"
#include "engineer.h"
#include "trainproperties.h"
using namespace std;
using namespace Msp;
-using namespace Marklin;
+using namespace R2C2;
TrainProperties::TrainProperties(Engineer &e, Train *t):
engineer(e),
if(train)
{
- ent_addr->set_text(lexical_cast(train->get_address()));
+ ent_addr->set_text(lexical_cast<string>(train->get_address()));
ent_name->set_text(train->get_name());
- drp_priority->set_selected_index(train->get_priority()+2);
+ if(TrainRouter *router = train->get_ai_of_type<TrainRouter>())
+ drp_priority->set_selected_index(router->get_priority()+2);
unsigned n_vehicles = train->get_n_vehicles();
for(unsigned i=1; i<n_vehicles; ++i)
}
train->set_name(ent_name->get_text());
- train->set_priority(drp_priority->get_selected_index()-2);
+ if(TrainRouter *router = train->get_ai_of_type<TrainRouter>())
+ router->set_priority(drp_priority->get_selected_index()-2);
// The locomotive is vehicle 0 so we need to add 1
for(set<unsigned>::const_iterator i=rem_vehicles.end(); i!=rem_vehicles.begin();)
++i;
}
- throw InvalidParameterValue("Vehicle type index out of range");
+ throw out_of_range("TrainProperties::get_vehicle_type");
}