mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Merge pull request #58 from tr4wzified/properfoldervalidation
Improved location validation
This commit is contained in:
@ -16,7 +16,7 @@ using Wabbajack.Properties;
|
|||||||
|
|
||||||
namespace Wabbajack
|
namespace Wabbajack
|
||||||
{
|
{
|
||||||
internal class AppState : INotifyPropertyChanged
|
internal class AppState : INotifyPropertyChanged, IDataErrorInfo
|
||||||
{
|
{
|
||||||
private ICommand _begin;
|
private ICommand _begin;
|
||||||
|
|
||||||
@ -158,6 +158,7 @@ namespace Wabbajack
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public string DownloadLocation
|
public string DownloadLocation
|
||||||
{
|
{
|
||||||
get => _downloadLocation;
|
get => _downloadLocation;
|
||||||
@ -315,7 +316,46 @@ namespace Wabbajack
|
|||||||
|
|
||||||
public void OnPropertyChanged(string name)
|
public void OnPropertyChanged(string 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()
|
private void UpdateLoop()
|
||||||
@ -421,20 +461,7 @@ namespace Wabbajack
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
var folder = UIUtils.ShowFolderSelectionDialog("Select Your MO2 profile directory");
|
var folder = UIUtils.ShowFolderSelectionDialog("Select Your MO2 profile directory");
|
||||||
|
Location = folder;
|
||||||
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}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -500,42 +527,40 @@ namespace Wabbajack
|
|||||||
th.Priority = ThreadPriority.BelowNormal;
|
th.Priority = ThreadPriority.BelowNormal;
|
||||||
th.Start();
|
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
|
else
|
||||||
{
|
{
|
||||||
if (_mo2Folder != null)
|
Utils.Log("Cannot compile modlist: no valid Mod Organizer profile directory selected.");
|
||||||
{
|
UIReady = true;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -547,5 +572,4 @@ namespace Wabbajack
|
|||||||
public string Msg { get; internal set; }
|
public string Msg { get; internal set; }
|
||||||
public int ID { get; internal set; }
|
public int ID { get; internal set; }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -64,8 +64,8 @@
|
|||||||
<RowDefinition MinHeight="10" />
|
<RowDefinition MinHeight="10" />
|
||||||
<RowDefinition />
|
<RowDefinition />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Label Grid.Row="0" Content="MO2 Location:" Grid.Column="0" />
|
<Label Grid.Row="0" Content="MO2 Profile:" 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, NotifyOnValidationError=True}" IsEnabled="{Binding UIReady}"/>
|
||||||
<Button Grid.Row="0" Content="Select" MinWidth="80" Grid.Column="2" Command="{Binding ChangePath}" 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" />
|
<Label Grid.Row="2" Content="Download Location:" Grid.Column="0" />
|
||||||
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding DownloadLocation}" IsEnabled="{Binding UIReady}"/>
|
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding DownloadLocation}" IsEnabled="{Binding UIReady}"/>
|
||||||
|
@ -838,6 +838,9 @@
|
|||||||
</Setter.Value>
|
</Setter.Value>
|
||||||
</Setter>
|
</Setter>
|
||||||
<Style.Triggers>
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding Path=(Validation.HasError), RelativeSource={RelativeSource self}}" Value="True">
|
||||||
|
<Setter Property="ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
|
||||||
|
</DataTrigger>
|
||||||
<!--<MultiTrigger>
|
<!--<MultiTrigger>
|
||||||
<MultiTrigger.Conditions>
|
<MultiTrigger.Conditions>
|
||||||
<Condition Property="IsInactiveSelectionHighlightEnabled" Value="true"/>
|
<Condition Property="IsInactiveSelectionHighlightEnabled" Value="true"/>
|
||||||
|
Reference in New Issue
Block a user