Allow enabling osu!mania touch overlay on non-mobile platforms

This commit is contained in:
AeroKoder
2025-07-29 16:27:45 -07:00
committed by Salman Alshamrani
parent bec0b94af6
commit ef972e4a04
8 changed files with 59 additions and 22 deletions

View File

@@ -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<ManiaTouchInputArea>().SingleOrDefault();

View File

@@ -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<ManiaMobileLayout>(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,
}
}

View File

@@ -1,20 +1,25 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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,
}
}

View File

@@ -1,6 +1,8 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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<bool>(ManiaRulesetSetting.TouchOverlay)
});
if (RuntimeInfo.IsMobile)
{
Add(new SettingsEnumDropdown<ManiaMobileLayout>
{
LabelText = RulesetSettingsStrings.MobileLayout,
Current = config.GetBindable<ManiaMobileLayout>(ManiaRulesetSetting.MobileLayout),
#pragma warning disable CS0618 // Type or member is obsolete
Items = Enum.GetValues<ManiaMobileLayout>().Where(l => l != ManiaMobileLayout.LandscapeWithOverlay),
#pragma warning restore CS0618 // Type or member is obsolete
});
}
}

View File

@@ -58,7 +58,7 @@ namespace osu.Game.Rulesets.Mania.UI
public readonly Bindable<Color4> AccentColour = new Bindable<Color4>(Color4.Black);
private IBindable<ManiaMobileLayout> mobilePlayStyle = null!;
private IBindable<bool> touchOverlay = null!;
private float leftColumnSpacing;
private float rightColumnSpacing;
@@ -123,7 +123,7 @@ namespace osu.Game.Rulesets.Mania.UI
RegisterPool<HoldNoteBody, DrawableHoldNoteBody>(10, 50);
if (rulesetConfig != null)
mobilePlayStyle = rulesetConfig.GetBindable<ManiaMobileLayout>(ManiaRulesetSetting.MobileLayout);
touchOverlay = rulesetConfig.GetBindable<bool>(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);

View File

@@ -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<Stage>()?.Parent?.DrawSize;

View File

@@ -59,6 +59,7 @@ namespace osu.Game.Rulesets.Mania.UI
private readonly Bindable<ManiaScrollingDirection> configDirection = new Bindable<ManiaScrollingDirection>();
private readonly BindableDouble configScrollSpeed = new BindableDouble();
private readonly Bindable<ManiaMobileLayout> mobileLayout = new Bindable<ManiaMobileLayout>();
private readonly Bindable<bool> touchOverlay = new Bindable<bool>();
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;
}
}

View File

@@ -95,9 +95,14 @@ namespace osu.Game.Localisation
public static LocalisableString MobileLayout => new TranslatableString(getKey(@"mobile_layout"), @"Mobile layout");
/// <summary>
/// "Portrait (expanded columns)"
/// "Portrait"
/// </summary>
public static LocalisableString PortraitExpandedColumns => new TranslatableString(getKey(@"portrait_expanded_columns"), @"Portrait (expanded columns)");
public static LocalisableString Portrait => new TranslatableString(getKey(@"portrait"), @"Portrait");
/// <summary>
/// "Landscape"
/// </summary>
public static LocalisableString Landscape => new TranslatableString(getKey(@"landscape"), @"Landscape");
/// <summary>
/// "Landscape (expanded columns)"
@@ -105,9 +110,9 @@ namespace osu.Game.Localisation
public static LocalisableString LandscapeExpandedColumns => new TranslatableString(getKey(@"landscape_expanded_columns"), @"Landscape (expanded columns)");
/// <summary>
/// "Landscape (touch overlay)"
/// "Touch overlay"
/// </summary>
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}";
}