mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 14:57:52 +08:00
improved tooltip
This commit is contained in:
parent
5597e819be
commit
820519c37d
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
@ -11,9 +12,12 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
@ -21,10 +25,6 @@ using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osuTK;
|
||||
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
|
||||
{
|
||||
@ -73,8 +73,7 @@ namespace osu.Game.Overlays.Mods
|
||||
private CancellationTokenSource? cancellationSource;
|
||||
private IBindable<StarDifficulty?> starDifficulty = null!;
|
||||
|
||||
private BeatmapDifficulty? baseDifficultyAttributes = null;
|
||||
|
||||
private BeatmapDifficulty? originalDifficulty = null;
|
||||
private bool haveRateChangedValues = false;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -257,36 +256,34 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
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>())
|
||||
mod.ApplyToDifficulty(moddedDifficulty);
|
||||
mod.ApplyToDifficulty(adjustedDifficulty);
|
||||
|
||||
baseDifficultyAttributes = moddedDifficulty;
|
||||
originalDifficulty = adjustedDifficulty;
|
||||
|
||||
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);
|
||||
overallDifficultyDisplay.AdjustType.Value = VerticalAttributeDisplay.CalculateEffect(moddedDifficulty.OverallDifficulty, rateAdjustedDifficulty.OverallDifficulty);
|
||||
approachRateDisplay.AdjustType.Value = VerticalAttributeDisplay.CalculateEffect(originalDifficulty.ApproachRate, adjustedDifficulty.ApproachRate);
|
||||
overallDifficultyDisplay.AdjustType.Value = VerticalAttributeDisplay.CalculateEffect(originalDifficulty.OverallDifficulty, adjustedDifficulty.OverallDifficulty);
|
||||
|
||||
circleSizeDisplay.Current.Value = rateAdjustedDifficulty.CircleSize;
|
||||
drainRateDisplay.Current.Value = rateAdjustedDifficulty.DrainRate;
|
||||
approachRateDisplay.Current.Value = rateAdjustedDifficulty.ApproachRate;
|
||||
overallDifficultyDisplay.Current.Value = rateAdjustedDifficulty.OverallDifficulty;
|
||||
circleSizeDisplay.Current.Value = adjustedDifficulty.CircleSize;
|
||||
drainRateDisplay.Current.Value = adjustedDifficulty.DrainRate;
|
||||
approachRateDisplay.Current.Value = adjustedDifficulty.ApproachRate;
|
||||
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 false;
|
||||
|
||||
if (a.ApproachRate != b.ApproachRate) return false;
|
||||
if (a.OverallDifficulty != b.OverallDifficulty) return false;
|
||||
if (a.DrainRate != b.DrainRate) return false;
|
||||
if (a.CircleSize != b.CircleSize) 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;
|
||||
}
|
||||
@ -315,7 +312,8 @@ namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
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 "";
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
@ -103,7 +104,7 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
public static ModEffect CalculateEffect(double oldValue, double newValue)
|
||||
{
|
||||
if (newValue == oldValue)
|
||||
if (Precision.AlmostEquals(newValue, oldValue, 0.01))
|
||||
return ModEffect.NotChanged;
|
||||
if (newValue < oldValue)
|
||||
return ModEffect.DifficultyReduction;
|
||||
|
@ -8,6 +8,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
@ -28,7 +29,7 @@ using System.Linq;
|
||||
|
||||
namespace osu.Game.Screens.Select.Details
|
||||
{
|
||||
public partial class AdvancedStats : Container
|
||||
public partial class AdvancedStats : Container, IHasTooltip
|
||||
{
|
||||
[Resolved]
|
||||
private BeatmapDifficultyCache difficultyCache { get; set; }
|
||||
@ -44,6 +45,9 @@ namespace osu.Game.Screens.Select.Details
|
||||
protected readonly StatisticRow FirstValue, HpDrain, Accuracy, ApproachRate;
|
||||
private readonly StatisticRow starDifficulty;
|
||||
|
||||
private BeatmapDifficulty originalDifficulty = null;
|
||||
private bool haveRateChangedValues = false;
|
||||
|
||||
private IBeatmapInfo beatmapInfo;
|
||||
|
||||
public IBeatmapInfo BeatmapInfo
|
||||
@ -125,13 +129,15 @@ namespace osu.Game.Screens.Select.Details
|
||||
foreach (var mod in mods.Value.OfType<IApplicableToDifficulty>())
|
||||
mod.ApplyToDifficulty(adjustedDifficulty);
|
||||
|
||||
// For now we not using rate adjusted difficulty here
|
||||
originalDifficulty = adjustedDifficulty;
|
||||
|
||||
//Ruleset ruleset = gameRuleset.Value.CreateInstance();
|
||||
//double rate = 1;
|
||||
//foreach (var mod in mods.Value.OfType<IApplicableToRate>())
|
||||
// rate = mod.ApplyToRate(0, rate);
|
||||
//adjustedDifficulty = ruleset.GetRateAdjustedDifficulty(adjustedDifficulty, rate);
|
||||
Ruleset ruleset = gameRuleset.Value.CreateInstance();
|
||||
double rate = 1;
|
||||
foreach (var mod in mods.Value.OfType<IApplicableToRate>())
|
||||
rate = mod.ApplyToRate(0, rate);
|
||||
adjustedDifficulty = ruleset.GetRateAdjustedDifficulty(adjustedDifficulty, rate);
|
||||
|
||||
haveRateChangedValues = !isDifferentArOd(originalDifficulty, adjustedDifficulty);
|
||||
}
|
||||
|
||||
switch (BeatmapInfo?.Ruleset.OnlineID)
|
||||
@ -196,6 +202,30 @@ namespace osu.Game.Screens.Select.Details
|
||||
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
|
||||
{
|
||||
private const float value_width = 25;
|
||||
|
Loading…
Reference in New Issue
Block a user