mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 01:02:55 +08:00
Merge branch 'master' into catch_spinner
This commit is contained in:
commit
6ee96c758f
@ -1 +1 @@
|
|||||||
Subproject commit 80e78fd45bb79ca4bc46ecc05deb6058f3879faa
|
Subproject commit eb076a3301231eb73917073499051e49a9b12978
|
57
osu.Game.Tests/Visual/TestCaseQuitButton.cs
Normal file
57
osu.Game.Tests/Visual/TestCaseQuitButton.cs
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Game.Screens.Play.HUD;
|
||||||
|
using OpenTK;
|
||||||
|
using OpenTK.Input;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual
|
||||||
|
{
|
||||||
|
[Description("'Hold to Quit' UI element")]
|
||||||
|
public class TestCaseQuitButton : ManualInputManagerTestCase
|
||||||
|
{
|
||||||
|
private bool exitAction;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
QuitButton quitButton;
|
||||||
|
|
||||||
|
Add(quitButton = new QuitButton
|
||||||
|
{
|
||||||
|
Origin = Anchor.BottomRight,
|
||||||
|
Anchor = Anchor.BottomRight,
|
||||||
|
Action = () => exitAction = true
|
||||||
|
});
|
||||||
|
|
||||||
|
var text = quitButton.Children.OfType<SpriteText>().First();
|
||||||
|
|
||||||
|
// initial display
|
||||||
|
AddUntilStep(() => text.IsPresent && !exitAction, "Text visible");
|
||||||
|
AddUntilStep(() => !text.IsPresent && !exitAction, "Text is not visible");
|
||||||
|
|
||||||
|
AddStep("Trigger text fade in", () => InputManager.MoveMouseTo(quitButton));
|
||||||
|
AddUntilStep(() => text.IsPresent && !exitAction, "Text visible");
|
||||||
|
AddStep("Trigger text fade out", () => InputManager.MoveMouseTo(Vector2.One));
|
||||||
|
AddUntilStep(() => !text.IsPresent && !exitAction, "Text is not visible");
|
||||||
|
|
||||||
|
AddStep("Trigger exit action", () =>
|
||||||
|
{
|
||||||
|
exitAction = false;
|
||||||
|
InputManager.MoveMouseTo(quitButton);
|
||||||
|
InputManager.ButtonDown(MouseButton.Left);
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("Early release", () => InputManager.ButtonUp(MouseButton.Left));
|
||||||
|
AddAssert("action not triggered", () => !exitAction);
|
||||||
|
|
||||||
|
AddStep("Trigger exit action", () => InputManager.ButtonDown(MouseButton.Left));
|
||||||
|
AddUntilStep(() => exitAction, $"{nameof(quitButton.Action)} was triggered");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
52
osu.Game/Graphics/Containers/HoldToConfirmContainer.cs
Normal file
52
osu.Game/Graphics/Containers/HoldToConfirmContainer.cs
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
|
||||||
|
namespace osu.Game.Graphics.Containers
|
||||||
|
{
|
||||||
|
public abstract class HoldToConfirmContainer : Container
|
||||||
|
{
|
||||||
|
public Action Action;
|
||||||
|
|
||||||
|
private const int activate_delay = 400;
|
||||||
|
private const int fadeout_delay = 200;
|
||||||
|
|
||||||
|
private bool fired;
|
||||||
|
private bool confirming;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the overlay should be allowed to return from a fired state.
|
||||||
|
/// </summary>
|
||||||
|
protected virtual bool AllowMultipleFires => false;
|
||||||
|
|
||||||
|
public Bindable<double> Progress = new BindableDouble();
|
||||||
|
|
||||||
|
protected void BeginConfirm()
|
||||||
|
{
|
||||||
|
if (confirming || !AllowMultipleFires && fired) return;
|
||||||
|
|
||||||
|
confirming = true;
|
||||||
|
|
||||||
|
this.TransformBindableTo(Progress, 1, activate_delay * (1 - Progress.Value), Easing.Out).OnComplete(_ => Confirm());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void Confirm()
|
||||||
|
{
|
||||||
|
Action?.Invoke();
|
||||||
|
fired = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void AbortConfirm()
|
||||||
|
{
|
||||||
|
if (!AllowMultipleFires && fired) return;
|
||||||
|
|
||||||
|
confirming = false;
|
||||||
|
|
||||||
|
this.TransformBindableTo(Progress, 0, fadeout_delay, Easing.Out);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,7 @@ using osu.Framework.Audio.Sample;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
|
|
||||||
namespace osu.Game.Graphics.Containers
|
namespace osu.Game.Graphics.Containers
|
||||||
{
|
{
|
||||||
@ -15,9 +16,14 @@ namespace osu.Game.Graphics.Containers
|
|||||||
private SampleChannel samplePopIn;
|
private SampleChannel samplePopIn;
|
||||||
private SampleChannel samplePopOut;
|
private SampleChannel samplePopOut;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
private readonly BindableBool allowOpeningOverlays = new BindableBool(true);
|
||||||
private void load(AudioManager audio)
|
|
||||||
|
[BackgroundDependencyLoader(true)]
|
||||||
|
private void load(OsuGame osuGame, AudioManager audio)
|
||||||
{
|
{
|
||||||
|
if (osuGame != null)
|
||||||
|
allowOpeningOverlays.BindTo(osuGame.AllowOpeningOverlays);
|
||||||
|
|
||||||
samplePopIn = audio.Sample.Get(@"UI/overlay-pop-in");
|
samplePopIn = audio.Sample.Get(@"UI/overlay-pop-in");
|
||||||
samplePopOut = audio.Sample.Get(@"UI/overlay-pop-out");
|
samplePopOut = audio.Sample.Get(@"UI/overlay-pop-out");
|
||||||
|
|
||||||
@ -46,15 +52,20 @@ namespace osu.Game.Graphics.Containers
|
|||||||
|
|
||||||
private void onStateChanged(Visibility visibility)
|
private void onStateChanged(Visibility visibility)
|
||||||
{
|
{
|
||||||
switch (visibility)
|
if (allowOpeningOverlays)
|
||||||
{
|
{
|
||||||
case Visibility.Visible:
|
switch (visibility)
|
||||||
samplePopIn?.Play();
|
{
|
||||||
break;
|
case Visibility.Visible:
|
||||||
case Visibility.Hidden:
|
samplePopIn?.Play();
|
||||||
samplePopOut?.Play();
|
break;
|
||||||
break;
|
case Visibility.Hidden:
|
||||||
|
samplePopOut?.Play();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
State = Visibility.Hidden;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,8 @@ namespace osu.Game
|
|||||||
|
|
||||||
public float ToolbarOffset => Toolbar.Position.Y + Toolbar.DrawHeight;
|
public float ToolbarOffset => Toolbar.Position.Y + Toolbar.DrawHeight;
|
||||||
|
|
||||||
public readonly BindableBool ShowOverlays = new BindableBool();
|
public readonly BindableBool HideOverlaysOnEnter = new BindableBool();
|
||||||
|
public readonly BindableBool AllowOpeningOverlays = new BindableBool(true);
|
||||||
|
|
||||||
private OsuScreen screenStack;
|
private OsuScreen screenStack;
|
||||||
|
|
||||||
@ -367,12 +368,12 @@ namespace osu.Game
|
|||||||
settings.StateChanged += _ => updateScreenOffset();
|
settings.StateChanged += _ => updateScreenOffset();
|
||||||
notifications.StateChanged += _ => updateScreenOffset();
|
notifications.StateChanged += _ => updateScreenOffset();
|
||||||
|
|
||||||
notifications.Enabled.BindTo(ShowOverlays);
|
notifications.Enabled.BindTo(AllowOpeningOverlays);
|
||||||
|
|
||||||
ShowOverlays.ValueChanged += show =>
|
HideOverlaysOnEnter.ValueChanged += hide =>
|
||||||
{
|
{
|
||||||
//central game screen change logic.
|
//central game screen change logic.
|
||||||
if (!show)
|
if (hide)
|
||||||
{
|
{
|
||||||
hideAllOverlays();
|
hideAllOverlays();
|
||||||
musicController.State = Visibility.Hidden;
|
musicController.State = Visibility.Hidden;
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
@ -14,22 +13,10 @@ namespace osu.Game.Overlays
|
|||||||
/// An overlay which will display a black screen that dims over a period before confirming an exit action.
|
/// An overlay which will display a black screen that dims over a period before confirming an exit action.
|
||||||
/// Action is BYO (derived class will need to call <see cref="BeginConfirm"/> and <see cref="AbortConfirm"/> from a user event).
|
/// Action is BYO (derived class will need to call <see cref="BeginConfirm"/> and <see cref="AbortConfirm"/> from a user event).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class HoldToConfirmOverlay : Container
|
public abstract class HoldToConfirmOverlay : HoldToConfirmContainer
|
||||||
{
|
{
|
||||||
public Action Action;
|
|
||||||
|
|
||||||
private Box overlay;
|
private Box overlay;
|
||||||
|
|
||||||
private const int activate_delay = 400;
|
|
||||||
private const int fadeout_delay = 200;
|
|
||||||
|
|
||||||
private bool fired;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Whether the overlay should be allowed to return from a fired state.
|
|
||||||
/// </summary>
|
|
||||||
protected virtual bool AllowMultipleFires => false;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
@ -45,22 +32,8 @@ namespace osu.Game.Overlays
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
protected void BeginConfirm()
|
Progress.ValueChanged += v => overlay.Alpha = (float)v;
|
||||||
{
|
|
||||||
if (!AllowMultipleFires && fired) return;
|
|
||||||
overlay.FadeIn(activate_delay * (1 - overlay.Alpha), Easing.Out).OnComplete(_ =>
|
|
||||||
{
|
|
||||||
Action?.Invoke();
|
|
||||||
fired = true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void AbortConfirm()
|
|
||||||
{
|
|
||||||
if (!AllowMultipleFires && fired) return;
|
|
||||||
overlay.FadeOut(fadeout_delay, Easing.Out);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,9 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Caching;
|
using osu.Framework.Caching;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Input;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
|
using OpenTK.Input;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
@ -22,6 +24,7 @@ namespace osu.Game.Overlays.Toolbar
|
|||||||
private readonly Drawable modeButtonLine;
|
private readonly Drawable modeButtonLine;
|
||||||
private ToolbarModeButton activeButton;
|
private ToolbarModeButton activeButton;
|
||||||
|
|
||||||
|
private RulesetStore rulesets;
|
||||||
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
|
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
|
||||||
|
|
||||||
public ToolbarModeSelector()
|
public ToolbarModeSelector()
|
||||||
@ -67,26 +70,42 @@ namespace osu.Game.Overlays.Toolbar
|
|||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(RulesetStore rulesets, OsuGame game)
|
private void load(RulesetStore rulesets, OsuGame game)
|
||||||
{
|
{
|
||||||
|
this.rulesets = rulesets;
|
||||||
foreach (var r in rulesets.AvailableRulesets)
|
foreach (var r in rulesets.AvailableRulesets)
|
||||||
{
|
{
|
||||||
modeButtons.Add(new ToolbarModeButton
|
modeButtons.Add(new ToolbarModeButton
|
||||||
{
|
{
|
||||||
Ruleset = r,
|
Ruleset = r,
|
||||||
Action = delegate
|
Action = delegate { ruleset.Value = r; }
|
||||||
{
|
|
||||||
ruleset.Value = r;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ruleset.ValueChanged += rulesetChanged;
|
ruleset.ValueChanged += rulesetChanged;
|
||||||
ruleset.DisabledChanged += disabledChanged;
|
ruleset.DisabledChanged += disabledChanged;
|
||||||
|
|
||||||
if (game != null)
|
if (game != null)
|
||||||
ruleset.BindTo(game.Ruleset);
|
ruleset.BindTo(game.Ruleset);
|
||||||
else
|
else
|
||||||
ruleset.Value = rulesets.AvailableRulesets.FirstOrDefault();
|
ruleset.Value = rulesets.AvailableRulesets.FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||||
|
{
|
||||||
|
base.OnKeyDown(state, args);
|
||||||
|
|
||||||
|
if (state.Keyboard.ControlPressed && !args.Repeat && args.Key >= Key.Number1 && args.Key <= Key.Number9)
|
||||||
|
{
|
||||||
|
int requested = args.Key - Key.Number1;
|
||||||
|
|
||||||
|
RulesetInfo found = rulesets.AvailableRulesets.Skip(requested).FirstOrDefault();
|
||||||
|
if (found != null)
|
||||||
|
ruleset.Value = found;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public override bool HandleKeyboardInput => !ruleset.Disabled && base.HandleKeyboardInput;
|
public override bool HandleKeyboardInput => !ruleset.Disabled && base.HandleKeyboardInput;
|
||||||
public override bool HandleMouseInput => !ruleset.Disabled && base.HandleMouseInput;
|
public override bool HandleMouseInput => !ruleset.Disabled && base.HandleMouseInput;
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
{
|
{
|
||||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4");
|
protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4");
|
||||||
|
|
||||||
public override bool ShowOverlaysOnEnter => false;
|
protected override bool HideOverlaysOnEnter => true;
|
||||||
public override bool AllowBeatmapRulesetChange => false;
|
public override bool AllowBeatmapRulesetChange => false;
|
||||||
|
|
||||||
private Box bottomBackground;
|
private Box bottomBackground;
|
||||||
|
@ -17,7 +17,7 @@ namespace osu.Game.Screens
|
|||||||
{
|
{
|
||||||
private bool showDisclaimer;
|
private bool showDisclaimer;
|
||||||
|
|
||||||
public override bool ShowOverlaysOnEnter => false;
|
protected override bool HideOverlaysOnEnter => true;
|
||||||
|
|
||||||
protected override bool AllowBackButton => false;
|
protected override bool AllowBackButton => false;
|
||||||
|
|
||||||
|
@ -27,7 +27,8 @@ namespace osu.Game.Screens.Menu
|
|||||||
{
|
{
|
||||||
public event Action<MenuState> StateChanged;
|
public event Action<MenuState> StateChanged;
|
||||||
|
|
||||||
private readonly BindableBool showOverlays = new BindableBool();
|
private readonly BindableBool hideOverlaysOnEnter = new BindableBool();
|
||||||
|
private readonly BindableBool allowOpeningOverlays = new BindableBool();
|
||||||
|
|
||||||
public Action OnEdit;
|
public Action OnEdit;
|
||||||
public Action OnExit;
|
public Action OnExit;
|
||||||
@ -135,7 +136,12 @@ namespace osu.Game.Screens.Menu
|
|||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(AudioManager audio, OsuGame game)
|
private void load(AudioManager audio, OsuGame game)
|
||||||
{
|
{
|
||||||
if (game != null) showOverlays.BindTo(game.ShowOverlays);
|
if (game != null)
|
||||||
|
{
|
||||||
|
hideOverlaysOnEnter.BindTo(game.HideOverlaysOnEnter);
|
||||||
|
allowOpeningOverlays.BindTo(game.AllowOpeningOverlays);
|
||||||
|
}
|
||||||
|
|
||||||
sampleBack = audio.Sample.Get(@"Menu/button-back-select");
|
sampleBack = audio.Sample.Get(@"Menu/button-back-select");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,6 +154,8 @@ namespace osu.Game.Screens.Menu
|
|||||||
case Key.Space:
|
case Key.Space:
|
||||||
logo?.TriggerOnClick(state);
|
logo?.TriggerOnClick(state);
|
||||||
return true;
|
return true;
|
||||||
|
case Key.Escape:
|
||||||
|
return goBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -158,17 +166,22 @@ namespace osu.Game.Screens.Menu
|
|||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
case GlobalAction.Back:
|
case GlobalAction.Back:
|
||||||
switch (State)
|
return goBack();
|
||||||
{
|
default:
|
||||||
case MenuState.TopLevel:
|
return false;
|
||||||
State = MenuState.Initial;
|
}
|
||||||
return true;
|
}
|
||||||
case MenuState.Play:
|
|
||||||
backButton.TriggerOnClick();
|
private bool goBack()
|
||||||
return true;
|
{
|
||||||
default:
|
switch (State)
|
||||||
return false;
|
{
|
||||||
}
|
case MenuState.TopLevel:
|
||||||
|
State = MenuState.Initial;
|
||||||
|
return true;
|
||||||
|
case MenuState.Play:
|
||||||
|
backButton.TriggerOnClick();
|
||||||
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -322,7 +335,8 @@ namespace osu.Game.Screens.Menu
|
|||||||
|
|
||||||
logoDelayedAction = Scheduler.AddDelayed(() =>
|
logoDelayedAction = Scheduler.AddDelayed(() =>
|
||||||
{
|
{
|
||||||
showOverlays.Value = false;
|
hideOverlaysOnEnter.Value = true;
|
||||||
|
allowOpeningOverlays.Value = false;
|
||||||
|
|
||||||
logo.ClearTransforms(targetMember: nameof(Position));
|
logo.ClearTransforms(targetMember: nameof(Position));
|
||||||
logo.RelativePositionAxes = Axes.Both;
|
logo.RelativePositionAxes = Axes.Both;
|
||||||
@ -351,7 +365,9 @@ namespace osu.Game.Screens.Menu
|
|||||||
logoTracking = true;
|
logoTracking = true;
|
||||||
|
|
||||||
logo.Impact();
|
logo.Impact();
|
||||||
showOverlays.Value = true;
|
|
||||||
|
hideOverlaysOnEnter.Value = false;
|
||||||
|
allowOpeningOverlays.Value = true;
|
||||||
}, 200);
|
}, 200);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -18,7 +18,8 @@ namespace osu.Game.Screens.Menu
|
|||||||
private readonly SpriteIcon icon;
|
private readonly SpriteIcon icon;
|
||||||
private Color4 iconColour;
|
private Color4 iconColour;
|
||||||
|
|
||||||
public override bool ShowOverlaysOnEnter => false;
|
protected override bool HideOverlaysOnEnter => true;
|
||||||
|
|
||||||
public override bool CursorVisible => false;
|
public override bool CursorVisible => false;
|
||||||
|
|
||||||
public Disclaimer()
|
public Disclaimer()
|
||||||
|
@ -31,7 +31,9 @@ namespace osu.Game.Screens.Menu
|
|||||||
private SampleChannel welcome;
|
private SampleChannel welcome;
|
||||||
private SampleChannel seeya;
|
private SampleChannel seeya;
|
||||||
|
|
||||||
public override bool ShowOverlaysOnEnter => false;
|
protected override bool HideOverlaysOnEnter => true;
|
||||||
|
protected override bool AllowOpeningOverlays => false;
|
||||||
|
|
||||||
public override bool CursorVisible => false;
|
public override bool CursorVisible => false;
|
||||||
|
|
||||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenEmpty();
|
protected override BackgroundScreen CreateBackground() => new BackgroundScreenEmpty();
|
||||||
|
@ -24,7 +24,8 @@ namespace osu.Game.Screens.Menu
|
|||||||
{
|
{
|
||||||
private readonly ButtonSystem buttons;
|
private readonly ButtonSystem buttons;
|
||||||
|
|
||||||
public override bool ShowOverlaysOnEnter => buttons.State != MenuState.Initial;
|
protected override bool HideOverlaysOnEnter => buttons.State == MenuState.Initial;
|
||||||
|
protected override bool AllowOpeningOverlays => buttons.State != MenuState.Initial;
|
||||||
|
|
||||||
protected override bool AllowBackButton => buttons.State != MenuState.Initial;
|
protected override bool AllowBackButton => buttons.State != MenuState.Initial;
|
||||||
|
|
||||||
|
@ -32,12 +32,19 @@ namespace osu.Game.Screens
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual BackgroundScreen CreateBackground() => null;
|
protected virtual BackgroundScreen CreateBackground() => null;
|
||||||
|
|
||||||
protected BindableBool ShowOverlays = new BindableBool();
|
private readonly BindableBool hideOverlaysOnEnter = new BindableBool();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether overlays should be shown when this screen is entered or resumed.
|
/// Whether overlays should be hidden when this screen is entered or resumed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual bool ShowOverlaysOnEnter => true;
|
protected virtual bool HideOverlaysOnEnter => hideOverlaysOnEnter;
|
||||||
|
|
||||||
|
private readonly BindableBool allowOpeningOverlays = new BindableBool();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether overlays should be able to be opened while this screen is active.
|
||||||
|
/// </summary>
|
||||||
|
protected virtual bool AllowOpeningOverlays => allowOpeningOverlays;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether this <see cref="OsuScreen"/> allows the cursor to be displayed.
|
/// Whether this <see cref="OsuScreen"/> allows the cursor to be displayed.
|
||||||
@ -88,7 +95,8 @@ namespace osu.Game.Screens
|
|||||||
if (osuGame != null)
|
if (osuGame != null)
|
||||||
{
|
{
|
||||||
Ruleset.BindTo(osuGame.Ruleset);
|
Ruleset.BindTo(osuGame.Ruleset);
|
||||||
ShowOverlays.BindTo(osuGame.ShowOverlays);
|
hideOverlaysOnEnter.BindTo(osuGame.HideOverlaysOnEnter);
|
||||||
|
allowOpeningOverlays.BindTo(osuGame.AllowOpeningOverlays);
|
||||||
}
|
}
|
||||||
|
|
||||||
sampleExit = audio.Sample.Get(@"UI/screen-back");
|
sampleExit = audio.Sample.Get(@"UI/screen-back");
|
||||||
@ -220,7 +228,8 @@ namespace osu.Game.Screens
|
|||||||
if (backgroundParallaxContainer != null)
|
if (backgroundParallaxContainer != null)
|
||||||
backgroundParallaxContainer.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT * BackgroundParallaxAmount;
|
backgroundParallaxContainer.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT * BackgroundParallaxAmount;
|
||||||
|
|
||||||
ShowOverlays.Value = ShowOverlaysOnEnter;
|
hideOverlaysOnEnter.Value = HideOverlaysOnEnter;
|
||||||
|
allowOpeningOverlays.Value = AllowOpeningOverlays;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onExitingLogo()
|
private void onExitingLogo()
|
||||||
|
198
osu.Game/Screens/Play/HUD/QuitButton.cs
Normal file
198
osu.Game/Screens/Play/HUD/QuitButton.cs
Normal file
@ -0,0 +1,198 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
|
using osu.Framework.Input;
|
||||||
|
using osu.Framework.MathUtils;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using OpenTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Play.HUD
|
||||||
|
{
|
||||||
|
public class QuitButton : FillFlowContainer
|
||||||
|
{
|
||||||
|
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true;
|
||||||
|
|
||||||
|
private readonly Button button;
|
||||||
|
|
||||||
|
public Action Action
|
||||||
|
{
|
||||||
|
set => button.Action = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly OsuSpriteText text;
|
||||||
|
|
||||||
|
public QuitButton()
|
||||||
|
{
|
||||||
|
Direction = FillDirection.Horizontal;
|
||||||
|
Spacing = new Vector2(20, 0);
|
||||||
|
Margin = new MarginPadding(10);
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
text = new OsuSpriteText
|
||||||
|
{
|
||||||
|
Text = "hold for menu",
|
||||||
|
Font = @"Exo2.0-Bold",
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft
|
||||||
|
},
|
||||||
|
button = new Button
|
||||||
|
{
|
||||||
|
HoverGained = () => text.FadeIn(500, Easing.OutQuint),
|
||||||
|
HoverLost = () => text.FadeOut(500, Easing.OutQuint)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
AutoSizeAxes = Axes.Both;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
text.FadeInFromZero(500, Easing.OutQuint).Delay(1500).FadeOut(500, Easing.OutQuint);
|
||||||
|
base.LoadComplete();
|
||||||
|
}
|
||||||
|
|
||||||
|
private float positionalAdjust;
|
||||||
|
|
||||||
|
protected override bool OnMouseMove(InputState state)
|
||||||
|
{
|
||||||
|
positionalAdjust = Vector2.Distance(state.Mouse.NativeState.Position, button.ScreenSpaceDrawQuad.Centre) / 200;
|
||||||
|
return base.OnMouseMove(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
if (text.Alpha > 0 || button.Progress.Value > 0 || button.IsHovered)
|
||||||
|
Alpha = 1;
|
||||||
|
else
|
||||||
|
Alpha = Interpolation.ValueAt(
|
||||||
|
MathHelper.Clamp(Clock.ElapsedFrameTime, 0, 1000),
|
||||||
|
Alpha, MathHelper.Clamp(1 - positionalAdjust, 0.04f, 1), 0, 200, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Button : HoldToConfirmContainer
|
||||||
|
{
|
||||||
|
private SpriteIcon icon;
|
||||||
|
private CircularProgress circularProgress;
|
||||||
|
private Circle overlayCircle;
|
||||||
|
|
||||||
|
protected override bool AllowMultipleFires => true;
|
||||||
|
|
||||||
|
public Action HoverGained;
|
||||||
|
public Action HoverLost;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours)
|
||||||
|
{
|
||||||
|
Size = new Vector2(60);
|
||||||
|
|
||||||
|
Child = new CircularContainer
|
||||||
|
{
|
||||||
|
Masking = true,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = colours.Gray1,
|
||||||
|
Alpha = 0.5f,
|
||||||
|
},
|
||||||
|
circularProgress = new CircularProgress
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
InnerRadius = 1
|
||||||
|
},
|
||||||
|
overlayCircle = new Circle
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = colours.Gray1,
|
||||||
|
Size = new Vector2(0.9f),
|
||||||
|
},
|
||||||
|
icon = new SpriteIcon
|
||||||
|
{
|
||||||
|
Shadow = false,
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Size = new Vector2(15),
|
||||||
|
Icon = FontAwesome.fa_close
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
bind();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void bind()
|
||||||
|
{
|
||||||
|
circularProgress.Current.BindTo(Progress);
|
||||||
|
Progress.ValueChanged += v => icon.Scale = new Vector2(1 + (float)v * 0.2f);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool pendingAnimation;
|
||||||
|
|
||||||
|
protected override void Confirm()
|
||||||
|
{
|
||||||
|
base.Confirm();
|
||||||
|
|
||||||
|
// temporarily unbind as to not look weird if releasing during confirm animation (can see the unwind of progress).
|
||||||
|
Progress.UnbindAll();
|
||||||
|
|
||||||
|
// avoid starting a new confirm call until we finish animating.
|
||||||
|
pendingAnimation = true;
|
||||||
|
|
||||||
|
Progress.Value = 0;
|
||||||
|
|
||||||
|
overlayCircle.ScaleTo(0, 100)
|
||||||
|
.Then().FadeOut().ScaleTo(1).FadeIn(500)
|
||||||
|
.OnComplete(a =>
|
||||||
|
{
|
||||||
|
icon.ScaleTo(1, 100);
|
||||||
|
circularProgress.FadeOut(100).OnComplete(_ =>
|
||||||
|
{
|
||||||
|
bind();
|
||||||
|
|
||||||
|
circularProgress.FadeIn();
|
||||||
|
pendingAnimation = false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnHover(InputState state)
|
||||||
|
{
|
||||||
|
HoverGained?.Invoke();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnHoverLost(InputState state)
|
||||||
|
{
|
||||||
|
HoverLost?.Invoke();
|
||||||
|
base.OnHoverLost(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||||
|
{
|
||||||
|
if (!pendingAnimation && state.Mouse.Buttons.Count == 1)
|
||||||
|
BeginConfirm();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
|
||||||
|
{
|
||||||
|
if (state.Mouse.Buttons.Count == 0)
|
||||||
|
AbortConfirm();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -34,6 +34,7 @@ namespace osu.Game.Screens.Play
|
|||||||
public readonly HealthDisplay HealthDisplay;
|
public readonly HealthDisplay HealthDisplay;
|
||||||
public readonly SongProgress Progress;
|
public readonly SongProgress Progress;
|
||||||
public readonly ModDisplay ModDisplay;
|
public readonly ModDisplay ModDisplay;
|
||||||
|
public readonly QuitButton HoldToQuit;
|
||||||
public readonly PlayerSettingsOverlay PlayerSettingsOverlay;
|
public readonly PlayerSettingsOverlay PlayerSettingsOverlay;
|
||||||
|
|
||||||
private Bindable<bool> showHud;
|
private Bindable<bool> showHud;
|
||||||
@ -51,14 +52,26 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
KeyCounter = CreateKeyCounter(),
|
|
||||||
ComboCounter = CreateComboCounter(),
|
ComboCounter = CreateComboCounter(),
|
||||||
ScoreCounter = CreateScoreCounter(),
|
ScoreCounter = CreateScoreCounter(),
|
||||||
AccuracyCounter = CreateAccuracyCounter(),
|
AccuracyCounter = CreateAccuracyCounter(),
|
||||||
HealthDisplay = CreateHealthDisplay(),
|
HealthDisplay = CreateHealthDisplay(),
|
||||||
Progress = CreateProgress(),
|
Progress = CreateProgress(),
|
||||||
ModDisplay = CreateModsContainer(),
|
ModDisplay = CreateModsContainer(),
|
||||||
PlayerSettingsOverlay = CreatePlayerSettingsOverlay()
|
PlayerSettingsOverlay = CreatePlayerSettingsOverlay(),
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomRight,
|
||||||
|
Origin = Anchor.BottomRight,
|
||||||
|
Position = -new Vector2(5, TwoLayerButton.SIZE_RETRACTED.Y),
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
KeyCounter = CreateKeyCounter(),
|
||||||
|
HoldToQuit = CreateQuitButton(),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -187,7 +200,6 @@ namespace osu.Game.Screens.Play
|
|||||||
Anchor = Anchor.BottomRight,
|
Anchor = Anchor.BottomRight,
|
||||||
Origin = Anchor.BottomRight,
|
Origin = Anchor.BottomRight,
|
||||||
Margin = new MarginPadding(10),
|
Margin = new MarginPadding(10),
|
||||||
Y = -TwoLayerButton.SIZE_RETRACTED.Y,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
protected virtual ScoreCounter CreateScoreCounter() => new ScoreCounter(6)
|
protected virtual ScoreCounter CreateScoreCounter() => new ScoreCounter(6)
|
||||||
@ -205,6 +217,12 @@ namespace osu.Game.Screens.Play
|
|||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
protected virtual QuitButton CreateQuitButton() => new QuitButton
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomRight,
|
||||||
|
Origin = Anchor.BottomRight,
|
||||||
|
};
|
||||||
|
|
||||||
protected virtual ModDisplay CreateModsContainer() => new ModDisplay
|
protected virtual ModDisplay CreateModsContainer() => new ModDisplay
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
|
@ -35,7 +35,7 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
protected override float BackgroundParallaxAmount => 0.1f;
|
protected override float BackgroundParallaxAmount => 0.1f;
|
||||||
|
|
||||||
public override bool ShowOverlaysOnEnter => false;
|
protected override bool HideOverlaysOnEnter => true;
|
||||||
|
|
||||||
public Action RestartRequested;
|
public Action RestartRequested;
|
||||||
|
|
||||||
@ -183,6 +183,7 @@ namespace osu.Game.Screens.Play
|
|||||||
ProcessCustomClock = false,
|
ProcessCustomClock = false,
|
||||||
Breaks = beatmap.Breaks
|
Breaks = beatmap.Breaks
|
||||||
},
|
},
|
||||||
|
RulesetContainer.Cursor?.CreateProxy() ?? new Container(),
|
||||||
hudOverlay = new HUDOverlay(scoreProcessor, RulesetContainer, working, offsetClock, adjustableClock)
|
hudOverlay = new HUDOverlay(scoreProcessor, RulesetContainer, working, offsetClock, adjustableClock)
|
||||||
{
|
{
|
||||||
Clock = Clock, // hud overlay doesn't want to use the audio clock directly
|
Clock = Clock, // hud overlay doesn't want to use the audio clock directly
|
||||||
@ -190,7 +191,6 @@ namespace osu.Game.Screens.Play
|
|||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre
|
Origin = Anchor.Centre
|
||||||
},
|
},
|
||||||
RulesetContainer.Cursor?.CreateProxy() ?? new Container(),
|
|
||||||
new SkipOverlay(firstObjectTime)
|
new SkipOverlay(firstObjectTime)
|
||||||
{
|
{
|
||||||
Clock = Clock, // skip button doesn't want to use the audio clock directly
|
Clock = Clock, // skip button doesn't want to use the audio clock directly
|
||||||
@ -219,6 +219,8 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
hudOverlay.HoldToQuit.Action = Exit;
|
||||||
|
|
||||||
if (ShowStoryboard)
|
if (ShowStoryboard)
|
||||||
initializeStoryboard(false);
|
initializeStoryboard(false);
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
private BeatmapMetadataDisplay info;
|
private BeatmapMetadataDisplay info;
|
||||||
|
|
||||||
private bool showOverlays = true;
|
private bool hideOverlays;
|
||||||
public override bool ShowOverlaysOnEnter => showOverlays;
|
protected override bool HideOverlaysOnEnter => hideOverlays;
|
||||||
|
|
||||||
private Task loadTask;
|
private Task loadTask;
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
player.RestartRequested = () =>
|
player.RestartRequested = () =>
|
||||||
{
|
{
|
||||||
showOverlays = false;
|
hideOverlays = true;
|
||||||
ValidForResume = true;
|
ValidForResume = true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ namespace osu.Game.Screens.Tournament
|
|||||||
{
|
{
|
||||||
private const string results_filename = "drawings_results.txt";
|
private const string results_filename = "drawings_results.txt";
|
||||||
|
|
||||||
public override bool ShowOverlaysOnEnter => false;
|
protected override bool HideOverlaysOnEnter => true;
|
||||||
|
|
||||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenDefault();
|
protected override BackgroundScreen CreateBackground() => new BackgroundScreenDefault();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user