1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-28 06:52:55 +08:00

Merge pull request #25760 from bdach/if-i-speak-i-am-in-big-trouble-pt-1

Fix `AdjustedAttributesTooltip` being broken by design
This commit is contained in:
Dean Herbert 2023-12-15 12:26:10 +09:00 committed by GitHub
commit 48e89b903c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 38 deletions

View File

@ -16,14 +16,13 @@ using osuTK;
namespace osu.Game.Overlays.Mods
{
public partial class AdjustedAttributesTooltip : VisibilityContainer, ITooltip
public partial class AdjustedAttributesTooltip : VisibilityContainer, ITooltip<AdjustedAttributesTooltip.Data?>
{
private FillFlowContainer attributesFillFlow = null!;
private Container content = null!;
private BeatmapDifficulty? originalDifficulty;
private BeatmapDifficulty? adjustedDifficulty;
private Data? data;
[Resolved]
private OsuColour colours { get; set; } = null!;
@ -73,26 +72,17 @@ namespace osu.Game.Overlays.Mods
updateDisplay();
}
public void UpdateAttributes(BeatmapDifficulty original, BeatmapDifficulty adjusted)
{
originalDifficulty = original;
adjustedDifficulty = adjusted;
if (IsLoaded)
updateDisplay();
}
private void updateDisplay()
{
attributesFillFlow.Clear();
if (originalDifficulty == null || adjustedDifficulty == null)
return;
attemptAdd("CS", bd => bd.CircleSize);
attemptAdd("HP", bd => bd.DrainRate);
attemptAdd("OD", bd => bd.OverallDifficulty);
attemptAdd("AR", bd => bd.ApproachRate);
if (data != null)
{
attemptAdd("CS", bd => bd.CircleSize);
attemptAdd("HP", bd => bd.DrainRate);
attemptAdd("OD", bd => bd.OverallDifficulty);
attemptAdd("AR", bd => bd.ApproachRate);
}
if (attributesFillFlow.Any())
content.Show();
@ -101,16 +91,21 @@ namespace osu.Game.Overlays.Mods
void attemptAdd(string name, Func<BeatmapDifficulty, double> lookup)
{
double a = lookup(originalDifficulty);
double b = lookup(adjustedDifficulty);
double originalValue = lookup(data.OriginalDifficulty);
double adjustedValue = lookup(data.AdjustedDifficulty);
if (!Precision.AlmostEquals(a, b))
attributesFillFlow.Add(new AttributeDisplay(name, a, b));
if (!Precision.AlmostEquals(originalValue, adjustedValue))
attributesFillFlow.Add(new AttributeDisplay(name, originalValue, adjustedValue));
}
}
public void SetContent(object content)
public void SetContent(Data? data)
{
if (this.data == data)
return;
this.data = data;
updateDisplay();
}
protected override void PopIn() => this.FadeIn(200, Easing.OutQuint);
@ -118,6 +113,18 @@ namespace osu.Game.Overlays.Mods
public void Move(Vector2 pos) => Position = pos;
public class Data
{
public BeatmapDifficulty OriginalDifficulty { get; }
public BeatmapDifficulty AdjustedDifficulty { get; }
public Data(BeatmapDifficulty originalDifficulty, BeatmapDifficulty adjustedDifficulty)
{
OriginalDifficulty = originalDifficulty;
AdjustedDifficulty = adjustedDifficulty;
}
}
private partial class AttributeDisplay : CompositeDrawable
{
public AttributeDisplay(string name, double original, double adjusted)

View File

@ -27,7 +27,7 @@ namespace osu.Game.Overlays.Mods
/// On the mod select overlay, this provides a local updating view of BPM, star rating and other
/// difficulty attributes so the user can have a better insight into what mods are changing.
/// </summary>
public partial class BeatmapAttributesDisplay : ModFooterInformationDisplay, IHasCustomTooltip
public partial class BeatmapAttributesDisplay : ModFooterInformationDisplay, IHasCustomTooltip<AdjustedAttributesTooltip.Data?>
{
private StarRatingDisplay starRatingDisplay = null!;
private BPMDisplay bpmDisplay = null!;
@ -57,11 +57,9 @@ namespace osu.Game.Overlays.Mods
private CancellationTokenSource? cancellationSource;
private IBindable<StarDifficulty?> starDifficulty = null!;
private AdjustedAttributesTooltip rateAdjustTooltip = null!;
public ITooltip<AdjustedAttributesTooltip.Data?> GetCustomTooltip() => new AdjustedAttributesTooltip();
public ITooltip GetCustomTooltip() => rateAdjustTooltip;
public object TooltipContent => this;
public AdjustedAttributesTooltip.Data? TooltipContent { get; private set; }
private const float transition_duration = 250;
@ -70,8 +68,6 @@ namespace osu.Game.Overlays.Mods
{
const float shear = ShearedOverlayContainer.SHEAR;
rateAdjustTooltip = new AdjustedAttributesTooltip();
LeftContent.AddRange(new Drawable[]
{
starRatingDisplay = new StarRatingDisplay(default, animated: true)
@ -182,7 +178,7 @@ namespace osu.Game.Overlays.Mods
Ruleset ruleset = gameRuleset.Value.CreateInstance();
BeatmapDifficulty adjustedDifficulty = ruleset.GetRateAdjustedDisplayDifficulty(originalDifficulty, rate);
rateAdjustTooltip.UpdateAttributes(originalDifficulty, adjustedDifficulty);
TooltipContent = new AdjustedAttributesTooltip.Data(originalDifficulty, adjustedDifficulty);
approachRateDisplay.AdjustType.Value = VerticalAttributeDisplay.CalculateEffect(originalDifficulty.ApproachRate, adjustedDifficulty.ApproachRate);
overallDifficultyDisplay.AdjustType.Value = VerticalAttributeDisplay.CalculateEffect(originalDifficulty.OverallDifficulty, adjustedDifficulty.OverallDifficulty);

View File

@ -30,7 +30,7 @@ using osu.Game.Overlays.Mods;
namespace osu.Game.Screens.Select.Details
{
public partial class AdvancedStats : Container, IHasCustomTooltip
public partial class AdvancedStats : Container, IHasCustomTooltip<AdjustedAttributesTooltip.Data>
{
[Resolved]
private BeatmapDifficultyCache difficultyCache { get; set; }
@ -46,9 +46,8 @@ namespace osu.Game.Screens.Select.Details
protected readonly StatisticRow FirstValue, HpDrain, Accuracy, ApproachRate;
private readonly StatisticRow starDifficulty;
private AdjustedAttributesTooltip rateAdjustTooltip;
public ITooltip GetCustomTooltip() => rateAdjustTooltip;
public object TooltipContent => this;
public ITooltip<AdjustedAttributesTooltip.Data> GetCustomTooltip() => new AdjustedAttributesTooltip();
public AdjustedAttributesTooltip.Data TooltipContent { get; private set; }
private IBeatmapInfo beatmapInfo;
@ -86,7 +85,6 @@ namespace osu.Game.Screens.Select.Details
private void load(OsuColour colours)
{
starDifficulty.AccentColour = colours.Yellow;
rateAdjustTooltip = new AdjustedAttributesTooltip();
}
protected override void LoadComplete()
@ -144,7 +142,7 @@ namespace osu.Game.Screens.Select.Details
adjustedDifficulty = ruleset.CreateInstance().GetRateAdjustedDisplayDifficulty(originalDifficulty, rate);
rateAdjustTooltip.UpdateAttributes(originalDifficulty, adjustedDifficulty);
TooltipContent = new AdjustedAttributesTooltip.Data(originalDifficulty, adjustedDifficulty);
}
}