Skip to content

Commit 0614f66

Browse files
committed
Improve unknown file handling in PAK Browser
1 parent 2d0319d commit 0614f66

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

ContentEditor.App/Imgui/Tools/PakBrowser.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ public void OnIMGUI()
193193
return;
194194
}
195195
}
196-
// TODO handle unknowns properly
197196
}
198197
if (ImguiHelpers.ButtonMultiColor(AppIcons.SIC_InfoPAK, new[] {Colors.IconPrimary, Colors.IconPrimary, Colors.Info} )) {
199198
ImGui.OpenPopup("PAKInfoPopup"u8);
@@ -496,12 +495,15 @@ private void GetPageFiles(ListFileWrapper baseList, short ColumnIndex, ImGuiSort
496495
{
497496
var cacheKey = (CurrentDir, ColumnIndex, SortDirection);
498497
if (!cachedResults.TryGetValue(cacheKey, out sortedEntries)) {
499-
var files = baseList.GetFiles(CurrentDir);
498+
string[] files;
499+
if (CurrentDir.StartsWith(PakReader.UnknownFilePathPrefix)) {
500+
files = ListFileWrapper.FilterFiles(reader?.UnknownFilePaths ?? [], CurrentDir);
501+
} else {
502+
files = baseList.GetFiles(CurrentDir);
503+
}
500504
if (string.IsNullOrEmpty(CurrentDir) && reader!.ContainsUnknownFiles) {
501505
Array.Resize(ref files, files.Length + 1);
502506
files[^1] = PakReader.UnknownFilePathPrefix;
503-
} else if (CurrentDir.StartsWith(PakReader.UnknownFilePathPrefix)) {
504-
files = reader!.UnknownFilePaths;
505507
}
506508
var sorted = cacheKey.ColumnIndex switch {
507509
0 => cacheKey.SortDirection == ImGuiSortDirection.Ascending ? files : files.Reverse(),
@@ -797,7 +799,7 @@ private void ShowFileContextMenu(string file, bool isBookmarked, bool showSort =
797799
}, AppConfig.Instance.GetGameExtractPath(Workspace.Config.Game));
798800
} else {
799801
PlatformUtils.ShowSaveFileDialog((savePath) => {
800-
var stream = reader!.GetFile(file);
802+
var stream = file.StartsWith(PakReader.UnknownFilePathPrefix) ? reader!.GetUnknownFile(file) : reader!.GetFile(file);
801803
if (stream == null) {
802804
Logger.Error("Could not find file " + file + " in selected PAK files");
803805
return;

0 commit comments

Comments
 (0)