From 12e98fe55df37690f24de1450c1f59a9e75dd274 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 6 May 2024 15:24:32 +0800 Subject: [PATCH] Move out of playfield so touch overlay is not affected by playfield position --- .../UI/DrawableManiaRuleset.cs | 10 ++++++- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 30 ++----------------- .../UI/ManiaTouchInputOverlay.cs | 5 ++-- 3 files changed, 15 insertions(+), 30 deletions(-) diff --git a/osu.Game.Rulesets.Mania/UI/DrawableManiaRuleset.cs b/osu.Game.Rulesets.Mania/UI/DrawableManiaRuleset.cs index 275b1311de..a948117748 100644 --- a/osu.Game.Rulesets.Mania/UI/DrawableManiaRuleset.cs +++ b/osu.Game.Rulesets.Mania/UI/DrawableManiaRuleset.cs @@ -31,6 +31,7 @@ using osu.Game.Skinning; namespace osu.Game.Rulesets.Mania.UI { + [Cached] public partial class DrawableManiaRuleset : DrawableScrollingRuleset { /// @@ -43,7 +44,7 @@ namespace osu.Game.Rulesets.Mania.UI /// public const double MAX_TIME_RANGE = 11485; - protected new ManiaPlayfield Playfield => (ManiaPlayfield)base.Playfield; + public new ManiaPlayfield Playfield => (ManiaPlayfield)base.Playfield; public new ManiaBeatmap Beatmap => (ManiaBeatmap)base.Beatmap; @@ -103,6 +104,11 @@ namespace osu.Game.Rulesets.Mania.UI configScrollSpeed.BindValueChanged(speed => this.TransformTo(nameof(smoothTimeRange), ComputeScrollTime(speed.NewValue), 200, Easing.OutQuint)); TimeRange.Value = smoothTimeRange = ComputeScrollTime(configScrollSpeed.Value); + + KeyBindingInputManager.Add(touchOverlay = new ManiaTouchInputOverlay + { + RelativeSizeAxes = Axes.Both + }); } protected override void AdjustScrollSpeed(int amount) => configScrollSpeed.Value += amount; @@ -116,6 +122,8 @@ namespace osu.Game.Rulesets.Mania.UI private ScheduledDelegate? pendingSkinChange; private float hitPosition; + private ManiaTouchInputOverlay touchOverlay = null!; + private void onSkinChange() { // schedule required to avoid calls after disposed. diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 385a47f8b8..b3420c49f3 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -7,12 +7,10 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using System; using System.Collections.Generic; -using System.Linq; using osu.Framework.Allocation; using osu.Framework.Graphics.Primitives; using osu.Game.Rulesets.Mania.Beatmaps; using osu.Game.Rulesets.Mania.Objects; -using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.UI.Scrolling; @@ -27,8 +25,6 @@ namespace osu.Game.Rulesets.Mania.UI private readonly List stages = new List(); - private readonly ManiaTouchInputOverlay touchOverlay; - public override Quad SkinnableComponentScreenSpaceDrawQuad { get @@ -64,23 +60,10 @@ namespace osu.Game.Rulesets.Mania.UI throw new ArgumentException("Can't have zero or fewer stages."); GridContainer playfieldGrid; - - RelativeSizeAxes = Axes.Y; - AutoSizeAxes = Axes.X; - - AddRangeInternal(new Drawable[] + AddInternal(playfieldGrid = new GridContainer { - playfieldGrid = new GridContainer - { - RelativeSizeAxes = Axes.Y, - AutoSizeAxes = Axes.X, - Content = new[] { new Drawable[stageDefinitions.Count] }, - ColumnDimensions = Enumerable.Range(0, stageDefinitions.Count).Select(_ => new Dimension(GridSizeMode.AutoSize)).ToArray() - }, - touchOverlay = new ManiaTouchInputOverlay - { - RelativeSizeAxes = Axes.Both - } + RelativeSizeAxes = Axes.Both, + Content = new[] { new Drawable[stageDefinitions.Count] } }); var normalColumnAction = ManiaAction.Key1; @@ -100,13 +83,6 @@ namespace osu.Game.Rulesets.Mania.UI } } - protected override void LoadComplete() - { - base.LoadComplete(); - - touchOverlay.Alpha = Mods?.Any(m => m is ModTouchDevice) == true ? 1 : 0; - } - public override void Add(HitObject hitObject) => getStageByColumn(((ManiaHitObject)hitObject).Column).Add(hitObject); public override bool Remove(HitObject hitObject) => getStageByColumn(((ManiaHitObject)hitObject).Column).Remove(hitObject); diff --git a/osu.Game.Rulesets.Mania/UI/ManiaTouchInputOverlay.cs b/osu.Game.Rulesets.Mania/UI/ManiaTouchInputOverlay.cs index ddff064133..a51a3a605b 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaTouchInputOverlay.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaTouchInputOverlay.cs @@ -33,12 +33,13 @@ namespace osu.Game.Rulesets.Mania.UI }; [Resolved] - private ManiaPlayfield playfield { get; set; } = null!; + private DrawableManiaRuleset drawableRuleset { get; set; } = null!; public ManiaTouchInputOverlay() { Anchor = Anchor.BottomCentre; Origin = Anchor.BottomCentre; + RelativeSizeAxes = Axes.Both; Height = 0.5f; } @@ -51,7 +52,7 @@ namespace osu.Game.Rulesets.Mania.UI bool first = true; - foreach (var stage in playfield.Stages) + foreach (var stage in drawableRuleset.Playfield.Stages) { foreach (var column in stage.Columns) {