1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-27 14:52:55 +08:00

Fixed bugs and added ranked status update

This commit is contained in:
Givikap120 2024-02-17 23:01:31 +02:00
parent cd8ac6a722
commit ed819fde15
3 changed files with 52 additions and 15 deletions

View File

@ -40,11 +40,16 @@ namespace osu.Game.Overlays.Mods
public Bindable<IBeatmapInfo?> BeatmapInfo { get; } = new Bindable<IBeatmapInfo?>();
/// <summary>
/// Should attribute display account for the multiplayer room global mods.
/// </summary>
public bool AccountForMultiplayerMods = false;
[Resolved]
private Bindable<IReadOnlyList<Mod>> mods { get; set; } = null!;
[Resolved(CanBeNull = true)]
private IBindable<PlaylistItem>? selectedItem { get; set; }
private IBindable<PlaylistItem>? multiplayerRoomItem { get; set; }
public BindableBool Collapsed { get; } = new BindableBool(true);
@ -112,7 +117,7 @@ namespace osu.Game.Overlays.Mods
updateValues();
}, true);
selectedItem?.BindValueChanged(_ => mods.TriggerChange());
multiplayerRoomItem?.BindValueChanged(_ => mods.TriggerChange());
BeatmapInfo.BindValueChanged(_ => updateValues(), true);
@ -176,23 +181,26 @@ namespace osu.Game.Overlays.Mods
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);
foreach (var mod in mods.Value.OfType<IApplicableToDifficulty>())
mod.ApplyToDifficulty(originalDifficulty);
if (AccountForMultiplayerMods && multiplayerRoomItem != null && multiplayerRoomItem.Value != null)
{
var multiplayerRoomMods = multiplayerRoomItem.Value.RequiredMods.Select(m => m.ToMod(ruleset));
foreach (var mod in multiplayerRoomMods.OfType<IApplicableToRate>())
rate = mod.ApplyToRate(0, rate);
foreach (var mod in multiplayerRoomMods.OfType<IApplicableToDifficulty>())
mod.ApplyToDifficulty(originalDifficulty);
}
BeatmapDifficulty adjustedDifficulty = ruleset.GetRateAdjustedDisplayDifficulty(originalDifficulty, rate);
bpmDisplay.Current.Value = BeatmapInfo.Value.BPM * rate;
TooltipContent = new AdjustedAttributesTooltip.Data(originalDifficulty, adjustedDifficulty);
approachRateDisplay.AdjustType.Value = VerticalAttributeDisplay.CalculateEffect(originalDifficulty.ApproachRate, adjustedDifficulty.ApproachRate);

View File

@ -25,7 +25,9 @@ using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.UserInterface;
using osu.Game.Input.Bindings;
using osu.Game.Localisation;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Online.Rooms;
using osu.Game.Utils;
using osuTK;
using osuTK.Input;
@ -42,6 +44,12 @@ namespace osu.Game.Overlays.Mods
[Cached]
public Bindable<IReadOnlyList<Mod>> SelectedMods { get; private set; } = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
[Resolved(CanBeNull = true)]
private IBindable<PlaylistItem>? multiplayerRoomItem { get; set; }
[Resolved]
private OsuGameBase game { get; set; } = null!;
/// <summary>
/// Contains a dictionary with the current <see cref="ModState"/> of all mods applicable for the current ruleset.
/// </summary>
@ -92,6 +100,11 @@ namespace osu.Game.Overlays.Mods
/// </summary>
protected virtual bool ShowPresets => false;
/// <summary>
/// Should overlay account for the multiplayer room global mods.
/// </summary>
public bool AccountForMultiplayerMods = false;
protected virtual ModColumn CreateModColumn(ModType modType) => new ModColumn(modType, false);
protected virtual IReadOnlyList<Mod> ComputeNewModsFromSelection(IReadOnlyList<Mod> oldSelection, IReadOnlyList<Mod> newSelection) => newSelection;
@ -278,7 +291,8 @@ namespace osu.Game.Overlays.Mods
{
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
BeatmapInfo = { Value = beatmap?.BeatmapInfo }
BeatmapInfo = { Value = beatmap?.BeatmapInfo },
AccountForMultiplayerMods = AccountForMultiplayerMods
},
}
});
@ -332,6 +346,8 @@ namespace osu.Game.Overlays.Mods
}
}, true);
multiplayerRoomItem?.BindValueChanged(_ => SelectedMods.TriggerChange());
customisationVisible.BindValueChanged(_ => updateCustomisationVisualState(), true);
SearchTextBox.Current.BindValueChanged(query =>
@ -460,8 +476,20 @@ namespace osu.Game.Overlays.Mods
foreach (var mod in SelectedMods.Value)
multiplier *= mod.ScoreMultiplier;
rankingInformationDisplay.ModMultiplier.Value = multiplier;
rankingInformationDisplay.Ranked.Value = SelectedMods.Value.All(m => m.Ranked);
if (AccountForMultiplayerMods && multiplayerRoomItem != null && multiplayerRoomItem.Value != null)
{
Ruleset ruleset = game.Ruleset.Value.CreateInstance();
var multiplayerRoomMods = multiplayerRoomItem.Value.RequiredMods.Select(m => m.ToMod(ruleset));
foreach (var mod in multiplayerRoomMods)
multiplier *= mod.ScoreMultiplier;
rankingInformationDisplay.Ranked.Value = rankingInformationDisplay.Ranked.Value && multiplayerRoomMods.All(m => m.Ranked);
}
rankingInformationDisplay.ModMultiplier.Value = multiplier;
}
private void updateCustomisation()

View File

@ -244,7 +244,8 @@ namespace osu.Game.Screens.OnlinePlay.Match
LoadComponent(UserModsSelectOverlay = new UserModSelectOverlay(OverlayColourScheme.Plum)
{
SelectedMods = { BindTarget = UserMods },
IsValidMod = _ => false
IsValidMod = _ => false,
AccountForMultiplayerMods = true
});
}