From ef972e4a04aa769683d7ae5b83bb4156006a2ef2 Mon Sep 17 00:00:00 2001 From: AeroKoder Date: Tue, 29 Jul 2025 16:27:45 -0700 Subject: [PATCH] Allow enabling osu!mania touch overlay on non-mobile platforms --- .../TestSceneManiaTouchInput.cs | 2 +- .../ManiaRulesetConfigManager.cs | 16 +++++++++++++++ osu.Game.Rulesets.Mania/ManiaMobileLayout.cs | 11 +++++++--- .../ManiaSettingsSubsection.cs | 11 ++++++++++ osu.Game.Rulesets.Mania/UI/Column.cs | 6 +++--- osu.Game.Rulesets.Mania/UI/ColumnFlow.cs | 2 +- .../UI/DrawableManiaRuleset.cs | 20 +++++++++---------- .../Localisation/RulesetSettingsStrings.cs | 13 ++++++++---- 8 files changed, 59 insertions(+), 22 deletions(-) diff --git a/osu.Game.Rulesets.Mania.Tests/TestSceneManiaTouchInput.cs b/osu.Game.Rulesets.Mania.Tests/TestSceneManiaTouchInput.cs index 3e83f4a5e8..f445af9caf 100644 --- a/osu.Game.Rulesets.Mania.Tests/TestSceneManiaTouchInput.cs +++ b/osu.Game.Rulesets.Mania.Tests/TestSceneManiaTouchInput.cs @@ -203,7 +203,7 @@ namespace osu.Game.Rulesets.Mania.Tests private void toggleTouchControls(bool enabled) { var maniaConfig = (ManiaRulesetConfigManager)RulesetConfigs.GetConfigFor(CreatePlayerRuleset())!; - maniaConfig.SetValue(ManiaRulesetSetting.MobileLayout, enabled ? ManiaMobileLayout.LandscapeWithOverlay : ManiaMobileLayout.Portrait); + maniaConfig.SetValue(ManiaRulesetSetting.TouchOverlay, enabled); } private ManiaTouchInputArea? getTouchOverlay() => this.ChildrenOfType().SingleOrDefault(); diff --git a/osu.Game.Rulesets.Mania/Configuration/ManiaRulesetConfigManager.cs b/osu.Game.Rulesets.Mania/Configuration/ManiaRulesetConfigManager.cs index b999a521d5..d58347076d 100644 --- a/osu.Game.Rulesets.Mania/Configuration/ManiaRulesetConfigManager.cs +++ b/osu.Game.Rulesets.Mania/Configuration/ManiaRulesetConfigManager.cs @@ -14,6 +14,7 @@ namespace osu.Game.Rulesets.Mania.Configuration public ManiaRulesetConfigManager(SettingsStore? settings, RulesetInfo ruleset, int? variant = null) : base(settings, ruleset, variant) { + Migrate(); } protected override void InitialiseDefaults() @@ -24,6 +25,20 @@ namespace osu.Game.Rulesets.Mania.Configuration SetDefault(ManiaRulesetSetting.ScrollDirection, ManiaScrollingDirection.Down); SetDefault(ManiaRulesetSetting.TimingBasedNoteColouring, false); SetDefault(ManiaRulesetSetting.MobileLayout, ManiaMobileLayout.Portrait); + SetDefault(ManiaRulesetSetting.TouchOverlay, false); + } + + public void Migrate() + { + var mobileLayout = GetBindable(ManiaRulesetSetting.MobileLayout); + +#pragma warning disable CS0618 // Type or member is obsolete + if (mobileLayout.Value == ManiaMobileLayout.LandscapeWithOverlay) +#pragma warning restore CS0618 // Type or member is obsolete + { + mobileLayout.Value = ManiaMobileLayout.Landscape; + SetValue(ManiaRulesetSetting.TouchOverlay, true); + } } public override TrackedSettings CreateTrackedSettings() => new TrackedSettings @@ -44,5 +59,6 @@ namespace osu.Game.Rulesets.Mania.Configuration ScrollDirection, TimingBasedNoteColouring, MobileLayout, + TouchOverlay, } } diff --git a/osu.Game.Rulesets.Mania/ManiaMobileLayout.cs b/osu.Game.Rulesets.Mania/ManiaMobileLayout.cs index 7d70dba092..fb41a83417 100644 --- a/osu.Game.Rulesets.Mania/ManiaMobileLayout.cs +++ b/osu.Game.Rulesets.Mania/ManiaMobileLayout.cs @@ -1,20 +1,25 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using osu.Framework.Localisation; using osu.Game.Localisation; +using osu.Game.Rulesets.Mania.Configuration; namespace osu.Game.Rulesets.Mania { public enum ManiaMobileLayout { - [LocalisableDescription(typeof(RulesetSettingsStrings), nameof(RulesetSettingsStrings.PortraitExpandedColumns))] + [LocalisableDescription(typeof(RulesetSettingsStrings), nameof(RulesetSettingsStrings.Portrait))] Portrait, - [LocalisableDescription(typeof(RulesetSettingsStrings), nameof(RulesetSettingsStrings.LandscapeExpandedColumns))] + [LocalisableDescription(typeof(RulesetSettingsStrings), nameof(RulesetSettingsStrings.Landscape))] Landscape, - [LocalisableDescription(typeof(RulesetSettingsStrings), nameof(RulesetSettingsStrings.LandscapeTouchOverlay))] + [LocalisableDescription(typeof(RulesetSettingsStrings), nameof(RulesetSettingsStrings.LandscapeExpandedColumns))] + LandscapeExpandedColumns, + + [Obsolete($"Use {nameof(ManiaRulesetSetting.TouchOverlay)} instead.")] // todo: can be removed 20260211 LandscapeWithOverlay, } } diff --git a/osu.Game.Rulesets.Mania/ManiaSettingsSubsection.cs b/osu.Game.Rulesets.Mania/ManiaSettingsSubsection.cs index 5ae7ec9480..791f46d407 100644 --- a/osu.Game.Rulesets.Mania/ManiaSettingsSubsection.cs +++ b/osu.Game.Rulesets.Mania/ManiaSettingsSubsection.cs @@ -1,6 +1,8 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; +using System.Linq; using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; @@ -48,12 +50,21 @@ namespace osu.Game.Rulesets.Mania }, }; + Add(new SettingsCheckbox + { + LabelText = RulesetSettingsStrings.TouchOverlay, + Current = config.GetBindable(ManiaRulesetSetting.TouchOverlay) + }); + if (RuntimeInfo.IsMobile) { Add(new SettingsEnumDropdown { LabelText = RulesetSettingsStrings.MobileLayout, Current = config.GetBindable(ManiaRulesetSetting.MobileLayout), +#pragma warning disable CS0618 // Type or member is obsolete + Items = Enum.GetValues().Where(l => l != ManiaMobileLayout.LandscapeWithOverlay), +#pragma warning restore CS0618 // Type or member is obsolete }); } } diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs index eccececd22..dec30043f5 100644 --- a/osu.Game.Rulesets.Mania/UI/Column.cs +++ b/osu.Game.Rulesets.Mania/UI/Column.cs @@ -58,7 +58,7 @@ namespace osu.Game.Rulesets.Mania.UI public readonly Bindable AccentColour = new Bindable(Color4.Black); - private IBindable mobilePlayStyle = null!; + private IBindable touchOverlay = null!; private float leftColumnSpacing; private float rightColumnSpacing; @@ -123,7 +123,7 @@ namespace osu.Game.Rulesets.Mania.UI RegisterPool(10, 50); if (rulesetConfig != null) - mobilePlayStyle = rulesetConfig.GetBindable(ManiaRulesetSetting.MobileLayout); + touchOverlay = rulesetConfig.GetBindable(ManiaRulesetSetting.TouchOverlay); } private void onSourceChanged() @@ -214,7 +214,7 @@ namespace osu.Game.Rulesets.Mania.UI protected override bool OnTouchDown(TouchDownEvent e) { // if touch overlay is visible, disallow columns from handling touch directly. - if (mobilePlayStyle.Value == ManiaMobileLayout.LandscapeWithOverlay) + if (touchOverlay.Value) return false; maniaInputManager?.KeyBindingContainer.TriggerPressed(Action.Value); diff --git a/osu.Game.Rulesets.Mania/UI/ColumnFlow.cs b/osu.Game.Rulesets.Mania/UI/ColumnFlow.cs index 953be8d507..03e5791519 100644 --- a/osu.Game.Rulesets.Mania/UI/ColumnFlow.cs +++ b/osu.Game.Rulesets.Mania/UI/ColumnFlow.cs @@ -104,7 +104,7 @@ namespace osu.Game.Rulesets.Mania.UI { float mobileAdjust = 1f; - if (RuntimeInfo.IsMobile && mobileLayout.Value == ManiaMobileLayout.Landscape) + if (RuntimeInfo.IsMobile && mobileLayout.Value == ManiaMobileLayout.LandscapeExpandedColumns) { // GridContainer+CellContainer containing this stage (gets split up for dual stages). Vector2? containingCell = this.FindClosestParent()?.Parent?.DrawSize; diff --git a/osu.Game.Rulesets.Mania/UI/DrawableManiaRuleset.cs b/osu.Game.Rulesets.Mania/UI/DrawableManiaRuleset.cs index fe3535d857..d9a03d1c30 100644 --- a/osu.Game.Rulesets.Mania/UI/DrawableManiaRuleset.cs +++ b/osu.Game.Rulesets.Mania/UI/DrawableManiaRuleset.cs @@ -59,6 +59,7 @@ namespace osu.Game.Rulesets.Mania.UI private readonly Bindable configDirection = new Bindable(); private readonly BindableDouble configScrollSpeed = new BindableDouble(); private readonly Bindable mobileLayout = new Bindable(); + private readonly Bindable touchOverlay = new Bindable(); public double TargetTimeRange { get; protected set; } @@ -122,24 +123,23 @@ namespace osu.Game.Rulesets.Mania.UI Config.BindWith(ManiaRulesetSetting.MobileLayout, mobileLayout); mobileLayout.BindValueChanged(_ => updateMobileLayout(), true); + + Config.BindWith(ManiaRulesetSetting.TouchOverlay, touchOverlay); + touchOverlay.BindValueChanged(_ => updateMobileLayout(), true); } private ManiaTouchInputArea? touchInputArea; private void updateMobileLayout() { - switch (mobileLayout.Value) + if (touchOverlay.Value) + KeyBindingInputManager.Add(touchInputArea = new ManiaTouchInputArea(this)); + else { - case ManiaMobileLayout.LandscapeWithOverlay: - KeyBindingInputManager.Add(touchInputArea = new ManiaTouchInputArea(this)); - break; + if (touchInputArea != null) + KeyBindingInputManager.Remove(touchInputArea, true); - default: - if (touchInputArea != null) - KeyBindingInputManager.Remove(touchInputArea, true); - - touchInputArea = null; - break; + touchInputArea = null; } } diff --git a/osu.Game/Localisation/RulesetSettingsStrings.cs b/osu.Game/Localisation/RulesetSettingsStrings.cs index fc4fb58e26..891da585d8 100644 --- a/osu.Game/Localisation/RulesetSettingsStrings.cs +++ b/osu.Game/Localisation/RulesetSettingsStrings.cs @@ -95,9 +95,14 @@ namespace osu.Game.Localisation public static LocalisableString MobileLayout => new TranslatableString(getKey(@"mobile_layout"), @"Mobile layout"); /// - /// "Portrait (expanded columns)" + /// "Portrait" /// - public static LocalisableString PortraitExpandedColumns => new TranslatableString(getKey(@"portrait_expanded_columns"), @"Portrait (expanded columns)"); + public static LocalisableString Portrait => new TranslatableString(getKey(@"portrait"), @"Portrait"); + + /// + /// "Landscape" + /// + public static LocalisableString Landscape => new TranslatableString(getKey(@"landscape"), @"Landscape"); /// /// "Landscape (expanded columns)" @@ -105,9 +110,9 @@ namespace osu.Game.Localisation public static LocalisableString LandscapeExpandedColumns => new TranslatableString(getKey(@"landscape_expanded_columns"), @"Landscape (expanded columns)"); /// - /// "Landscape (touch overlay)" + /// "Touch overlay" /// - public static LocalisableString LandscapeTouchOverlay => new TranslatableString(getKey(@"landscape_touch_overlay"), @"Landscape (touch overlay)"); + public static LocalisableString TouchOverlay => new TranslatableString(getKey(@"touch_overlay"), @"Touch overlay"); private static string getKey(string key) => $@"{prefix}:{key}"; }