Skip to content

Commit

Permalink
update objects with missing image ids from openloco
Browse files Browse the repository at this point in the history
  • Loading branch information
LeftofZen committed Mar 11, 2024
1 parent 3765020 commit 78350a4
Show file tree
Hide file tree
Showing 8 changed files with 175 additions and 8 deletions.
13 changes: 12 additions & 1 deletion Core/Objects/CargoObject.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.ComponentModel;
using OpenLoco.ObjectEditor.Data;
using OpenLoco.ObjectEditor.DatFileParsing;
using OpenLoco.ObjectEditor.Types;

namespace OpenLoco.ObjectEditor.Objects
{
Expand Down Expand Up @@ -53,10 +54,20 @@ public record CargoObject(
[property: LocoStructOffset(0x1B)] uint16_t PaymentFactor,
[property: LocoStructOffset(0x1D)] uint8_t PaymentIndex,
[property: LocoStructOffset(0x1E)] uint8_t UnitSize
) : ILocoStruct
) : ILocoStruct, ILocoImageTableNames
{
public bool Validate()
=> var_02 <= 3840
&& CargoTransferTime != 0;

public bool TryGetImageName(int id, out string? value)
=> ImageIdNameMap.TryGetValue(id, out value);

public static Dictionary<int, string> ImageIdNameMap = new()
{
{ 0, "kInlineSprite" },
// There are NumPlatformVariations sprites after this one
{ 1, "kStationPlatformBegin" },
};
}
}
12 changes: 11 additions & 1 deletion Core/Objects/LandObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using OpenLoco.ObjectEditor.Data;
using OpenLoco.ObjectEditor.DatFileParsing;
using OpenLoco.ObjectEditor.Headers;
using OpenLoco.ObjectEditor.Types;

namespace OpenLoco.ObjectEditor.Objects
{
Expand Down Expand Up @@ -37,7 +38,7 @@ public record LandObject(
[property: LocoStructOffset(0x1B)] uint8_t NumVariations,
[property: LocoStructOffset(0x1C)] uint8_t VariationLikelihood,
[property: LocoStructOffset(0x1D), Browsable(false)] uint8_t pad_1D
) : ILocoStruct, ILocoStructVariableData
) : ILocoStruct, ILocoStructVariableData, ILocoImageTableNames
{
public S5Header CliffEdgeHeader { get; set; }
public S5Header UnkObjHeader { get; set; }
Expand Down Expand Up @@ -94,5 +95,14 @@ public bool Validate()

return (var_04 == 1 || var_04 == 2 || var_04 == 4);
}

public bool TryGetImageName(int id, out string? value)
=> ImageIdNameMap.TryGetValue(id, out value);

public static Dictionary<int, string> ImageIdNameMap = new()
{
{ 0, "kFlatSE" },
{ 1, "toolbar_terraform_land" },
};
}
}
20 changes: 19 additions & 1 deletion Core/Objects/RoadStationObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using OpenLoco.ObjectEditor.Data;
using OpenLoco.ObjectEditor.DatFileParsing;
using OpenLoco.ObjectEditor.Headers;
using OpenLoco.ObjectEditor.Types;

namespace OpenLoco.ObjectEditor.Objects
{
Expand Down Expand Up @@ -37,7 +38,7 @@ public record RoadStationObject(
[property: LocoStructOffset(0x2C), LocoStructVariableLoad, Browsable(false)] object_id _CargoTypeId,
[property: LocoStructOffset(0x2D)] uint8_t pad_2D,
[property: LocoStructOffset(0x2E), LocoStructVariableLoad, LocoArrayLength(RoadStationObject.CargoOffsetBytesSize), Browsable(false)] uint8_t[] _CargoOffsetBytes
) : ILocoStruct, ILocoStructVariableData
) : ILocoStruct, ILocoStructVariableData, ILocoImageTableNames
{
public const int MaxImageOffsets = 4;
public const int MaxNumMods = 7;
Expand Down Expand Up @@ -144,5 +145,22 @@ public bool Validate()
}
return true;
}

public bool TryGetImageName(int id, out string? value)
=> ImageIdNameMap.TryGetValue(id, out value);

public static Dictionary<int, string> ImageIdNameMap = new()
{
{ 0, "preview_image" },
{ 1, "preview_image_windows" },
{ 2, "totalPreviewImages" },

// These are relative to ImageOffsets
// ImageOffsets is the imageIds per sequenceIndex (for start/middle/end of the platform)
//namespace Style0
//{
// constexpr uint32_t totalNumImages = 8;
//}
};
}
}
46 changes: 45 additions & 1 deletion Core/Objects/ScaffoldingObject.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.ComponentModel;
using OpenLoco.ObjectEditor.Data;
using OpenLoco.ObjectEditor.DatFileParsing;
using OpenLoco.ObjectEditor.Types;

