|
| 1 | +using OpenLoco.Dat.Data; |
1 | 2 | using OpenLoco.Dat.Objects;
|
2 | 3 | using OpenLoco.Dat.Types;
|
3 | 4 | using ReactiveUI;
|
|
8 | 9 |
|
9 | 10 | namespace OpenLoco.Gui.ViewModels
|
10 | 11 | {
|
| 12 | + [TypeConverter(typeof(ExpandableObjectConverter))] |
| 13 | + public class S5ViewModel : ReactiveObject //, IObjectViewModel<S5Header> |
| 14 | + { |
| 15 | + public S5ViewModel(string name, uint checksum, SourceGame sourceGame, ObjectType objectType) |
| 16 | + { |
| 17 | + Name = name; |
| 18 | + Checksum = checksum; |
| 19 | + SourceGame = sourceGame; |
| 20 | + ObjectType = objectType; |
| 21 | + } |
| 22 | + public S5ViewModel(S5Header s5Header) |
| 23 | + { |
| 24 | + Name = s5Header.Name; |
| 25 | + Checksum = s5Header.Checksum; |
| 26 | + SourceGame = s5Header.SourceGame; |
| 27 | + ObjectType = s5Header.ObjectType; |
| 28 | + } |
| 29 | + |
| 30 | + public string Name { get; set; } |
| 31 | + public uint32_t Checksum { get; set; } |
| 32 | + public SourceGame SourceGame { get; set; } |
| 33 | + |
| 34 | + public ObjectType ObjectType { get; set; } |
| 35 | + |
| 36 | + public S5Header GetAsUnderlyingType() |
| 37 | + => new(Name, Checksum) |
| 38 | + { |
| 39 | + ObjectType = ObjectType, |
| 40 | + SourceGame = SourceGame |
| 41 | + }; |
| 42 | + } |
| 43 | + |
11 | 44 | public class VehicleViewModel : ReactiveObject, IObjectViewModel<ILocoStruct>
|
12 | 45 | {
|
13 | 46 | [Reactive, Category("Stats")] public TransportMode Mode { get; set; }
|
@@ -48,7 +81,7 @@ public class VehicleViewModel : ReactiveObject, IObjectViewModel<ILocoStruct>
|
48 | 81 | [Reactive, Category("Sound")] public FrictionSound? FrictionSound { get; set; }
|
49 | 82 | [Reactive, Category("Sound")] public Engine1Sound? Engine1Sound { get; set; }
|
50 | 83 | [Reactive, Category("Sound")] public Engine2Sound? Engine2Sound { get; set; }
|
51 |
| - [Reactive, Category("Sound")] public BindingList<S5Header> StartSounds { get; set; } |
| 84 | + [Reactive, Category("Sound")] public BindingList<S5ViewModel> StartSounds { get; set; } |
52 | 85 |
|
53 | 86 | public VehicleViewModel(VehicleObject veh)
|
54 | 87 | {
|
@@ -84,7 +117,7 @@ public VehicleViewModel(VehicleObject veh)
|
84 | 117 | RackRail = veh.RackRail;
|
85 | 118 | Sound = veh.Sound;
|
86 | 119 | SoundType = veh.DrivingSoundType;
|
87 |
| - StartSounds = new(veh.StartSounds); |
| 120 | + StartSounds = new(veh.StartSounds.ConvertAll(x => new S5ViewModel(x))); |
88 | 121 | FrictionSound = veh.SoundPropertyFriction;
|
89 | 122 | Engine1Sound = veh.SoundPropertyEngine1;
|
90 | 123 | Engine2Sound = veh.SoundPropertyEngine2;
|
@@ -122,6 +155,7 @@ public VehicleObject GetAsStruct(VehicleObject veh)
|
122 | 155 | ObsoleteYear = ObsoleteYear,
|
123 | 156 | RackRail = RackRail,
|
124 | 157 | Sound = Sound,
|
| 158 | + StartSounds = StartSounds.ToList().ConvertAll(x => x.GetAsUnderlyingType()), |
125 | 159 | DrivingSoundType = SoundType,
|
126 | 160 | SoundPropertyFriction = FrictionSound,
|
127 | 161 | SoundPropertyEngine1 = Engine1Sound,
|
|
0 commit comments