mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Merge remote-tracking branch 'refs/remotes/ppy/master' into beatmap-mod-selector
This commit is contained in:
@ -52,19 +52,23 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
AddStep("start confirming", () => overlay.Begin());
|
AddStep("start confirming", () => overlay.Begin());
|
||||||
AddStep("abort confirming", () => overlay.Abort());
|
AddStep("abort confirming", () => overlay.Abort());
|
||||||
|
|
||||||
|
AddAssert("ensure not fired internally", () => !overlay.Fired);
|
||||||
AddAssert("ensure aborted", () => !fired);
|
AddAssert("ensure aborted", () => !fired);
|
||||||
|
|
||||||
AddStep("start confirming", () => overlay.Begin());
|
AddStep("start confirming", () => overlay.Begin());
|
||||||
|
|
||||||
AddUntilStep("wait until confirmed", () => fired);
|
AddUntilStep("wait until confirmed", () => fired);
|
||||||
|
AddAssert("ensure fired internally", () => overlay.Fired);
|
||||||
|
|
||||||
|
AddStep("abort after fire", () => overlay.Abort());
|
||||||
|
AddAssert("ensure not fired internally", () => !overlay.Fired);
|
||||||
|
AddStep("start confirming", () => overlay.Begin());
|
||||||
|
AddUntilStep("wait until fired again", () => overlay.Fired);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestHoldToConfirmOverlay : ExitConfirmOverlay
|
private class TestHoldToConfirmOverlay : ExitConfirmOverlay
|
||||||
{
|
{
|
||||||
protected override bool AllowMultipleFires => true;
|
|
||||||
|
|
||||||
public void Begin() => BeginConfirm();
|
public void Begin() => BeginConfirm();
|
||||||
public void Abort() => AbortConfirm();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,6 +114,8 @@ namespace osu.Game.Configuration
|
|||||||
|
|
||||||
Set(OsuSetting.UIScale, 1f, 0.8f, 1.6f, 0.01f);
|
Set(OsuSetting.UIScale, 1f, 0.8f, 1.6f, 0.01f);
|
||||||
|
|
||||||
|
Set(OsuSetting.UIHoldActivationDelay, 200, 0, 500);
|
||||||
|
|
||||||
Set(OsuSetting.IntroSequence, IntroSequence.Triangles);
|
Set(OsuSetting.IntroSequence, IntroSequence.Triangles);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,6 +185,7 @@ namespace osu.Game.Configuration
|
|||||||
ScalingSizeY,
|
ScalingSizeY,
|
||||||
UIScale,
|
UIScale,
|
||||||
IntroSequence,
|
IntroSequence,
|
||||||
|
UIHoldActivationDelay,
|
||||||
HitLighting
|
HitLighting
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,11 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Game.Configuration;
|
||||||
|
|
||||||
namespace osu.Game.Graphics.Containers
|
namespace osu.Game.Graphics.Containers
|
||||||
{
|
{
|
||||||
@ -12,12 +14,13 @@ namespace osu.Game.Graphics.Containers
|
|||||||
{
|
{
|
||||||
public Action Action;
|
public Action Action;
|
||||||
|
|
||||||
private const int default_activation_delay = 200;
|
|
||||||
private const int fadeout_delay = 200;
|
private const int fadeout_delay = 200;
|
||||||
|
|
||||||
private readonly double activationDelay;
|
/// <summary>
|
||||||
|
/// Whether currently in a fired state (and the confirm <see cref="Action"/> has been sent).
|
||||||
|
/// </summary>
|
||||||
|
public bool Fired { get; private set; }
|
||||||
|
|
||||||
private bool fired;
|
|
||||||
private bool confirming;
|
private bool confirming;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -27,35 +30,35 @@ namespace osu.Game.Graphics.Containers
|
|||||||
|
|
||||||
public Bindable<double> Progress = new BindableDouble();
|
public Bindable<double> Progress = new BindableDouble();
|
||||||
|
|
||||||
/// <summary>
|
private Bindable<int> holdActivationDelay;
|
||||||
/// Create a new instance.
|
|
||||||
/// </summary>
|
[BackgroundDependencyLoader]
|
||||||
/// <param name="activationDelay">The time requried before an action is confirmed.</param>
|
private void load(OsuConfigManager config)
|
||||||
protected HoldToConfirmContainer(double activationDelay = default_activation_delay)
|
|
||||||
{
|
{
|
||||||
this.activationDelay = activationDelay;
|
holdActivationDelay = config.GetBindable<int>(OsuSetting.UIHoldActivationDelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void BeginConfirm()
|
protected void BeginConfirm()
|
||||||
{
|
{
|
||||||
if (confirming || (!AllowMultipleFires && fired)) return;
|
if (confirming || (!AllowMultipleFires && Fired)) return;
|
||||||
|
|
||||||
confirming = true;
|
confirming = true;
|
||||||
|
|
||||||
this.TransformBindableTo(Progress, 1, activationDelay * (1 - Progress.Value), Easing.Out).OnComplete(_ => Confirm());
|
this.TransformBindableTo(Progress, 1, holdActivationDelay.Value * (1 - Progress.Value), Easing.Out).OnComplete(_ => Confirm());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void Confirm()
|
protected virtual void Confirm()
|
||||||
{
|
{
|
||||||
Action?.Invoke();
|
Action?.Invoke();
|
||||||
fired = true;
|
Fired = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void AbortConfirm()
|
protected void AbortConfirm()
|
||||||
{
|
{
|
||||||
if (!AllowMultipleFires && fired) return;
|
if (!AllowMultipleFires && Fired) return;
|
||||||
|
|
||||||
confirming = false;
|
confirming = false;
|
||||||
|
Fired = false;
|
||||||
|
|
||||||
this.TransformBindableTo(Progress, 0, fadeout_delay, Easing.Out);
|
this.TransformBindableTo(Progress, 0, fadeout_delay, Easing.Out);
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,8 @@ namespace osu.Game.Overlays
|
|||||||
public class DialogOverlay : OsuFocusedOverlayContainer
|
public class DialogOverlay : OsuFocusedOverlayContainer
|
||||||
{
|
{
|
||||||
private readonly Container dialogContainer;
|
private readonly Container dialogContainer;
|
||||||
private PopupDialog currentDialog;
|
|
||||||
|
public PopupDialog CurrentDialog { get; private set; }
|
||||||
|
|
||||||
public DialogOverlay()
|
public DialogOverlay()
|
||||||
{
|
{
|
||||||
@ -31,15 +32,15 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
public void Push(PopupDialog dialog)
|
public void Push(PopupDialog dialog)
|
||||||
{
|
{
|
||||||
if (dialog == currentDialog) return;
|
if (dialog == CurrentDialog) return;
|
||||||
|
|
||||||
currentDialog?.Hide();
|
CurrentDialog?.Hide();
|
||||||
currentDialog = dialog;
|
CurrentDialog = dialog;
|
||||||
|
|
||||||
dialogContainer.Add(currentDialog);
|
dialogContainer.Add(CurrentDialog);
|
||||||
|
|
||||||
currentDialog.Show();
|
CurrentDialog.Show();
|
||||||
currentDialog.State.ValueChanged += state => onDialogOnStateChanged(dialog, state.NewValue);
|
CurrentDialog.State.ValueChanged += state => onDialogOnStateChanged(dialog, state.NewValue);
|
||||||
Show();
|
Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,8 +53,11 @@ namespace osu.Game.Overlays
|
|||||||
//handle the dialog being dismissed.
|
//handle the dialog being dismissed.
|
||||||
dialog.Delay(PopupDialog.EXIT_DURATION).Expire();
|
dialog.Delay(PopupDialog.EXIT_DURATION).Expire();
|
||||||
|
|
||||||
if (dialog == currentDialog)
|
if (dialog == CurrentDialog)
|
||||||
|
{
|
||||||
Hide();
|
Hide();
|
||||||
|
CurrentDialog = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void PopIn()
|
protected override void PopIn()
|
||||||
@ -66,9 +70,9 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
base.PopOut();
|
base.PopOut();
|
||||||
|
|
||||||
if (currentDialog?.State.Value == Visibility.Visible)
|
if (CurrentDialog?.State.Value == Visibility.Visible)
|
||||||
{
|
{
|
||||||
currentDialog.Hide();
|
CurrentDialog.Hide();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +84,7 @@ namespace osu.Game.Overlays
|
|||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
case GlobalAction.Select:
|
case GlobalAction.Select:
|
||||||
currentDialog?.Buttons.OfType<PopupDialogOkButton>().FirstOrDefault()?.Click();
|
CurrentDialog?.Buttons.OfType<PopupDialogOkButton>().FirstOrDefault()?.Click();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
audio.Tracks.RemoveAdjustment(AdjustableProperty.Volume, audioVolume);
|
audio?.Tracks.RemoveAdjustment(AdjustableProperty.Volume, audioVolume);
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Settings.Sections.Graphics
|
namespace osu.Game.Overlays.Settings.Sections.Graphics
|
||||||
{
|
{
|
||||||
@ -13,7 +15,7 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuConfigManager config)
|
private void load(OsuConfigManager config)
|
||||||
{
|
{
|
||||||
Children = new[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new SettingsCheckbox
|
new SettingsCheckbox
|
||||||
{
|
{
|
||||||
@ -25,7 +27,18 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
|
|||||||
LabelText = "Parallax",
|
LabelText = "Parallax",
|
||||||
Bindable = config.GetBindable<bool>(OsuSetting.MenuParallax)
|
Bindable = config.GetBindable<bool>(OsuSetting.MenuParallax)
|
||||||
},
|
},
|
||||||
|
new SettingsSlider<int, TimeSlider>
|
||||||
|
{
|
||||||
|
LabelText = "Hold-to-confirm activation time",
|
||||||
|
Bindable = config.GetBindable<int>(OsuSetting.UIHoldActivationDelay),
|
||||||
|
KeyboardStep = 50
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class TimeSlider : OsuSliderBar<int>
|
||||||
|
{
|
||||||
|
public override string TooltipText => Current.Value.ToString("N0") + "ms";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,10 @@ namespace osu.Game.Screens.Menu
|
|||||||
{
|
{
|
||||||
public class ExitConfirmOverlay : HoldToConfirmOverlay, IKeyBindingHandler<GlobalAction>
|
public class ExitConfirmOverlay : HoldToConfirmOverlay, IKeyBindingHandler<GlobalAction>
|
||||||
{
|
{
|
||||||
|
protected override bool AllowMultipleFires => true;
|
||||||
|
|
||||||
|
public void Abort() => AbortConfirm();
|
||||||
|
|
||||||
public bool OnPressed(GlobalAction action)
|
public bool OnPressed(GlobalAction action)
|
||||||
{
|
{
|
||||||
if (action == GlobalAction.Back)
|
if (action == GlobalAction.Back)
|
||||||
@ -24,7 +28,8 @@ namespace osu.Game.Screens.Menu
|
|||||||
{
|
{
|
||||||
if (action == GlobalAction.Back)
|
if (action == GlobalAction.Back)
|
||||||
{
|
{
|
||||||
AbortConfirm();
|
if (!Fired)
|
||||||
|
AbortConfirm();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,18 +1,22 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
|
using osu.Game.Overlays.Dialog;
|
||||||
using osu.Game.Screens.Backgrounds;
|
using osu.Game.Screens.Backgrounds;
|
||||||
using osu.Game.Screens.Charts;
|
using osu.Game.Screens.Charts;
|
||||||
using osu.Game.Screens.Edit;
|
using osu.Game.Screens.Edit;
|
||||||
@ -51,15 +55,24 @@ namespace osu.Game.Screens.Menu
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private IAPIProvider api { get; set; }
|
private IAPIProvider api { get; set; }
|
||||||
|
|
||||||
|
[Resolved(canBeNull: true)]
|
||||||
|
private DialogOverlay dialogOverlay { get; set; }
|
||||||
|
|
||||||
private BackgroundScreenDefault background;
|
private BackgroundScreenDefault background;
|
||||||
|
|
||||||
protected override BackgroundScreen CreateBackground() => background;
|
protected override BackgroundScreen CreateBackground() => background;
|
||||||
|
|
||||||
|
private Bindable<int> holdDelay;
|
||||||
|
|
||||||
|
private ExitConfirmOverlay exitConfirmOverlay;
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(DirectOverlay direct, SettingsOverlay settings)
|
private void load(DirectOverlay direct, SettingsOverlay settings, OsuConfigManager config)
|
||||||
{
|
{
|
||||||
if (host.CanExit)
|
if (host.CanExit)
|
||||||
AddInternal(new ExitConfirmOverlay { Action = this.Exit });
|
AddInternal(exitConfirmOverlay = new ExitConfirmOverlay { Action = this.Exit });
|
||||||
|
|
||||||
|
holdDelay = config.GetBindable<int>(OsuSetting.UIHoldActivationDelay);
|
||||||
|
|
||||||
AddRangeInternal(new Drawable[]
|
AddRangeInternal(new Drawable[]
|
||||||
{
|
{
|
||||||
@ -74,7 +87,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
OnEdit = delegate { this.Push(new Editor()); },
|
OnEdit = delegate { this.Push(new Editor()); },
|
||||||
OnSolo = onSolo,
|
OnSolo = onSolo,
|
||||||
OnMulti = delegate { this.Push(new Multiplayer()); },
|
OnMulti = delegate { this.Push(new Multiplayer()); },
|
||||||
OnExit = this.Exit,
|
OnExit = confirmAndExit,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -103,6 +116,12 @@ namespace osu.Game.Screens.Menu
|
|||||||
preloadSongSelect();
|
preloadSongSelect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void confirmAndExit()
|
||||||
|
{
|
||||||
|
exitConfirmed = true;
|
||||||
|
this.Exit();
|
||||||
|
}
|
||||||
|
|
||||||
private void preloadSongSelect()
|
private void preloadSongSelect()
|
||||||
{
|
{
|
||||||
if (songSelect == null)
|
if (songSelect == null)
|
||||||
@ -141,6 +160,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
}
|
}
|
||||||
|
|
||||||
private bool loginDisplayed;
|
private bool loginDisplayed;
|
||||||
|
private bool exitConfirmed;
|
||||||
|
|
||||||
protected override void LogoArriving(OsuLogo logo, bool resuming)
|
protected override void LogoArriving(OsuLogo logo, bool resuming)
|
||||||
{
|
{
|
||||||
@ -221,9 +241,40 @@ namespace osu.Game.Screens.Menu
|
|||||||
|
|
||||||
public override bool OnExiting(IScreen next)
|
public override bool OnExiting(IScreen next)
|
||||||
{
|
{
|
||||||
|
if (holdDelay.Value == 0 && !exitConfirmed && dialogOverlay != null && !(dialogOverlay.CurrentDialog is ConfirmExitDialog))
|
||||||
|
{
|
||||||
|
dialogOverlay.Push(new ConfirmExitDialog(confirmAndExit, () => exitConfirmOverlay.Abort()));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
buttons.State = ButtonSystemState.Exit;
|
buttons.State = ButtonSystemState.Exit;
|
||||||
this.FadeOut(3000);
|
this.FadeOut(3000);
|
||||||
return base.OnExiting(next);
|
return base.OnExiting(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class ConfirmExitDialog : PopupDialog
|
||||||
|
{
|
||||||
|
public ConfirmExitDialog(Action confirm, Action cancel)
|
||||||
|
{
|
||||||
|
HeaderText = "Are you sure you want to exit?";
|
||||||
|
BodyText = "Last chance to back out.";
|
||||||
|
|
||||||
|
Icon = FontAwesome.Solid.ExclamationTriangle;
|
||||||
|
|
||||||
|
Buttons = new PopupDialogButton[]
|
||||||
|
{
|
||||||
|
new PopupDialogOkButton
|
||||||
|
{
|
||||||
|
Text = @"Good bye",
|
||||||
|
Action = confirm
|
||||||
|
},
|
||||||
|
new PopupDialogCancelButton
|
||||||
|
{
|
||||||
|
Text = @"Just a little more",
|
||||||
|
Action = cancel
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user