namespace OpenLoco.ObjectEditor.Objects
{
Expand All @@ -13,9 +14,52 @@ public record ScaffoldingObject(
[property: LocoStructOffset(0x02), Browsable(false)] image_id Image,
[property: LocoStructOffset(0x06), LocoArrayLength(3)] uint16_t[] SegmentHeights,
[property: LocoStructOffset(0x0C), LocoArrayLength(3)] uint16_t[] RoofHeights
) : ILocoStruct
) : ILocoStruct, ILocoImageTableNames
{
public bool Validate() => true;

public bool TryGetImageName(int id, out string? value)
=> ImageIdNameMap.TryGetValue(id, out value);

public static Dictionary<int, string> ImageIdNameMap = new()
{
{ 0, "type01x1SegmentBack" },
{ 1, "type01x1SegmentFront" },
{ 2, "type01x1RoofNE" },
{ 3, "type01x1RoofSE" },
{ 4, "type01x1RoofSW" },
{ 5, "type01x1RoofNW" },
{ 6, "type02x2SegmentBack" },
{ 7, "type02x2SegmentFront" },
{ 8, "type02x2RoofNE" },
{ 9, "type02x2RoofSE" },
{ 10, "type02x2RoofSW" },
{ 11, "type02x2RoofNW" },
{ 12, "type11x1SegmentBack" },
{ 13, "type11x1SegmentFront" },
{ 14, "type11x1RoofNE" },
{ 15, "type11x1RoofSE" },
{ 16, "type11x1RoofSW" },
{ 17, "type11x1RoofNW" },
{ 18, "type12x2SegmentBack" },
{ 19, "type12x2SegmentFront" },
{ 20, "type12x2RoofNE" },
{ 21, "type12x2RoofSE" },
{ 22, "type12x2RoofSW" },
{ 23, "type12x2RoofNW" },
{ 24, "type21x1SegmentBack" },
{ 25, "type21x1SegmentFront" },
{ 26, "type21x1RoofNE" },
{ 27, "type21x1RoofSE" },
{ 28, "type21x1RoofSW" },
{ 29, "type21x1RoofNW" },
{ 30, "type22x2SegmentBack" },
{ 31, "type22x2SegmentFront" },
{ 32, "type22x2RoofNE" },
{ 33, "type22x2RoofSE" },
{ 34, "type22x2RoofSW" },
{ 35, "type22x2RoofNW" },
};
}

}
18 changes: 17 additions & 1 deletion Core/Objects/SnowObject.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.ComponentModel;
using OpenLoco.ObjectEditor.Data;
using OpenLoco.ObjectEditor.DatFileParsing;
using OpenLoco.ObjectEditor.Types;

namespace OpenLoco.ObjectEditor.Objects
{
Expand All @@ -11,8 +12,23 @@ namespace OpenLoco.ObjectEditor.Objects
public record SnowObject(
[property: LocoStructOffset(0x00), LocoString, Browsable(false)] string_id Name,
[property: LocoStructOffset(0x02), Browsable(false)] image_id Image
) : ILocoStruct
) : ILocoStruct, ILocoImageTableNames
{
public bool Validate() => true;

public bool TryGetImageName(int id, out string? value)
=> ImageIdNameMap.TryGetValue(id, out value);

public static Dictionary<int, string> ImageIdNameMap = new()
{
{ 0, "surfaceEighthZoom" },
{ 10, "outlineEighthZoom" },
{ 19, "surfaceQuarterZoom" },
{ 38, "outlineQuarterZoom" },
{ 57, "surfaceHalfZoom" },
{ 76, "outlineHalfZoom" },
{ 95, "surfaceFullZoom" },
{ 114, "outlineFullZoom" },
};
}
}
41 changes: 40 additions & 1 deletion Core/Objects/TrainStationObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using OpenLoco.ObjectEditor.Data;
using OpenLoco.ObjectEditor.DatFileParsing;
using OpenLoco.ObjectEditor.Headers;
using OpenLoco.ObjectEditor.Types;

namespace OpenLoco.ObjectEditor.Objects
{
Expand Down Expand Up @@ -37,7 +38,7 @@ public record TrainStationObject(
[property: LocoStructOffset(0x2C)] uint16_t ObsoleteYear,
[property: LocoStructOffset(0x2E), LocoStructVariableLoad, LocoArrayLength(TrainStationObject.CargoOffsetBytesSize), Browsable(false)] uint8_t[] _CargoOffsetBytes,
[property: LocoStructOffset(0x3E), LocoStructVariableLoad, LocoArrayLength(TrainStationObject.ManualPowerLength), Browsable(false)] uint8_t[] _ManualPower
) : ILocoStruct, ILocoStructVariableData
) : ILocoStruct, ILocoStructVariableData, ILocoImageTableNames
{
public List<S5Header> Compatible { get; set; } = [];

Expand Down Expand Up @@ -147,5 +148,43 @@ public bool Validate()
}
return NumCompatible <= 7;
}

