Skip to content

Commit 04a4adf

Browse files
authored
Readd object availability (#186)
* readd availability * progress * add enum display for scalar * add placeholder text for enum serialisation * ui
1 parent 68611f7 commit 04a4adf

File tree

19 files changed

+1152
-142
lines changed

19 files changed

+1152
-142
lines changed

DatabaseExporter/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ [.. o.Authors.Select(a => a.Name)],
113113
[.. o.Tags.Select(t => t.Name)],
114114
[.. o.Packs.Select(m => m.Name)],
115115
o.Object.Licence?.Name,
116+
o.Object.Availability,
116117
o.Object.CreatedDate,
117118
o.Object.ModifiedDate,
118119
o.Object.UploadedDate,

DatabaseImporter/Program.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Common.Json;
2+
using Definitions;
23
using Microsoft.EntityFrameworkCore;
34
using OpenLoco.Common.Logging;
45
using OpenLoco.Dat.Data;
@@ -205,7 +206,7 @@ static void SeedDb(LocoDbContext db, bool deleteExisting)
205206
var metadataKey = objIndex.DisplayName; // should be InternalName
206207
if (!objectMetadataDict.TryGetValue(metadataKey, out var meta))
207208
{
208-
var newMetadata = new ObjectMetadata(Guid.NewGuid().ToString(), null, [], [], [], null, DateTimeOffset.Now, null, DateTimeOffset.Now, ObjectSource.Custom);
209+
var newMetadata = new ObjectMetadata(Guid.NewGuid().ToString(), null, [], [], [], null, ObjectAvailability.Available, DateTimeOffset.Now, null, DateTimeOffset.Now, ObjectSource.Custom);
209210
meta = newMetadata;
210211
objectMetadataDict.Add(objIndex.DisplayName, newMetadata);
211212
}

Definitions/DTO/DtoExtensions.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ public static DtoObjectDescriptor ToDtoDescriptor(this ExpandedTbl<TblObject, Tb
1111
x!.Object.Id,
1212
x!.Object.Name,
1313
x!.Object.DatObjects.FirstOrDefault()?.DatName ?? "<--->",
14+
x!.Object.DatObjects.FirstOrDefault()?.DatChecksum ?? 0,
1415
x!.Object.Description,
1516
x!.Object.ObjectSource,
1617
x!.Object.ObjectType,
1718
x!.Object.VehicleType,
19+
x!.Object.Availability,
1820
x!.Object.CreatedDate,
1921
x!.Object.ModifiedDate,
2022
x!.Object.UploadedDate,
@@ -91,7 +93,7 @@ public static TblDatObject ToTable(this DtoDatObjectEntry dto)
9193
=> new() { Id = dto.Id, DatName = dto.DatName, DatChecksum = dto.DatChecksum, xxHash3 = dto.xxHash3, ObjectId = dto.ObjectId };
9294

9395
public static DtoObjectEntry ToDtoEntry(this TblObject table)
94-
=> new(table.Id, table.Name, table.DatObjects.FirstOrDefault()?.DatName ?? "<--->", table.DatObjects.FirstOrDefault()?.DatChecksum, table.Description, table.ObjectSource, table.ObjectType, table.VehicleType, table.CreatedDate, table.ModifiedDate, table.UploadedDate);
96+
=> new(table.Id, table.Name, table.DatObjects.FirstOrDefault()?.DatName ?? "<--->", table.DatObjects.FirstOrDefault()?.DatChecksum, table.Description, table.ObjectSource, table.ObjectType, table.VehicleType, table.Availability, table.CreatedDate, table.ModifiedDate, table.UploadedDate);
9597

9698
public static TblObject ToTable(this DtoObjectEntry dto)
9799
=> new() { Id = dto.Id, Name = dto.InternalName, Description = dto.Description, ObjectSource = dto.ObjectSource, ObjectType = dto.ObjectType, VehicleType = dto.VehicleType, CreatedDate = dto.CreatedDate, ModifiedDate = dto.ModifiedDate, UploadedDate = dto.UploadedDate };

Definitions/DTO/DtoObjectDescriptor.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ public record DtoObjectDescriptor(
88
DbKey Id,
99
string InternalName,
1010
string DisplayName,
11+
uint? DatChecksum,
1112
string? Description,
1213
ObjectSource ObjectSource,
1314
ObjectType ObjectType,
1415
VehicleType? VehicleType,
16+
ObjectAvailability Availability,
1517
DateTimeOffset? CreatedDate,
1618
DateTimeOffset? ModifiedDate,
1719
DateTimeOffset UploadedDate,

Definitions/DTO/DtoObjectEntry.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Definitions;
12
using OpenLoco.Dat.Data;
23
using OpenLoco.Dat.Objects;
34

@@ -12,6 +13,7 @@ public record DtoObjectEntry(
1213
ObjectSource ObjectSource,
1314
ObjectType ObjectType,
1415
VehicleType? VehicleType,
16+
ObjectAvailability Availability,
1517
DateTimeOffset? CreatedDate,
1618
DateTimeOffset? ModifiedDate,
1719
DateTimeOffset UploadedDate);

Definitions/Database/DataTables/TblObject.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Definitions;
12
using OpenLoco.Dat.Data;
23
using OpenLoco.Dat.Objects;
34

@@ -11,6 +12,8 @@ public class TblObject : DbCoreObject
1112

1213
public VehicleType? VehicleType { get; set; }
1314

15+
public ObjectAvailability Availability { get; set; }
16+
1417
public ICollection<TblObjectPack> ObjectPacks { get; set; } = []; // aka modpack
1518

1619
public ICollection<TblDatObject> DatObjects { get; set; } = []; // the DAT objects that created or reference this OpenLoco object. May be 0, may be multiple

0 commit comments

Comments
 (0)