mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Add better method of validating location
This commit is contained in:
parent
25685cc4b6
commit
a5be534815
@ -13,7 +13,7 @@ using Wabbajack.Common;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
internal class AppState : INotifyPropertyChanged
|
||||
internal class AppState : INotifyPropertyChanged, IDataErrorInfo
|
||||
{
|
||||
private ICommand _begin;
|
||||
|
||||
@ -129,6 +129,7 @@ namespace Wabbajack
|
||||
OnPropertyChanged("Location");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public string DownloadLocation
|
||||
{
|
||||
@ -222,7 +223,47 @@ namespace Wabbajack
|
||||
|
||||
public void OnPropertyChanged(string name)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
||||
//PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
||||
if(PropertyChanged != null)
|
||||
{
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(name));
|
||||
}
|
||||
}
|
||||
public string Error
|
||||
{
|
||||
get { return "Error"; }
|
||||
}
|
||||
|
||||
public string this[string columnName]
|
||||
{
|
||||
get
|
||||
{
|
||||
return Validate(columnName);
|
||||
}
|
||||
}
|
||||
private string Validate(string columnName)
|
||||
{
|
||||
string validationMessage = null;
|
||||
switch (columnName)
|
||||
{
|
||||
case "Location":
|
||||
if (Location == null)
|
||||
{
|
||||
validationMessage = null;
|
||||
}
|
||||
else if (Location != null && Directory.Exists(Location) && File.Exists(Path.Combine(Location, "modlist.txt")))
|
||||
{
|
||||
Location = Path.Combine(Location, "modlist.txt");
|
||||
validationMessage = null;
|
||||
ConfigureForBuild();
|
||||
}
|
||||
else
|
||||
{
|
||||
validationMessage = "Invalid Mod Organizer profile directory";
|
||||
}
|
||||
break;
|
||||
}
|
||||
return validationMessage;
|
||||
}
|
||||
|
||||
private void UpdateLoop()
|
||||
@ -301,20 +342,7 @@ namespace Wabbajack
|
||||
else
|
||||
{
|
||||
var folder = UIUtils.ShowFolderSelectionDialog("Select Your MO2 profile directory");
|
||||
|
||||
if (folder != null)
|
||||
{
|
||||
var file = Path.Combine(folder, "modlist.txt");
|
||||
if(File.Exists(file))
|
||||
{
|
||||
Location = file;
|
||||
ConfigureForBuild();
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.Log($"No modlist.txt found at {file}");
|
||||
}
|
||||
}
|
||||
Location = folder;
|
||||
}
|
||||
}
|
||||
|
||||
@ -379,42 +407,40 @@ namespace Wabbajack
|
||||
th.Priority = ThreadPriority.BelowNormal;
|
||||
th.Start();
|
||||
}
|
||||
else if (_mo2Folder != null)
|
||||
{
|
||||
var compiler = new Compiler(_mo2Folder, msg => LogMsg(msg));
|
||||
compiler.IgnoreMissingFiles = IgnoreMissingFiles;
|
||||
compiler.MO2Profile = ModListName;
|
||||
var th = new Thread(() =>
|
||||
{
|
||||
UIReady = false;
|
||||
try
|
||||
{
|
||||
compiler.Compile();
|
||||
if (compiler.ModList != null && compiler.ModList.ReportHTML != null)
|
||||
HTMLReport = compiler.ModList.ReportHTML;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
while (ex.InnerException != null) ex = ex.InnerException;
|
||||
LogMsg(ex.StackTrace);
|
||||
LogMsg(ex.ToString());
|
||||
LogMsg($"{ex.Message} - Can't continue");
|
||||
}
|
||||
finally
|
||||
{
|
||||
UIReady = true;
|
||||
}
|
||||
});
|
||||
th.Priority = ThreadPriority.BelowNormal;
|
||||
th.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_mo2Folder != null)
|
||||
{
|
||||
var compiler = new Compiler(_mo2Folder, msg => LogMsg(msg));
|
||||
compiler.IgnoreMissingFiles = IgnoreMissingFiles;
|
||||
compiler.MO2Profile = ModListName;
|
||||
var th = new Thread(() =>
|
||||
{
|
||||
UIReady = false;
|
||||
try
|
||||
{
|
||||
compiler.Compile();
|
||||
if (compiler.ModList != null && compiler.ModList.ReportHTML != null)
|
||||
HTMLReport = compiler.ModList.ReportHTML;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
while (ex.InnerException != null) ex = ex.InnerException;
|
||||
LogMsg(ex.StackTrace);
|
||||
LogMsg(ex.ToString());
|
||||
LogMsg($"{ex.Message} - Can't continue");
|
||||
}
|
||||
finally
|
||||
{
|
||||
UIReady = true;
|
||||
}
|
||||
});
|
||||
th.Priority = ThreadPriority.BelowNormal;
|
||||
th.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.Log("Cannot compile modlist: no valid Mod Organizer profile directory selected.");
|
||||
UIReady = true;
|
||||
}
|
||||
Utils.Log("Cannot compile modlist: no valid Mod Organizer profile directory selected.");
|
||||
UIReady = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -424,5 +450,4 @@ namespace Wabbajack
|
||||
public string Msg { get; internal set; }
|
||||
public int ID { get; internal set; }
|
||||
}
|
||||
}
|
||||
}
|
@ -37,7 +37,7 @@
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Label Grid.Row="0" Content="MO2 Location:" Grid.Column="0" />
|
||||
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Location}" IsEnabled="{Binding UIReady}"/>
|
||||
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Location, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" IsEnabled="{Binding UIReady}"/>
|
||||
<Button Grid.Row="0" Content="Select" MinWidth="80" Grid.Column="2" Command="{Binding ChangePath}" IsEnabled="{Binding UIReady}"/>
|
||||
<Label Grid.Row="2" Content="Download Location:" Grid.Column="0" />
|
||||
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding DownloadLocation}" IsEnabled="{Binding UIReady}"/>
|
||||
|
Loading…
Reference in New Issue
Block a user