Skip to content

Commit

Permalink
Re-build Wad tree on Hashtable load (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
Crauzer authored Mar 9, 2023
1 parent 4d050ae commit a5273a0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 4 additions & 2 deletions Obsidian/Data/Wad/WadTabModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ public WadTabModel(string name, WadFile wad, HashtableService hashtable)
this.Wad = wad;
this.Hashtable = hashtable;

InitializeTree();
Rebuild();
}

private void InitializeTree()
public void Rebuild()
{
this.Items.Clear();

foreach (var (chunkPathHash, chunk) in this.Wad.Chunks)
{
string path = this.Hashtable.GetChunkPath(chunk);
Expand Down
12 changes: 11 additions & 1 deletion Obsidian/Pages/ExplorerPage.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,24 @@ public async Task LoadHashtable()
ToggleLoadingHashtable(true);
try
{
await Task.Run(() =>
// Load hashtables
await InvokeAsync(() =>
{
foreach (string hashtableFile in dialog.FileNames)
{
this.Hashtable.LoadHashtable(hashtableFile);
}
});

// Re-build trees
await InvokeAsync(() =>
{
foreach (WadTabModel wadTab in this.Tabs)
{
wadTab.Rebuild();
}
});

this.Snackbar.Add("Successfully loaded hashtables!", Severity.Success);
}
catch (Exception exception)
Expand Down

0 comments on commit a5273a0

Please sign in to comment.