train/rail vehicle: renamed property lob to length

Dieser Commit ist enthalten in:
Reinder Feenstra 2025-09-30 22:31:01 +02:00
Ursprung ad62e8e656
Commit f407dfd88e
17 geänderte Dateien mit 75 neuen und 63 gelöschten Zeilen

Datei anzeigen

@ -51,11 +51,11 @@ Train::Train(World& world, std::string_view _id) :
IdObject(world, _id),
m_speedTimer{EventLoop::ioContext},
name{this, "name", id, PropertyFlags::ReadWrite | PropertyFlags::Store | PropertyFlags::ScriptReadOnly},
lob{*this, "lob", 0, LengthUnit::MilliMeter, PropertyFlags::ReadWrite | PropertyFlags::Store},
length{*this, "length", 0, LengthUnit::MilliMeter, PropertyFlags::ReadWrite | PropertyFlags::Store},
overrideLength{this, "override_length", false, PropertyFlags::ReadWrite | PropertyFlags::Store,
[this](bool value)
{
Attributes::setEnabled(lob, value);
Attributes::setEnabled(length, value);
if(!value)
updateLength();
}},
@ -176,8 +176,8 @@ Train::Train(World& world, std::string_view _id) :
Attributes::addDisplayName(name, DisplayName::Object::name);
Attributes::addEnabled(name, false);
m_interfaceItems.add(name);
Attributes::addEnabled(lob, overrideLength);
m_interfaceItems.add(lob);
Attributes::addEnabled(length, overrideLength);
m_interfaceItems.add(length);
m_interfaceItems.add(overrideLength);
Attributes::addEnabled(direction, false);
Attributes::addValues(direction, DirectionValues);
@ -354,7 +354,7 @@ void Train::loaded()
{
IdObject::loaded();
Attributes::setEnabled(lob, overrideLength);
Attributes::setEnabled(length, overrideLength);
Attributes::setEnabled(weight, overrideWeight);
auto self = shared_ptr<Train>();
@ -471,8 +471,8 @@ void Train::updateLength()
double mm = 0;
for(const auto& vehicle : *vehicles)
mm += vehicle->lob.getValue(LengthUnit::MilliMeter);
lob.setValueInternal(convertUnit(mm, LengthUnit::MilliMeter, lob.unit()));
mm += vehicle->length.getValue(LengthUnit::MilliMeter);
length.setValueInternal(convertUnit(mm, LengthUnit::MilliMeter, length.unit()));
}
void Train::updateWeight()

Datei anzeigen

@ -96,7 +96,7 @@ class Train : public IdObject
CREATE_DEF(Train)
Property<std::string> name;
LengthProperty lob;
LengthProperty length;
Property<bool> overrideLength;
Property<Direction> direction;
Property<bool> isStopped;

Datei anzeigen

@ -43,7 +43,7 @@ bool TrainListTableModel::isListedProperty(std::string_view name)
name == "name" ||
name == "active" ||
name == "blocks" ||
name == "lob" ||
name == "length" ||
name == "weight";
}
@ -55,7 +55,7 @@ TrainListTableModel::TrainListTableModel(TrainList& list) :
DisplayName::Object::name,
"train:active",
"train:block",
"train:lob",
"train:length",
"train:weight"
});
}
@ -81,7 +81,7 @@ std::string TrainListTableModel::getText(uint32_t column, uint32_t row) const
return !train.blocks.empty() ? train.blocks[0]->block->name.value() : std::string{};
case columnLength:
return toString(train.lob);
return toString(train.length);
case columnWeight:
return toString(train.weight);
@ -105,7 +105,7 @@ void TrainListTableModel::propertyChanged(BaseProperty& property, uint32_t row)
changed(row, columnActive);
else if(property.name() == "blocks")
changed(row, columnBlock);
else if(property.name() == "lob")
else if(property.name() == "length")
changed(row, columnLength);
else if(property.name() == "weight")
changed(row, columnWeight);

Datei anzeigen

