From 498a1ad1aa096cc01bd3484727032db9225dd21c Mon Sep 17 00:00:00 2001 From: Nanuke Rynyk <4591126+naNuke@users.noreply.github.com> Date: Sun, 7 Jun 2026 21:20:11 +0200 Subject: [PATCH] PackageEditor: Compare package to installed package (shows droplist of viable files) --- .../Packages/SharedPackageTools.cs | 60 +++++++++++++++++++ .../PackageEditor/PackageEditorWindow.xaml | 3 + .../PackageEditor/PackageEditorWindow.xaml.cs | 6 +- 3 files changed, 68 insertions(+), 1 deletion(-) diff --git a/LegendaryExplorer/LegendaryExplorer/Packages/SharedPackageTools.cs b/LegendaryExplorer/LegendaryExplorer/Packages/SharedPackageTools.cs index b39491a009..be014ccd25 100644 --- a/LegendaryExplorer/LegendaryExplorer/Packages/SharedPackageTools.cs +++ b/LegendaryExplorer/LegendaryExplorer/Packages/SharedPackageTools.cs @@ -190,6 +190,66 @@ public static void ComparePackageToAnother(WPFBase wpfBase, Action entryDoubleClickCallback, bool structuralCompare = false) + { + // no pcc no joy + if (wpfBase?.Pcc == null) return; + + if (!wpfBase.Pcc.Game.IsMEGame()) + { + MessageBox.Show(wpfBase, "Can only compare packages from the Original Trilogy or Legendary Edition.", + "Can't compare", MessageBoxButton.OK, MessageBoxImage.Error); + return; + } + + Task.Run(() => + { + wpfBase.BusyText = "Finding installed candidates..."; + wpfBase.IsBusy = true; + + CaseInsensitiveDictionary dlcFiles = []; + + string pccFileName = Path.GetFileName(wpfBase.Pcc.FilePath); + foreach (string file in MELoadedFiles.GetAllGameFiles(null, wpfBase.Pcc.Game)) + { + string fileName = Path.GetFileName(file); + if (fileName == null) continue; + if (fileName != pccFileName) continue; // only files of same name + if (file == wpfBase.Pcc.FilePath) continue; // skip same file as current opened + + string dlcFolder = file.Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar) + .FirstOrDefault(p => p.StartsWith("DLC_")); + dlcFolder ??= "basegame"; + + // save file + dlcFiles.Add(dlcFolder, file); + } + + return dlcFiles; + }).ContinueWithOnUIThread(foundCandidates => + { + wpfBase.IsBusy = false; + if (!foundCandidates.Result.Any()) + { + MessageBox.Show(wpfBase, "Cannot find any candidates for this file!"); + return; + } + + var choice = InputComboBoxDialog.GetValue(wpfBase, "Choose installation source to compare to:", + "Installed file comparison", foundCandidates.Result.Keys, foundCandidates.Result.Keys.Last()); + if (string.IsNullOrEmpty(choice)) return; + + foundCandidates.Result.TryGetValue(choice, out string selectedFile); + if (selectedFile == null) + { + MessageBox.Show("Selected candidate not found in the lists! This is a bug", "OH NO"); + return; + } + + CompareToPackageWrapper(wpfBase, entryDoubleClickCallback, structuralCompare: structuralCompare, diskPath: selectedFile); + }); + } + public static bool CanCompareToUnmodded(WPFBase wpfBase) => wpfBase.Pcc != null && wpfBase.Pcc.Game != MEGame.UDK && (!(wpfBase.Pcc.IsInBasegame() || wpfBase.Pcc.IsInOfficialDLC()) || ME3TweaksBackups.GetGameBackupPath(wpfBase.Pcc.Game) != null); public static UnmoddedCandidatesLookup GetUnmoddedCandidatesForPackage(WPFBase wpfBase) diff --git a/LegendaryExplorer/LegendaryExplorer/Tools/PackageEditor/PackageEditorWindow.xaml b/LegendaryExplorer/LegendaryExplorer/Tools/PackageEditor/PackageEditorWindow.xaml index 4565705572..2c942a77cb 100644 --- a/LegendaryExplorer/LegendaryExplorer/Tools/PackageEditor/PackageEditorWindow.xaml +++ b/LegendaryExplorer/LegendaryExplorer/Tools/PackageEditor/PackageEditorWindow.xaml @@ -166,8 +166,11 @@ + + SharedPackageTools.ComparePackageToUnmodded(this, entryDoubleClickToTreeview, true), () => SharedPackageTools.CanCompareToUnmodded(this)); ComparePackagesCommand = new GenericCommand(() => SharedPackageTools.ComparePackageToAnother(this, entryDoubleClickToTreeview), PackageIsLoaded); StructuralComparePackagesCommand = new GenericCommand(() => SharedPackageTools.ComparePackageToAnother(this, entryDoubleClickToTreeview, true), PackageIsLoaded); + CompareToInstalledCommand = new GenericCommand(() => SharedPackageTools.ComparePackageToInstalledPackage(this, entryDoubleClickToTreeview), PackageIsLoaded); + StructuralCompareToInstalledCommand = new GenericCommand(() => SharedPackageTools.ComparePackageToInstalledPackage(this, entryDoubleClickToTreeview, true), PackageIsLoaded); ExportAllDataCommand = new GenericCommand(ExportAllData, ExportIsSelected); ExportBinaryDataCommand = new GenericCommand(ExportBinaryData, ExportIsSelected); ImportAllDataCommand = new GenericCommand(ImportAllData, ExportIsSelected); @@ -4686,4 +4690,4 @@ public void PropogateRecentsChange(string propogationSource, IEnumerable "PackageEditor"; } -} \ No newline at end of file +}