Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
Add bundle selection when importing
Browse files Browse the repository at this point in the history
Now you can select which bundle to import.
If no bundle is selected, then it will still automatically select the smallest of all loaded bundle.
  • Loading branch information
aianlinb committed Oct 20, 2020
1 parent 6e91811 commit 4930d71
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions VisualBundle/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,9 @@ private void OnButtonMoveClick(object sender, RoutedEventArgs e)
#endif
private void OnButtonAddClick(object sender, RoutedEventArgs e)
{
BundleRecord bundleToSave = (BundleRecord)(((ItemModel)View1.SelectedItem)?.Record);
if (MessageBox.Show(
"This will import all files to the smallest bundle of all loaded bundles (doesn't contain which were filtered)." + Environment.NewLine
(bundleToSave == null ? "This will import all files to the smallest of all loaded bundles (doesn't contain which were filtered)." : "This will import all files to \"" + bundleToSave.Name + "\"") + Environment.NewLine
+ "All files to be imported must be defined by the _.index.bin." + Environment.NewLine
+ "Are you sure you want to do this?",
"Import Confirm",
Expand All @@ -465,8 +466,6 @@ private void OnButtonAddClick(object sender, RoutedEventArgs e)
if (fbd.ShowDialog() == true)
{
var fileNames = Directory.GetFiles(fbd.DirectoryPath, "*", SearchOption.AllDirectories);
int l = loadedBundles[0].UncompressedSize;
BundleRecord bundleToSave = loadedBundles[0];
RunBackground(() =>
{
Dispatcher.Invoke(() => { CurrentBackground.Message.Text = "Checking files . . ."; });
Expand All @@ -480,14 +479,20 @@ private void OnButtonAddClick(object sender, RoutedEventArgs e)
}
}
foreach (var b in loadedBundles)
if (bundleToSave == null)
{
if (b.UncompressedSize < l)
bundleToSave = loadedBundles[0];
int l = loadedBundles[0].UncompressedSize;
foreach (var b in loadedBundles)
{
l = b.UncompressedSize;
bundleToSave = b;
if (b.UncompressedSize < l)
{
l = b.UncompressedSize;
bundleToSave = b;
}
}
}
string str = "Imported {0}/" + fileNames.Length.ToString() + " Files";
int count = 0;
foreach (var f in fileNames)
Expand Down

0 comments on commit 4930d71

Please sign in to comment.