mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
CompilerVM: Modlist file picker shows errors if not in MO2 directory
This commit is contained in:
parent
0ef91d9da8
commit
5b4cb1fa89
@ -77,6 +77,12 @@ namespace Wabbajack
|
|||||||
return new ErrorResponse(successful, reason);
|
return new ErrorResponse(successful, reason);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
public static ErrorResponse Convert(IErrorResponse err, bool nullIsSuccess = true)
|
||||||
|
{
|
||||||
|
if (err == null) return ErrorResponse.Create(nullIsSuccess);
|
||||||
|
return new ErrorResponse(err.Succeeded, err.Reason, err.Exception);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IErrorResponse
|
public interface IErrorResponse
|
||||||
|
@ -52,12 +52,6 @@ namespace Wabbajack
|
|||||||
|
|
||||||
public FilePickerVM DownloadLocation { get; }
|
public FilePickerVM DownloadLocation { get; }
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public bool ModlistLocationInError { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public bool DownloadLocationInError { get; set; }
|
|
||||||
|
|
||||||
public IReactiveCommand BeginCommand { get; }
|
public IReactiveCommand BeginCommand { get; }
|
||||||
|
|
||||||
public CompilerVM(MainWindowVM mainWindowVM, string source)
|
public CompilerVM(MainWindowVM mainWindowVM, string source)
|
||||||
@ -155,6 +149,14 @@ namespace Wabbajack
|
|||||||
})
|
})
|
||||||
.DisposeWith(this.CompositeDisposable);
|
.DisposeWith(this.CompositeDisposable);
|
||||||
|
|
||||||
|
// Wire missing Mo2Folder to signal error state for Modlist Location
|
||||||
|
this.ModlistLocation.AdditionalError = this.WhenAny(x => x.Mo2Folder)
|
||||||
|
.Select<string, IErrorResponse>(moFolder =>
|
||||||
|
{
|
||||||
|
if (Directory.Exists(moFolder)) return ErrorResponse.Success;
|
||||||
|
return ErrorResponse.Fail("MO2 Folder could not be located from the given modlist location. Make sure your modlist is inside a valid MO2 distribution.");
|
||||||
|
});
|
||||||
|
|
||||||
// Load settings
|
// Load settings
|
||||||
CompilationSettings settings = this.MWVM.Settings.CompilationSettings.TryCreate(source);
|
CompilationSettings settings = this.MWVM.Settings.CompilationSettings.TryCreate(source);
|
||||||
this.AuthorText = settings.Author;
|
this.AuthorText = settings.Author;
|
||||||
@ -189,15 +191,6 @@ namespace Wabbajack
|
|||||||
.DisposeWith(this.CompositeDisposable);
|
.DisposeWith(this.CompositeDisposable);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ConfigureForBuild(string location)
|
|
||||||
{
|
|
||||||
var profile_folder = Path.GetDirectoryName(location);
|
|
||||||
if (!File.Exists(Path.Combine(this.Mo2Folder, "ModOrganizer.exe")))
|
|
||||||
{
|
|
||||||
Utils.Log($"Error! No ModOrganizer2.exe found in {this.Mo2Folder}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task ExecuteBegin()
|
private async Task ExecuteBegin()
|
||||||
{
|
{
|
||||||
if (this.Mo2Folder != null)
|
if (this.Mo2Folder != null)
|
||||||
|
@ -46,6 +46,9 @@ namespace Wabbajack
|
|||||||
private readonly ObservableAsPropertyHelper<bool> _Exists;
|
private readonly ObservableAsPropertyHelper<bool> _Exists;
|
||||||
public bool Exists => _Exists.Value;
|
public bool Exists => _Exists.Value;
|
||||||
|
|
||||||
|
private readonly ObservableAsPropertyHelper<ErrorResponse> _ErrorState;
|
||||||
|
public ErrorResponse ErrorState => _ErrorState.Value;
|
||||||
|
|
||||||
private readonly ObservableAsPropertyHelper<bool> _InError;
|
private readonly ObservableAsPropertyHelper<bool> _InError;
|
||||||
public bool InError => _InError.Value;
|
public bool InError => _InError.Value;
|
||||||
|
|
||||||
@ -96,15 +99,25 @@ namespace Wabbajack
|
|||||||
.ObserveOn(RxApp.MainThreadScheduler)
|
.ObserveOn(RxApp.MainThreadScheduler)
|
||||||
.ToProperty(this, nameof(this.Exists));
|
.ToProperty(this, nameof(this.Exists));
|
||||||
|
|
||||||
this._InError = Observable.CombineLatest(
|
this._ErrorState = Observable.CombineLatest(
|
||||||
this.WhenAny(x => x.Exists),
|
this.WhenAny(x => x.Exists)
|
||||||
|
.Select(exists => ErrorResponse.Create(successful: exists, exists ? default(string) : "Path does not exist")),
|
||||||
this.WhenAny(x => x.AdditionalError)
|
this.WhenAny(x => x.AdditionalError)
|
||||||
.Select(x => x ?? Observable.Return<IErrorResponse>(ErrorResponse.Success))
|
.Select(x => x ?? Observable.Return<IErrorResponse>(ErrorResponse.Success))
|
||||||
.Switch()
|
.Switch(),
|
||||||
.Select(err => !err?.Succeeded ?? false),
|
resultSelector: (exist, err) =>
|
||||||
resultSelector: (exist, err) => !exist || err)
|
{
|
||||||
|
if (exist.Failed) return exist;
|
||||||
|
return ErrorResponse.Convert(err);
|
||||||
|
})
|
||||||
|
.ToProperty(this, nameof(this.ErrorState));
|
||||||
|
|
||||||
|
this._InError = this.WhenAny(x => x.ErrorState)
|
||||||
|
.Select(x => !x.Succeeded)
|
||||||
.ToProperty(this, nameof(this.InError));
|
.ToProperty(this, nameof(this.InError));
|
||||||
|
|
||||||
|
// Doesn't derive from ErrorState, as we want to bubble non-empty tooltips,
|
||||||
|
// which is slightly different logic
|
||||||
this._ErrorTooltip = Observable.CombineLatest(
|
this._ErrorTooltip = Observable.CombineLatest(
|
||||||
this.WhenAny(x => x.Exists)
|
this.WhenAny(x => x.Exists)
|
||||||
.Select(exists => exists ? default(string) : "Path does not exist"),
|
.Select(exists => exists ? default(string) : "Path does not exist"),
|
||||||
@ -113,12 +126,8 @@ namespace Wabbajack
|
|||||||
.Switch(),
|
.Switch(),
|
||||||
resultSelector: (exists, err) =>
|
resultSelector: (exists, err) =>
|
||||||
{
|
{
|
||||||
if ((!err?.Succeeded ?? false)
|
if (!string.IsNullOrWhiteSpace(exists)) return exists;
|
||||||
&& !string.IsNullOrWhiteSpace(err.Reason))
|
return err?.Reason;
|
||||||
{
|
|
||||||
return err.Reason;
|
|
||||||
}
|
|
||||||
return exists;
|
|
||||||
})
|
})
|
||||||
.ToProperty(this, nameof(this.ErrorTooltip));
|
.ToProperty(this, nameof(this.ErrorTooltip));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user