mirror of
https://github.com/ppy/osu
synced 2025-01-10 16:19:47 +00:00
Show difficulty values inclusive of mods
This commit is contained in:
parent
1e2c1323ff
commit
400142545d
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
@ -19,6 +20,9 @@ using osu.Game.Graphics.Sprites;
|
|||||||
using osu.Game.Localisation;
|
using osu.Game.Localisation;
|
||||||
using osu.Game.Localisation.SkinComponents;
|
using osu.Game.Localisation.SkinComponents;
|
||||||
using osu.Game.Resources.Localisation.Web;
|
using osu.Game.Resources.Localisation.Web;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Utils;
|
||||||
|
|
||||||
namespace osu.Game.Skinning.Components
|
namespace osu.Game.Skinning.Components
|
||||||
{
|
{
|
||||||
@ -34,6 +38,12 @@ namespace osu.Game.Skinning.Components
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private IBindable<WorkingBeatmap> beatmap { get; set; } = null!;
|
private IBindable<WorkingBeatmap> beatmap { get; set; } = null!;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private IBindable<IReadOnlyList<Mod>> mods { get; set; } = null!;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private IBindable<RulesetInfo> ruleset { get; set; } = null!;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private BeatmapDifficultyCache difficultyCache { get; set; } = null!;
|
private BeatmapDifficultyCache difficultyCache { get; set; } = null!;
|
||||||
|
|
||||||
@ -74,6 +84,9 @@ namespace osu.Game.Skinning.Components
|
|||||||
updateText();
|
updateText();
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
|
mods.BindValueChanged(_ => updateText());
|
||||||
|
ruleset.BindValueChanged(_ => updateText());
|
||||||
|
|
||||||
updateText();
|
updateText();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,16 +190,16 @@ namespace osu.Game.Skinning.Components
|
|||||||
return beatmap.Value.BeatmapInfo.BPM.ToLocalisableString(@"F2");
|
return beatmap.Value.BeatmapInfo.BPM.ToLocalisableString(@"F2");
|
||||||
|
|
||||||
case BeatmapAttribute.CircleSize:
|
case BeatmapAttribute.CircleSize:
|
||||||
return ((double)beatmap.Value.BeatmapInfo.Difficulty.CircleSize).ToLocalisableString(@"F2");
|
return computeDifficulty().CircleSize.ToLocalisableString(@"F2");
|
||||||
|
|
||||||
case BeatmapAttribute.HPDrain:
|
case BeatmapAttribute.HPDrain:
|
||||||
return ((double)beatmap.Value.BeatmapInfo.Difficulty.DrainRate).ToLocalisableString(@"F2");
|
return computeDifficulty().DrainRate.ToLocalisableString(@"F2");
|
||||||
|
|
||||||
case BeatmapAttribute.Accuracy:
|
case BeatmapAttribute.Accuracy:
|
||||||
return ((double)beatmap.Value.BeatmapInfo.Difficulty.OverallDifficulty).ToLocalisableString(@"F2");
|
return computeDifficulty().OverallDifficulty.ToLocalisableString(@"F2");
|
||||||
|
|
||||||
case BeatmapAttribute.ApproachRate:
|
case BeatmapAttribute.ApproachRate:
|
||||||
return ((double)beatmap.Value.BeatmapInfo.Difficulty.ApproachRate).ToLocalisableString(@"F2");
|
return computeDifficulty().ApproachRate.ToLocalisableString(@"F2");
|
||||||
|
|
||||||
case BeatmapAttribute.StarRating:
|
case BeatmapAttribute.StarRating:
|
||||||
return difficultyBindable?.Value is StarDifficulty starDifficulty
|
return difficultyBindable?.Value is StarDifficulty starDifficulty
|
||||||
@ -196,6 +209,22 @@ namespace osu.Game.Skinning.Components
|
|||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BeatmapDifficulty computeDifficulty()
|
||||||
|
{
|
||||||
|
BeatmapDifficulty difficulty = new BeatmapDifficulty(beatmap.Value.BeatmapInfo.Difficulty);
|
||||||
|
|
||||||
|
foreach (var mod in mods.Value.OfType<IApplicableToDifficulty>())
|
||||||
|
mod.ApplyToDifficulty(difficulty);
|
||||||
|
|
||||||
|
if (ruleset.Value is RulesetInfo rulesetInfo)
|
||||||
|
{
|
||||||
|
double rate = ModUtils.CalculateRateWithMods(mods.Value);
|
||||||
|
difficulty = rulesetInfo.CreateInstance().GetRateAdjustedDisplayDifficulty(difficulty, rate);
|
||||||
|
}
|
||||||
|
|
||||||
|
return difficulty;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SetFont(FontUsage font) => text.Font = font.With(size: 40);
|
protected override void SetFont(FontUsage font) => text.Font = font.With(size: 40);
|
||||||
|
Loading…
Reference in New Issue
Block a user