Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-build Wad tree on Hashtable load #145

Merged
merged 1 commit into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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