From 02f5ea200ea7b464d6d78170dc7b7beeb3e61559 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Sat, 30 Dec 2023 07:41:55 +0300 Subject: [PATCH] Fix failing tests --- .../Skinning/Argon/ArgonManiaComboCounter.cs | 13 +++++------ .../Legacy/LegacyManiaComboCounter.cs | 22 ++++++++++--------- osu.Game/Screens/Play/Player.cs | 4 ++++ 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Skinning/Argon/ArgonManiaComboCounter.cs b/osu.Game.Rulesets.Mania/Skinning/Argon/ArgonManiaComboCounter.cs index 1c8e43345a..ad515528fb 100644 --- a/osu.Game.Rulesets.Mania/Skinning/Argon/ArgonManiaComboCounter.cs +++ b/osu.Game.Rulesets.Mania/Skinning/Argon/ArgonManiaComboCounter.cs @@ -7,9 +7,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; -using osu.Game.Rulesets.Mania.UI; using osu.Game.Rulesets.Scoring; -using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI.Scrolling; using osu.Game.Screens.Play.HUD; using osu.Game.Skinning; @@ -24,15 +22,11 @@ namespace osu.Game.Rulesets.Mania.Skinning.Argon protected override double RollingDuration => 500; protected override Easing RollingEasing => Easing.OutQuint; - private DrawableManiaRuleset maniaRuleset = null!; - bool ISerialisableDrawable.SupportsClosestAnchor => false; [BackgroundDependencyLoader] - private void load(DrawableRuleset ruleset, ScoreProcessor scoreProcessor) + private void load(ScoreProcessor scoreProcessor) { - maniaRuleset = (DrawableManiaRuleset)ruleset; - Current.BindTo(scoreProcessor.Combo); Current.BindValueChanged(combo => { @@ -50,6 +44,9 @@ namespace osu.Game.Rulesets.Mania.Skinning.Argon UsesFixedAnchor = true; } + [Resolved] + private IScrollingInfo scrollingInfo { get; set; } = null!; + private IBindable direction = null!; protected override void LoadComplete() @@ -57,7 +54,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Argon base.LoadComplete(); text.Alpha = Current.Value > 0 ? 1 : 0; - direction = maniaRuleset.ScrollingInfo.Direction.GetBoundCopy(); + direction = scrollingInfo.Direction.GetBoundCopy(); direction.BindValueChanged(_ => updateAnchor()); // two schedules are required so that updateAnchor is executed in the next frame, diff --git a/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyManiaComboCounter.cs b/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyManiaComboCounter.cs index fd309f6250..00619834c8 100644 --- a/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyManiaComboCounter.cs +++ b/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyManiaComboCounter.cs @@ -3,9 +3,8 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; +using osu.Framework.Extensions.EnumExtensions; using osu.Framework.Graphics; -using osu.Game.Rulesets.Mania.UI; -using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI.Scrolling; using osu.Game.Skinning; using osuTK; @@ -15,15 +14,11 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy { public partial class LegacyManiaComboCounter : LegacyComboCounter, ISerialisableDrawable { - private DrawableManiaRuleset maniaRuleset = null!; - bool ISerialisableDrawable.SupportsClosestAnchor => false; [BackgroundDependencyLoader] - private void load(ISkinSource skin, DrawableRuleset ruleset) + private void load(ISkinSource skin) { - maniaRuleset = (DrawableManiaRuleset)ruleset; - DisplayedCountText.Anchor = Anchor.Centre; DisplayedCountText.Origin = Anchor.Centre; @@ -34,13 +29,16 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy UsesFixedAnchor = true; } + [Resolved] + private IScrollingInfo scrollingInfo { get; set; } = null!; + private IBindable direction = null!; protected override void LoadComplete() { base.LoadComplete(); - direction = maniaRuleset.ScrollingInfo.Direction.GetBoundCopy(); + direction = scrollingInfo.Direction.GetBoundCopy(); direction.BindValueChanged(_ => updateAnchor()); // two schedules are required so that updateAnchor is executed in the next frame, @@ -50,8 +48,12 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy private void updateAnchor() { - Anchor &= ~(Anchor.y0 | Anchor.y2); - Anchor |= direction.Value == ScrollingDirection.Up ? Anchor.y2 : Anchor.y0; + // if the anchor isn't a vertical center, set top or bottom anchor based on scroll direction + if (!Anchor.HasFlagFast(Anchor.y1)) + { + Anchor &= ~(Anchor.y0 | Anchor.y2); + Anchor |= direction.Value == ScrollingDirection.Up ? Anchor.y2 : Anchor.y0; + } // since we flip the vertical anchor when changing scroll direction, // we can use the sign of the Y value as an indicator to make the combo counter displayed correctly. diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index c960ac357f..c10ef9731f 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -32,6 +32,7 @@ using osu.Game.Rulesets; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; +using osu.Game.Rulesets.UI.Scrolling; using osu.Game.Scoring; using osu.Game.Scoring.Legacy; using osu.Game.Screens.Play.HUD; @@ -224,6 +225,9 @@ namespace osu.Game.Screens.Play DrawableRuleset = ruleset.CreateDrawableRulesetWith(playableBeatmap, gameplayMods); dependencies.CacheAs(DrawableRuleset); + if (DrawableRuleset is IDrawableScrollingRuleset scrollingRuleset) + dependencies.CacheAs(scrollingRuleset.ScrollingInfo); + ScoreProcessor = ruleset.CreateScoreProcessor(); ScoreProcessor.Mods.Value = gameplayMods; ScoreProcessor.ApplyBeatmap(playableBeatmap);