1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 20:22:55 +08:00

improved tooltip

This commit is contained in:
Givikap120 2023-11-04 21:55:46 +02:00
parent 5597e819be
commit 820519c37d
3 changed files with 60 additions and 31 deletions

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading;
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -11,9 +12,12 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Framework.Utils;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables; using osu.Game.Beatmaps.Drawables;
using osu.Game.Configuration;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
@ -21,10 +25,6 @@ using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
using System.Threading;
using osu.Framework.Input.Events;
using osu.Game.Configuration;
using osu.Game.Rulesets.Difficulty;
namespace osu.Game.Overlays.Mods namespace osu.Game.Overlays.Mods
{ {
@ -73,8 +73,7 @@ namespace osu.Game.Overlays.Mods
private CancellationTokenSource? cancellationSource; private CancellationTokenSource? cancellationSource;
private IBindable<StarDifficulty?> starDifficulty = null!; private IBindable<StarDifficulty?> starDifficulty = null!;
private BeatmapDifficulty? baseDifficultyAttributes = null; private BeatmapDifficulty? originalDifficulty = null;
private bool haveRateChangedValues = false; private bool haveRateChangedValues = false;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -257,36 +256,34 @@ namespace osu.Game.Overlays.Mods
bpmDisplay.Current.Value = BeatmapInfo.Value.BPM * rate; bpmDisplay.Current.Value = BeatmapInfo.Value.BPM * rate;
var moddedDifficulty = new BeatmapDifficulty(BeatmapInfo.Value.Difficulty); var adjustedDifficulty = new BeatmapDifficulty(BeatmapInfo.Value.Difficulty);
foreach (var mod in mods.Value.OfType<IApplicableToDifficulty>()) foreach (var mod in mods.Value.OfType<IApplicableToDifficulty>())
mod.ApplyToDifficulty(moddedDifficulty); mod.ApplyToDifficulty(adjustedDifficulty);
baseDifficultyAttributes = moddedDifficulty; originalDifficulty = adjustedDifficulty;
Ruleset ruleset = gameRuleset.Value.CreateInstance(); Ruleset ruleset = gameRuleset.Value.CreateInstance();
var rateAdjustedDifficulty = ruleset.GetRateAdjustedDifficulty(moddedDifficulty, rate); adjustedDifficulty = ruleset.GetRateAdjustedDifficulty(adjustedDifficulty, rate);
haveRateChangedValues = !haveEqualDifficulties(rateAdjustedDifficulty, moddedDifficulty); haveRateChangedValues = !isDifferentArOd(originalDifficulty, adjustedDifficulty);
approachRateDisplay.AdjustType.Value = VerticalAttributeDisplay.CalculateEffect(moddedDifficulty.ApproachRate, rateAdjustedDifficulty.ApproachRate); approachRateDisplay.AdjustType.Value = VerticalAttributeDisplay.CalculateEffect(originalDifficulty.ApproachRate, adjustedDifficulty.ApproachRate);
overallDifficultyDisplay.AdjustType.Value = VerticalAttributeDisplay.CalculateEffect(moddedDifficulty.OverallDifficulty, rateAdjustedDifficulty.OverallDifficulty); overallDifficultyDisplay.AdjustType.Value = VerticalAttributeDisplay.CalculateEffect(originalDifficulty.OverallDifficulty, adjustedDifficulty.OverallDifficulty);
circleSizeDisplay.Current.Value = rateAdjustedDifficulty.CircleSize; circleSizeDisplay.Current.Value = adjustedDifficulty.CircleSize;
drainRateDisplay.Current.Value = rateAdjustedDifficulty.DrainRate; drainRateDisplay.Current.Value = adjustedDifficulty.DrainRate;
approachRateDisplay.Current.Value = rateAdjustedDifficulty.ApproachRate; approachRateDisplay.Current.Value = adjustedDifficulty.ApproachRate;
overallDifficultyDisplay.Current.Value = rateAdjustedDifficulty.OverallDifficulty; overallDifficultyDisplay.Current.Value = adjustedDifficulty.OverallDifficulty;
}); });
private bool haveEqualDifficulties(BeatmapDifficulty? a, BeatmapDifficulty? b) private bool isDifferentArOd(BeatmapDifficulty? a, BeatmapDifficulty? b)
{ {
if (a == null && b == null) return true; if (a == null && b == null) return true;
if (a == null || b == null) return false; if (a == null || b == null) return false;
if (a.ApproachRate != b.ApproachRate) return false; if (!Precision.AlmostEquals(a.ApproachRate, b.ApproachRate, 0.01)) return false;
if (a.OverallDifficulty != b.OverallDifficulty) return false; if (!Precision.AlmostEquals(a.OverallDifficulty, b.OverallDifficulty, 0.01)) return false;
if (a.DrainRate != b.DrainRate) return false;
if (a.CircleSize != b.CircleSize) return false;
return true; return true;
} }
@ -315,7 +312,8 @@ namespace osu.Game.Overlays.Mods
{ {
if (haveRateChangedValues) if (haveRateChangedValues)
{ {
return "Some of the values are Rate-Adjusted."; return LocalisableString.Format("Values are changed by mods that change speed.\n" +
"Original values: AR = {0}, OD = {1}", originalDifficulty?.ApproachRate ?? 0, originalDifficulty?.OverallDifficulty ?? 0);
} }
return ""; return "";
} }

