mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 07:33:55 +09:00
Update beatmap details SR on ruleset/mod changes
This commit is contained in:
@ -14,10 +14,13 @@ using osu.Framework.Bindables;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Overlays.Settings;
|
using osu.Game.Overlays.Settings;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Select.Details
|
namespace osu.Game.Screens.Select.Details
|
||||||
{
|
{
|
||||||
@ -26,6 +29,12 @@ namespace osu.Game.Screens.Select.Details
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private IBindable<IReadOnlyList<Mod>> mods { get; set; }
|
private IBindable<IReadOnlyList<Mod>> mods { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private IBindable<RulesetInfo> ruleset { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private BeatmapDifficultyManager difficultyManager { get; set; }
|
||||||
|
|
||||||
protected readonly StatisticRow FirstValue, HpDrain, Accuracy, ApproachRate;
|
protected readonly StatisticRow FirstValue, HpDrain, Accuracy, ApproachRate;
|
||||||
private readonly StatisticRow starDifficulty;
|
private readonly StatisticRow starDifficulty;
|
||||||
|
|
||||||
@ -71,6 +80,7 @@ namespace osu.Game.Screens.Select.Details
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
|
ruleset.BindValueChanged(_ => updateStatistics());
|
||||||
mods.BindValueChanged(modsChanged, true);
|
mods.BindValueChanged(modsChanged, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,11 +142,33 @@ namespace osu.Game.Screens.Select.Details
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
starDifficulty.Value = ((float)(Beatmap?.StarDifficulty ?? 0), null);
|
|
||||||
|
|
||||||
HpDrain.Value = (baseDifficulty?.DrainRate ?? 0, adjustedDifficulty?.DrainRate);
|
HpDrain.Value = (baseDifficulty?.DrainRate ?? 0, adjustedDifficulty?.DrainRate);
|
||||||
Accuracy.Value = (baseDifficulty?.OverallDifficulty ?? 0, adjustedDifficulty?.OverallDifficulty);
|
Accuracy.Value = (baseDifficulty?.OverallDifficulty ?? 0, adjustedDifficulty?.OverallDifficulty);
|
||||||
ApproachRate.Value = (baseDifficulty?.ApproachRate ?? 0, adjustedDifficulty?.ApproachRate);
|
ApproachRate.Value = (baseDifficulty?.ApproachRate ?? 0, adjustedDifficulty?.ApproachRate);
|
||||||
|
|
||||||
|
updateStarDifficulty();
|
||||||
|
}
|
||||||
|
|
||||||
|
private CancellationTokenSource starDifficultyCancellationSource;
|
||||||
|
|
||||||
|
private void updateStarDifficulty()
|
||||||
|
{
|
||||||
|
starDifficultyCancellationSource?.Cancel();
|
||||||
|
|
||||||
|
if (Beatmap == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var ourSource = starDifficultyCancellationSource = new CancellationTokenSource();
|
||||||
|
|
||||||
|
Task.WhenAll(difficultyManager.GetDifficultyAsync(Beatmap, ruleset.Value, cancellationToken: ourSource.Token),
|
||||||
|
difficultyManager.GetDifficultyAsync(Beatmap, ruleset.Value, mods.Value, ourSource.Token)).ContinueWith(t =>
|
||||||
|
{
|
||||||
|
Schedule(() =>
|
||||||
|
{
|
||||||
|
if (!ourSource.IsCancellationRequested)
|
||||||
|
starDifficulty.Value = ((float)t.Result[0], (float)t.Result[1]);
|
||||||
|
});
|
||||||
|
}, ourSource.Token);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class StatisticRow : Container, IHasAccentColour
|
public class StatisticRow : Container, IHasAccentColour
|
||||||
|
Reference in New Issue
Block a user