Skip to content

Commit 7aee0df

Browse files
committed
Bugfix for multi-launch UI freezes (Closes #941) (#943)
1 parent 5fcb231 commit 7aee0df

File tree

4 files changed

+30
-16
lines changed

4 files changed

+30
-16
lines changed

Daybreak/Controls/Templates/LaunchButtonTemplate.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ private async Task CheckGameState(CancellationToken cancellationToken)
131131
}
132132

133133
// If FocusView is disabled, don't initialize memory scanner, instead just allow the user to kill the game
134-
if (!this.liveOptions.Value.Enabled)
134+
if (!this.liveOptions.Value.Enabled ||
135+
!launcherViewContext.IsSelected)
135136
{
136137
this.GameRunning = false;
137138
this.CanLaunch = false;

Daybreak/Models/LauncherViewContext.cs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,37 @@
44
namespace Daybreak.Models;
55
public sealed class LauncherViewContext : INotifyPropertyChanged
66
{
7-
private bool canLaunch = false;
8-
private bool canKill = false;
9-
107
public event PropertyChangedEventHandler? PropertyChanged;
118

129
public LaunchConfigurationWithCredentials? Configuration { get; init; }
1310

11+
public bool IsSelected
12+
{
13+
get;
14+
set
15+
{
16+
field = value;
17+
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(this.IsSelected)));
18+
}
19+
} = false;
20+
1421
public bool CanLaunch
1522
{
16-
get => this.canLaunch;
23+
get;
1724
set
1825
{
19-
this.canLaunch = value;
26+
field = value;
2027
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(this.CanLaunch)));
2128
}
22-
}
29+
} = false;
2330

2431
public bool CanKill
2532
{
26-
get => this.canKill;
33+
get;
2734
set
2835
{
29-
this.canKill = value;
36+
field = value;
3037
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(this.CanKill)));
3138
}
32-
}
39+
} = false;
3340
}

Daybreak/Services/Scanner/GuildwarsMemoryReader.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,15 @@
2020
namespace Daybreak.Services.Scanner;
2121

2222
public sealed class GuildwarsMemoryReader(
23-
IApplicationLauncher applicationLauncher,
2423
IMemoryScanner memoryScanner,
2524
IMetricsService metricsService,
2625
ILogger<GuildwarsMemoryReader> logger) : IGuildwarsMemoryReader
2726
{
28-
private const int MaxTrapezoidCount = 1000000;
2927
private const int RetryInitializationCount = 5;
3028
private const string LatencyMeterName = "Memory Reader Latency";
3129
private const string LatencyMeterUnitsName = "Milliseconds";
3230
private const string LatencyMeterDescription = "Amount of milliseconds elapsed while reading memory. P95 aggregation";
3331

34-
private readonly IApplicationLauncher applicationLauncher = applicationLauncher.ThrowIfNull();
3532
private readonly IMemoryScanner memoryScanner = memoryScanner.ThrowIfNull();
3633
private readonly Histogram<double> latencyMeter = metricsService.ThrowIfNull().CreateHistogram<double>(LatencyMeterName, LatencyMeterUnitsName, LatencyMeterDescription, AggregationTypes.P95);
3734
private readonly ILogger<GuildwarsMemoryReader> logger = logger.ThrowIfNull();
@@ -745,10 +742,10 @@ private static PlayerInformation GetPlayerInformation(
745742
Primary = primaryProfession,
746743
Secondary = secondaryProfession,
747744
Attributes = attributes,
748-
Skills = skillContexts.Select(s =>
745+
Skills = [.. skillContexts.Select(s =>
749746
Skill.TryParse((int)s.Id, out var parsedSkill) ?
750747
parsedSkill :
751-
Skill.NoSkill).ToList()
748+
Skill.NoSkill)]
752749
};
753750
}
754751

Daybreak/Views/LauncherView.xaml.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,16 @@ private async Task SetLaunchButtonState()
189189
return;
190190
}
191191

192-
await this.Dispatcher.InvokeAsync(() => this.CanLaunch = this.LatestConfiguration.CanLaunch);
192+
await this.Dispatcher.InvokeAsync(() =>
193+
{
194+
foreach (var config in this.LaunchConfigurations)
195+
{
196+
config.IsSelected = false;
197+
}
198+
199+
this.LatestConfiguration.IsSelected = true;
200+
this.CanLaunch = this.LatestConfiguration.CanLaunch;
201+
});
193202
}
194203

195204
private async Task KillGuildWars()

0 commit comments

Comments
 (0)