Skip to content

Commit 67756db

Browse files
authored
Launch button improvements (Closes #1086 #1114) (#1122)
1 parent 850a281 commit 67756db

9 files changed

Lines changed: 87 additions & 5 deletions

File tree

Daybreak.Shared/Models/LaunchConfigurations/LaunchConfiguration.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ namespace Daybreak.Shared.Models.LaunchConfigurations;
44

55
public sealed class LaunchConfiguration
66
{
7+
[JsonProperty(nameof(Name))]
8+
public string? Name { get; set; }
9+
710
[JsonProperty(nameof(Identifier))]
811
public string? Identifier { get; set; }
912

Daybreak.Shared/Models/LaunchConfigurations/LaunchConfigurationWithCredentials.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
public sealed class LaunchConfigurationWithCredentials : IEquatable<LaunchConfigurationWithCredentials>
44
{
55
public string? Identifier { get; init; }
6+
public string? Name { get; set; }
67
public string? ExecutablePath { get; set; }
78
public string? Arguments { get; set; }
89
public LoginCredentials? Credentials { get; set; }
@@ -16,7 +17,8 @@ public bool Equals(LaunchConfigurationWithCredentials? other)
1617

1718
return this?.Identifier?.Equals(other?.Identifier) is true &&
1819
this?.ExecutablePath?.Equals(other?.ExecutablePath) is not false && //ExecutablePath can be null, so in that case the comparison returns null
19-
this?.Credentials?.Equals(other?.Credentials) is true;
20+
this?.Credentials?.Equals(other?.Credentials) is true &&
21+
this?.Name?.Equals(other?.Name) is true;
2022
}
2123

2224
public override bool Equals(object? obj)

Daybreak/Services/LaunchConfigurations/LaunchConfigurationService.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ private bool SaveConfigurationInternal(LaunchConfigurationWithCredentials launch
9999
if (configs.FirstOrDefault(c => c.Identifier == launchConfigurationWithCredentials.Identifier) is
100100
LaunchConfiguration config)
101101
{
102+
config.Name = launchConfigurationWithCredentials.Name;
102103
config.Identifier = launchConfigurationWithCredentials.Identifier;
103104
config.CredentialsIdentifier = launchConfigurationWithCredentials.Credentials?.Identifier;
104105
config.Executable = launchConfigurationWithCredentials.ExecutablePath;
@@ -110,6 +111,7 @@ private bool SaveConfigurationInternal(LaunchConfigurationWithCredentials launch
110111

111112
configs.Add(new LaunchConfiguration
112113
{
114+
Name = launchConfigurationWithCredentials.Name,
113115
CredentialsIdentifier = launchConfigurationWithCredentials.Credentials?.Identifier,
114116
Executable = launchConfigurationWithCredentials.ExecutablePath,
115117
Identifier = launchConfigurationWithCredentials.Identifier,
@@ -138,7 +140,8 @@ private bool IsValidInternal(LaunchConfigurationWithCredentials launchConfigurat
138140
Identifier = launchConfiguration.Identifier,
139141
Credentials = credentials,
140142
ExecutablePath = launchConfiguration.Executable,
141-
Arguments = launchConfiguration.Arguments
143+
Arguments = launchConfiguration.Arguments,
144+
Name = launchConfiguration.Name
142145
};
143146
}
144147
}

Daybreak/Views/LaunchConfigurationsView.razor

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,21 @@
2929
</FluentTextField>
3030
</div>
3131
</div>
32+
<div class="launch-config-name">
33+
<div class="launch-config-name-label">
34+
<FluentLabel>Name</FluentLabel>
35+
</div>
36+
<div class="launch-config-name-field">
37+
<FluentTextField Value="@config.Name"
38+
ValueChanged="@((newValue) => this.ViewModel.CustomNameChanged(config, newValue))"
39+
Spellcheck="false"
40+
Immediate="true"
41+
ImmediateDelay="500"
42+
InputMode="InputMode.Text"
43+
AutoComplete="false"
44+
Placeholder="Custom name" />
45+
</div>
46+
</div>
3247
<div class="launch-config-executable">
3348
<div class="launch-config-executable-label">
3449
<FluentLabel>Executable</FluentLabel>

Daybreak/Views/LaunchConfigurationsView.razor.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,10 @@ public void DeleteLaunchConfiguration(LaunchConfigurationWithCredentials configu
7171
this.launchConfigurationService.DeleteConfiguration(configuration);
7272
this.LaunchConfigurations.Remove(configuration);
7373
}
74+
75+
public void CustomNameChanged(LaunchConfigurationWithCredentials configuration, string newName)
76+
{
77+
configuration.Name = newName;
78+
this.launchConfigurationService.SaveConfiguration(configuration);
79+
}
7480
}

Daybreak/Views/LaunchConfigurationsView.razor.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
.launch-config-identifier,
4141
.launch-config-executable,
4242
.launch-config-credentials,
43+
.launch-config-name,
4344
.launch-config-args {
4445
display: flex;
4546
flex-direction: row;
@@ -52,13 +53,15 @@
5253
.launch-config-identifier-label,
5354
.launch-config-executable-label,
5455
.launch-config-credentials-label,
56+
.launch-config-name-label,
5557
.launch-config-args-label {
5658
width: 250px;
5759
}
5860

5961
.launch-config-identifier-field,
6062
.launch-config-executable-field,
6163
.launch-config-credentials-field,
64+
.launch-config-name-field,
6265
.launch-config-args-field {
6366
width: 50%;
6467
}
@@ -67,13 +70,15 @@
6770
.launch-config-identifier-label ::deep *,
6871
.launch-config-executable-label ::deep *,
6972
.launch-config-credentials-label ::deep *,
73+
.launch-config-name-label ::deep *,
7074
.launch-config-args-label ::deep * {
7175
font-size: var(--font-size-large) !important;
7276
}
7377

7478
.launch-config-identifier-field ::deep fluent-text-field,
7579
.launch-config-executable-field ::deep fluent-text-field,
7680
.launch-config-credentials-field ::deep fluent-text-field,
81+
.launch-config-name-field ::deep fluent-text-field,
7782
.launch-config-args-field ::deep fluent-text-field {
7883
width: 100%;
7984
box-sizing: border-box !important;
@@ -83,6 +88,7 @@
8388
.launch-config-identifier-field ::deep fluent-select,
8489
.launch-config-executable-field ::deep fluent-select,
8590
.launch-config-credentials-field ::deep fluent-select,
91+
.launch-config-name-field ::deep fluent-select,
8692
.launch-config-args-field ::deep fluent-select {
8793
width: 100%;
8894
box-sizing: border-box !important;

Daybreak/Views/LaunchView.razor

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@
1515
{
1616
<div class="spinner" />
1717
}
18-
<span class="launch-text">@this.ViewModel.LaunchButtonText</span>
18+
<div class="launch-text-container">
19+
<span class="launch-text">@this.ViewModel.LaunchButtonText</span>
20+
@if (!string.IsNullOrEmpty(this.ViewModel.LaunchButtonSubtext))
21+
{
22+
<span class="launch-subtext">@this.ViewModel.LaunchButtonSubtext</span>
23+
}
24+
</div>
1925
</div>
2026
</button>
2127

@@ -36,7 +42,11 @@
3642
<div class="dropdown-item @(config == ViewModel.SelectedConfiguration ? "selected" : "")"
3743
@onclick="() => this.ViewModel.SelectConfiguration(config)">
3844
<div class="config-info">
39-
<div class="config-name">@(config.Configuration?.Credentials?.Username ?? "Unknown User")</div>
45+
<div class="config-name">@(config.Configuration?.Name ?? config.Configuration?.Credentials?.Username ?? "Unknown User")</div>
46+
@if (!string.IsNullOrEmpty(config.Configuration?.ExecutablePath))
47+
{
48+
<div class="config-path">@config.Configuration.ExecutablePath</div>
49+
}
4050
</div>
4151
</div>
4252
}

Daybreak/Views/LaunchView.razor.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ public bool IsDropdownOpen
108108

109109
public string LaunchButtonText => this.GetLaunchButtonText();
110110

111+
public string LaunchButtonSubtext => this.GetLaunchButtonSubtext();
112+
111113
public override ValueTask ParametersSet(LaunchView view, CancellationToken cancellationToken)
112114
{
113115
if (!this.IsOnboarded())
@@ -306,7 +308,9 @@ private void UpdateCanLaunch()
306308

307309
private string GetLaunchButtonText()
308310
{
309-
var configName = this.SelectedConfiguration?.Configuration?.Credentials?.Username ?? "Guild Wars";
311+
var configName = this.SelectedConfiguration?.Configuration?.Name ??
312+
this.SelectedConfiguration?.Configuration?.Credentials?.Username ??
313+
"Guild Wars";
310314
if (this.IsLaunching)
311315
{
312316
return "Launching...";
@@ -325,6 +329,22 @@ private string GetLaunchButtonText()
325329
return $"Launch {configName}";
326330
}
327331

332+
private string GetLaunchButtonSubtext()
333+
{
334+
var configName = this.SelectedConfiguration?.Configuration?.Name;
335+
if (this.IsLaunching)
336+
{
337+
return string.Empty;
338+
}
339+
340+
if (configName is not null)
341+
{
342+
return string.Empty;
343+
}
344+
345+
return this.SelectedConfiguration?.Configuration?.ExecutablePath ?? string.Empty;
346+
}
347+
328348
private void KillGuildWars()
329349
{
330350
if (this.SelectedConfiguration?.AppContext is null)

Daybreak/Views/LaunchView.razor.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,17 @@
5959
color: var(--foreground-on-accent-rest)
6060
}
6161

62+
.launch-text-container {
63+
display: flex;
64+
flex-direction: column;
65+
align-items: center;
66+
gap: 0.25rem;
67+
}
68+
69+
.launch-subtext {
70+
font-size: var(--font-size-small);
71+
}
72+
6273
.dropdown-toggle-button {
6374
padding: 1rem 0.75rem;
6475
border: none;
@@ -138,6 +149,12 @@
138149
margin-bottom: 0.25rem;
139150
}
140151

152+
.config-path {
153+
font-size: var(--font-size-small);
154+
color: var(--accent-foreground-rest);
155+
margin-bottom: 0.25rem;
156+
}
157+
141158
.dropdown-backdrop {
142159
position: fixed;
143160
top: 0;

0 commit comments

Comments
 (0)