Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Dat/FileParsing/LocoBinaryReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ public EmitterAnimation[] ReadEmitterAnimations(int count)
public FrictionSound ReadFrictionSound()
=> new()
{
SoundObjectId = ReadByte(),
MinSpeed = ReadInt32(),
SpeedFreqFactor = ReadByte(),
BaseFrequency = ReadUInt16(),
Expand All @@ -295,7 +294,6 @@ public FrictionSound ReadFrictionSound()
public SimpleMotorSound ReadSimpleMotorSound()
=> new()
{
SoundObjectId = ReadByte(),
IdleFrequency = ReadUInt16(),
IdleVolume = ReadByte(),
CoastingFrequency = ReadUInt16(),
Expand All @@ -312,7 +310,6 @@ public SimpleMotorSound ReadSimpleMotorSound()
public GearboxMotorSound ReadGearboxMotorSound()
=> new()
{
SoundObjectId = ReadByte(),
IdleFrequency = ReadUInt16(),
IdleVolume = ReadByte(),
FirstGearFrequency = ReadUInt16(),
Expand Down
3 changes: 0 additions & 3 deletions Dat/FileParsing/LocoBinaryWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ public void Write(EmitterAnimation[] animations)

public void Write(FrictionSound sound)
{
Write(sound.SoundObjectId);
Write(sound.MinSpeed);
Write(sound.SpeedFreqFactor);
Write(sound.BaseFrequency);
Expand All @@ -178,7 +177,6 @@ public void Write(FrictionSound sound)

public void Write(SimpleMotorSound sound)
{
Write(sound.SoundObjectId);
Write(sound.IdleFrequency);
Write(sound.IdleVolume);
Write(sound.CoastingFrequency);
Expand All @@ -194,7 +192,6 @@ public void Write(SimpleMotorSound sound)

public void Write(GearboxMotorSound sound)
{
Write(sound.SoundObjectId);
Write(sound.IdleFrequency);
Write(sound.IdleVolume);
Write(sound.FirstGearFrequency);
Expand Down
10 changes: 8 additions & 2 deletions Dat/Loaders/Vehicle/VehicleObjectLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private static void LoadVariable(LocoBinaryReader br, VehicleObject model, byte
// track type
if (!model.Flags.HasFlag(VehicleObjectFlags.AnyRoadType) && (model.Mode == TransportMode.Rail || model.Mode == TransportMode.Road))
{
model.TrackType = br.ReadS5Header();
model.RoadOrTrackType = br.ReadS5Header();
}

// required track extra
Expand Down Expand Up @@ -187,14 +187,17 @@ private static void LoadFixed(LocoBinaryReader br, VehicleObject model, out byte
switch (model.DrivingSoundType)
{
case DrivingSoundType.Friction:
br.SkipByte(); // this is the object id which is the first byte of all of the sound union structs. it will be read from Sound property
model.FrictionSound = br.ReadFrictionSound();
br.SkipByte(StructSizes.SoundData - StructSizes.FrictionSound);
break;
case DrivingSoundType.SimpleMotor:
br.SkipByte(); // this is the object id which is the first byte of all of the sound union structs. it will be read from Sound property
model.SimpleMotorSound = br.ReadSimpleMotorSound();
br.SkipByte(StructSizes.SoundData - StructSizes.SimpleMotorSound);
break;
case DrivingSoundType.GearboxMotor:
br.SkipByte(); // this is the object id which is the first byte of all of the sound union structs. it will be read from Sound property
model.GearboxMotorSound = br.ReadGearboxMotorSound();
br.SkipByte(StructSizes.SoundData - StructSizes.GearboxMotorSound);
break;
Expand Down Expand Up @@ -256,16 +259,19 @@ public static void Save(Stream stream, LocoObject obj)
{
case DrivingSoundType.Friction:
ArgumentNullException.ThrowIfNull(model.FrictionSound);
bw.WriteEmptyBytes(1); // this is the object id which is the first byte of all of the sound union structs
bw.Write(model.FrictionSound);
bw.WriteEmptyBytes(StructSizes.SoundData - StructSizes.FrictionSound);
break;
case DrivingSoundType.SimpleMotor:
ArgumentNullException.ThrowIfNull(model.SimpleMotorSound);
bw.WriteEmptyBytes(1); // this is the object id which is the first byte of all of the sound union structs
bw.Write(model.SimpleMotorSound);
bw.WriteEmptyBytes(StructSizes.SoundData - StructSizes.SimpleMotorSound);
break;
case DrivingSoundType.GearboxMotor:
ArgumentNullException.ThrowIfNull(model.GearboxMotorSound);
bw.WriteEmptyBytes(1); // this is the object id which is the first byte of all of the sound union structs
bw.Write(model.GearboxMotorSound);
bw.WriteEmptyBytes(StructSizes.SoundData - StructSizes.GearboxMotorSound);
break;
Expand Down Expand Up @@ -299,7 +305,7 @@ private static void SaveVariable(VehicleObject model, LocoBinaryWriter bw)
// track type
if (!model.Flags.HasFlag(VehicleObjectFlags.AnyRoadType) && (model.Mode == TransportMode.Rail || model.Mode == TransportMode.Road))
{
bw.WriteS5Header(model.TrackType);
bw.WriteS5Header(model.RoadOrTrackType);
}

// track extras
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Definitions.ObjectModels.Objects.Vehicle;
[TypeConverter(typeof(ExpandableObjectConverter))]
public class EmitterAnimation : ILocoStruct
{
public ObjectModelHeader AnimationObject { get; set; } // will be SteamObject
public ObjectModelHeader AnimationObject { get; set; } // will be SteamObject
public uint8_t EmitterVerticalPos { get; set; }
public SimpleAnimationType Type { get; set; }

Expand Down
3 changes: 2 additions & 1 deletion Definitions/ObjectModels/Objects/Vehicle/FrictionSound.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using Definitions.ObjectModels.Types;
using System.ComponentModel;

namespace Definitions.ObjectModels.Objects.Vehicle;

[TypeConverter(typeof(ExpandableObjectConverter))]
public class FrictionSound
{
public uint8_t SoundObjectId { get; set; }
public ObjectModelHeader SoundObject { get; set; }
public int32_t MinSpeed { get; set; }
public uint8_t SpeedFreqFactor { get; set; }
public uint16_t BaseFrequency { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using Definitions.ObjectModels.Types;
using System.ComponentModel;

namespace Definitions.ObjectModels.Objects.Vehicle;

[TypeConverter(typeof(ExpandableObjectConverter))]
public class GearboxMotorSound
{
public uint8_t SoundObjectId { get; set; }
public ObjectModelHeader SoundObject { get; set; }
public uint16_t IdleFrequency { get; set; }
public uint8_t IdleVolume { get; set; }
public uint16_t FirstGearFrequency { get; set; } // All subsequent gears are based on this frequency
Expand Down
3 changes: 2 additions & 1 deletion Definitions/ObjectModels/Objects/Vehicle/SimpleMotorSound.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using Definitions.ObjectModels.Types;
using System.ComponentModel;

namespace Definitions.ObjectModels.Objects.Vehicle;

[TypeConverter(typeof(ExpandableObjectConverter))]
public class SimpleMotorSound
{
public uint8_t SoundObjectId { get; set; }
public ObjectModelHeader SoundObject { get; set; }
public uint16_t IdleFrequency { get; set; }
public uint8_t IdleVolume { get; set; }
public uint16_t CoastingFrequency { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion Definitions/ObjectModels/Objects/Vehicle/VehicleObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class VehicleObject : ILocoStruct
public TransportMode Mode { get; set; }
public VehicleType Type { get; set; }
public uint8_t NumCarComponents { get; set; }
public ObjectModelHeader? TrackType { get; set; }
public ObjectModelHeader? RoadOrTrackType { get; set; }
public object_id TrackTypeId { get; set; }
public uint8_t CostIndex { get; set; }
public int16_t CostFactor { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Definitions.ObjectModels;
namespace Definitions.ObjectModels.Types;

public enum ColourSwatch
{
Expand Down
4 changes: 4 additions & 0 deletions Definitions/ObjectModels/Types/ObjectModelHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ namespace Definitions.ObjectModels.Types;
[TypeConverter(typeof(ExpandableObjectConverter))]
public class ObjectModelHeader(string name, ObjectType objectType, ObjectSource objectSource, uint datchecksum) : ILocoStruct
{
public ObjectModelHeader()
: this(string.Empty, ObjectType.Airport, ObjectSource.Custom, 0)
{ }

public string Name { get; set; } = name;
public ObjectType ObjectType { get; set; } = objectType;
public ObjectSource ObjectSource { get; set; } = objectSource;
Expand Down
4 changes: 2 additions & 2 deletions Definitions/ObjectModels/Types/Pos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class Pos2
public coord_t X { get; set; }
public coord_t Y { get; set; }

public static Pos2 Zero => new Pos2 { X = 0, Y = 0 };
public static Pos2 Zero => new() { X = 0, Y = 0 };
}

[TypeConverter(typeof(ExpandableObjectConverter))]
Expand All @@ -18,5 +18,5 @@ public class Pos3
public coord_t Y { get; set; }
public coord_t Z { get; set; }

public static Pos3 Zero => new Pos3 { X = 0, Y = 0, Z = 0 };
public static Pos3 Zero => new() { X = 0, Y = 0, Z = 0 };
}
13 changes: 11 additions & 2 deletions Gui/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
<materialIcons:MaterialIconStyles />
<StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Fluent.xaml" />
<StyleInclude Source="avares://Avalonia.Controls.ColorPicker/Themes/Fluent/Fluent.xaml" />
<StyleInclude Source="avares://Avalonia.Controls.TreeDataGrid/Themes/Fluent.axaml" />
<StyleInclude Source="/Views/Pos3View.axaml"></StyleInclude>

<Style Selector="TabItem">
<Setter Property="FontSize" Value="16" />
Expand Down Expand Up @@ -63,7 +65,14 @@
<Setter Property="IsAutoNameWidth" Value="True" />
</Style>

<StyleInclude Source="avares://Avalonia.Controls.TreeDataGrid/Themes/Fluent.axaml" />
<Style Selector="vi|ExtendedPropertyGrid">
<Setter Property="IsTitleVisible" Value="False" />
<Setter Property="IsHeaderVisible" Value="False" />
<Setter Property="IsCategoryVisible" Value="False" />
<Setter Property="IsQuickFilterVisible" Value="True" />
<Setter Property="IsAutoNameWidth" Value="True" />
</Style>

</Application.Styles>

<Application.DataTemplates>
Expand Down Expand Up @@ -109,7 +118,7 @@
</DataTemplate>
<DataTemplate DataType="vm:IObjectViewModel">
<ScrollViewer>
<pgc:PropertyGrid Background="{DynamicResource ExpanderContentBackground}" IsCategoryVisible="True" DataContext="{Binding}" />
<vi:ExtendedPropertyGrid Background="{DynamicResource ExpanderContentBackground}" IsHeaderVisible="True" IsCategoryVisible="False" IsAutoNameWidth="True" IsQuickFilterVisible="True" DataContext="{Binding}" />
</ScrollViewer>
</DataTemplate>
</Application.DataTemplates>
Expand Down
4 changes: 4 additions & 0 deletions Gui/Gui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,9 @@
<Compile Update="Views\ObjectEditorView.axaml.cs">
<DependentUpon>ObjectEditorView.axaml</DependentUpon>
</Compile>
<Compile Update="Views\Pos3View.axaml.cs">
<DependentUpon>Pos3View.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion Gui/ViewModels/Graphics/ColourRemapSwatchViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Definitions.ObjectModels;
using Definitions.ObjectModels.Types;
using ReactiveUI.Fody.Helpers;
using AvaColour = Avalonia.Media.Color;

Expand Down
21 changes: 6 additions & 15 deletions Gui/ViewModels/LocoTypes/Objects/AirportViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,16 @@ public int16_t SellCostFactor
set => Model.SellCostFactor = value;
}

[Category("Building"), Length(1, AirportObjectLoader.Constants.BuildingVariationCount)]
[Category("Building")]
[Length(1, AirportObjectLoader.Constants.BuildingVariationCount)]
public BindingList<BindingList<uint8_t>> BuildingVariations { get; init; } = new(model.BuildingComponents.BuildingVariations.Select(x => x.ToBindingList()).ToBindingList());

[Category("Building"), Length(1, AirportObjectLoader.Constants.BuildingHeightCount)]
[Category("Building")]
[Length(1, AirportObjectLoader.Constants.BuildingHeightCount)]
public BindingList<uint8_t> BuildingHeights { get; init; } = model.BuildingComponents.BuildingHeights.ToBindingList();

[Category("Building"), Length(1, AirportObjectLoader.Constants.BuildingAnimationCount)]
[Category("Building")]
[Length(1, AirportObjectLoader.Constants.BuildingAnimationCount)]
public BindingList<BuildingPartAnimation> BuildingAnimations { get; init; } = model.BuildingComponents.BuildingAnimations.ToBindingList();

[Category("Building")]
Expand All @@ -111,16 +114,4 @@ public uint32_t var_B6
get => Model.var_B6;
set => Model.var_B6 = value;
}

//public AirportViewModel(AirportObject model)
// : base(model)
//{
// BuildingHeights = new(model.BuildingComponents.BuildingHeights);
// BuildingAnimations = new(model.BuildingComponents.BuildingAnimations);
// BuildingVariations = new(model.BuildingComponents.BuildingVariations.Select(x => new BindingList<uint8_t>(x)));
// BuildingPositions = new(model.BuildingPositions);
// MovementNodes = new(model.MovementNodes);
// MovementEdges = new(model.MovementEdges);
// var_B6 = new BindingList<uint8_t>(model.var_B6);
//}
}
6 changes: 4 additions & 2 deletions Gui/ViewModels/LocoTypes/Objects/BridgeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,11 @@ public int16_t SellCostFactor
set => Model.SellCostFactor = value;
}

[Category("Compatible")] public BindingList<ObjectModelHeader> CompatibleTrackObjects { get; init; } = new(model.CompatibleTrackObjects);
[Category("Compatible")]
public BindingList<ObjectModelHeader> CompatibleTrackObjects { get; init; } = new(model.CompatibleTrackObjects);

[Category("Compatible")] public BindingList<ObjectModelHeader> CompatibleRoadObjects { get; init; } = new(model.CompatibleRoadObjects);
[Category("Compatible")]
public BindingList<ObjectModelHeader> CompatibleRoadObjects { get; init; } = new(model.CompatibleRoadObjects);

[Category("<unknown>")]
public uint8_t var_03
Expand Down
9 changes: 6 additions & 3 deletions Gui/ViewModels/LocoTypes/Objects/DockViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,16 @@ public int16_t SellCostFactor
set => Model.SellCostFactor = value;
}

[Category("Building"), Length(1, DockObjectLoader.Constants.BuildingVariationCount)]
[Category("Building")]
[Length(1, DockObjectLoader.Constants.BuildingVariationCount)]
public BindingList<BindingList<uint8_t>> BuildingVariations { get; init; } = new(model.BuildingComponents.BuildingVariations.Select(x => x.ToBindingList()).ToBindingList());

[Category("Building"), Length(1, DockObjectLoader.Constants.BuildingHeightCount)]
[Category("Building")]
[Length(1, DockObjectLoader.Constants.BuildingHeightCount)]
public BindingList<uint8_t> BuildingHeights { get; init; } = model.BuildingComponents.BuildingHeights.ToBindingList();

[Category("Building"), Length(1, DockObjectLoader.Constants.BuildingAnimationCount)]
[Category("Building")]
[Length(1, DockObjectLoader.Constants.BuildingAnimationCount)]
public BindingList<BuildingPartAnimation> BuildingAnimations { get; init; } = model.BuildingComponents.BuildingAnimations.ToBindingList();

[Category("<unknown>")]
Expand Down
21 changes: 14 additions & 7 deletions Gui/ViewModels/LocoTypes/Objects/IndustryViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@ public uint32_t Colours
[Category("Production")]
public BindingList<IndustryObjectProductionRateRange> InitialProductionRate { get; init; } = new(model.InitialProductionRate);

[Category("Production"), Length(0, IndustryObjectLoader.Constants.MaxProducedCargoType)]
[Category("Production")]
[Length(0, IndustryObjectLoader.Constants.MaxProducedCargoType)]
public BindingList<ObjectModelHeader> ProducedCargo { get; init; } = new(model.ProducedCargo);

[Category("Production"), Length(0, IndustryObjectLoader.Constants.MaxProducedCargoType)]
[Category("Production")]
[Length(0, IndustryObjectLoader.Constants.MaxProducedCargoType)]
public BindingList<ObjectModelHeader> RequiredCargo { get; init; } = new(model.RequiredCargo);

[Category("Production")]
Expand Down Expand Up @@ -118,16 +120,20 @@ public uint8_t FarmNumStagesOfGrowth
set => Model.FarmNumStagesOfGrowth = value;
}

[Category("Building"), Length(IndustryObjectLoader.Constants.AnimationSequencesCount, IndustryObjectLoader.Constants.AnimationSequencesCount)]
[Category("Building")]
[Length(IndustryObjectLoader.Constants.AnimationSequencesCount, IndustryObjectLoader.Constants.AnimationSequencesCount)]
public BindingList<BindingList<uint8_t>> AnimationSequences { get; init; } = model.AnimationSequences.Select(x => x.ToBindingList()).ToBindingList();

[Category("Building"), Length(1, IndustryObjectLoader.Constants.BuildingVariationCount)]
[Category("Building")]
[Length(1, IndustryObjectLoader.Constants.BuildingVariationCount)]
public BindingList<BindingList<uint8_t>> BuildingVariations { get; init; } = new(model.BuildingComponents.BuildingVariations.Select(x => x.ToBindingList()).ToBindingList());

[Category("Building"), Length(1, IndustryObjectLoader.Constants.BuildingHeightCount)]
[Category("Building")]
[Length(1, IndustryObjectLoader.Constants.BuildingHeightCount)]
public BindingList<uint8_t> BuildingHeights { get; init; } = model.BuildingComponents.BuildingHeights.ToBindingList();

[Category("Building"), Length(1, IndustryObjectLoader.Constants.BuildingAnimationCount)]
[Category("Building")]
[Length(1, IndustryObjectLoader.Constants.BuildingAnimationCount)]
public BindingList<BuildingPartAnimation> BuildingAnimations { get; init; } = model.BuildingComponents.BuildingAnimations.ToBindingList();

[Category("Building")]
Expand Down Expand Up @@ -168,7 +174,8 @@ public Colour ScaffoldingColour
set => Model.ScaffoldingColour = value;
}

[Category("Building"), Length(0, IndustryObjectLoader.Constants.MaxWallTypeCount)]
[Category("Building")]
[Length(0, IndustryObjectLoader.Constants.MaxWallTypeCount)]
public BindingList<ObjectModelHeader> WallTypes { get; init; } = model.WallTypes.ToBindingList();

[Category("Building")]
Expand Down
4 changes: 3 additions & 1 deletion Gui/ViewModels/LocoTypes/Objects/RegionViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ public uint8_t pad_07
set => Model.pad_07 = value;
}

[Category("Cargo")] public BindingList<ObjectModelHeader> CargoInfluenceObjects { get; init; } = new(model.CargoInfluenceObjects);
public BindingList<ObjectModelHeader> DependentObjects { get; init; } = new(model.DependentObjects);

[Category("Cargo")]
public BindingList<ObjectModelHeader> CargoInfluenceObjects { get; init; } = new(model.CargoInfluenceObjects);

[Category("Cargo")]
public BindingList<CargoInfluenceTownFilterType> CargoInfluenceTownFilter { get; init; } = new(model.CargoInfluenceTownFilter);
}
Loading