View File

@ -9,6 +9,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Framework.Utils;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
@ -103,7 +104,7 @@ namespace osu.Game.Overlays.Mods
public static ModEffect CalculateEffect(double oldValue, double newValue) public static ModEffect CalculateEffect(double oldValue, double newValue)
{ {
if (newValue == oldValue) if (Precision.AlmostEquals(newValue, oldValue, 0.01))
return ModEffect.NotChanged; return ModEffect.NotChanged;
if (newValue < oldValue) if (newValue < oldValue)
return ModEffect.DifficultyReduction; return ModEffect.DifficultyReduction;

View File

@ -8,6 +8,7 @@ using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
@ -28,7 +29,7 @@ using System.Linq;
namespace osu.Game.Screens.Select.Details namespace osu.Game.Screens.Select.Details
{ {
public partial class AdvancedStats : Container public partial class AdvancedStats : Container, IHasTooltip
{ {
[Resolved] [Resolved]
private BeatmapDifficultyCache difficultyCache { get; set; } private BeatmapDifficultyCache difficultyCache { get; set; }
@ -44,6 +45,9 @@ namespace osu.Game.Screens.Select.Details
protected readonly StatisticRow FirstValue, HpDrain, Accuracy, ApproachRate; protected readonly StatisticRow FirstValue, HpDrain, Accuracy, ApproachRate;
private readonly StatisticRow starDifficulty; private readonly StatisticRow starDifficulty;
private BeatmapDifficulty originalDifficulty = null;
private bool haveRateChangedValues = false;
private IBeatmapInfo beatmapInfo; private IBeatmapInfo beatmapInfo;
public IBeatmapInfo BeatmapInfo public IBeatmapInfo BeatmapInfo
@ -125,13 +129,15 @@ namespace osu.Game.Screens.Select.Details
foreach (var mod in mods.Value.OfType<IApplicableToDifficulty>()) foreach (var mod in mods.Value.OfType<IApplicableToDifficulty>())
mod.ApplyToDifficulty(adjustedDifficulty); mod.ApplyToDifficulty(adjustedDifficulty);
// For now we not using rate adjusted difficulty here originalDifficulty = adjustedDifficulty;
//Ruleset ruleset = gameRuleset.Value.CreateInstance(); Ruleset ruleset = gameRuleset.Value.CreateInstance();
//double rate = 1; double rate = 1;
//foreach (var mod in mods.Value.OfType<IApplicableToRate>()) foreach (var mod in mods.Value.OfType<IApplicableToRate>())
// rate = mod.ApplyToRate(0, rate); rate = mod.ApplyToRate(0, rate);
//adjustedDifficulty = ruleset.GetRateAdjustedDifficulty(adjustedDifficulty, rate); adjustedDifficulty = ruleset.GetRateAdjustedDifficulty(adjustedDifficulty, rate);
haveRateChangedValues = !isDifferentArOd(originalDifficulty, adjustedDifficulty);
} }
switch (BeatmapInfo?.Ruleset.OnlineID) switch (BeatmapInfo?.Ruleset.OnlineID)
@ -196,6 +202,30 @@ namespace osu.Game.Screens.Select.Details
starDifficultyCancellationSource?.Cancel(); starDifficultyCancellationSource?.Cancel();
} }
private bool isDifferentArOd(BeatmapDifficulty a, BeatmapDifficulty b)
{
if (a == null && b == null) return true;
if (a == null || b == null) return false;
if (!Precision.AlmostEquals(a.ApproachRate, b.ApproachRate, 0.01)) return false;
if (!Precision.AlmostEquals(a.OverallDifficulty, b.OverallDifficulty, 0.01)) return false;
return true;
}
public LocalisableString TooltipText
{
get
{
if (haveRateChangedValues)
{
return LocalisableString.Format("Values are changed by mods that change speed.\n" +
"Original values: AR = {0}, OD = {1}", originalDifficulty?.ApproachRate ?? 0, originalDifficulty?.OverallDifficulty ?? 0);
}
return "";
}
}
public partial class StatisticRow : Container, IHasAccentColour public partial class StatisticRow : Container, IHasAccentColour
{ {
private const float value_width = 25; private const float value_width = 25;