Skip to content

Commit 9b0f599

Browse files
committed
tidy up sync/async in saving objects
1 parent 7719336 commit 9b0f599

File tree

2 files changed

+11
-22
lines changed

2 files changed

+11
-22
lines changed

AvaGui/Models/UiLocoFile.cs

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,7 @@ namespace AvaGui.Models
66
[TypeConverter(typeof(ExpandableObjectConverter))]
77
public class UiLocoFile : IUiObject
88
{
9-
public DatFileInfo DatFileInfo { get; set; }
10-
public ILocoObject LocoObject { get; set; }
9+
public DatFileInfo? DatFileInfo { get; set; }
10+
public ILocoObject? LocoObject { get; set; }
1111
}
12-
13-
//[TypeConverter(typeof(ExpandableObjectConverter))]
14-
//public class UILocoObject
15-
//{
16-
// public UILocoObject(ILocoStruct @struct, StringTable stringTable, BindingList<G1Element32> g1Elements)
17-
// {
18-
// Struct = @struct;
19-
// StringTable = stringTable;
20-
// G1Elements = g1Elements;
21-
// }
22-
23-
// public ILocoStruct Struct { get; set; }
24-
// public StringTable StringTable { get; set; }
25-
26-
// [TypeConverter(typeof(TypeListConverter))]
27-
// public BindingList<G1Element32> G1Elements { get; set; }
28-
//}
2912
}

AvaGui/ViewModels/DatTypes/ObjectEditorViewModel.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class ObjectEditorViewModel : ReactiveObject, ILocoFileViewModel
1414
{
1515
public ReactiveCommand<Unit, Unit> ReloadObjectCommand { get; init; }
1616
public ReactiveCommand<Unit, Unit> SaveObjectCommand { get; init; }
17-
public ReactiveCommand<Unit, Task> SaveAsObjectCommand { get; init; }
17+
public ReactiveCommand<Unit, Unit> SaveAsObjectCommand { get; init; }
1818

1919
[Reactive]
2020
public StringTableViewModel? StringTableViewModel { get; set; }
@@ -77,7 +77,13 @@ public void ReloadCurrentObject()
7777
{
7878
CurrentObject = newObj;
7979
}
80+
else
81+
{
82+
// todo: show warnings here
83+
CurrentObject = null;
84+
}
8085
}
86+
8187
public void SaveCurrentObject()
8288
{
8389
if (CurrentObject?.LocoObject == null)
@@ -90,9 +96,9 @@ public void SaveCurrentObject()
9096
SawyerStreamWriter.Save(CurrentFile.Path, CurrentObject.DatFileInfo.S5Header.Name, CurrentObject.LocoObject);
9197
}
9298

93-
public async Task SaveAsCurrentObject()
99+
public void SaveAsCurrentObject()
94100
{
95-
var saveFile = await PlatformSpecific.SaveFilePicker();
101+
var saveFile = Task.Run(PlatformSpecific.SaveFilePicker).Result;
96102
if (saveFile == null)
97103
{
98104
return;

0 commit comments

Comments
 (0)