mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 02:22:59 +08:00
Refactor logic and tooltip formatting
This commit is contained in:
parent
6bd5eda2a0
commit
4df1eb1b37
@ -238,14 +238,12 @@ namespace osu.Game.Rulesets.Catch
|
||||
{
|
||||
BeatmapDifficulty adjustedDifficulty = new BeatmapDifficulty(baseDifficulty);
|
||||
|
||||
double preempt = adjustedDifficulty.ApproachRate < 5 ?
|
||||
(1200.0 + 600.0 * (5 - adjustedDifficulty.ApproachRate) / 5) :
|
||||
(1200.0 - 750.0 * (adjustedDifficulty.ApproachRate - 5) / 5);
|
||||
double preempt = adjustedDifficulty.ApproachRate < 5 ? (1200.0 + 600.0 * (5 - adjustedDifficulty.ApproachRate) / 5) : (1200.0 - 750.0 * (adjustedDifficulty.ApproachRate - 5) / 5);
|
||||
|
||||
preempt /= rate;
|
||||
adjustedDifficulty.ApproachRate = (float)(preempt > 1200 ? ((1800 - preempt) / 120) : ((1200 - preempt) / 150 + 5));
|
||||
|
||||
return adjustedDifficulty ?? (BeatmapDifficulty)baseDifficulty;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +59,8 @@ namespace osu.Game.Overlays.Mods
|
||||
private IBindable<StarDifficulty?> starDifficulty = null!;
|
||||
|
||||
private BeatmapDifficulty? originalDifficulty;
|
||||
private BeatmapDifficulty? adjustedDifficulty;
|
||||
|
||||
private bool haveRateChangedValues;
|
||||
|
||||
private const float transition_duration = 250;
|
||||
@ -171,17 +173,15 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
bpmDisplay.Current.Value = BeatmapInfo.Value.BPM * rate;
|
||||
|
||||
var adjustedDifficulty = new BeatmapDifficulty(BeatmapInfo.Value.Difficulty);
|
||||
originalDifficulty = new BeatmapDifficulty(BeatmapInfo.Value.Difficulty);
|
||||
|
||||
foreach (var mod in mods.Value.OfType<IApplicableToDifficulty>())
|
||||
mod.ApplyToDifficulty(adjustedDifficulty);
|
||||
|
||||
originalDifficulty = adjustedDifficulty;
|
||||
mod.ApplyToDifficulty(originalDifficulty);
|
||||
|
||||
Ruleset ruleset = gameRuleset.Value.CreateInstance();
|
||||
adjustedDifficulty = ruleset.GetRateAdjustedDifficulty(adjustedDifficulty, rate);
|
||||
adjustedDifficulty = ruleset.GetRateAdjustedDifficulty(originalDifficulty, rate);
|
||||
|
||||
haveRateChangedValues = isDifferentArOd(originalDifficulty, adjustedDifficulty);
|
||||
haveRateChangedValues = hasRateAdjustedProperties(originalDifficulty, adjustedDifficulty);
|
||||
|
||||
approachRateDisplay.AdjustType.Value = VerticalAttributeDisplay.CalculateEffect(originalDifficulty.ApproachRate, adjustedDifficulty.ApproachRate);
|
||||
overallDifficultyDisplay.AdjustType.Value = VerticalAttributeDisplay.CalculateEffect(originalDifficulty.OverallDifficulty, adjustedDifficulty.OverallDifficulty);
|
||||
@ -192,22 +192,34 @@ namespace osu.Game.Overlays.Mods
|
||||
overallDifficultyDisplay.Current.Value = adjustedDifficulty.OverallDifficulty;
|
||||
});
|
||||
|
||||
private bool isDifferentArOd(BeatmapDifficulty? a, BeatmapDifficulty? b)
|
||||
{
|
||||
if (a == null && b == null) return false;
|
||||
if (a == null || b == null) return true;
|
||||
|
||||
if (!Precision.AlmostEquals(a.ApproachRate, b.ApproachRate, 0.01)) return true;
|
||||
if (!Precision.AlmostEquals(a.OverallDifficulty, b.OverallDifficulty, 0.01)) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void updateCollapsedState()
|
||||
{
|
||||
RightContent.FadeTo(Collapsed.Value && !IsHovered ? 0 : 1, transition_duration, Easing.OutQuint);
|
||||
}
|
||||
|
||||
public LocalisableString TooltipText
|
||||
{
|
||||
get
|
||||
{
|
||||
if (haveRateChangedValues)
|
||||
{
|
||||
return $"One or more values are being adjusted by mods that change speed." +
|
||||
$" (AR {originalDifficulty?.ApproachRate ?? 0}→{adjustedDifficulty?.ApproachRate ?? 0}, " +
|
||||
$"OD {originalDifficulty?.OverallDifficulty ?? 0}→{adjustedDifficulty?.OverallDifficulty ?? 0})";
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool hasRateAdjustedProperties(BeatmapDifficulty a, BeatmapDifficulty b)
|
||||
{
|
||||
if (!Precision.AlmostEquals(a.ApproachRate, b.ApproachRate)) return true;
|
||||
if (!Precision.AlmostEquals(a.OverallDifficulty, b.OverallDifficulty)) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private partial class BPMDisplay : RollingCounter<double>
|
||||
{
|
||||
protected override double RollingDuration => 500;
|
||||
@ -222,19 +234,5 @@ namespace osu.Game.Overlays.Mods
|
||||
UseFullGlyphHeight = false,
|
||||
};
|
||||
}
|
||||
|
||||
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 "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user