Skip to content

Commit 782a535

Browse files
committed
name some RoadObjectFlags, Tree seasonal flags, and other internal types
1 parent 63a11d8 commit 782a535

23 files changed

Lines changed: 156 additions & 88 deletions

Dat/Loaders/RoadObjectLoader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,10 @@ internal enum DatRoadObjectFlags : uint16_t
141141
{
142142
None = 0,
143143
IsOneWay = 1 << 0,
144-
unk_01 = 1 << 1,
144+
UseTracksMenu = 1 << 1, // Whether to show this in the tracks menu or the roads menu
145145
unk_02 = 1 << 2,
146146
unk_03 = 1 << 3, // Likely isTram
147-
unk_04 = 1 << 4,
147+
NoWheelSlipping = 1 << 4, // Vehicles cannot slip on this road
148148
unk_05 = 1 << 5,
149149
IsRoad = 1 << 6, // If not set this is tram track
150150
unk_07 = 1 << 7,

Dat/Loaders/TreeObjectLoader.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static LocoObject Load(Stream stream)
4343
br.SkipImageId(Constants.ImageCount); // Image sprites, not part of object definition
4444
br.SkipImageId(Constants.ImageCount); // Snow sprites, not part of object definition
4545
model.ShadowImageOffset = br.ReadUInt16();
46-
model.var_3C = ((DatTreeFlagsUnk)br.ReadByte()).Convert();
46+
model.SeasonalVariants = ((DatTreeFlagsUnk)br.ReadByte()).Convert();
4747
model.SeasonState = br.ReadByte();
4848
model.CurrentSeason = br.ReadByte();
4949
model.CostIndex = br.ReadByte();
@@ -90,7 +90,7 @@ public static void Save(Stream stream, LocoObject obj)
9090
bw.WriteEmptyImageId(Constants.ImageCount); // Image sprites, not part
9191
bw.WriteEmptyImageId(Constants.ImageCount); // Snow sprites, not part of object definition
9292
bw.Write(model.ShadowImageOffset);
93-
bw.Write((uint8_t)model.var_3C.Convert()); // Convert to Dat
93+
bw.Write((uint8_t)model.SeasonalVariants.Convert()); // Convert to Dat
9494
bw.Write(model.SeasonState);
9595
bw.Write(model.CurrentSeason);
9696
bw.Write(model.CostIndex);
@@ -151,9 +151,9 @@ public static DatTreeObjectFlags Convert(this TreeObjectFlags treeObjectFlags)
151151

152152
internal static class TreeFlagsUnkConverter
153153
{
154-
public static TreeFlagsUnk Convert(this DatTreeFlagsUnk datTreeFlagsUnk)
155-
=> (TreeFlagsUnk)datTreeFlagsUnk;
154+
public static TreeObjectSeasonalVariantFlags Convert(this DatTreeFlagsUnk datTreeFlagsUnk)
155+
=> (TreeObjectSeasonalVariantFlags)datTreeFlagsUnk;
156156

157-
public static DatTreeFlagsUnk Convert(this TreeFlagsUnk treeFlagsUnk)
157+
public static DatTreeFlagsUnk Convert(this TreeObjectSeasonalVariantFlags treeFlagsUnk)
158158
=> (DatTreeFlagsUnk)treeFlagsUnk;
159159
}

Definitions/Database/DataTables/Objects/TblObjectTree.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class TblObjectTree : DbSubObject, IConvertibleToTable<TblObjectTree, Tre
2020
public uint32_t Colours { get; set; }
2121
public int16_t Rating { get; set; }
2222
public int16_t DemolishRatingReduction { get; set; }
23-
public TreeFlagsUnk var_3C { get; set; } // something with images
23+
public TreeObjectSeasonalVariantFlags SeasonalVariants { get; set; } // something with images
2424

2525
public static TblObjectTree FromObject(TblObject tbl, TreeObject obj)
2626
=> new()

Definitions/Definitions.csproj

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,34 @@
1111

1212
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'" />
1313

14+
<ItemGroup>
15+
<Content Remove="C:\Users\bigba\.nuget\packages\microsoft.codeanalysis.workspaces.msbuild\4.14.0\contentFiles\any\any\BuildHost-net472\cs\System.CommandLine.resources.dll" />
16+
<Content Remove="C:\Users\bigba\.nuget\packages\microsoft.codeanalysis.workspaces.msbuild\4.14.0\contentFiles\any\any\BuildHost-net472\de\System.CommandLine.resources.dll" />
17+
<Content Remove="C:\Users\bigba\.nuget\packages\microsoft.codeanalysis.workspaces.msbuild\4.14.0\contentFiles\any\any\BuildHost-net472\es\System.CommandLine.resources.dll" />
18+
<Content Remove="C:\Users\bigba\.nuget\packages\microsoft.codeanalysis.workspaces.msbuild\4.14.0\contentFiles\any\any\BuildHost-net472\fr\System.CommandLine.resources.dll" />
19+
<Content Remove="C:\Users\bigba\.nuget\packages\microsoft.codeanalysis.workspaces.msbuild\4.14.0\contentFiles\any\any\BuildHost-net472\it\System.CommandLine.resources.dll" />
20+
<Content Remove="C:\Users\bigba\.nuget\packages\microsoft.codeanalysis.workspaces.msbuild\4.14.0\contentFiles\any\any\BuildHost-net472\ja\System.CommandLine.resources.dll" />
21+
<Content Remove="C:\Users\bigba\.nuget\packages\microsoft.codeanalysis.workspaces.msbuild\4.14.0\contentFiles\any\any\BuildHost-net472\ko\System.CommandLine.resources.dll" />
22+
<Content Remove="C:\Users\bigba\.nuget\packages\microsoft.codeanalysis.workspaces.msbuild\4.14.0\contentFiles\any\any\BuildHost-net472\Microsoft.Build.Locator.dll" />
23+
<Content Remove="C:\Users\bigba\.nuget\packages\microsoft.codeanalysis.workspaces.msbuild\4.14.0\contentFiles\any\any\BuildHost-net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.exe" />
24+
<Content Remove="C:\Users\bigba\.nuget\packages\microsoft.codeanalysis.workspaces.msbuild\4.14.0\contentFiles\any\any\BuildHost-net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.exe.config" />
25+
<Content Remove="C:\Users\bigba\.nuget\packages\microsoft.codeanalysis.workspaces.msbuild\4.14.0\contentFiles\any\any\BuildHost-net472\Microsoft.IO.Redist.dll" />
26+
<Content Remove="C:\Users\bigba\.nuget\packages\microsoft.codeanalysis.workspaces.msbuild\4.14.0\contentFiles\any\any\BuildHost-net472\Newtonsoft.Json.dll" />
27+
<Content Remove="C:\Users\bigba\.nuget\packages\microsoft.codeanalysis.workspaces.msbuild\4.14.0\contentFiles\any\any\BuildHost-net472\pl\System.CommandLine.resources.dll" />
28+
<Content Remove="C:\Users\bigba\.nuget\packages\microsoft.codeanalysis.workspaces.msbuild\4.14.0\contentFiles\any\any\BuildHost-net472\pt-BR\System.CommandLine.resources.dll" />
29+
<Content Remove="C:\Users\bigba\.nuget\packages\microsoft.codeanalysis.workspaces.msbuild\4.14.0\contentFiles\any\any\BuildHost-net472\ru\System.CommandLine.resources.dll" />
30+
<Content Remove="C:\Users\bigba\.nuget\packages\microsoft.codeanalysis.workspaces.msbuild\4.14.0\contentFiles\any\any\BuildHost-net472\System.Buffers.dll" />
31+
<Content Remove="C:\Users\bigba\.nuget\packages\microsoft.codeanalysis.workspaces.msbuild\4.14.0\contentFiles\any\any\BuildHost-net472\System.Collections.Immutable.dll" />
32+
<Content Remove="C:\Users\bigba\.nuget\packages\microsoft.codeanalysis.workspaces.msbuild\4.14.0\contentFiles\any\any\BuildHost-net472\System.CommandLine.dll" />
33+
<Content Remove="C:\Users\bigba\.nuget\packages\microsoft.codeanalysis.workspaces.msbuild\4.14.0\contentFiles\any\any\BuildHost-net472\System.Memory.dll" />
34+
<Content Remove="C:\Users\bigba\.nuget\packages\microsoft.codeanalysis.workspaces.msbuild\4.14.0\contentFiles\any\any\BuildHost-net472\System.Numerics.Vectors.dll" />
35+
<Content Remove="C:\Users\bigba\.nuget\packages\microsoft.codeanalysis.workspaces.msbuild\4.14.0\contentFiles\any\any\BuildHost-net472\System.Runtime.CompilerServices.Unsafe.dll" />
36+
<Content Remove="C:\Users\bigba\.nuget\packages\microsoft.codeanalysis.workspaces.msbuild\4.14.0\contentFiles\any\any\BuildHost-net472\System.Threading.Tasks.Extensions.dll" />
37+
<Content Remove="C:\Users\bigba\.nuget\packages\microsoft.codeanalysis.workspaces.msbuild\4.14.0\contentFiles\any\any\BuildHost-net472\tr\System.CommandLine.resources.dll" />
38+
<Content Remove="C:\Users\bigba\.nuget\packages\microsoft.codeanalysis.workspaces.msbuild\4.14.0\contentFiles\any\any\BuildHost-net472\zh-Hans\System.CommandLine.resources.dll" />
39+
<Content Remove="C:\Users\bigba\.nuget\packages\microsoft.codeanalysis.workspaces.msbuild\4.14.0\contentFiles\any\any\BuildHost-net472\zh-Hant\System.CommandLine.resources.dll" />
40+
</ItemGroup>
41+
1442
<ItemGroup>
1543
<Compile Include="..\Dat\Types\GlobalUsings.cs" Link="GlobalUsings.cs" />
1644
</ItemGroup>

Definitions/ObjectModels/Objects/Road/RoadObjectFlags.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ public enum RoadObjectFlags : uint16_t
55
{
66
None = 0,
77
IsOneWay = 1 << 0,
8-
unk_01 = 1 << 1,
8+
UseTracksMenu = 1 << 1,
99
unk_02 = 1 << 2,
1010
unk_03 = 1 << 3, // Likely isTram
11-
unk_04 = 1 << 4,
11+
NoWheelSlipping = 1 << 4,
1212
unk_05 = 1 << 5,
1313
IsRoad = 1 << 6, // If not set this is tram track
1414
unk_07 = 1 << 7,

Definitions/ObjectModels/Objects/Tree/TreeFlags.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

Definitions/ObjectModels/Objects/Tree/TreeObject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class TreeObject : ILocoStruct
1212
public uint8_t NumGrowthStages { get; set; }
1313
public TreeObjectFlags Flags { get; set; }
1414
public uint16_t ShadowImageOffset { get; set; }
15-
public TreeFlagsUnk var_3C { get; set; } // something with images
15+
public TreeObjectSeasonalVariantFlags SeasonalVariants { get; set; } // something with images
1616
public uint8_t SeasonState { get; set; }
1717
public uint8_t CurrentSeason { get; set; } // i don't think this is part of definition, its game state
1818
public uint8_t CostIndex { get; set; }
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace Definitions.ObjectModels.Objects.Tree;
2+
3+
[Flags]
4+
public enum TreeObjectSeasonalVariantFlags : uint8_t
5+
{
6+
Variant0 = 1 << 0,
7+
Variant1 = 1 << 1,
8+
Variant2 = 1 << 2,
9+
Variant3 = 1 << 3,
10+
Variant4 = 1 << 4,
11+
Variant5 = 1 << 5,
12+
}

Gui/ViewModels/LocoTypes/BaseLocoFileViewModel.cs renamed to Gui/ViewModels/LocoTypes/BaseFileViewModel.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ public enum SaveType { JSON, DAT }
2121
// todo: add filename
2222
public record SaveParameters(SaveType SaveType, SawyerEncoding? SawyerEncoding);
2323

24-
public abstract class BaseLocoFileViewModel : ReactiveObject, ILocoFileViewModel
24+
public abstract class BaseFileViewModel : ReactiveObject, IFileViewModel
2525
{
26-
protected BaseLocoFileViewModel(FileSystemItem currentFile, ObjectEditorModel model)
26+
protected BaseFileViewModel(FileSystemItem currentFile, ObjectEditorModel model)
2727
{
2828
CurrentFile = currentFile;
2929
Model = model;
@@ -47,7 +47,7 @@ protected BaseLocoFileViewModel(FileSystemItem currentFile, ObjectEditorModel mo
4747

4848
public abstract void Load();
4949
public abstract void Save();
50-
public abstract void SaveAs(SaveParameters saveParameters);
50+
public abstract string? SaveAs(SaveParameters saveParameters);
5151
public virtual void Delete() { }
5252

5353
async Task SaveAsWrapper()
@@ -97,7 +97,13 @@ async Task SaveAsWrapper()
9797
}
9898
: null;
9999

100-
SaveAs(new SaveParameters(type, encoding));
100+
var filename = SaveAs(new SaveParameters(type, encoding));
101+
102+
// Open the newly-saved document as a new tab in the tabviewpagemodel
103+
if (filename != null)
104+
{
105+
// todo:
106+
}
101107
}
102108

103109
async Task SaveWrapper()

Gui/ViewModels/LocoTypes/G1ViewModel.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace Gui.ViewModels;
99

10-
public class G1ViewModel : BaseLocoFileViewModel
10+
public class G1ViewModel : BaseFileViewModel
1111
{
1212
public G1ViewModel(FileSystemItem currentFile, ObjectEditorModel model)
1313
: base(currentFile, model) => Load();
@@ -48,22 +48,24 @@ public override void Save()
4848
SawyerStreamWriter.SaveG1(savePath, Model.G1);
4949
}
5050

51-
public override void SaveAs(SaveParameters saveParameters)
51+
public override string? SaveAs(SaveParameters saveParameters)
5252
{
5353
if (Model.G1 == null)
5454
{
5555
logger?.Error("G1 was null and was unable to saved");
56-
return;
56+
return null;
5757
}
5858

5959
var saveFile = Task.Run(async () => await PlatformSpecific.SaveFilePicker(PlatformSpecific.DatFileTypes)).Result;
6060
if (saveFile == null)
6161
{
62-
return;
62+
return null;
6363
}
6464

6565
var savePath = saveFile.Path.LocalPath;
6666
logger?.Info($"Saving G1.dat to {savePath}");
6767
SawyerStreamWriter.SaveG1(savePath, Model.G1);
68+
69+
return savePath;
6870
}
6971
}

0 commit comments

Comments
 (0)