1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 15:17:27 +08:00

Add disable taps checkbox to touch input settings

This commit is contained in:
Susko3 2023-11-05 12:40:06 +01:00
parent bc9cdb4ce0
commit 86fb33cb90
4 changed files with 53 additions and 11 deletions

View File

@ -11,6 +11,7 @@ using osu.Framework.Input.Handlers;
using osu.Framework.Platform;
using osu.Game;
using osu.Game.Overlays.Settings;
using osu.Game.Overlays.Settings.Sections.Input;
using osu.Game.Updater;
using osu.Game.Utils;
@ -97,6 +98,9 @@ namespace osu.Android
case AndroidJoystickHandler jh:
return new AndroidJoystickSettings(jh);
case AndroidTouchHandler:
return new TouchSettings(handler);
default:
return base.CreateSettingsSubsectionFor(handler);
}

View File

@ -330,6 +330,10 @@ namespace osu.Game.Configuration
ShowHealthDisplayWhenCantFail,
FadePlayfieldWhenHealthLow,
/// <summary>
/// Disables mouse buttons clicks and touchscreen taps during gameplay.
/// </summary>
MouseDisableButtons,
MouseDisableWheel,
ConfineMouseMode,

View File

@ -0,0 +1,24 @@
// 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 osu.Framework.Localisation;
namespace osu.Game.Localisation
{
public static class TouchSettingsStrings
{
private const string prefix = @"osu.Game.Resources.Localisation.TouchSettings";
/// <summary>
/// "Touch"
/// </summary>
public static LocalisableString Touch => new TranslatableString(getKey(@"touch"), @"Touch");
/// <summary>
/// "Disable taps during gameplay"
/// </summary>
public static LocalisableString DisableTapsDuringGameplay => new TranslatableString(getKey(@"disable_taps_during_gameplay"), @"Disable taps during gameplay");
private static string getKey(string key) => $@"{prefix}:{key}";
}
}

View File

@ -3,38 +3,48 @@
using System.Collections.Generic;
using System.Linq;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Input.Handlers.Touch;
using osu.Framework.Input.Handlers;
using osu.Framework.Localisation;
using osu.Game.Configuration;
using osu.Game.Localisation;
namespace osu.Game.Overlays.Settings.Sections.Input
{
/// <summary>
/// Touch input settings subsection common to all touch handlers (even on different platforms).
/// </summary>
public partial class TouchSettings : SettingsSubsection
{
private readonly TouchHandler handler;
private readonly InputHandler handler;
public TouchSettings(TouchHandler handler)
protected override LocalisableString Header => TouchSettingsStrings.Touch;
public TouchSettings(InputHandler handler)
{
this.handler = handler;
}
[BackgroundDependencyLoader]
private void load()
private void load(OsuConfigManager osuConfig)
{
Children = new Drawable[]
if (!RuntimeInfo.IsMobile) // don't allow disabling the only input method (touch) on mobile.
{
new SettingsCheckbox
Add(new SettingsCheckbox
{
LabelText = CommonStrings.Enabled,
Current = handler.Enabled
},
};
});
}
Add(new SettingsCheckbox
{
LabelText = TouchSettingsStrings.DisableTapsDuringGameplay,
Current = osuConfig.GetBindable<bool>(OsuSetting.MouseDisableButtons)
});
}
public override IEnumerable<LocalisableString> FilterTerms => base.FilterTerms.Concat(new LocalisableString[] { @"touchscreen" });
protected override LocalisableString Header => handler.Description;
}
}