Skip to content

Commit b1ef8cb

Browse files
committed
fix rackrail in vehicle viewmodel
1 parent e35881f commit b1ef8cb

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

Gui/ViewModels/LocoTypes/Objects/VehicleViewModel.cs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,11 @@ public VehicleViewModel(VehicleObject model) : base(model)
3535
RoadOrTrackType = model.RoadOrTrackType;
3636
RackRail = model.RackRail;
3737

38-
HasRackRail = model.Flags.HasFlag(VehicleObjectFlags.RackRail);
39-
4038
SimpleMotorSound = model.SimpleMotorSound ?? new SimpleMotorSound();
4139
FrictionSound = model.FrictionSound ?? new FrictionSound();
4240
GearboxMotorSound = model.GearboxMotorSound ?? new GearboxMotorSound();
4341
Sound = model.Sound;
4442

45-
_ = this.WhenAnyValue(x => x.RackRail)
46-
.Subscribe((_) => model.RackRail = RackRail);
47-
4843
#region Road/Track Type Binding
4944

5045
_ = this.WhenAnyValue(x => x.Mode, x => x.Flags)
@@ -53,9 +48,6 @@ public VehicleViewModel(VehicleObject model) : base(model)
5348
_ = this.WhenAnyValue(x => x.IsTrackTypeSettable)
5449
.Subscribe((_) => this.RaisePropertyChanged(nameof(RoadOrTrackType)));
5550

56-
_ = this.WhenAnyValue(x => x.RoadOrTrackType)
57-
.Subscribe((_) => model.RoadOrTrackType = RoadOrTrackType);
58-
5951
#endregion
6052

6153
#region Sound Properties Binding
@@ -165,10 +157,13 @@ public VehicleObjectFlags Flags
165157
bool IsTrackTypeSettable
166158
=> !model.Flags.HasFlag(VehicleObjectFlags.AnyRoadType) && (model.Mode == TransportMode.Rail || model.Mode == TransportMode.Road);
167159

168-
[Reactive]
169160
[ConditionTarget]
170161
[PropertyVisibilityCondition(nameof(IsTrackTypeSettable), true)]
171-
public ObjectModelHeader? RoadOrTrackType { get; set; }
162+
public ObjectModelHeader? RoadOrTrackType
163+
{
164+
get => model.RoadOrTrackType;
165+
set => model.RoadOrTrackType = value;
166+
}
172167

173168
[ConditionTarget]
174169
public bool HasRackRail
@@ -177,16 +172,23 @@ public bool HasRackRail
177172
set
178173
{
179174
model.Flags = model.Flags.ToggleFlag(VehicleObjectFlags.RackRail, value);
180-
RackRail = value && RackRail == null
181-
? new ObjectModelHeader("<obj>", ObjectType.TrackExtra, ObjectSource.OpenLoco, 0)
182-
: null;
175+
176+
if (RackRail == null && model.Flags.HasFlag(VehicleObjectFlags.RackRail))
177+
{
178+
RackRail = new ObjectModelHeader() { Name = "<obj>", ObjectSource = ObjectSource.Custom, ObjectType = ObjectType.TrackExtra };
179+
}
180+
181+
this.RaisePropertyChanged(nameof(RackRail));
183182
}
184183
}
185184

186-
[Reactive]
187185
[ConditionTarget]
188186
[PropertyVisibilityCondition(nameof(HasRackRail), true)]
189-
public ObjectModelHeader? RackRail { get; set; }
187+
public ObjectModelHeader? RackRail
188+
{
189+
get => model.RackRail;
190+
set => model.RackRail = value;
191+
}
190192

191193
[Range(0, 4)]
192194
public uint8_t NumCarComponents

Gui/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.5.4
1+
5.5.5

0 commit comments

Comments
 (0)