mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Simplified names in Wabbajack
This commit is contained in:
parent
00d4181b1b
commit
d8276fb2ea
@ -8,7 +8,7 @@ namespace Wabbajack
|
|||||||
{
|
{
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
return object.Equals(value, parameter);
|
return Equals(value, parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
@ -36,20 +36,20 @@ namespace Wabbajack
|
|||||||
|
|
||||||
public CompilerVM(MainWindowVM mainWindowVM)
|
public CompilerVM(MainWindowVM mainWindowVM)
|
||||||
{
|
{
|
||||||
this.MWVM = mainWindowVM;
|
MWVM = mainWindowVM;
|
||||||
|
|
||||||
// Load settings
|
// Load settings
|
||||||
CompilerSettings settings = this.MWVM.Settings.Compiler;
|
CompilerSettings settings = MWVM.Settings.Compiler;
|
||||||
this.SelectedCompilerType = settings.LastCompiledModManager;
|
SelectedCompilerType = settings.LastCompiledModManager;
|
||||||
this.MWVM.Settings.SaveSignal
|
MWVM.Settings.SaveSignal
|
||||||
.Subscribe(_ =>
|
.Subscribe(_ =>
|
||||||
{
|
{
|
||||||
settings.LastCompiledModManager = this.SelectedCompilerType;
|
settings.LastCompiledModManager = SelectedCompilerType;
|
||||||
})
|
})
|
||||||
.DisposeWith(this.CompositeDisposable);
|
.DisposeWith(CompositeDisposable);
|
||||||
|
|
||||||
// Swap to proper sub VM based on selected type
|
// Swap to proper sub VM based on selected type
|
||||||
this._Compiler = this.WhenAny(x => x.SelectedCompilerType)
|
_Compiler = this.WhenAny(x => x.SelectedCompilerType)
|
||||||
// Delay so the initial VM swap comes in immediately, subVM comes right after
|
// Delay so the initial VM swap comes in immediately, subVM comes right after
|
||||||
.DelayInitial(TimeSpan.FromMilliseconds(50), RxApp.MainThreadScheduler)
|
.DelayInitial(TimeSpan.FromMilliseconds(50), RxApp.MainThreadScheduler)
|
||||||
.Select<ModManager, ISubCompilerVM>(type =>
|
.Select<ModManager, ISubCompilerVM>(type =>
|
||||||
@ -71,17 +71,17 @@ namespace Wabbajack
|
|||||||
pair.Previous?.Unload();
|
pair.Previous?.Unload();
|
||||||
})
|
})
|
||||||
.Select(p => p.Current)
|
.Select(p => p.Current)
|
||||||
.ToProperty(this, nameof(this.Compiler));
|
.ToProperty(this, nameof(Compiler));
|
||||||
|
|
||||||
// Let sub VM determine what settings we're displaying and when
|
// Let sub VM determine what settings we're displaying and when
|
||||||
this._CurrentModlistSettings = this.WhenAny(x => x.Compiler.ModlistSettings)
|
_CurrentModlistSettings = this.WhenAny(x => x.Compiler.ModlistSettings)
|
||||||
.ToProperty(this, nameof(this.CurrentModlistSettings));
|
.ToProperty(this, nameof(CurrentModlistSettings));
|
||||||
|
|
||||||
// Let sub VM determine what progress we're seeing
|
// Let sub VM determine what progress we're seeing
|
||||||
this._CurrentStatusTracker = this.WhenAny(x => x.Compiler.StatusTracker)
|
_CurrentStatusTracker = this.WhenAny(x => x.Compiler.StatusTracker)
|
||||||
.ToProperty(this, nameof(this.CurrentStatusTracker));
|
.ToProperty(this, nameof(CurrentStatusTracker));
|
||||||
|
|
||||||
this._Image = this.WhenAny(x => x.CurrentModlistSettings.ImagePath.TargetPath)
|
_Image = this.WhenAny(x => x.CurrentModlistSettings.ImagePath.TargetPath)
|
||||||
// Throttle so that it only loads image after any sets of swaps have completed
|
// Throttle so that it only loads image after any sets of swaps have completed
|
||||||
.Throttle(TimeSpan.FromMilliseconds(50), RxApp.MainThreadScheduler)
|
.Throttle(TimeSpan.FromMilliseconds(50), RxApp.MainThreadScheduler)
|
||||||
.DistinctUntilChanged()
|
.DistinctUntilChanged()
|
||||||
@ -94,12 +94,12 @@ namespace Wabbajack
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
})
|
})
|
||||||
.ToProperty(this, nameof(this.Image));
|
.ToProperty(this, nameof(Image));
|
||||||
|
|
||||||
this._Compiling = this.WhenAny(x => x.Compiler.ActiveCompilation)
|
_Compiling = this.WhenAny(x => x.Compiler.ActiveCompilation)
|
||||||
.Select(compilation => compilation != null)
|
.Select(compilation => compilation != null)
|
||||||
.ObserveOnGuiThread()
|
.ObserveOnGuiThread()
|
||||||
.ToProperty(this, nameof(this.Compiling));
|
.ToProperty(this, nameof(Compiling));
|
||||||
|
|
||||||
// Compile progress updates and populate ObservableCollection
|
// Compile progress updates and populate ObservableCollection
|
||||||
var subscription = this.WhenAny(x => x.Compiler.ActiveCompilation)
|
var subscription = this.WhenAny(x => x.Compiler.ActiveCompilation)
|
||||||
@ -110,9 +110,9 @@ namespace Wabbajack
|
|||||||
.EnsureUniqueChanges()
|
.EnsureUniqueChanges()
|
||||||
.ObserveOn(RxApp.MainThreadScheduler)
|
.ObserveOn(RxApp.MainThreadScheduler)
|
||||||
.Sort(SortExpressionComparer<CPUStatus>.Ascending(s => s.ID), SortOptimisations.ComparesImmutableValuesOnly)
|
.Sort(SortExpressionComparer<CPUStatus>.Ascending(s => s.ID), SortOptimisations.ComparesImmutableValuesOnly)
|
||||||
.Bind(this.MWVM.StatusList)
|
.Bind(MWVM.StatusList)
|
||||||
.Subscribe()
|
.Subscribe()
|
||||||
.DisposeWith(this.CompositeDisposable);
|
.DisposeWith(CompositeDisposable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,20 +37,20 @@ namespace Wabbajack
|
|||||||
|
|
||||||
public MO2CompilerVM(CompilerVM parent)
|
public MO2CompilerVM(CompilerVM parent)
|
||||||
{
|
{
|
||||||
this.ModlistLocation = new FilePickerVM()
|
ModlistLocation = new FilePickerVM()
|
||||||
{
|
{
|
||||||
ExistCheckOption = FilePickerVM.ExistCheckOptions.On,
|
ExistCheckOption = FilePickerVM.ExistCheckOptions.On,
|
||||||
PathType = FilePickerVM.PathTypeOptions.File,
|
PathType = FilePickerVM.PathTypeOptions.File,
|
||||||
PromptTitle = "Select Modlist"
|
PromptTitle = "Select Modlist"
|
||||||
};
|
};
|
||||||
this.DownloadLocation = new FilePickerVM()
|
DownloadLocation = new FilePickerVM()
|
||||||
{
|
{
|
||||||
ExistCheckOption = FilePickerVM.ExistCheckOptions.On,
|
ExistCheckOption = FilePickerVM.ExistCheckOptions.On,
|
||||||
PathType = FilePickerVM.PathTypeOptions.Folder,
|
PathType = FilePickerVM.PathTypeOptions.Folder,
|
||||||
PromptTitle = "Select Download Location",
|
PromptTitle = "Select Download Location",
|
||||||
};
|
};
|
||||||
|
|
||||||
this._Mo2Folder = this.WhenAny(x => x.ModlistLocation.TargetPath)
|
_Mo2Folder = this.WhenAny(x => x.ModlistLocation.TargetPath)
|
||||||
.Select(loc =>
|
.Select(loc =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -63,8 +63,8 @@ namespace Wabbajack
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.ToProperty(this, nameof(this.Mo2Folder));
|
.ToProperty(this, nameof(Mo2Folder));
|
||||||
this._MOProfile = this.WhenAny(x => x.ModlistLocation.TargetPath)
|
_MOProfile = this.WhenAny(x => x.ModlistLocation.TargetPath)
|
||||||
.Select(loc =>
|
.Select(loc =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -77,10 +77,10 @@ namespace Wabbajack
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.ToProperty(this, nameof(this.MOProfile));
|
.ToProperty(this, nameof(MOProfile));
|
||||||
|
|
||||||
// Wire missing Mo2Folder to signal error state for Modlist Location
|
// Wire missing Mo2Folder to signal error state for Modlist Location
|
||||||
this.ModlistLocation.AdditionalError = this.WhenAny(x => x.Mo2Folder)
|
ModlistLocation.AdditionalError = this.WhenAny(x => x.Mo2Folder)
|
||||||
.Select<string, IErrorResponse>(moFolder =>
|
.Select<string, IErrorResponse>(moFolder =>
|
||||||
{
|
{
|
||||||
if (Directory.Exists(moFolder)) return ErrorResponse.Success;
|
if (Directory.Exists(moFolder)) return ErrorResponse.Success;
|
||||||
@ -88,7 +88,7 @@ namespace Wabbajack
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Wire start command
|
// Wire start command
|
||||||
this.BeginCommand = ReactiveCommand.CreateFromTask(
|
BeginCommand = ReactiveCommand.CreateFromTask(
|
||||||
canExecute: Observable.CombineLatest(
|
canExecute: Observable.CombineLatest(
|
||||||
this.WhenAny(x => x.ModlistLocation.InError),
|
this.WhenAny(x => x.ModlistLocation.InError),
|
||||||
this.WhenAny(x => x.DownloadLocation.InError),
|
this.WhenAny(x => x.DownloadLocation.InError),
|
||||||
@ -98,15 +98,15 @@ namespace Wabbajack
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.ActiveCompilation = new MO2Compiler(this.Mo2Folder)
|
ActiveCompilation = new MO2Compiler(Mo2Folder)
|
||||||
{
|
{
|
||||||
MO2Profile = this.MOProfile,
|
MO2Profile = MOProfile,
|
||||||
ModListName = this.ModlistSettings.ModListName,
|
ModListName = ModlistSettings.ModListName,
|
||||||
ModListAuthor = this.ModlistSettings.AuthorText,
|
ModListAuthor = ModlistSettings.AuthorText,
|
||||||
ModListDescription = this.ModlistSettings.Description,
|
ModListDescription = ModlistSettings.Description,
|
||||||
ModListImage = this.ModlistSettings.ImagePath.TargetPath,
|
ModListImage = ModlistSettings.ImagePath.TargetPath,
|
||||||
ModListWebsite = this.ModlistSettings.Website,
|
ModListWebsite = ModlistSettings.Website,
|
||||||
ModListReadme = this.ModlistSettings.ReadMeText.TargetPath,
|
ModListReadme = ModlistSettings.ReadMeText.TargetPath,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -118,7 +118,7 @@ namespace Wabbajack
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await this.ActiveCompilation.Begin();
|
await ActiveCompilation.Begin();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -127,26 +127,26 @@ namespace Wabbajack
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
this.StatusTracker = null;
|
StatusTracker = null;
|
||||||
this.ActiveCompilation.Dispose();
|
ActiveCompilation.Dispose();
|
||||||
this.ActiveCompilation = null;
|
ActiveCompilation = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Load settings
|
// Load settings
|
||||||
this.settings = parent.MWVM.Settings.Compiler.MO2Compilation;
|
settings = parent.MWVM.Settings.Compiler.MO2Compilation;
|
||||||
this.ModlistLocation.TargetPath = settings.LastCompiledProfileLocation;
|
ModlistLocation.TargetPath = settings.LastCompiledProfileLocation;
|
||||||
if (!string.IsNullOrWhiteSpace(settings.DownloadLocation))
|
if (!string.IsNullOrWhiteSpace(settings.DownloadLocation))
|
||||||
{
|
{
|
||||||
this.DownloadLocation.TargetPath = settings.DownloadLocation;
|
DownloadLocation.TargetPath = settings.DownloadLocation;
|
||||||
}
|
}
|
||||||
parent.MWVM.Settings.SaveSignal
|
parent.MWVM.Settings.SaveSignal
|
||||||
.Subscribe(_ => Unload())
|
.Subscribe(_ => Unload())
|
||||||
.DisposeWith(this.CompositeDisposable);
|
.DisposeWith(CompositeDisposable);
|
||||||
|
|
||||||
// Load custom modlist settings per MO2 profile
|
// Load custom modlist settings per MO2 profile
|
||||||
this._ModlistSettings = Observable.CombineLatest(
|
_ModlistSettings = Observable.CombineLatest(
|
||||||
this.WhenAny(x => x.ModlistLocation.ErrorState),
|
this.WhenAny(x => x.ModlistLocation.ErrorState),
|
||||||
this.WhenAny(x => x.ModlistLocation.TargetPath),
|
this.WhenAny(x => x.ModlistLocation.TargetPath),
|
||||||
resultSelector: (State, Path) => (State, Path))
|
resultSelector: (State, Path) => (State, Path))
|
||||||
@ -158,7 +158,7 @@ namespace Wabbajack
|
|||||||
var modlistSettings = settings.ModlistSettings.TryCreate(u.Path);
|
var modlistSettings = settings.ModlistSettings.TryCreate(u.Path);
|
||||||
return new ModlistSettingsEditorVM(modlistSettings)
|
return new ModlistSettingsEditorVM(modlistSettings)
|
||||||
{
|
{
|
||||||
ModListName = this.MOProfile
|
ModListName = MOProfile
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
// Interject and save old while loading new
|
// Interject and save old while loading new
|
||||||
@ -171,7 +171,7 @@ namespace Wabbajack
|
|||||||
.Select(x => x.Current)
|
.Select(x => x.Current)
|
||||||
// Save to property
|
// Save to property
|
||||||
.ObserveOnGuiThread()
|
.ObserveOnGuiThread()
|
||||||
.ToProperty(this, nameof(this.ModlistSettings));
|
.ToProperty(this, nameof(ModlistSettings));
|
||||||
|
|
||||||
// If Mo2 folder changes and download location is empty, set it for convenience
|
// If Mo2 folder changes and download location is empty, set it for convenience
|
||||||
this.WhenAny(x => x.Mo2Folder)
|
this.WhenAny(x => x.Mo2Folder)
|
||||||
@ -184,22 +184,22 @@ namespace Wabbajack
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var tmp_compiler = new MO2Compiler(this.Mo2Folder);
|
var tmp_compiler = new MO2Compiler(Mo2Folder);
|
||||||
this.DownloadLocation.TargetPath = tmp_compiler.MO2DownloadsFolder;
|
DownloadLocation.TargetPath = tmp_compiler.MO2DownloadsFolder;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Utils.Log($"Error setting default download location {ex}");
|
Utils.Log($"Error setting default download location {ex}");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.DisposeWith(this.CompositeDisposable);
|
.DisposeWith(CompositeDisposable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Unload()
|
public void Unload()
|
||||||
{
|
{
|
||||||
settings.DownloadLocation = this.DownloadLocation.TargetPath;
|
settings.DownloadLocation = DownloadLocation.TargetPath;
|
||||||
settings.LastCompiledProfileLocation = this.ModlistLocation.TargetPath;
|
settings.LastCompiledProfileLocation = ModlistLocation.TargetPath;
|
||||||
this.ModlistSettings?.Save();
|
ModlistSettings?.Save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ namespace Wabbajack
|
|||||||
public ModlistSettingsEditorVM(CompilationModlistSettings settings)
|
public ModlistSettingsEditorVM(CompilationModlistSettings settings)
|
||||||
{
|
{
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
this.ImagePath = new FilePickerVM()
|
ImagePath = new FilePickerVM()
|
||||||
{
|
{
|
||||||
ExistCheckOption = FilePickerVM.ExistCheckOptions.IfNotEmpty,
|
ExistCheckOption = FilePickerVM.ExistCheckOptions.IfNotEmpty,
|
||||||
PathType = FilePickerVM.PathTypeOptions.File,
|
PathType = FilePickerVM.PathTypeOptions.File,
|
||||||
@ -36,7 +36,7 @@ namespace Wabbajack
|
|||||||
new CommonFileDialogFilter("Banner image", "*.png")
|
new CommonFileDialogFilter("Banner image", "*.png")
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.ReadMeText = new FilePickerVM()
|
ReadMeText = new FilePickerVM()
|
||||||
{
|
{
|
||||||
PathType = FilePickerVM.PathTypeOptions.File,
|
PathType = FilePickerVM.PathTypeOptions.File,
|
||||||
ExistCheckOption = FilePickerVM.ExistCheckOptions.IfNotEmpty,
|
ExistCheckOption = FilePickerVM.ExistCheckOptions.IfNotEmpty,
|
||||||
@ -45,25 +45,25 @@ namespace Wabbajack
|
|||||||
|
|
||||||
public void Init()
|
public void Init()
|
||||||
{
|
{
|
||||||
this.AuthorText = settings.Author;
|
AuthorText = settings.Author;
|
||||||
if (!string.IsNullOrWhiteSpace(settings.ModListName))
|
if (!string.IsNullOrWhiteSpace(settings.ModListName))
|
||||||
{
|
{
|
||||||
this.ModListName = settings.ModListName;
|
ModListName = settings.ModListName;
|
||||||
}
|
}
|
||||||
this.Description = settings.Description;
|
Description = settings.Description;
|
||||||
this.ReadMeText.TargetPath = settings.Readme;
|
ReadMeText.TargetPath = settings.Readme;
|
||||||
this.ImagePath.TargetPath = settings.SplashScreen;
|
ImagePath.TargetPath = settings.SplashScreen;
|
||||||
this.Website = settings.Website;
|
Website = settings.Website;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Save()
|
public void Save()
|
||||||
{
|
{
|
||||||
settings.Author = this.AuthorText;
|
settings.Author = AuthorText;
|
||||||
settings.ModListName = this.ModListName;
|
settings.ModListName = ModListName;
|
||||||
settings.Description = this.Description;
|
settings.Description = Description;
|
||||||
settings.Readme = this.ReadMeText.TargetPath;
|
settings.Readme = ReadMeText.TargetPath;
|
||||||
settings.SplashScreen = this.ImagePath.TargetPath;
|
settings.SplashScreen = ImagePath.TargetPath;
|
||||||
settings.Website = this.Website;
|
settings.Website = Website;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ namespace Wabbajack
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.ActiveCompilation = new VortexCompiler(
|
ActiveCompilation = new VortexCompiler(
|
||||||
SelectedGame.Game,
|
SelectedGame.Game,
|
||||||
GameLocation.TargetPath,
|
GameLocation.TargetPath,
|
||||||
VortexCompiler.TypicalVortexFolder(),
|
VortexCompiler.TypicalVortexFolder(),
|
||||||
@ -109,7 +109,7 @@ namespace Wabbajack
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await this.ActiveCompilation.Begin();
|
await ActiveCompilation.Begin();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -118,9 +118,9 @@ namespace Wabbajack
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
this.StatusTracker = null;
|
StatusTracker = null;
|
||||||
this.ActiveCompilation.Dispose();
|
ActiveCompilation.Dispose();
|
||||||
this.ActiveCompilation = null;
|
ActiveCompilation = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -169,7 +169,7 @@ namespace Wabbajack
|
|||||||
.DisposeWith(CompositeDisposable);
|
.DisposeWith(CompositeDisposable);
|
||||||
|
|
||||||
// Load custom ModList settings when game type changes
|
// Load custom ModList settings when game type changes
|
||||||
this._modListSettings = this.WhenAny(x => x.SelectedGame)
|
_modListSettings = this.WhenAny(x => x.SelectedGame)
|
||||||
.Select(game =>
|
.Select(game =>
|
||||||
{
|
{
|
||||||
var gameSettings = _settings.ModlistSettings.TryCreate(game.Game);
|
var gameSettings = _settings.ModlistSettings.TryCreate(game.Game);
|
||||||
|
@ -64,8 +64,8 @@ namespace Wabbajack
|
|||||||
|
|
||||||
public FilePickerVM(object parentVM = null)
|
public FilePickerVM(object parentVM = null)
|
||||||
{
|
{
|
||||||
this.Parent = parentVM;
|
Parent = parentVM;
|
||||||
this.SetTargetPathCommand = ConstructTypicalPickerCommand();
|
SetTargetPathCommand = ConstructTypicalPickerCommand();
|
||||||
|
|
||||||
// Check that file exists
|
// Check that file exists
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ namespace Wabbajack
|
|||||||
.Publish()
|
.Publish()
|
||||||
.RefCount();
|
.RefCount();
|
||||||
|
|
||||||
this._Exists = Observable.Interval(TimeSpan.FromSeconds(3))
|
_Exists = Observable.Interval(TimeSpan.FromSeconds(3))
|
||||||
// Only check exists on timer if desired
|
// Only check exists on timer if desired
|
||||||
.FilterSwitch(existsCheckTuple
|
.FilterSwitch(existsCheckTuple
|
||||||
.Select(t =>
|
.Select(t =>
|
||||||
@ -137,9 +137,9 @@ namespace Wabbajack
|
|||||||
.StartWith(false)
|
.StartWith(false)
|
||||||
.DistinctUntilChanged()
|
.DistinctUntilChanged()
|
||||||
.ObserveOn(RxApp.MainThreadScheduler)
|
.ObserveOn(RxApp.MainThreadScheduler)
|
||||||
.ToProperty(this, nameof(this.Exists));
|
.ToProperty(this, nameof(Exists));
|
||||||
|
|
||||||
this._ErrorState = Observable.CombineLatest(
|
_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")),
|
.Select(exists => ErrorResponse.Create(successful: exists, exists ? default(string) : "Path does not exist")),
|
||||||
this.WhenAny(x => x.AdditionalError)
|
this.WhenAny(x => x.AdditionalError)
|
||||||
@ -150,15 +150,15 @@ namespace Wabbajack
|
|||||||
if (exist.Failed) return exist;
|
if (exist.Failed) return exist;
|
||||||
return ErrorResponse.Convert(err);
|
return ErrorResponse.Convert(err);
|
||||||
})
|
})
|
||||||
.ToProperty(this, nameof(this.ErrorState));
|
.ToProperty(this, nameof(ErrorState));
|
||||||
|
|
||||||
this._InError = this.WhenAny(x => x.ErrorState)
|
_InError = this.WhenAny(x => x.ErrorState)
|
||||||
.Select(x => !x.Succeeded)
|
.Select(x => !x.Succeeded)
|
||||||
.ToProperty(this, nameof(this.InError));
|
.ToProperty(this, nameof(InError));
|
||||||
|
|
||||||
// Doesn't derive from ErrorState, as we want to bubble non-empty tooltips,
|
// Doesn't derive from ErrorState, as we want to bubble non-empty tooltips,
|
||||||
// which is slightly different logic
|
// which is slightly different logic
|
||||||
this._ErrorTooltip = Observable.CombineLatest(
|
_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"),
|
||||||
this.WhenAny(x => x.AdditionalError)
|
this.WhenAny(x => x.AdditionalError)
|
||||||
@ -169,7 +169,7 @@ namespace Wabbajack
|
|||||||
if (!string.IsNullOrWhiteSpace(exists)) return exists;
|
if (!string.IsNullOrWhiteSpace(exists)) return exists;
|
||||||
return err?.Reason;
|
return err?.Reason;
|
||||||
})
|
})
|
||||||
.ToProperty(this, nameof(this.ErrorTooltip));
|
.ToProperty(this, nameof(ErrorTooltip));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICommand ConstructTypicalPickerCommand()
|
public ICommand ConstructTypicalPickerCommand()
|
||||||
@ -178,22 +178,22 @@ namespace Wabbajack
|
|||||||
execute: () =>
|
execute: () =>
|
||||||
{
|
{
|
||||||
string dirPath;
|
string dirPath;
|
||||||
if (File.Exists(this.TargetPath))
|
if (File.Exists(TargetPath))
|
||||||
{
|
{
|
||||||
dirPath = System.IO.Path.GetDirectoryName(this.TargetPath);
|
dirPath = Path.GetDirectoryName(TargetPath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dirPath = this.TargetPath;
|
dirPath = TargetPath;
|
||||||
}
|
}
|
||||||
var dlg = new CommonOpenFileDialog
|
var dlg = new CommonOpenFileDialog
|
||||||
{
|
{
|
||||||
Title = this.PromptTitle,
|
Title = PromptTitle,
|
||||||
IsFolderPicker = this.PathType == PathTypeOptions.Folder,
|
IsFolderPicker = PathType == PathTypeOptions.Folder,
|
||||||
InitialDirectory = this.TargetPath,
|
InitialDirectory = TargetPath,
|
||||||
AddToMostRecentlyUsedList = false,
|
AddToMostRecentlyUsedList = false,
|
||||||
AllowNonFileSystemItems = false,
|
AllowNonFileSystemItems = false,
|
||||||
DefaultDirectory = this.TargetPath,
|
DefaultDirectory = TargetPath,
|
||||||
EnsureFileExists = true,
|
EnsureFileExists = true,
|
||||||
EnsurePathExists = true,
|
EnsurePathExists = true,
|
||||||
EnsureReadOnly = false,
|
EnsureReadOnly = false,
|
||||||
@ -201,12 +201,12 @@ namespace Wabbajack
|
|||||||
Multiselect = false,
|
Multiselect = false,
|
||||||
ShowPlacesList = true,
|
ShowPlacesList = true,
|
||||||
};
|
};
|
||||||
foreach (var filter in this.Filters)
|
foreach (var filter in Filters)
|
||||||
{
|
{
|
||||||
dlg.Filters.Add(filter);
|
dlg.Filters.Add(filter);
|
||||||
}
|
}
|
||||||
if (dlg.ShowDialog() != CommonFileDialogResult.Ok) return;
|
if (dlg.ShowDialog() != CommonFileDialogResult.Ok) return;
|
||||||
this.TargetPath = dlg.FileName;
|
TargetPath = dlg.FileName;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,8 @@ namespace Wabbajack
|
|||||||
|
|
||||||
public GameVM(Game game)
|
public GameVM(Game game)
|
||||||
{
|
{
|
||||||
this.Game = game;
|
Game = game;
|
||||||
this.DisplayName = game.ToDescriptionString();
|
DisplayName = game.ToDescriptionString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,57 +96,57 @@ namespace Wabbajack
|
|||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.MWVM = mainWindowVM;
|
MWVM = mainWindowVM;
|
||||||
this.ModListPath = source;
|
ModListPath = source;
|
||||||
|
|
||||||
this.Location = new FilePickerVM()
|
Location = new FilePickerVM()
|
||||||
{
|
{
|
||||||
ExistCheckOption = FilePickerVM.ExistCheckOptions.Off,
|
ExistCheckOption = FilePickerVM.ExistCheckOptions.Off,
|
||||||
PathType = FilePickerVM.PathTypeOptions.Folder,
|
PathType = FilePickerVM.PathTypeOptions.Folder,
|
||||||
PromptTitle = "Select Installation Directory",
|
PromptTitle = "Select Installation Directory",
|
||||||
};
|
};
|
||||||
this.Location.AdditionalError = this.WhenAny(x => x.Location.TargetPath)
|
Location.AdditionalError = this.WhenAny(x => x.Location.TargetPath)
|
||||||
.Select(x => Utils.IsDirectoryPathValid(x));
|
.Select(x => Utils.IsDirectoryPathValid(x));
|
||||||
this.DownloadLocation = new FilePickerVM()
|
DownloadLocation = new FilePickerVM()
|
||||||
{
|
{
|
||||||
ExistCheckOption = FilePickerVM.ExistCheckOptions.Off,
|
ExistCheckOption = FilePickerVM.ExistCheckOptions.Off,
|
||||||
PathType = FilePickerVM.PathTypeOptions.Folder,
|
PathType = FilePickerVM.PathTypeOptions.Folder,
|
||||||
PromptTitle = "Select a location for MO2 downloads",
|
PromptTitle = "Select a location for MO2 downloads",
|
||||||
};
|
};
|
||||||
this.DownloadLocation.AdditionalError = this.WhenAny(x => x.DownloadLocation.TargetPath)
|
DownloadLocation.AdditionalError = this.WhenAny(x => x.DownloadLocation.TargetPath)
|
||||||
.Select(x => Utils.IsDirectoryPathValid(x));
|
.Select(x => Utils.IsDirectoryPathValid(x));
|
||||||
|
|
||||||
// Load settings
|
// Load settings
|
||||||
ModlistInstallationSettings settings = this.MWVM.Settings.Installer.ModlistSettings.TryCreate(source);
|
ModlistInstallationSettings settings = MWVM.Settings.Installer.ModlistSettings.TryCreate(source);
|
||||||
this.Location.TargetPath = settings.InstallationLocation;
|
Location.TargetPath = settings.InstallationLocation;
|
||||||
this.DownloadLocation.TargetPath = settings.DownloadLocation;
|
DownloadLocation.TargetPath = settings.DownloadLocation;
|
||||||
this.MWVM.Settings.SaveSignal
|
MWVM.Settings.SaveSignal
|
||||||
.Subscribe(_ =>
|
.Subscribe(_ =>
|
||||||
{
|
{
|
||||||
settings.InstallationLocation = this.Location.TargetPath;
|
settings.InstallationLocation = Location.TargetPath;
|
||||||
settings.DownloadLocation = this.DownloadLocation.TargetPath;
|
settings.DownloadLocation = DownloadLocation.TargetPath;
|
||||||
})
|
})
|
||||||
.DisposeWith(this.CompositeDisposable);
|
.DisposeWith(CompositeDisposable);
|
||||||
|
|
||||||
this._ModList = this.WhenAny(x => x.ModListPath)
|
_ModList = this.WhenAny(x => x.ModListPath)
|
||||||
.ObserveOn(RxApp.TaskpoolScheduler)
|
.ObserveOn(RxApp.TaskpoolScheduler)
|
||||||
.Select(modListPath =>
|
.Select(modListPath =>
|
||||||
{
|
{
|
||||||
if (modListPath == null) return default(ModListVM);
|
if (modListPath == null) return default(ModListVM);
|
||||||
var modList = MO2Installer.LoadFromFile(modListPath);
|
var modList = AInstaller.LoadFromFile(modListPath);
|
||||||
if (modList == null)
|
if (modList == null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Invalid Modlist, or file not found.", "Invalid Modlist", MessageBoxButton.OK,
|
MessageBox.Show("Invalid Modlist, or file not found.", "Invalid Modlist", MessageBoxButton.OK,
|
||||||
MessageBoxImage.Error);
|
MessageBoxImage.Error);
|
||||||
Application.Current.Dispatcher.Invoke(() =>
|
Application.Current.Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
this.MWVM.MainWindow.ExitWhenClosing = false;
|
MWVM.MainWindow.ExitWhenClosing = false;
|
||||||
var window = new ModeSelectionWindow
|
var window = new ModeSelectionWindow
|
||||||
{
|
{
|
||||||
ShowActivated = true
|
ShowActivated = true
|
||||||
};
|
};
|
||||||
window.Show();
|
window.Show();
|
||||||
this.MWVM.MainWindow.Close();
|
MWVM.MainWindow.Close();
|
||||||
});
|
});
|
||||||
return default(ModListVM);
|
return default(ModListVM);
|
||||||
}
|
}
|
||||||
@ -154,11 +154,11 @@ namespace Wabbajack
|
|||||||
})
|
})
|
||||||
.ObserveOnGuiThread()
|
.ObserveOnGuiThread()
|
||||||
.StartWith(default(ModListVM))
|
.StartWith(default(ModListVM))
|
||||||
.ToProperty(this, nameof(this.ModList));
|
.ToProperty(this, nameof(ModList));
|
||||||
this._HTMLReport = this.WhenAny(x => x.ModList)
|
_HTMLReport = this.WhenAny(x => x.ModList)
|
||||||
.Select(modList => modList?.ReportHTML)
|
.Select(modList => modList?.ReportHTML)
|
||||||
.ToProperty(this, nameof(this.HTMLReport));
|
.ToProperty(this, nameof(HTMLReport));
|
||||||
this._ProgressPercent = Observable.CombineLatest(
|
_ProgressPercent = Observable.CombineLatest(
|
||||||
this.WhenAny(x => x.Installing),
|
this.WhenAny(x => x.Installing),
|
||||||
this.WhenAny(x => x.InstallingMode),
|
this.WhenAny(x => x.InstallingMode),
|
||||||
resultSelector: (installing, mode) => !installing && mode)
|
resultSelector: (installing, mode) => !installing && mode)
|
||||||
@ -166,13 +166,13 @@ namespace Wabbajack
|
|||||||
// Disable for now, until more reliable
|
// Disable for now, until more reliable
|
||||||
//this.WhenAny(x => x.MWVM.QueueProgress)
|
//this.WhenAny(x => x.MWVM.QueueProgress)
|
||||||
// .Select(i => i / 100f)
|
// .Select(i => i / 100f)
|
||||||
.ToProperty(this, nameof(this.ProgressPercent));
|
.ToProperty(this, nameof(ProgressPercent));
|
||||||
|
|
||||||
this.Slideshow = new SlideShow(this);
|
Slideshow = new SlideShow(this);
|
||||||
|
|
||||||
// Set display items to modlist if configuring or complete,
|
// Set display items to modlist if configuring or complete,
|
||||||
// or to the current slideshow data if installing
|
// or to the current slideshow data if installing
|
||||||
this._Image = Observable.CombineLatest(
|
_Image = Observable.CombineLatest(
|
||||||
this.WhenAny(x => x.ModList)
|
this.WhenAny(x => x.ModList)
|
||||||
.SelectMany(x => x?.ImageObservable ?? Observable.Empty<BitmapImage>())
|
.SelectMany(x => x?.ImageObservable ?? Observable.Empty<BitmapImage>())
|
||||||
.NotNull()
|
.NotNull()
|
||||||
@ -182,41 +182,41 @@ namespace Wabbajack
|
|||||||
this.WhenAny(x => x.Installing),
|
this.WhenAny(x => x.Installing),
|
||||||
resultSelector: (modList, slideshow, installing) => installing ? slideshow : modList)
|
resultSelector: (modList, slideshow, installing) => installing ? slideshow : modList)
|
||||||
.Select<BitmapImage, ImageSource>(x => x)
|
.Select<BitmapImage, ImageSource>(x => x)
|
||||||
.ToProperty(this, nameof(this.Image));
|
.ToProperty(this, nameof(Image));
|
||||||
this._TitleText = Observable.CombineLatest(
|
_TitleText = Observable.CombineLatest(
|
||||||
this.WhenAny(x => x.ModList.Name),
|
this.WhenAny(x => x.ModList.Name),
|
||||||
this.WhenAny(x => x.Slideshow.TargetMod.ModName)
|
this.WhenAny(x => x.Slideshow.TargetMod.ModName)
|
||||||
.StartWith(default(string)),
|
.StartWith(default(string)),
|
||||||
this.WhenAny(x => x.Installing),
|
this.WhenAny(x => x.Installing),
|
||||||
resultSelector: (modList, mod, installing) => installing ? mod : modList)
|
resultSelector: (modList, mod, installing) => installing ? mod : modList)
|
||||||
.ToProperty(this, nameof(this.TitleText));
|
.ToProperty(this, nameof(TitleText));
|
||||||
this._AuthorText = Observable.CombineLatest(
|
_AuthorText = Observable.CombineLatest(
|
||||||
this.WhenAny(x => x.ModList.Author),
|
this.WhenAny(x => x.ModList.Author),
|
||||||
this.WhenAny(x => x.Slideshow.TargetMod.ModAuthor)
|
this.WhenAny(x => x.Slideshow.TargetMod.ModAuthor)
|
||||||
.StartWith(default(string)),
|
.StartWith(default(string)),
|
||||||
this.WhenAny(x => x.Installing),
|
this.WhenAny(x => x.Installing),
|
||||||
resultSelector: (modList, mod, installing) => installing ? mod : modList)
|
resultSelector: (modList, mod, installing) => installing ? mod : modList)
|
||||||
.ToProperty(this, nameof(this.AuthorText));
|
.ToProperty(this, nameof(AuthorText));
|
||||||
this._Description = Observable.CombineLatest(
|
_Description = Observable.CombineLatest(
|
||||||
this.WhenAny(x => x.ModList.Description),
|
this.WhenAny(x => x.ModList.Description),
|
||||||
this.WhenAny(x => x.Slideshow.TargetMod.ModDescription)
|
this.WhenAny(x => x.Slideshow.TargetMod.ModDescription)
|
||||||
.StartWith(default(string)),
|
.StartWith(default(string)),
|
||||||
this.WhenAny(x => x.Installing),
|
this.WhenAny(x => x.Installing),
|
||||||
resultSelector: (modList, mod, installing) => installing ? mod : modList)
|
resultSelector: (modList, mod, installing) => installing ? mod : modList)
|
||||||
.ToProperty(this, nameof(this.Description));
|
.ToProperty(this, nameof(Description));
|
||||||
this._ModListName = this.WhenAny(x => x.ModList)
|
_ModListName = this.WhenAny(x => x.ModList)
|
||||||
.Select(x => x?.Name)
|
.Select(x => x?.Name)
|
||||||
.ToProperty(this, nameof(this.ModListName));
|
.ToProperty(this, nameof(ModListName));
|
||||||
|
|
||||||
// Define commands
|
// Define commands
|
||||||
this.ShowReportCommand = ReactiveCommand.Create(ShowReport);
|
ShowReportCommand = ReactiveCommand.Create(ShowReport);
|
||||||
this.OpenReadmeCommand = ReactiveCommand.Create(
|
OpenReadmeCommand = ReactiveCommand.Create(
|
||||||
execute: this.OpenReadmeWindow,
|
execute: OpenReadmeWindow,
|
||||||
canExecute: this.WhenAny(x => x.ModList)
|
canExecute: this.WhenAny(x => x.ModList)
|
||||||
.Select(modList => !string.IsNullOrEmpty(modList?.Readme))
|
.Select(modList => !string.IsNullOrEmpty(modList?.Readme))
|
||||||
.ObserveOnGuiThread());
|
.ObserveOnGuiThread());
|
||||||
this.BeginCommand = ReactiveCommand.Create(
|
BeginCommand = ReactiveCommand.Create(
|
||||||
execute: this.ExecuteBegin,
|
execute: ExecuteBegin,
|
||||||
canExecute: Observable.CombineLatest(
|
canExecute: Observable.CombineLatest(
|
||||||
this.WhenAny(x => x.Installing),
|
this.WhenAny(x => x.Installing),
|
||||||
this.WhenAny(x => x.Location.InError),
|
this.WhenAny(x => x.Location.InError),
|
||||||
@ -227,8 +227,8 @@ namespace Wabbajack
|
|||||||
return !loc && !download;
|
return !loc && !download;
|
||||||
})
|
})
|
||||||
.ObserveOnGuiThread());
|
.ObserveOnGuiThread());
|
||||||
this.VisitWebsiteCommand = ReactiveCommand.Create(
|
VisitWebsiteCommand = ReactiveCommand.Create(
|
||||||
execute: () => Process.Start(this.ModList.Website),
|
execute: () => Process.Start(ModList.Website),
|
||||||
canExecute: this.WhenAny(x => x.ModList.Website)
|
canExecute: this.WhenAny(x => x.ModList.Website)
|
||||||
.Select(x => x?.StartsWith("https://") ?? false)
|
.Select(x => x?.StartsWith("https://") ?? false)
|
||||||
.ObserveOnGuiThread());
|
.ObserveOnGuiThread());
|
||||||
@ -238,14 +238,14 @@ namespace Wabbajack
|
|||||||
.Skip(1) // Don't do it initially
|
.Skip(1) // Don't do it initially
|
||||||
.Subscribe(installPath =>
|
.Subscribe(installPath =>
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(this.DownloadLocation.TargetPath))
|
if (string.IsNullOrWhiteSpace(DownloadLocation.TargetPath))
|
||||||
{
|
{
|
||||||
this.DownloadLocation.TargetPath = Path.Combine(installPath, "downloads");
|
DownloadLocation.TargetPath = Path.Combine(installPath, "downloads");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.DisposeWith(this.CompositeDisposable);
|
.DisposeWith(CompositeDisposable);
|
||||||
|
|
||||||
this._ProgressTitle = Observable.CombineLatest(
|
_ProgressTitle = Observable.CombineLatest(
|
||||||
this.WhenAny(x => x.Installing),
|
this.WhenAny(x => x.Installing),
|
||||||
this.WhenAny(x => x.InstallingMode),
|
this.WhenAny(x => x.InstallingMode),
|
||||||
resultSelector: (installing, mode) =>
|
resultSelector: (installing, mode) =>
|
||||||
@ -253,7 +253,7 @@ namespace Wabbajack
|
|||||||
if (!installing) return "Configuring";
|
if (!installing) return "Configuring";
|
||||||
return mode ? "Installing" : "Installed";
|
return mode ? "Installing" : "Installed";
|
||||||
})
|
})
|
||||||
.ToProperty(this, nameof(this.ProgressTitle));
|
.ToProperty(this, nameof(ProgressTitle));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ShowReport()
|
private void ShowReport()
|
||||||
@ -265,15 +265,15 @@ namespace Wabbajack
|
|||||||
|
|
||||||
private void OpenReadmeWindow()
|
private void OpenReadmeWindow()
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(this.ModList.Readme)) return;
|
if (string.IsNullOrEmpty(ModList.Readme)) return;
|
||||||
using (var fs = new FileStream(this.ModListPath, FileMode.Open, FileAccess.Read, FileShare.Read))
|
using (var fs = new FileStream(ModListPath, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||||
using (var ar = new ZipArchive(fs, ZipArchiveMode.Read))
|
using (var ar = new ZipArchive(fs, ZipArchiveMode.Read))
|
||||||
using (var ms = new MemoryStream())
|
using (var ms = new MemoryStream())
|
||||||
{
|
{
|
||||||
var entry = ar.GetEntry(this.ModList.Readme);
|
var entry = ar.GetEntry(ModList.Readme);
|
||||||
if (entry == null)
|
if (entry == null)
|
||||||
{
|
{
|
||||||
Utils.Log($"Tried to open a non-existant readme: {this.ModList.Readme}");
|
Utils.Log($"Tried to open a non-existant readme: {ModList.Readme}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
using (var e = entry.Open())
|
using (var e = entry.Open())
|
||||||
@ -283,7 +283,7 @@ namespace Wabbajack
|
|||||||
ms.Seek(0, SeekOrigin.Begin);
|
ms.Seek(0, SeekOrigin.Begin);
|
||||||
using (var reader = new StreamReader(ms))
|
using (var reader = new StreamReader(ms))
|
||||||
{
|
{
|
||||||
var viewer = new TextViewer(reader.ReadToEnd(), this.ModList.Name);
|
var viewer = new TextViewer(reader.ReadToEnd(), ModList.Name);
|
||||||
viewer.Show();
|
viewer.Show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -291,9 +291,9 @@ namespace Wabbajack
|
|||||||
|
|
||||||
private void ExecuteBegin()
|
private void ExecuteBegin()
|
||||||
{
|
{
|
||||||
this.Installing = true;
|
Installing = true;
|
||||||
this.InstallingMode = true;
|
InstallingMode = true;
|
||||||
var installer = new MO2Installer(this.ModListPath, this.ModList.SourceModList, Location.TargetPath)
|
var installer = new MO2Installer(ModListPath, ModList.SourceModList, Location.TargetPath)
|
||||||
{
|
{
|
||||||
DownloadFolder = DownloadLocation.TargetPath
|
DownloadFolder = DownloadLocation.TargetPath
|
||||||
};
|
};
|
||||||
@ -306,7 +306,7 @@ namespace Wabbajack
|
|||||||
.EnsureUniqueChanges()
|
.EnsureUniqueChanges()
|
||||||
.ObserveOn(RxApp.MainThreadScheduler)
|
.ObserveOn(RxApp.MainThreadScheduler)
|
||||||
.Sort(SortExpressionComparer<CPUStatus>.Ascending(s => s.ID), SortOptimisations.ComparesImmutableValuesOnly)
|
.Sort(SortExpressionComparer<CPUStatus>.Ascending(s => s.ID), SortOptimisations.ComparesImmutableValuesOnly)
|
||||||
.Bind(this.MWVM.StatusList)
|
.Bind(MWVM.StatusList)
|
||||||
.Subscribe();
|
.Subscribe();
|
||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
@ -326,9 +326,9 @@ namespace Wabbajack
|
|||||||
{
|
{
|
||||||
// Dispose of CPU tracking systems
|
// Dispose of CPU tracking systems
|
||||||
subscription.Dispose();
|
subscription.Dispose();
|
||||||
this.MWVM.StatusList.Clear();
|
MWVM.StatusList.Clear();
|
||||||
|
|
||||||
this.Installing = false;
|
Installing = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using DynamicData;
|
using DynamicData;
|
||||||
using DynamicData.Binding;
|
using DynamicData.Binding;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using ReactiveUI.Fody.Helpers;
|
using ReactiveUI.Fody.Helpers;
|
||||||
@ -36,11 +36,11 @@ namespace Wabbajack
|
|||||||
|
|
||||||
public MainWindowVM(RunMode mode, string source, MainWindow mainWindow, MainSettings settings)
|
public MainWindowVM(RunMode mode, string source, MainWindow mainWindow, MainSettings settings)
|
||||||
{
|
{
|
||||||
this.Mode = mode;
|
Mode = mode;
|
||||||
this.MainWindow = mainWindow;
|
MainWindow = mainWindow;
|
||||||
this.Settings = settings;
|
Settings = settings;
|
||||||
this._Installer = new Lazy<InstallerVM>(() => new InstallerVM(this, source));
|
_Installer = new Lazy<InstallerVM>(() => new InstallerVM(this, source));
|
||||||
this._Compiler = new Lazy<CompilerVM>(() => new CompilerVM(this));
|
_Compiler = new Lazy<CompilerVM>(() => new CompilerVM(this));
|
||||||
|
|
||||||
// Set up logging
|
// Set up logging
|
||||||
Utils.LogMessages
|
Utils.LogMessages
|
||||||
@ -51,27 +51,27 @@ namespace Wabbajack
|
|||||||
.FlattenBufferResult()
|
.FlattenBufferResult()
|
||||||
.Top(5000)
|
.Top(5000)
|
||||||
.ObserveOn(RxApp.MainThreadScheduler)
|
.ObserveOn(RxApp.MainThreadScheduler)
|
||||||
.Bind(this.Log)
|
.Bind(Log)
|
||||||
.Subscribe()
|
.Subscribe()
|
||||||
.DisposeWith(this.CompositeDisposable);
|
.DisposeWith(CompositeDisposable);
|
||||||
|
|
||||||
// Wire mode to drive the active pane.
|
// Wire mode to drive the active pane.
|
||||||
// Note: This is currently made into a derivative property driven by mode,
|
// Note: This is currently made into a derivative property driven by mode,
|
||||||
// but it can be easily changed into a normal property that can be set from anywhere if needed
|
// but it can be easily changed into a normal property that can be set from anywhere if needed
|
||||||
this._ActivePane = this.WhenAny(x => x.Mode)
|
_ActivePane = this.WhenAny(x => x.Mode)
|
||||||
.Select<RunMode, ViewModel>(m =>
|
.Select<RunMode, ViewModel>(m =>
|
||||||
{
|
{
|
||||||
switch (m)
|
switch (m)
|
||||||
{
|
{
|
||||||
case RunMode.Compile:
|
case RunMode.Compile:
|
||||||
return this._Compiler.Value;
|
return _Compiler.Value;
|
||||||
case RunMode.Install:
|
case RunMode.Install:
|
||||||
return this._Installer.Value;
|
return _Installer.Value;
|
||||||
default:
|
default:
|
||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.ToProperty(this, nameof(this.ActivePane));
|
.ToProperty(this, nameof(ActivePane));
|
||||||
|
|
||||||
|
|
||||||
// Compile progress updates and populate ObservableCollection
|
// Compile progress updates and populate ObservableCollection
|
||||||
|
@ -32,7 +32,7 @@ namespace Wabbajack
|
|||||||
ModListPath = modListPath;
|
ModListPath = modListPath;
|
||||||
SourceModList = sourceModList;
|
SourceModList = sourceModList;
|
||||||
|
|
||||||
ImageObservable = Observable.Return(this.ImageURL)
|
ImageObservable = Observable.Return(ImageURL)
|
||||||
.ObserveOn(RxApp.TaskpoolScheduler)
|
.ObserveOn(RxApp.TaskpoolScheduler)
|
||||||
.Select(url =>
|
.Select(url =>
|
||||||
{
|
{
|
||||||
@ -41,7 +41,7 @@ namespace Wabbajack
|
|||||||
if (!File.Exists(url)) return default(MemoryStream);
|
if (!File.Exists(url)) return default(MemoryStream);
|
||||||
if (string.IsNullOrWhiteSpace(sourceModList.Image)) return default(MemoryStream);
|
if (string.IsNullOrWhiteSpace(sourceModList.Image)) return default(MemoryStream);
|
||||||
if (sourceModList.Image.Length != 36) return default(MemoryStream);
|
if (sourceModList.Image.Length != 36) return default(MemoryStream);
|
||||||
using (var fs = new FileStream(this.ModListPath, FileMode.Open, FileAccess.Read, FileShare.Read))
|
using (var fs = new FileStream(ModListPath, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||||
using (var ar = new ZipArchive(fs, ZipArchiveMode.Read))
|
using (var ar = new ZipArchive(fs, ZipArchiveMode.Read))
|
||||||
{
|
{
|
||||||
var ms = new MemoryStream();
|
var ms = new MemoryStream();
|
||||||
@ -55,7 +55,7 @@ namespace Wabbajack
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Utils.LogToFile($"Exception while caching Mod List image {this.Name}\n{ex.ExceptionToString()}");
|
Utils.LogToFile($"Exception while caching Mod List image {Name}\n{ex.ExceptionToString()}");
|
||||||
return default(MemoryStream);
|
return default(MemoryStream);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -74,7 +74,7 @@ namespace Wabbajack
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Utils.LogToFile($"Exception while caching Mod List image {this.Name}\n{ex.ExceptionToString()}");
|
Utils.LogToFile($"Exception while caching Mod List image {Name}\n{ex.ExceptionToString()}");
|
||||||
return default(BitmapImage);
|
return default(BitmapImage);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -35,14 +35,14 @@ namespace Wabbajack
|
|||||||
|
|
||||||
public ModVM(NexusDownloader.State m)
|
public ModVM(NexusDownloader.State m)
|
||||||
{
|
{
|
||||||
this.ModName = NexusApiUtils.FixupSummary(m.ModName);
|
ModName = NexusApiUtils.FixupSummary(m.ModName);
|
||||||
this.ModID = m.ModID;
|
ModID = m.ModID;
|
||||||
this.ModDescription = NexusApiUtils.FixupSummary(m.Summary);
|
ModDescription = NexusApiUtils.FixupSummary(m.Summary);
|
||||||
this.ModAuthor = NexusApiUtils.FixupSummary(m.Author);
|
ModAuthor = NexusApiUtils.FixupSummary(m.Author);
|
||||||
this.IsNSFW = m.Adult;
|
IsNSFW = m.Adult;
|
||||||
this.ModURL = m.NexusURL;
|
ModURL = m.NexusURL;
|
||||||
this.ImageURL = m.SlideShowPic;
|
ImageURL = m.SlideShowPic;
|
||||||
this.ImageObservable = Observable.Return(this.ImageURL)
|
ImageObservable = Observable.Return(ImageURL)
|
||||||
.ObserveOn(RxApp.TaskpoolScheduler)
|
.ObserveOn(RxApp.TaskpoolScheduler)
|
||||||
.SelectTask(async url =>
|
.SelectTask(async url =>
|
||||||
{
|
{
|
||||||
@ -59,7 +59,7 @@ namespace Wabbajack
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Utils.LogToFile($"Exception while caching slide {this.ModName} ({this.ModID})\n{ex.ExceptionToString()}");
|
Utils.LogToFile($"Exception while caching slide {ModName} ({ModID})\n{ex.ExceptionToString()}");
|
||||||
return default(MemoryStream);
|
return default(MemoryStream);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -79,7 +79,7 @@ namespace Wabbajack
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Utils.LogToFile($"Exception while caching slide {this.ModName} ({this.ModID})\n{ex.ExceptionToString()}");
|
Utils.LogToFile($"Exception while caching slide {ModName} ({ModID})\n{ex.ExceptionToString()}");
|
||||||
return default(BitmapImage);
|
return default(BitmapImage);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -22,9 +22,9 @@ namespace Wabbajack.UI
|
|||||||
|
|
||||||
public ModeSelectionWindowVM()
|
public ModeSelectionWindowVM()
|
||||||
{
|
{
|
||||||
this._CanInstall = this.WhenAny(x => x.SelectedModList)
|
_CanInstall = this.WhenAny(x => x.SelectedModList)
|
||||||
.Select(x => x != null)
|
.Select(x => x != null)
|
||||||
.ToProperty(this, nameof(this.CanInstall));
|
.ToProperty(this, nameof(CanInstall));
|
||||||
}
|
}
|
||||||
|
|
||||||
internal string Download()
|
internal string Download()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using DynamicData;
|
using DynamicData;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using ReactiveUI.Fody.Helpers;
|
using ReactiveUI.Fody.Helpers;
|
||||||
using System;
|
using System;
|
||||||
@ -35,20 +35,20 @@ namespace Wabbajack
|
|||||||
|
|
||||||
public SlideShow(InstallerVM appState)
|
public SlideShow(InstallerVM appState)
|
||||||
{
|
{
|
||||||
this.Installer = appState;
|
Installer = appState;
|
||||||
|
|
||||||
// Wire target slideshow index
|
// Wire target slideshow index
|
||||||
var intervalSeconds = 10;
|
var intervalSeconds = 10;
|
||||||
// Compile all the sources that trigger a slideshow update, any of which trigger a counter update
|
// Compile all the sources that trigger a slideshow update, any of which trigger a counter update
|
||||||
var selectedIndex = Observable.Merge(
|
var selectedIndex = Observable.Merge(
|
||||||
// If user requests one manually
|
// If user requests one manually
|
||||||
this.SlideShowNextItemCommand.StartingExecution(),
|
SlideShowNextItemCommand.StartingExecution(),
|
||||||
// If the natural timer fires
|
// If the natural timer fires
|
||||||
Observable.Merge(
|
Observable.Merge(
|
||||||
// Start with an initial timer
|
// Start with an initial timer
|
||||||
Observable.Return(Observable.Interval(TimeSpan.FromSeconds(intervalSeconds))),
|
Observable.Return(Observable.Interval(TimeSpan.FromSeconds(intervalSeconds))),
|
||||||
// but reset timer if user requests one
|
// but reset timer if user requests one
|
||||||
this.SlideShowNextItemCommand.StartingExecution()
|
SlideShowNextItemCommand.StartingExecution()
|
||||||
.Select(_ => Observable.Interval(TimeSpan.FromSeconds(intervalSeconds))))
|
.Select(_ => Observable.Interval(TimeSpan.FromSeconds(intervalSeconds))))
|
||||||
// When a new timer comes in, swap to it
|
// When a new timer comes in, swap to it
|
||||||
.Switch()
|
.Switch()
|
||||||
@ -84,34 +84,34 @@ namespace Wabbajack
|
|||||||
.OfType<NexusDownloader.State>()
|
.OfType<NexusDownloader.State>()
|
||||||
.Select(nexus => new ModVM(nexus))
|
.Select(nexus => new ModVM(nexus))
|
||||||
// Shuffle it
|
// Shuffle it
|
||||||
.Shuffle(this._random)
|
.Shuffle(_random)
|
||||||
.AsObservableChangeSet(x => x.ModID);
|
.AsObservableChangeSet(x => x.ModID);
|
||||||
})
|
})
|
||||||
// Switch to the new list after every modlist change
|
// Switch to the new list after every modlist change
|
||||||
.Switch()
|
.Switch()
|
||||||
// Filter out any NSFW slides if we don't want them
|
// Filter out any NSFW slides if we don't want them
|
||||||
.AutoRefreshOnObservable(slide => this.WhenAny(x => x.ShowNSFW))
|
.AutoRefreshOnObservable(slide => this.WhenAny(x => x.ShowNSFW))
|
||||||
.Filter(slide => !slide.IsNSFW || this.ShowNSFW)
|
.Filter(slide => !slide.IsNSFW || ShowNSFW)
|
||||||
.RefCount();
|
.RefCount();
|
||||||
|
|
||||||
// Find target mod to display by combining dynamic list with currently desired index
|
// Find target mod to display by combining dynamic list with currently desired index
|
||||||
this._TargetMod = Observable.CombineLatest(
|
_TargetMod = Observable.CombineLatest(
|
||||||
modVMs.QueryWhenChanged(),
|
modVMs.QueryWhenChanged(),
|
||||||
selectedIndex,
|
selectedIndex,
|
||||||
resultSelector: (query, selected) => query.Items.ElementAtOrDefault(selected % query.Count))
|
resultSelector: (query, selected) => query.Items.ElementAtOrDefault(selected % query.Count))
|
||||||
.StartWith(default(ModVM))
|
.StartWith(default(ModVM))
|
||||||
.ObserveOn(RxApp.MainThreadScheduler)
|
.ObserveOn(RxApp.MainThreadScheduler)
|
||||||
.ToProperty(this, nameof(this.TargetMod));
|
.ToProperty(this, nameof(TargetMod));
|
||||||
|
|
||||||
// Mark interest and materialize image of target mod
|
// Mark interest and materialize image of target mod
|
||||||
this._Image = this.WhenAny(x => x.TargetMod)
|
_Image = this.WhenAny(x => x.TargetMod)
|
||||||
// We want to Switch here, not SelectMany, as we want to hotswap to newest target without waiting on old ones
|
// We want to Switch here, not SelectMany, as we want to hotswap to newest target without waiting on old ones
|
||||||
.Select(x => x?.ImageObservable ?? Observable.Return(default(BitmapImage)))
|
.Select(x => x?.ImageObservable ?? Observable.Return(default(BitmapImage)))
|
||||||
.Switch()
|
.Switch()
|
||||||
.ToProperty(this, nameof(this.Image));
|
.ToProperty(this, nameof(Image));
|
||||||
|
|
||||||
this.VisitNexusSiteCommand = ReactiveCommand.Create(
|
VisitNexusSiteCommand = ReactiveCommand.Create(
|
||||||
execute: () => Process.Start(this.TargetMod.ModURL),
|
execute: () => Process.Start(TargetMod.ModURL),
|
||||||
canExecute: this.WhenAny(x => x.TargetMod.ModURL)
|
canExecute: this.WhenAny(x => x.TargetMod.ModURL)
|
||||||
.Select(x => x?.StartsWith("https://") ?? false)
|
.Select(x => x?.StartsWith("https://") ?? false)
|
||||||
.ObserveOnGuiThread());
|
.ObserveOnGuiThread());
|
||||||
@ -126,4 +126,4 @@ namespace Wabbajack
|
|||||||
// so at the boundary of a page, the next image won't be cached. Need like a Page() /w an offset parameter, or something.
|
// so at the boundary of a page, the next image won't be cached. Need like a Page() /w an offset parameter, or something.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,17 +64,17 @@ namespace Wabbajack
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
this._ShowAuthor = this.WhenAny(x => x.Author)
|
_ShowAuthor = this.WhenAny(x => x.Author)
|
||||||
.Select(x => !string.IsNullOrWhiteSpace(x))
|
.Select(x => !string.IsNullOrWhiteSpace(x))
|
||||||
.ToProperty(this, nameof(this.ShowAuthor));
|
.ToProperty(this, nameof(ShowAuthor));
|
||||||
|
|
||||||
this._ShowDescription = this.WhenAny(x => x.Description)
|
_ShowDescription = this.WhenAny(x => x.Description)
|
||||||
.Select(x => !string.IsNullOrWhiteSpace(x))
|
.Select(x => !string.IsNullOrWhiteSpace(x))
|
||||||
.ToProperty(this, nameof(this.ShowDescription));
|
.ToProperty(this, nameof(ShowDescription));
|
||||||
|
|
||||||
this._ShowTitle = this.WhenAny(x => x.Title)
|
_ShowTitle = this.WhenAny(x => x.Title)
|
||||||
.Select(x => !string.IsNullOrWhiteSpace(x))
|
.Select(x => !string.IsNullOrWhiteSpace(x))
|
||||||
.ToProperty(this, nameof(this.ShowTitle));
|
.ToProperty(this, nameof(ShowTitle));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ namespace Wabbajack
|
|||||||
|
|
||||||
private void Button_Click(object sender, RoutedEventArgs e)
|
private void Button_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
this.IsChecked = true;
|
IsChecked = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,8 @@ namespace Wabbajack
|
|||||||
|
|
||||||
if (args.Length != 3) return;
|
if (args.Length != 3) return;
|
||||||
var modlistPath = args[2];
|
var modlistPath = args[2];
|
||||||
this._settings = MainSettings.LoadSettings();
|
_settings = MainSettings.LoadSettings();
|
||||||
Initialize(RunMode.Install, modlistPath, this._settings);
|
Initialize(RunMode.Install, modlistPath, _settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MainWindow(RunMode mode, string source, MainSettings settings)
|
public MainWindow(RunMode mode, string source, MainSettings settings)
|
||||||
@ -32,10 +32,10 @@ namespace Wabbajack
|
|||||||
private void Initialize(RunMode mode, string source, MainSettings settings)
|
private void Initialize(RunMode mode, string source, MainSettings settings)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
this._settings = settings;
|
_settings = settings;
|
||||||
_mwvm = new MainWindowVM(mode, source, this, settings);
|
_mwvm = new MainWindowVM(mode, source, this, settings);
|
||||||
Utils.Log($"Wabbajack Build - {ThisAssembly.Git.Sha}");
|
Utils.Log($"Wabbajack Build - {ThisAssembly.Git.Sha}");
|
||||||
this.DataContext = _mwvm;
|
DataContext = _mwvm;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal bool ExitWhenClosing = true;
|
internal bool ExitWhenClosing = true;
|
||||||
@ -43,11 +43,11 @@ namespace Wabbajack
|
|||||||
private void Window_Closing(object sender, CancelEventArgs e)
|
private void Window_Closing(object sender, CancelEventArgs e)
|
||||||
{
|
{
|
||||||
_mwvm.Dispose();
|
_mwvm.Dispose();
|
||||||
MainSettings.SaveSettings(this._settings);
|
MainSettings.SaveSettings(_settings);
|
||||||
if (ExitWhenClosing)
|
if (ExitWhenClosing)
|
||||||
{
|
{
|
||||||
Application.Current.Shutdown();
|
Application.Current.Shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,8 +36,8 @@ namespace Wabbajack
|
|||||||
{
|
{
|
||||||
ShutdownOnClose = false;
|
ShutdownOnClose = false;
|
||||||
var window = new MainWindow(RunMode.Compile, null, settings);
|
var window = new MainWindow(RunMode.Compile, null, settings);
|
||||||
window.Left = this.Left;
|
window.Left = Left;
|
||||||
window.Top = this.Top;
|
window.Top = Top;
|
||||||
window.Show();
|
window.Show();
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
@ -65,8 +65,8 @@ namespace Wabbajack
|
|||||||
ShutdownOnClose = false;
|
ShutdownOnClose = false;
|
||||||
settings.Installer.LastInstalledListLocation = Path.GetDirectoryName(file);
|
settings.Installer.LastInstalledListLocation = Path.GetDirectoryName(file);
|
||||||
var window = new MainWindow(RunMode.Install, file, settings);
|
var window = new MainWindow(RunMode.Install, file, settings);
|
||||||
window.Left = this.Left;
|
window.Left = Left;
|
||||||
window.Top = this.Top;
|
window.Top = Top;
|
||||||
window.Show();
|
window.Show();
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ namespace Wabbajack
|
|||||||
protected static void WireNotifyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
protected static void WireNotifyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (!(d is UserControlRx control)) return;
|
if (!(d is UserControlRx control)) return;
|
||||||
if (object.Equals(e.OldValue, e.NewValue)) return;
|
if (Equals(e.OldValue, e.NewValue)) return;
|
||||||
control.RaisePropertyChanged(e.Property.Name);
|
control.RaisePropertyChanged(e.Property.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user