Skip to content

Commit

Permalink
misc: 尝试解决切换歌曲时物件分布表闪烁的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
MATRIX-feather committed Feb 27, 2024
1 parent cd1925c commit 99c77d0
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void UpdateStrain(WorkingBeatmap workingBeatmap)
ppStrainCancellationTokenSource?.Cancel();
ppStrainCancellationTokenSource = new CancellationTokenSource();

Task.Run(async () => await updateStrain(workingBeatmap), ppStrainCancellationTokenSource.Token)
Task.Run(async () => await updateStrain(workingBeatmap, Hub.GetDataRoot().MenuValues.PP.Strains), ppStrainCancellationTokenSource.Token)
.ContinueWith(task =>
{
if (!task.IsCompleted) return;
Expand All @@ -84,8 +84,10 @@ public void UpdateStrain(WorkingBeatmap workingBeatmap)
[Resolved]
private Bindable<RulesetInfo> globalRuleset { get; set; } = null!;

private Task<float[]> updateStrain(WorkingBeatmap workingBeatmap)
private Task<float[]> updateStrain(WorkingBeatmap workingBeatmap, float[]? defaultVal = null)
{
defaultVal ??= new[] { 0f };

try
{
double length = workingBeatmap.Track.Length;
Expand All @@ -97,14 +99,12 @@ private Task<float[]> updateStrain(WorkingBeatmap workingBeatmap)
//todo: 没有音频的时候使用谱面长度来计算并更新分布和进度
if (Clock.CurrentTime - invokeTime >= 10 * 1000)
{
Hub.GetDataRoot().MenuValues.PP.Strains = new[] { 0f };

Logging.Log("谱面音频在10秒内都没有加载,将放弃计算物件分布...", level: LogLevel.Important);
return Task.FromResult(new[] { 0f });
}

scheduleStrainComputes = true;
return Task.FromResult(new [] { 0f });
return Task.FromResult(defaultVal);
}

scheduleStrainComputes = false;
Expand Down

0 comments on commit 99c77d0

Please sign in to comment.