Add a user-defined name to vehicle definitions.
This also adds partial support for a custom vehicle graphic.
This commit is contained in:
@@ -2633,6 +2633,7 @@ bool edit_vehicle(cVehicle& what, int num, bool is_boat) {
|
||||
dlg["loc"].setText(boost::lexical_cast<std::string>(what.loc));
|
||||
dlg["num"].setTextToNum(num);
|
||||
dlg["title"].setText(is_boat ? "Edit Boat" : "Edit Horse");
|
||||
dlg["name"].setText(what.name);
|
||||
|
||||
cLed& prop = dynamic_cast<cLed&>(dlg["owned"]);
|
||||
prop.setState(what.property ? led_red : led_off);
|
||||
@@ -2645,6 +2646,7 @@ bool edit_vehicle(cVehicle& what, int num, bool is_boat) {
|
||||
if(dlg.accepted()) {
|
||||
what.property = prop.getState() != led_off;
|
||||
what.exists = true;
|
||||
what.name = dlg["name"].getText();
|
||||
}
|
||||
return what.exists;
|
||||
}
|
||||
|
@@ -336,6 +336,24 @@ void writeScenarioToXml(ticpp::Printer&& data, cScenario& scenario) {
|
||||
data.PushAttribute("id", scenario.journal_strs.size() - 1);
|
||||
data.CloseElement("journal");
|
||||
}
|
||||
for(size_t i = 0; i < scenario.boats.size(); i++) {
|
||||
if(scenario.boats[i].name.empty() && scenario.boats[i].pic == 0) continue;
|
||||
data.OpenElement("vehicle");
|
||||
data.PushAttribute("type", "boat");
|
||||
data.PushAttribute("id", i + 1);
|
||||
if(!scenario.boats[i].name.empty()) data.PushElement("name", scenario.boats[i].name);
|
||||
if(scenario.boats[i].pic > 0) data.PushElement("pic", scenario.boats[i].pic);
|
||||
data.CloseElement("vehicle");
|
||||
}
|
||||
for(size_t i = 0; i < scenario.horses.size(); i++) {
|
||||
if(scenario.horses[i].name.empty() && scenario.horses[i].pic == 0) continue;
|
||||
data.OpenElement("vehicle");
|
||||
data.PushAttribute("type", "horse");
|
||||
data.PushAttribute("id", i + 1);
|
||||
if(!scenario.horses[i].name.empty()) data.PushElement("name", scenario.horses[i].name);
|
||||
if(scenario.horses[i].pic > 0) data.PushElement("pic", scenario.horses[i].pic);
|
||||
data.CloseElement("vehicle");
|
||||
}
|
||||
data.CloseElement("game");
|
||||
data.OpenElement("editor");
|
||||
data.PushElement("default-ground", scenario.default_ground);
|
||||
|
Reference in New Issue
Block a user