public bool TryGetImageName(int id, out string? value)
=> ImageIdNameMap.TryGetValue(id, out value);

public static Dictionary<int, string> ImageIdNameMap = new()
{
{ 0, "preview_image" },
{ 1, "preview_image_windows" },
{ 2, "totalPreviewImages" },
};

// These are relative to ImageOffsets
// ImageOffsets is the imageIds per sequenceIndex (for start/middle/end of the platform)
//namespace Style0
//{
// constexpr uint32_t straightBackNE = 0;
// constexpr uint32_t straightFrontNE = 1;
// constexpr uint32_t straightCanopyNE = 2;
// constexpr uint32_t straightCanopyTranslucentNE = 3;
// constexpr uint32_t straightBackSE = 4;
// constexpr uint32_t straightFrontSE = 5;
// constexpr uint32_t straightCanopySE = 6;
// constexpr uint32_t straightCanopyTranslucentSE = 7;
// constexpr uint32_t diagonalNE0 = 8;
// constexpr uint32_t diagonalNE3 = 9;
// constexpr uint32_t diagonalNE1 = 10;
// constexpr uint32_t diagonalCanopyNE1 = 11;
// constexpr uint32_t diagonalCanopyTranslucentNE1 = 12;
// constexpr uint32_t diagonalSE1 = 13;
// constexpr uint32_t diagonalSE2 = 14;
// constexpr uint32_t diagonalSE3 = 15;
// constexpr uint32_t diagonalCanopyTranslucentSE3 = 16;
// constexpr uint32_t totalNumImages = 17;
//}
//namespace Style1
//{
// constexpr uint32_t totalNumImages = 8;
//}
}
}
22 changes: 21 additions & 1 deletion Core/Objects/WallObject.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.ComponentModel;
using OpenLoco.ObjectEditor.Data;
using OpenLoco.ObjectEditor.DatFileParsing;
using OpenLoco.ObjectEditor.Types;

namespace OpenLoco.ObjectEditor.Objects
{
Expand Down Expand Up @@ -41,8 +42,27 @@ public record WallObject(
[property: LocoStructOffset(0x07)] WallObjectFlags Flags,
[property: LocoStructOffset(0x08)] uint8_t Height,
[property: LocoStructOffset(0x09), LocoPropertyMaybeUnused] WallObjectFlags2 Flags2
) : ILocoStruct
) : ILocoStruct, ILocoImageTableNames
{
public bool Validate() => true;

public bool TryGetImageName(int id, out string? value)
=> ImageIdNameMap.TryGetValue(id, out value);

public static Dictionary<int, string> ImageIdNameMap = new()
{
{ 0, "kFlatSE" },
{ 1, "kFlatNE" },
{ 2, "SlopedSE" },
{ 3, "SlopedNE" },
{ 4, "SlopedNW" },
{ 5, "SlopedSW" },
{ 6, "kGlassFlatSE" },
{ 7, "kGlassFlatNE" },
{ 8, "kGlassSlopedSE" },
{ 9, "kGlassSlopedNE" },
{ 10, "kGlassSlopedNW" },
{ 11, "kGlassSlopedSW" },
};
}
}
11 changes: 10 additions & 1 deletion Core/Objects/WaterObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.ComponentModel;
using OpenLoco.ObjectEditor.Data;
using OpenLoco.ObjectEditor.DatFileParsing;
using OpenLoco.ObjectEditor.Types;

namespace OpenLoco.ObjectEditor.Objects
{
Expand All @@ -17,7 +18,7 @@ public record WaterObject(
[property: LocoStructOffset(0x05), LocoPropertyMaybeUnused] uint8_t var_05,
[property: LocoStructOffset(0x06), Browsable(false)] image_id Image,
[property: LocoStructOffset(0x0A), Browsable(false)] image_id MapPixelImage
) : ILocoStruct
) : ILocoStruct, ILocoImageTableNames
{
public bool Validate()
{
Expand All @@ -31,5 +32,13 @@ public bool Validate()
}
return true;
}

public bool TryGetImageName(int id, out string? value)
=> ImageIdNameMap.TryGetValue(id, out value);

public static Dictionary<int, string> ImageIdNameMap = new()
{
{ 42, "kToolbarTerraformWater" },
};
}
}

0 comments on commit 78350a4

Please sign in to comment.