@ -117,7 +117,7 @@ bool TrainVehicleList::isListedProperty(std::string_view name)
void TrainVehicleList::propertyChanged(BaseProperty& property)
{
if(property.name() == "lob")
if(property.name() == "length")
train().updateLength();
else if(property.name() == "total_weight")
train().updateWeight();

Datei anzeigen

@ -104,7 +104,7 @@ namespace DisplayName
{
constexpr std::string_view cargoCapacity = "vehicle.rail:cargo_capacity";
constexpr std::string_view cargoLoaded = "vehicle.rail:cargo_loaded";
constexpr std::string_view lob = "vehicle.rail:lob";
constexpr std::string_view length = "vehicle.rail:length";
constexpr std::string_view power = "vehicle.rail:power";
constexpr std::string_view speedMax = "vehicle.rail:speed_max";
constexpr std::string_view decoder = "vehicle.rail:decoder";

Datei anzeigen

@ -39,7 +39,7 @@
RailVehicle::RailVehicle(World& world, std::string_view _id) :
Vehicle(world, _id),
decoder{this, "decoder", nullptr, PropertyFlags::ReadOnly | PropertyFlags::Store},
lob{*this, "lob", 0, LengthUnit::MilliMeter, PropertyFlags::ReadWrite | PropertyFlags::Store},
length{*this, "length", 0, LengthUnit::MilliMeter, PropertyFlags::ReadWrite | PropertyFlags::Store},
speedMax{*this, "speed_max", 0, SpeedUnit::KiloMeterPerHour, PropertyFlags::ReadWrite | PropertyFlags::Store},
weight{*this, "weight", 0, WeightUnit::Ton, PropertyFlags::ReadWrite | PropertyFlags::Store, [this](double /*value*/, WeightUnit /*unit*/){ updateTotalWeight(); }},
totalWeight{*this, "total_weight", 0, WeightUnit::Ton, PropertyFlags::ReadOnly | PropertyFlags::NoStore}
@ -78,9 +78,9 @@ RailVehicle::RailVehicle(World& world, std::string_view _id) :
Attributes::addObjectList(decoder, m_world.decoders);
m_interfaceItems.insertBefore(decoder, notes);
Attributes::addDisplayName(lob, DisplayName::Vehicle::Rail::lob);
Attributes::addEnabled(lob, editable);
m_interfaceItems.insertBefore(lob, notes);
Attributes::addDisplayName(length, DisplayName::Vehicle::Rail::length);
Attributes::addEnabled(length, editable);
m_interfaceItems.insertBefore(length, notes);
Attributes::addDisplayName(speedMax, DisplayName::Vehicle::Rail::speedMax);
Attributes::addEnabled(speedMax, editable);
@ -201,7 +201,7 @@ void RailVehicle::worldEvent(WorldState state, WorldEvent event)
{
const bool editable = contains(state, WorldState::Edit);
Attributes::setEnabled(decoder, editable);
Attributes::setEnabled(lob, editable);
Attributes::setEnabled(length, editable);
Attributes::setEnabled(speedMax, editable);
Attributes::setEnabled(weight, editable);
break;

Datei anzeigen

@ -49,7 +49,7 @@ class RailVehicle : public Vehicle
public:
ObjectProperty<Decoder> decoder;
LengthProperty lob;
LengthProperty length;
SpeedProperty speedMax;
WeightProperty weight;
WeightProperty totalWeight;

Datei anzeigen

@ -27,14 +27,14 @@
constexpr uint32_t columnId = 0;
constexpr uint32_t columnName = 1;
constexpr uint32_t columnType = 2;
constexpr uint32_t columnLOB = 3;
constexpr uint32_t columnLength = 3;
bool RailVehicleListTableModel::isListedProperty(std::string_view name)
{
return
name == "id" ||
name == "name" ||
name == "lob";
name == "length";
}
RailVehicleListTableModel::RailVehicleListTableModel(ObjectList<RailVehicle>& list) :
@ -44,7 +44,7 @@ RailVehicleListTableModel::RailVehicleListTableModel(ObjectList<RailVehicle>& li
DisplayName::Object::id,
DisplayName::Object::name,
"rail_vehicle_list:type",
DisplayName::Vehicle::Rail::lob,
DisplayName::Vehicle::Rail::length,
});
}
@ -65,8 +65,8 @@ std::string RailVehicleListTableModel::getText(uint32_t column, uint32_t row) co
case columnType:
return std::string("$class_id:").append(vehicle.getClassId()).append("$");
case columnLOB:
return toString(vehicle.lob);
case columnLength:
return toString(vehicle.length);
default:
assert(false);
@ -83,6 +83,6 @@ void RailVehicleListTableModel::propertyChanged(BaseProperty& property, uint32_t
changed(row, columnId);
else if(property.name() == "name")
changed(row, columnName);
else if(property.name() == "lob")
changed(row, columnLOB);
else if(property.name() == "length")
changed(row, columnLength);
}

Datei anzeigen

@ -256,10 +256,22 @@ void WorldLoader::createObject(ObjectData& objectData)
else if(startsWith(classId, RailVehicles::classIdPrefix))
{
if(classId == "vehicle.rail.freight_car") { classId = FreightWagon::classId; } //! \todo Remove in v0.4
if(objectData.json.contains("lob") && !objectData.json.contains("length")) //! \todo Remove in v0.4
{
objectData.json["length"] = objectData.json["lob"];
objectData.json.erase("lob");
}
objectData.object = RailVehicles::create(*m_world, classId, id);
}
else if(classId == Train::classId)
{
if(objectData.json.contains("lob") && !objectData.json.contains("length")) //! \todo Remove in v0.4
{
objectData.json["length"] = objectData.json["lob"];
objectData.json.erase("lob");
}
objectData.object = Train::create(*m_world, id);
}
else if(classId == TrainBlockStatus::classId)
{
auto block = std::dynamic_pointer_cast<BlockRailTile>(getObject(objectData.json["block"].get<std::string_view>()));

Datei anzeigen

@ -4041,8 +4041,8 @@
"fuzzy": 0
},
{
"term": "train:lob",
"definition": "L\u00e4nge \u00fcber Puffer",
"term": "train:length",
"definition": "L\u00e4nge",
"context": "",
"term_plural": "",
"reference": "",
@ -4203,8 +4203,8 @@
"fuzzy": 0
},
{
"term": "vehicle.rail:lob",
"definition": "LOB",
"term": "vehicle.rail:length",
"definition": "L\u00e4nge",
"context": "",
"term_plural": "",
"reference": "",

Datei anzeigen

@ -4041,8 +4041,8 @@
"fuzzy": 0
},
{
"term": "train:lob",
"definition": "Length over buffers",
"term": "train:length",
"definition": "Length",
"context": "",
"term_plural": "",
"reference": "",
@ -4203,8 +4203,8 @@
"fuzzy": 0
},
{
"term": "vehicle.rail:lob",
"definition": "LOB",
"term": "vehicle.rail:length",
"definition": "Length",
"context": "",
"term_plural": "",
"reference": "",
@ -6818,4 +6818,4 @@
"term": "qtapp.mainmenu:community_forum",
"definition": "Community forum"
}
]
]

