Skip to content

Commit

Permalink
Support for GuildWars launch arguments (Closes #691) (#693)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexMacocian committed Apr 27, 2024
1 parent 5464091 commit 07d0631
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Daybreak/Models/LaunchConfigurations/LaunchConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public sealed class LaunchConfigurationWithCredentials : IEquatable<LaunchConfig
{
public string? Identifier { get; init; }
public string? ExecutablePath { get; set; }
public string? Arguments { get; set; }
public LoginCredentials? Credentials { get; set; }

public bool Equals(LaunchConfigurationWithCredentials? other)
Expand Down
5 changes: 5 additions & 0 deletions Daybreak/Services/ApplicationLauncher/ApplicationLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ public void RestartDaybreakAsNormalUser()
"\"Daybreak\""
};

foreach(var arg in launchConfigurationWithCredentials.Arguments?.Split(" ") ?? [])
{
args.Add(arg);
}

var mods = this.modsManager.GetMods().Where(m => m.IsEnabled && m.IsInstalled).ToList();
var disabledmods = this.modsManager.GetMods().Where(m => !m.IsEnabled && m.IsInstalled).ToList();
foreach(var mod in mods)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -149,7 +151,8 @@ private bool IsValidInternal(LaunchConfigurationWithCredentials launchConfigurat
{
Identifier = launchConfiguration.Identifier,
Credentials = credentials,
ExecutablePath = launchConfiguration.Executable
ExecutablePath = launchConfiguration.Executable,
Arguments = launchConfiguration.Arguments
};
}
}
13 changes: 13 additions & 0 deletions Daybreak/Views/Launch/LaunchConfigurationView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@
HorizontalContentAlignment="Center"
Text="{Binding Identifier}"/>
</Grid>
<Grid>
<TextBlock FontSize="16"
Text="Arguments: "
Foreground="{StaticResource MahApps.Brushes.ThemeForeground}"
VerticalAlignment="Center"/>
<TextBox FontSize="16"
Foreground="{StaticResource MahApps.Brushes.ThemeForeground}"
Margin="200, 0, 0, 0"
Height="40"
VerticalContentAlignment="Center"
HorizontalContentAlignment="Center"
Text="{Binding ElementName=_this, Path=LaunchArguments, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
</Grid>
<Grid>
<TextBlock Text="Selected credentials: " FontSize="16"
VerticalAlignment="Center"
Expand Down
8 changes: 8 additions & 0 deletions Daybreak/Views/Launch/LaunchConfigurationView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public partial class LaunchConfigurationView : UserControl
private LoginCredentials selectedCredentials = default!;
[GenerateDependencyProperty]
private string selectedPath = default!;
[GenerateDependencyProperty]
private string launchArguments = default!;

public ObservableCollection<LoginCredentials> Credentials { get; set; } = [];
public ObservableCollection<string> ExecutablePaths { get; set; } = [];
Expand Down Expand Up @@ -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)
Expand All @@ -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(
Expand Down

0 comments on commit 07d0631

Please sign in to comment.