1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 14:32:55 +08:00

Update BeatmapAttributesDisplay.cs

This commit is contained in:
Givikap120 2024-02-17 22:12:15 +02:00
parent 2adc8b15e7
commit cd8ac6a722

View File

@ -19,6 +19,7 @@ using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Online.Rooms;
using osuTK;
namespace osu.Game.Overlays.Mods
@ -42,6 +43,9 @@ namespace osu.Game.Overlays.Mods
[Resolved]
private Bindable<IReadOnlyList<Mod>> mods { get; set; } = null!;
[Resolved(CanBeNull = true)]
private IBindable<PlaylistItem>? selectedItem { get; set; }
public BindableBool Collapsed { get; } = new BindableBool(true);
private ModSettingChangeTracker? modSettingChangeTracker;
@ -108,6 +112,8 @@ namespace osu.Game.Overlays.Mods
updateValues();
}, true);
selectedItem?.BindValueChanged(_ => mods.TriggerChange());
BeatmapInfo.BindValueChanged(_ => updateValues(), true);
Collapsed.BindValueChanged(_ =>
@ -164,10 +170,20 @@ namespace osu.Game.Overlays.Mods
starRatingDisplay.FinishTransforms(true);
});
Ruleset ruleset = gameRuleset.Value.CreateInstance();
double rate = 1;
foreach (var mod in mods.Value.OfType<IApplicableToRate>())
rate = mod.ApplyToRate(0, rate);
if (selectedItem != null && selectedItem.Value != null)
{
var globalMods = selectedItem.Value.RequiredMods.Select(m => m.ToMod(ruleset));
foreach (var mod in globalMods.OfType<IApplicableToRate>())
rate = mod.ApplyToRate(0, rate);
}
bpmDisplay.Current.Value = BeatmapInfo.Value.BPM * rate;
BeatmapDifficulty originalDifficulty = new BeatmapDifficulty(BeatmapInfo.Value.Difficulty);
@ -175,7 +191,6 @@ namespace osu.Game.Overlays.Mods
foreach (var mod in mods.Value.OfType<IApplicableToDifficulty>())
mod.ApplyToDifficulty(originalDifficulty);
Ruleset ruleset = gameRuleset.Value.CreateInstance();
BeatmapDifficulty adjustedDifficulty = ruleset.GetRateAdjustedDisplayDifficulty(originalDifficulty, rate);
TooltipContent = new AdjustedAttributesTooltip.Data(originalDifficulty, adjustedDifficulty);