Skip to content

Commit

Permalink
added autorun command, closed #132
Browse files Browse the repository at this point in the history
  • Loading branch information
Monitor221hz committed Mar 6, 2024
1 parent e962035 commit 01efb28
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}";
Expand Down
17 changes: 15 additions & 2 deletions PandoraPlus/MVVM/ViewModel/EngineViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ public class EngineViewModel : INotifyPropertyChanged
private readonly PandoraModInfoProvider pandoraModInfoProvider = new PandoraModInfoProvider();

private string logText = "";
private HashSet<string> 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();

Expand Down Expand Up @@ -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");
Expand All @@ -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()
{
Expand Down Expand Up @@ -203,8 +212,6 @@ private async void LaunchEngine(object? parameter)
engineRunning = true;
LaunchEnabled = !engineRunning;
}



logText= string.Empty;

Expand Down Expand Up @@ -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();
}
}




Expand Down

0 comments on commit 01efb28

Please sign in to comment.