mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 15:03:13 +08:00
Use OsuGame.OverlayActivationMode rather than per-Player
This commit is contained in:
parent
1877312a91
commit
782fc1d60f
@ -8,13 +8,12 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Screens.Play;
|
||||
|
||||
namespace osu.Game.Input
|
||||
{
|
||||
/// <summary>
|
||||
/// Connects <see cref="OsuSetting.ConfineMouseMode"/> with <see cref="FrameworkSetting.ConfineMouseMode"/>,
|
||||
/// while optionally binding an <see cref="OverlayActivation"/> mode, usually that of the current <see cref="Player"/>.
|
||||
/// while binding <see cref="OsuGame.OverlayActivationMode"/>.
|
||||
/// It is assumed that while overlay activation is <see cref="OverlayActivation.Disabled"/>, we should also confine the
|
||||
/// mouse cursor if it has been requested with <see cref="OsuConfineMouseMode.WhenOverlaysDisabled"/>.
|
||||
/// </summary>
|
||||
@ -22,22 +21,16 @@ namespace osu.Game.Input
|
||||
{
|
||||
private Bindable<ConfineMouseMode> frameworkConfineMode;
|
||||
private Bindable<OsuConfineMouseMode> osuConfineMode;
|
||||
|
||||
/// <summary>
|
||||
/// The bindable used to indicate whether gameplay is active.
|
||||
/// Should be bound to the corresponding bindable of the current <see cref="Player"/>.
|
||||
/// Defaults to <see cref="OverlayActivation.All"/> to assume that all other screens are considered "not gameplay".
|
||||
/// </summary>
|
||||
public IBindable<OverlayActivation> OverlayActivationMode { get; } = new Bindable<OverlayActivation>(OverlayActivation.All);
|
||||
private IBindable<OverlayActivation> overlayActivationMode;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(FrameworkConfigManager frameworkConfigManager, OsuConfigManager osuConfigManager)
|
||||
private void load(OsuGame game, FrameworkConfigManager frameworkConfigManager, OsuConfigManager osuConfigManager)
|
||||
{
|
||||
frameworkConfineMode = frameworkConfigManager.GetBindable<ConfineMouseMode>(FrameworkSetting.ConfineMouseMode);
|
||||
osuConfineMode = osuConfigManager.GetBindable<OsuConfineMouseMode>(OsuSetting.ConfineMouseMode);
|
||||
osuConfineMode.ValueChanged += _ => updateConfineMode();
|
||||
|
||||
OverlayActivationMode.BindValueChanged(_ => updateConfineMode(), true);
|
||||
overlayActivationMode = game.OverlayActivationMode.GetBoundCopy();
|
||||
overlayActivationMode.BindValueChanged(_ => updateConfineMode(), true);
|
||||
}
|
||||
|
||||
private void updateConfineMode()
|
||||
@ -53,7 +46,7 @@ namespace osu.Game.Input
|
||||
break;
|
||||
|
||||
case OsuConfineMouseMode.WhenOverlaysDisabled:
|
||||
frameworkConfineMode.Value = OverlayActivationMode.Value == OverlayActivation.Disabled ? ConfineMouseMode.Always : ConfineMouseMode.Never;
|
||||
frameworkConfineMode.Value = overlayActivationMode?.Value == OverlayActivation.Disabled ? ConfineMouseMode.Always : ConfineMouseMode.Never;
|
||||
break;
|
||||
|
||||
case OsuConfineMouseMode.Always:
|
||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Input
|
||||
Fullscreen,
|
||||
|
||||
/// <summary>
|
||||
/// The mouse cursor will be locked to the window bounds during gameplay,
|
||||
/// The mouse cursor will be locked to the window bounds while overlays are disabled,
|
||||
/// but may otherwise move freely.
|
||||
/// </summary>
|
||||
[Description("During Gameplay")]
|
||||
|
@ -18,7 +18,6 @@ using osu.Framework.Threading;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Input;
|
||||
using osu.Game.IO.Archives;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Overlays;
|
||||
@ -67,9 +66,6 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
private Bindable<bool> mouseWheelDisabled;
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private ConfineMouseTracker confineMouseTracker { get; set; }
|
||||
|
||||
private readonly Bindable<bool> storyboardReplacesBackground = new Bindable<bool>();
|
||||
|
||||
public int RestartCount;
|
||||
@ -229,8 +225,6 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
DrawableRuleset.HasReplayLoaded.BindValueChanged(_ => updatePauseOnFocusLostState(), true);
|
||||
|
||||
confineMouseTracker?.OverlayActivationMode.BindTo(OverlayActivationMode);
|
||||
|
||||
// bind clock into components that require it
|
||||
DrawableRuleset.IsPaused.BindTo(GameplayClockContainer.IsPaused);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user