From 01efb28fc967772acf50da3a070dd14993335e38 Mon Sep 17 00:00:00 2001 From: Screen Date: Wed, 6 Mar 2024 16:25:48 +0000 Subject: [PATCH] added autorun command, closed #132 --- .../Patch/Patchers/Skyrim/SkyrimPatcher.cs | 2 +- PandoraPlus/MVVM/ViewModel/EngineViewModel.cs | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/PandoraPlus/MVVM/Model/Patch/Patchers/Skyrim/SkyrimPatcher.cs b/PandoraPlus/MVVM/Model/Patch/Patchers/Skyrim/SkyrimPatcher.cs index 0048727..ce1af47 100644 --- a/PandoraPlus/MVVM/Model/Patch/Patchers/Skyrim/SkyrimPatcher.cs +++ b/PandoraPlus/MVVM/Model/Patch/Patchers/Skyrim/SkyrimPatcher.cs @@ -33,7 +33,7 @@ public class SkyrimPatcher : IPatcher public IPatcher.PatcherFlags Flags { get; private set; } = IPatcher.PatcherFlags.None; - private static readonly Version currentVersion = new Version(1, 1, 6); + private static readonly Version currentVersion = new Version(1, 2, 0); private static readonly string versionLabel = "alpha"; public string GetVersionString() => $"{currentVersion.ToString()}-{versionLabel}"; diff --git a/PandoraPlus/MVVM/ViewModel/EngineViewModel.cs b/PandoraPlus/MVVM/ViewModel/EngineViewModel.cs index 81084b8..4acde95 100644 --- a/PandoraPlus/MVVM/ViewModel/EngineViewModel.cs +++ b/PandoraPlus/MVVM/ViewModel/EngineViewModel.cs @@ -26,12 +26,14 @@ public class EngineViewModel : INotifyPropertyChanged private readonly PandoraModInfoProvider pandoraModInfoProvider = new PandoraModInfoProvider(); private string logText = ""; + private HashSet startupArguments = new(StringComparer.OrdinalIgnoreCase); public event PropertyChangedEventHandler? PropertyChanged; private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); public bool? DialogResult { get; set; } = true; + public bool CloseOnFinish { get; } = false; public BehaviourEngine Engine { get; private set; } = new BehaviourEngine(); @@ -70,6 +72,7 @@ private void RaisePropertyChanged([CallerMemberName] string? propertyName=null) } public EngineViewModel() { + startupArguments = Environment.GetCommandLineArgs().ToHashSet(StringComparer.OrdinalIgnoreCase); LaunchCommand = new RelayCommand(LaunchEngine, CanLaunchEngine); ExitCommand = new RelayCommand(Exit); activeModConfig = new FileInfo($"{currentDirectory}\\Pandora_Engine\\ActiveMods.txt"); @@ -82,6 +85,12 @@ public EngineViewModel() CultureInfo.CurrentCulture = culture; preloadTask = Task.Run(Engine.PreloadAsync); + if (startupArguments.Contains("autorun")) + { + CloseOnFinish = true; + LaunchCommand.Execute(null); + } + } public async Task LoadAsync() { @@ -203,8 +212,6 @@ private async void LaunchEngine(object? parameter) engineRunning = true; LaunchEnabled = !engineRunning; } - - logText= string.Empty; @@ -244,7 +251,13 @@ private async void LaunchEngine(object? parameter) { await WriteLogBoxLine($"Launch finished in {Math.Round(timer.ElapsedMilliseconds / 1000.0, 2)} seconds"); await Task.Run(() => { SaveActiveMods(activeMods); }); + + if (CloseOnFinish) + { + System.Windows.Application.Current.Shutdown(); + } } +