From 07d06313d9364a59596541dcbc595fdb103712bf Mon Sep 17 00:00:00 2001 From: Macocian Alexandru Victor Date: Sat, 27 Apr 2024 13:34:26 +0200 Subject: [PATCH] Support for GuildWars launch arguments (Closes #691) (#693) --- .../LaunchConfigurations/LaunchConfiguration.cs | 3 +++ .../LaunchConfigurationWithCredentials.cs | 1 + .../ApplicationLauncher/ApplicationLauncher.cs | 5 +++++ .../LaunchConfigurationService.cs | 7 +++++-- Daybreak/Views/Launch/LaunchConfigurationView.xaml | 13 +++++++++++++ .../Views/Launch/LaunchConfigurationView.xaml.cs | 8 ++++++++ 6 files changed, 35 insertions(+), 2 deletions(-) diff --git a/Daybreak/Models/LaunchConfigurations/LaunchConfiguration.cs b/Daybreak/Models/LaunchConfigurations/LaunchConfiguration.cs index c6437a30..a7ac33f2 100644 --- a/Daybreak/Models/LaunchConfigurations/LaunchConfiguration.cs +++ b/Daybreak/Models/LaunchConfigurations/LaunchConfiguration.cs @@ -10,6 +10,9 @@ public sealed class LaunchConfiguration [JsonProperty(nameof(Executable))] public string? Executable { get; set; } + [JsonProperty(nameof(Arguments))] + public string? Arguments { get; set; } + [JsonProperty(nameof(CredentialsIdentifier))] public string? CredentialsIdentifier { get; set; } } diff --git a/Daybreak/Models/LaunchConfigurations/LaunchConfigurationWithCredentials.cs b/Daybreak/Models/LaunchConfigurations/LaunchConfigurationWithCredentials.cs index e752dc66..3c50dabe 100644 --- a/Daybreak/Models/LaunchConfigurations/LaunchConfigurationWithCredentials.cs +++ b/Daybreak/Models/LaunchConfigurations/LaunchConfigurationWithCredentials.cs @@ -6,6 +6,7 @@ public sealed class LaunchConfigurationWithCredentials : IEquatable m.IsEnabled && m.IsInstalled).ToList(); var disabledmods = this.modsManager.GetMods().Where(m => !m.IsEnabled && m.IsInstalled).ToList(); foreach(var mod in mods) diff --git a/Daybreak/Services/LaunchConfigurations/LaunchConfigurationService.cs b/Daybreak/Services/LaunchConfigurations/LaunchConfigurationService.cs index d2779db4..9cf085ca 100644 --- a/Daybreak/Services/LaunchConfigurations/LaunchConfigurationService.cs +++ b/Daybreak/Services/LaunchConfigurations/LaunchConfigurationService.cs @@ -117,6 +117,7 @@ private bool SaveConfigurationInternal(LaunchConfigurationWithCredentials launch config.Identifier = launchConfigurationWithCredentials.Identifier; config.CredentialsIdentifier = launchConfigurationWithCredentials.Credentials!.Identifier; config.Executable = launchConfigurationWithCredentials.ExecutablePath; + config.Arguments = launchConfigurationWithCredentials.Arguments; this.liveUpdateableOptions.Value.LaunchConfigurations = configs; this.liveUpdateableOptions.UpdateOption(); return true; @@ -126,7 +127,8 @@ private bool SaveConfigurationInternal(LaunchConfigurationWithCredentials launch { CredentialsIdentifier = launchConfigurationWithCredentials.Credentials!.Identifier, Executable = launchConfigurationWithCredentials.ExecutablePath, - Identifier = launchConfigurationWithCredentials.Identifier + Identifier = launchConfigurationWithCredentials.Identifier, + Arguments = launchConfigurationWithCredentials.Arguments, }); this.liveUpdateableOptions.Value.LaunchConfigurations = configs; this.liveUpdateableOptions.UpdateOption(); @@ -149,7 +151,8 @@ private bool IsValidInternal(LaunchConfigurationWithCredentials launchConfigurat { Identifier = launchConfiguration.Identifier, Credentials = credentials, - ExecutablePath = launchConfiguration.Executable + ExecutablePath = launchConfiguration.Executable, + Arguments = launchConfiguration.Arguments }; } } diff --git a/Daybreak/Views/Launch/LaunchConfigurationView.xaml b/Daybreak/Views/Launch/LaunchConfigurationView.xaml index 6cf005a3..9a29a4b3 100644 --- a/Daybreak/Views/Launch/LaunchConfigurationView.xaml +++ b/Daybreak/Views/Launch/LaunchConfigurationView.xaml @@ -40,6 +40,19 @@ HorizontalContentAlignment="Center" Text="{Binding Identifier}"/> + + + + Credentials { get; set; } = []; public ObservableCollection ExecutablePaths { get; set; } = []; @@ -66,6 +68,11 @@ private void UserControl_Loaded(object sender, System.Windows.RoutedEventArgs e) { this.SelectedPath = config.ExecutablePath; } + + if (config.Arguments?.IsNullOrWhiteSpace() is false) + { + this.LaunchArguments = config.Arguments; + } } private void BackButton_Clicked(object sender, EventArgs e) @@ -82,6 +89,7 @@ private void SaveButton_Clicked(object sender, EventArgs e) config.Credentials = this.SelectedCredentials; config.ExecutablePath = this.SelectedPath; + config.Arguments = this.LaunchArguments; if (!this.launchConfigurationService.SaveConfiguration(config)) { this.notificationService.NotifyInformation(