Datei anzeigen

@ -4113,8 +4113,8 @@
"fuzzy": 0
},
{
"term": "train:lob",
"definition": "Longitud entre topes",
"term": "train:length",
"definition": "Longitud",
"context": "",
"term_plural": "",
"reference": "",
@ -4275,8 +4275,8 @@
"fuzzy": 0
},
{
"term": "vehicle.rail:lob",
"definition": "LOB, longitud entre topes",
"term": "vehicle.rail:length",
"definition": "Longitud",
"context": "",
"term_plural": "",
"reference": "",
@ -6416,4 +6416,4 @@
"comment": "",
"fuzzy": 0
}
]
]

Datei anzeigen

@ -4041,8 +4041,8 @@
"fuzzy": 0
},
{
"term": "train:lob",
"definition": "Longueur avec tampons",
"term": "train:length",
"definition": "Longueur",
"context": "",
"term_plural": "",
"reference": "",
@ -4203,8 +4203,8 @@
"fuzzy": 0
},
{
"term": "vehicle.rail:lob",
"definition": "Longueur avec tampons",
"term": "vehicle.rail:length",
"definition": "Longueur",
"context": "",
"term_plural": "",
"reference": "",
@ -6758,4 +6758,4 @@
"comment": "",
"fuzzy": 0
}
]
]

Datei anzeigen

@ -3303,8 +3303,8 @@
"fuzzy": 0
},
{
"term": "vehicle.rail:lob",
"definition": "LOB",
"term": "vehicle.rail:length",
"definition": "Lingte",
"context": "",
"term_plural": "",
"reference": "",
@ -5201,4 +5201,4 @@
"comment": "",
"fuzzy": 0
}
]
]

Datei anzeigen

@ -4065,8 +4065,8 @@
"fuzzy": 0
},
{
"term": "train:lob",
"definition": "Lunghezza con respingenti",
"term": "train:length",
"definition": "Lunghezza",
"context": "",
"term_plural": "",
"reference": "",
@ -4227,8 +4227,8 @@
"fuzzy": 0
},
{
"term": "vehicle.rail:lob",
"definition": "Lunghezza veicolo",
"term": "vehicle.rail:length",
"definition": "Lunghezza",
"context": "",
"term_plural": "",
"reference": "",

Datei anzeigen

@ -4041,8 +4041,8 @@
"fuzzy": 0
},
{
"term": "train:lob",
"definition": "Lengte over de buffers",
"term": "train:length",
"definition": "Lengte",
"context": "",
"term_plural": "",
"reference": "",
@ -4203,8 +4203,8 @@
"fuzzy": 0
},
{
"term": "vehicle.rail:lob",
"definition": "LOB",
"term": "vehicle.rail:length",
"definition": "Lengte",
"context": "",
"term_plural": "",
"reference": "",
@ -6390,4 +6390,4 @@
"term": "output_map:swap_outputs",
"definition": "Uitgangen omwisselen"
}
]
]

Datei anzeigen

@ -4041,8 +4041,8 @@
"fuzzy": 0
},
{
"term": "train:lob",
"definition": "L\u00e4ngd \u00f6ver buffertar",
"term": "train:length",
"definition": "L\u00e4ngd",
"context": "",
"term_plural": "",
"reference": "",
@ -4203,8 +4203,8 @@
"fuzzy": 0
},
{
"term": "vehicle.rail:lob",
"definition": "LOBB",
"term": "vehicle.rail:length",
"definition": "L\u00e4ngd",
"context": "",
"term_plural": "",
"reference": "",
@ -6308,4 +6308,4 @@
"comment": "",
"fuzzy": 0
}
]
]