mirror of
https://github.com/osukey/osukey.git
synced 2025-05-22 14:07:38 +09:00
Merge branch 'master' into editor-drag-box
This commit is contained in:
commit
56fa5c9db1
@ -7,6 +7,7 @@ using System.Linq;
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions;
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Extensions.ObjectExtensions;
|
using osu.Framework.Extensions.ObjectExtensions;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -17,6 +18,7 @@ using osu.Framework.Screens;
|
|||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
@ -56,6 +58,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
private TestMultiplayerClient multiplayerClient => multiplayerComponents.MultiplayerClient;
|
private TestMultiplayerClient multiplayerClient => multiplayerComponents.MultiplayerClient;
|
||||||
private TestMultiplayerRoomManager roomManager => multiplayerComponents.RoomManager;
|
private TestMultiplayerRoomManager roomManager => multiplayerComponents.RoomManager;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuConfigManager config { get; set; }
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(GameHost host, AudioManager audio)
|
private void load(GameHost host, AudioManager audio)
|
||||||
{
|
{
|
||||||
@ -668,6 +673,43 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
AddUntilStep("wait for results", () => multiplayerComponents.CurrentScreen is ResultsScreen);
|
AddUntilStep("wait for results", () => multiplayerComponents.CurrentScreen is ResultsScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestGameplayExitFlow()
|
||||||
|
{
|
||||||
|
Bindable<double> holdDelay = null;
|
||||||
|
|
||||||
|
AddStep("Set hold delay to zero", () =>
|
||||||
|
{
|
||||||
|
holdDelay = config.GetBindable<double>(OsuSetting.UIHoldActivationDelay);
|
||||||
|
holdDelay.Value = 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
createRoom(() => new Room
|
||||||
|
{
|
||||||
|
Name = { Value = "Test Room" },
|
||||||
|
Playlist =
|
||||||
|
{
|
||||||
|
new PlaylistItem(beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.Ruleset.OnlineID == 0)).BeatmapInfo)
|
||||||
|
{
|
||||||
|
RulesetID = new OsuRuleset().RulesetInfo.OnlineID,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
enterGameplay();
|
||||||
|
|
||||||
|
AddUntilStep("wait for playing", () => this.ChildrenOfType<Player>().FirstOrDefault()?.LocalUserPlaying.Value == true);
|
||||||
|
|
||||||
|
AddStep("attempt exit without hold", () => InputManager.Key(Key.Escape));
|
||||||
|
AddAssert("still in gameplay", () => multiplayerComponents.CurrentScreen is Player);
|
||||||
|
|
||||||
|
AddStep("attempt exit with hold", () => InputManager.PressKey(Key.Escape));
|
||||||
|
AddUntilStep("wait for lounge", () => multiplayerComponents.CurrentScreen is Screens.OnlinePlay.Multiplayer.Multiplayer);
|
||||||
|
|
||||||
|
AddStep("stop holding", () => InputManager.ReleaseKey(Key.Escape));
|
||||||
|
AddStep("set hold delay to default", () => holdDelay.SetDefault());
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestGameplayDoesntStartWithNonLoadedUser()
|
public void TestGameplayDoesntStartWithNonLoadedUser()
|
||||||
{
|
{
|
||||||
|
@ -18,6 +18,7 @@ using osu.Game.Rulesets;
|
|||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Rulesets.Osu.Mods;
|
using osu.Game.Rulesets.Osu.Mods;
|
||||||
|
using osuTK;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.UserInterface
|
namespace osu.Game.Tests.Visual.UserInterface
|
||||||
@ -164,7 +165,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
AddStep("select mod requiring configuration", () => SelectedMods.Value = new[] { new OsuModDifficultyAdjust() });
|
AddStep("select mod requiring configuration", () => SelectedMods.Value = new[] { new OsuModDifficultyAdjust() });
|
||||||
assertCustomisationToggleState(disabled: false, active: true);
|
assertCustomisationToggleState(disabled: false, active: true);
|
||||||
|
|
||||||
AddStep("dismiss mod customisation via mouse", () =>
|
AddStep("dismiss mod customisation via toggle", () =>
|
||||||
{
|
{
|
||||||
InputManager.MoveMouseTo(modSelectScreen.ChildrenOfType<ShearedToggleButton>().Single());
|
InputManager.MoveMouseTo(modSelectScreen.ChildrenOfType<ShearedToggleButton>().Single());
|
||||||
InputManager.Click(MouseButton.Left);
|
InputManager.Click(MouseButton.Left);
|
||||||
@ -191,6 +192,29 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
assertCustomisationToggleState(disabled: true, active: false); // config was dismissed without explicit user action.
|
assertCustomisationToggleState(disabled: true, active: false); // config was dismissed without explicit user action.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDismissCustomisationViaDimmedArea()
|
||||||
|
{
|
||||||
|
createScreen();
|
||||||
|
assertCustomisationToggleState(disabled: true, active: false);
|
||||||
|
|
||||||
|
AddStep("select mod requiring configuration", () => SelectedMods.Value = new[] { new OsuModDifficultyAdjust() });
|
||||||
|
assertCustomisationToggleState(disabled: false, active: true);
|
||||||
|
|
||||||
|
AddStep("move mouse to settings area", () => InputManager.MoveMouseTo(this.ChildrenOfType<ModSettingsArea>().Single()));
|
||||||
|
AddStep("move mouse to dimmed area", () =>
|
||||||
|
{
|
||||||
|
InputManager.MoveMouseTo(new Vector2(
|
||||||
|
modSelectScreen.ScreenSpaceDrawQuad.TopLeft.X,
|
||||||
|
(modSelectScreen.ScreenSpaceDrawQuad.TopLeft.Y + modSelectScreen.ScreenSpaceDrawQuad.BottomLeft.Y) / 2));
|
||||||
|
});
|
||||||
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||||
|
assertCustomisationToggleState(disabled: false, active: false);
|
||||||
|
|
||||||
|
AddStep("move mouse to first mod panel", () => InputManager.MoveMouseTo(modSelectScreen.ChildrenOfType<ModPanel>().First()));
|
||||||
|
AddAssert("first mod panel is hovered", () => modSelectScreen.ChildrenOfType<ModPanel>().First().IsHovered);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ensure that two mod overlays are not cross polluting via central settings instances.
|
/// Ensure that two mod overlays are not cross polluting via central settings instances.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -10,12 +10,32 @@ using osu.Game.Configuration;
|
|||||||
|
|
||||||
namespace osu.Game.Graphics.Containers
|
namespace osu.Game.Graphics.Containers
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A container which adds a common "hold-to-perform" pattern to a container.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// This container does not handle triggering the hold/abort operations.
|
||||||
|
/// To use this class, please call <see cref="BeginConfirm"/> and <see cref="AbortConfirm"/> when necessary.
|
||||||
|
///
|
||||||
|
/// The <see cref="Progress"/> is exposed as a transforming bindable which smoothly tracks the progress of a hold operation.
|
||||||
|
/// It can be used for animating and displaying progress directly.
|
||||||
|
/// </remarks>
|
||||||
public abstract class HoldToConfirmContainer : Container
|
public abstract class HoldToConfirmContainer : Container
|
||||||
{
|
{
|
||||||
public Action Action;
|
public const double DANGEROUS_HOLD_ACTIVATION_DELAY = 500;
|
||||||
|
|
||||||
private const int fadeout_delay = 200;
|
private const int fadeout_delay = 200;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the associated action is considered dangerous, warranting a longer hold.
|
||||||
|
/// </summary>
|
||||||
|
public bool IsDangerousAction { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The action to perform when a hold successfully completes.
|
||||||
|
/// </summary>
|
||||||
|
public Action Action;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether currently in a fired state (and the confirm <see cref="Action"/> has been sent).
|
/// Whether currently in a fired state (and the confirm <see cref="Action"/> has been sent).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -23,46 +43,61 @@ namespace osu.Game.Graphics.Containers
|
|||||||
|
|
||||||
private bool confirming;
|
private bool confirming;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The current activation delay for this control.
|
||||||
|
/// </summary>
|
||||||
|
public IBindable<double> HoldActivationDelay => holdActivationDelay;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The progress of any ongoing hold operation. 0 means no hold has started; 1 means a hold has been completed.
|
||||||
|
/// </summary>
|
||||||
|
public IBindable<double> Progress => progress;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the overlay should be allowed to return from a fired state.
|
/// Whether the overlay should be allowed to return from a fired state.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual bool AllowMultipleFires => false;
|
protected virtual bool AllowMultipleFires => false;
|
||||||
|
|
||||||
/// <summary>
|
private readonly Bindable<double> progress = new BindableDouble();
|
||||||
/// Specify a custom activation delay, overriding the game-wide user setting.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// This should be used in special cases where we want to be extra sure the user knows what they are doing. An example is when changes would be lost.
|
|
||||||
/// </remarks>
|
|
||||||
protected virtual double? HoldActivationDelay => null;
|
|
||||||
|
|
||||||
public Bindable<double> Progress = new BindableDouble();
|
private readonly Bindable<double> holdActivationDelay = new Bindable<double>();
|
||||||
|
|
||||||
private Bindable<double> holdActivationDelay;
|
[Resolved]
|
||||||
|
private OsuConfigManager config { get; set; }
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
protected HoldToConfirmContainer(bool isDangerousAction = false)
|
||||||
private void load(OsuConfigManager config)
|
|
||||||
{
|
{
|
||||||
holdActivationDelay = HoldActivationDelay != null
|
IsDangerousAction = isDangerousAction;
|
||||||
? new Bindable<double>(HoldActivationDelay.Value)
|
|
||||||
: config.GetBindable<double>(OsuSetting.UIHoldActivationDelay);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
if (IsDangerousAction)
|
||||||
|
holdActivationDelay.Value = DANGEROUS_HOLD_ACTIVATION_DELAY;
|
||||||
|
else
|
||||||
|
config.BindWith(OsuSetting.UIHoldActivationDelay, holdActivationDelay);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Begin a new confirmation. Should be called when the container is interacted with (ie. the user presses a key).
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Calling this method when already in the process of confirming has no effect.
|
||||||
|
/// </remarks>
|
||||||
protected void BeginConfirm()
|
protected void BeginConfirm()
|
||||||
{
|
{
|
||||||
if (confirming || (!AllowMultipleFires && Fired)) return;
|
if (confirming || (!AllowMultipleFires && Fired)) return;
|
||||||
|
|
||||||
confirming = true;
|
confirming = true;
|
||||||
|
|
||||||
this.TransformBindableTo(Progress, 1, holdActivationDelay.Value * (1 - Progress.Value), Easing.Out).OnComplete(_ => Confirm());
|
this.TransformBindableTo(progress, 1, holdActivationDelay.Value * (1 - progress.Value), Easing.Out).OnComplete(_ => Confirm());
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void Confirm()
|
|
||||||
{
|
|
||||||
Action?.Invoke();
|
|
||||||
Fired = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Abort any ongoing confirmation. Should be called when the container's interaction is no longer valid (ie. the user releases a key).
|
||||||
|
/// </summary>
|
||||||
protected void AbortConfirm()
|
protected void AbortConfirm()
|
||||||
{
|
{
|
||||||
if (!AllowMultipleFires && Fired) return;
|
if (!AllowMultipleFires && Fired) return;
|
||||||
@ -71,9 +106,19 @@ namespace osu.Game.Graphics.Containers
|
|||||||
Fired = false;
|
Fired = false;
|
||||||
|
|
||||||
this
|
this
|
||||||
.TransformBindableTo(Progress, Progress.Value)
|
.TransformBindableTo(progress, progress.Value)
|
||||||
.Delay(200)
|
.Delay(200)
|
||||||
.TransformBindableTo(Progress, 0, fadeout_delay, Easing.InSine);
|
.TransformBindableTo(progress, 0, fadeout_delay, Easing.InSine);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A method which is invoked when the confirmation sequence completes successfully.
|
||||||
|
/// By default, will fire the associated <see cref="Action"/>.
|
||||||
|
/// </summary>
|
||||||
|
protected virtual void Confirm()
|
||||||
|
{
|
||||||
|
Action?.Invoke();
|
||||||
|
Fired = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,10 @@ namespace osu.Game.Overlays.Dialog
|
|||||||
|
|
||||||
private class DangerousConfirmContainer : HoldToConfirmContainer
|
private class DangerousConfirmContainer : HoldToConfirmContainer
|
||||||
{
|
{
|
||||||
protected override double? HoldActivationDelay => 500;
|
public DangerousConfirmContainer()
|
||||||
|
: base(isDangerousAction: true)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
protected override bool OnMouseDown(MouseDownEvent e)
|
protected override bool OnMouseDown(MouseDownEvent e)
|
||||||
{
|
{
|
||||||
|
@ -464,6 +464,8 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
public Action? OnClicked { get; set; }
|
public Action? OnClicked { get; set; }
|
||||||
|
|
||||||
|
public override bool HandlePositionalInput => base.HandlePositionalInput && HandleMouse.Value;
|
||||||
|
|
||||||
protected override bool Handle(UIEvent e)
|
protected override bool Handle(UIEvent e)
|
||||||
{
|
{
|
||||||
if (!HandleMouse.Value)
|
if (!HandleMouse.Value)
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// 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.Linq;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
@ -25,7 +24,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
|
|
||||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => base.ReceivePositionalInputAt(screenSpacePos) && anyToolboxHovered(screenSpacePos);
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => base.ReceivePositionalInputAt(screenSpacePos) && anyToolboxHovered(screenSpacePos);
|
||||||
|
|
||||||
private bool anyToolboxHovered(Vector2 screenSpacePos) => FillFlow.Children.Any(d => d.ScreenSpaceDrawQuad.Contains(screenSpacePos));
|
private bool anyToolboxHovered(Vector2 screenSpacePos) => FillFlow.ScreenSpaceDrawQuad.Contains(screenSpacePos);
|
||||||
|
|
||||||
protected override bool OnMouseDown(MouseDownEvent e) => true;
|
protected override bool OnMouseDown(MouseDownEvent e) => true;
|
||||||
|
|
||||||
|
@ -12,13 +12,14 @@ using osu.Framework.Graphics.Sprites;
|
|||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
|
using osu.Framework.Threading;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
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.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play.HUD
|
namespace osu.Game.Screens.Play.HUD
|
||||||
{
|
{
|
||||||
@ -28,20 +29,22 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
public readonly Bindable<bool> IsPaused = new Bindable<bool>();
|
public readonly Bindable<bool> IsPaused = new Bindable<bool>();
|
||||||
|
|
||||||
private readonly Button button;
|
private HoldButton button;
|
||||||
|
|
||||||
public Action Action
|
public Action Action { get; set; }
|
||||||
{
|
|
||||||
set => button.Action = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly OsuSpriteText text;
|
private OsuSpriteText text;
|
||||||
|
|
||||||
public HoldForMenuButton()
|
public HoldForMenuButton()
|
||||||
{
|
{
|
||||||
Direction = FillDirection.Horizontal;
|
Direction = FillDirection.Horizontal;
|
||||||
Spacing = new Vector2(20, 0);
|
Spacing = new Vector2(20, 0);
|
||||||
Margin = new MarginPadding(10);
|
Margin = new MarginPadding(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader(true)]
|
||||||
|
private void load(Player player)
|
||||||
|
{
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
text = new OsuSpriteText
|
text = new OsuSpriteText
|
||||||
@ -50,25 +53,20 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft
|
Origin = Anchor.CentreLeft
|
||||||
},
|
},
|
||||||
button = new Button
|
button = new HoldButton(player?.Configuration.AllowRestart == false)
|
||||||
{
|
{
|
||||||
HoverGained = () => text.FadeIn(500, Easing.OutQuint),
|
HoverGained = () => text.FadeIn(500, Easing.OutQuint),
|
||||||
HoverLost = () => text.FadeOut(500, Easing.OutQuint),
|
HoverLost = () => text.FadeOut(500, Easing.OutQuint),
|
||||||
IsPaused = { BindTarget = IsPaused }
|
IsPaused = { BindTarget = IsPaused },
|
||||||
|
Action = () => Action(),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private OsuConfigManager config { get; set; }
|
|
||||||
|
|
||||||
private Bindable<double> activationDelay;
|
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
activationDelay = config.GetBindable<double>(OsuSetting.UIHoldActivationDelay);
|
button.HoldActivationDelay.BindValueChanged(v =>
|
||||||
activationDelay.BindValueChanged(v =>
|
|
||||||
{
|
{
|
||||||
text.Text = v.NewValue > 0
|
text.Text = v.NewValue > 0
|
||||||
? "hold for menu"
|
? "hold for menu"
|
||||||
@ -102,7 +100,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Button : HoldToConfirmContainer, IKeyBindingHandler<GlobalAction>
|
private class HoldButton : HoldToConfirmContainer, IKeyBindingHandler<GlobalAction>
|
||||||
{
|
{
|
||||||
private SpriteIcon icon;
|
private SpriteIcon icon;
|
||||||
private CircularProgress circularProgress;
|
private CircularProgress circularProgress;
|
||||||
@ -115,6 +113,16 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
public Action HoverGained;
|
public Action HoverGained;
|
||||||
public Action HoverLost;
|
public Action HoverLost;
|
||||||
|
|
||||||
|
private const double shake_duration = 20;
|
||||||
|
|
||||||
|
private bool pendingAnimation;
|
||||||
|
private ScheduledDelegate shakeOperation;
|
||||||
|
|
||||||
|
public HoldButton(bool isDangerousAction)
|
||||||
|
: base(isDangerousAction)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
@ -161,11 +169,38 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
private void bind()
|
private void bind()
|
||||||
{
|
{
|
||||||
circularProgress.Current.BindTo(Progress);
|
((IBindable<double>)circularProgress.Current).BindTo(Progress);
|
||||||
Progress.ValueChanged += progress => icon.Scale = new Vector2(1 + (float)progress.NewValue * 0.2f);
|
Progress.ValueChanged += progress =>
|
||||||
|
{
|
||||||
|
icon.Scale = new Vector2(1 + (float)progress.NewValue * 0.2f);
|
||||||
|
|
||||||
|
if (IsDangerousAction)
|
||||||
|
{
|
||||||
|
Colour = Interpolation.ValueAt(progress.NewValue, Color4.White, Color4.Red, 0, 1, Easing.OutQuint);
|
||||||
|
|
||||||
|
if (progress.NewValue > 0 && progress.NewValue < 1)
|
||||||
|
{
|
||||||
|
shakeOperation ??= Scheduler.AddDelayed(shake, shake_duration, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Child.MoveTo(Vector2.Zero, shake_duration * 2, Easing.OutQuint);
|
||||||
|
shakeOperation?.Cancel();
|
||||||
|
shakeOperation = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool pendingAnimation;
|
private void shake()
|
||||||
|
{
|
||||||
|
const float shake_magnitude = 8;
|
||||||
|
|
||||||
|
Child.MoveTo(new Vector2(
|
||||||
|
RNG.NextSingle(-1, 1) * (float)Progress.Value * shake_magnitude,
|
||||||
|
RNG.NextSingle(-1, 1) * (float)Progress.Value * shake_magnitude
|
||||||
|
), shake_duration);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Confirm()
|
protected override void Confirm()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user