Skip to content

Commit d6307bf

Browse files
committed
fix crash when attempting to show vanilla object from the object service
1 parent 7c8873d commit d6307bf

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

Gui/Models/ObjectEditorModel.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,15 @@ bool TryLoadOnlineFile(FileSystemItemBase filesystemItem, out UiDatLocoFile? loc
212212
}
213213
else if (string.IsNullOrEmpty(cachedLocoObjDto.DatBytes))
214214
{
215-
Logger.Warning($"Unable to download object {filesystemItem.DisplayName} with unique id {uniqueObjectId} from online - received no DAT object data. Will still show metadata");
215+
if (cachedLocoObjDto.ObjectSource == ObjectSource.LocomotionSteam || cachedLocoObjDto.ObjectSource == ObjectSource.LocomotionGoG)
216+
{
217+
Logger.Warning($"This is a vanilla object. The DAT file cannot be downloaded due to copyright. Any available metadata will still be shown.");
218+
}
219+
Logger.Warning($"Unable to download object {filesystemItem.DisplayName} with unique id {uniqueObjectId} from online - received no DAT object data. Any available metadata will still be shown.");
216220
}
217221
else if (cachedLocoObjDto.ObjectSource is ObjectSource.LocomotionSteam or ObjectSource.LocomotionGoG)
218222
{
219-
Logger.Warning($"Unable to download object {filesystemItem.DisplayName} with unique id {uniqueObjectId} from online - requested object is a vanilla object and it is illegal to distribute copyright material. Will still show metadata");
223+
Logger.Warning($"Unable to download object {filesystemItem.DisplayName} with unique id {uniqueObjectId} from online - requested object is a vanilla object and it is illegal to distribute copyright material. Any available metadata will still be shown.");
220224
}
221225

222226
Logger.Info($"Downloaded object {filesystemItem.DisplayName} with unique id {uniqueObjectId} and added it to the local cache");

Gui/ViewModels/DatTypes/DatObjectEditorViewModel.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,15 @@ public override void Load()
182182
else
183183
{
184184
// todo: show warnings here
185+
// in online mode, vanilla objects won't be downloaded so they hit this case, which is a valid use-case
185186
CurrentObject = null;
186187
CurrentObjectViewModel = null;
187188
}
188189
}
189190

191+
public string ExtraContentViewModelTabName
192+
=> ExtraContentViewModel == null ? "<no content>" : ExtraContentViewModel.Name;
193+
190194
public override void Delete()
191195
{
192196
if (CurrentFile.FileLocation != FileLocation.Local)

Gui/Views/DatObjectEditorView.axaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,13 @@
6060
</ItemsRepeater>
6161
</DockPanel>
6262
</TabItem>
63-
<TabItem Header="{Binding ExtraContentViewModel.Name}">
63+
64+
<TabItem Header="{Binding ExtraContentViewModelTabName}">
6465
<DockPanel>
6566
<ContentControl Content="{Binding ExtraContentViewModel}" />
6667
</DockPanel>
6768
</TabItem>
69+
6870
<TabItem Header="Metadata">
6971
<Border Background="{DynamicResource ExpanderContentBackground}" Margin="8">
7072
<DockPanel Margin="8">

0 commit comments

Comments
 (0)