From e5d36b34523d2c0fbc3f3a2bf097660f3fb21fb8 Mon Sep 17 00:00:00 2001 From: trawzified Date: Sat, 5 Oct 2019 17:05:51 +0200 Subject: [PATCH] Fix bug where installing modlist would always result in location validation error, Add more validation --- Wabbajack/AppState.cs | 28 +++++++++++++++++++++++----- Wabbajack/MainWindow.xaml | 2 +- Wabbajack/MainWindow.xaml.cs | 4 +++- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/Wabbajack/AppState.cs b/Wabbajack/AppState.cs index 4bfda9e1..ae0af6a3 100644 --- a/Wabbajack/AppState.cs +++ b/Wabbajack/AppState.cs @@ -30,10 +30,10 @@ namespace Wabbajack private bool _ignoreMissingFiles; private string _location; + private string _locationLabel; private string _mo2Folder; - private string _mode; private ModList _modList; private string _modListName; @@ -64,9 +64,9 @@ namespace Wabbajack if (Assembly.GetEntryAssembly().Location.ToLower().Contains("\\downloads\\")) { MessageBox.Show( - "This app seems to be running inside a folder called `Downloads`, such folders are often highly monitored by antivirus software and they can often " + - "conflict with the operations Wabbajack needs to perform. Please move this executable outside of your `Downloads` folder and then restart the app.", - "Cannot run inside `Downloads`", + "This app seems to be running inside a folder called 'Downloads', such folders are often highly monitored by antivirus software and they can often " + + "conflict with the operations Wabbajack needs to perform. Please move this executable outside of your 'Downloads' folder and then restart the app.", + "Cannot run inside 'Downloads'", MessageBoxButton.OK, MessageBoxImage.Error); Environment.Exit(1); @@ -132,6 +132,16 @@ namespace Wabbajack OnPropertyChanged("Location"); } } + + public string LocationLabel + { + get => _locationLabel; + set + { + _locationLabel = value; + OnPropertyChanged("LocationLabel"); + } + } public string DownloadLocation @@ -320,12 +330,20 @@ namespace Wabbajack { validationMessage = null; } - else if (Location != null && Directory.Exists(Location) && File.Exists(Path.Combine(Location, "modlist.txt"))) + else if (Mode == "Building" && Location != null && Directory.Exists(Location) && File.Exists(Path.Combine(Location, "modlist.txt"))) { Location = Path.Combine(Location, "modlist.txt"); validationMessage = null; ConfigureForBuild(); } + else if (Mode == "Installing" && Location != null && Directory.Exists(Location) && !Directory.EnumerateFileSystemEntries(Location).Any()) + { + validationMessage = null; + } + else if (Mode == "Installing" && Location != null && Directory.Exists(Location) && Directory.EnumerateFileSystemEntries(Location).Any()) + { + validationMessage = "You have selected a non-empty directory. Installing the modlist here might result in a broken install!"; + } else { validationMessage = "Invalid Mod Organizer profile directory"; diff --git a/Wabbajack/MainWindow.xaml b/Wabbajack/MainWindow.xaml index 22b0407f..5873f6ad 100644 --- a/Wabbajack/MainWindow.xaml +++ b/Wabbajack/MainWindow.xaml @@ -64,7 +64,7 @@ -