mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 18:32:55 +08:00
Merge master with conflicts resolved
This commit is contained in:
commit
cb98b07e33
@ -160,6 +160,15 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
exitAndConfirm();
|
exitAndConfirm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestRestartAfterResume()
|
||||||
|
{
|
||||||
|
pauseAndConfirm();
|
||||||
|
resumeAndConfirm();
|
||||||
|
restart();
|
||||||
|
confirmExited();
|
||||||
|
}
|
||||||
|
|
||||||
private void pauseAndConfirm()
|
private void pauseAndConfirm()
|
||||||
{
|
{
|
||||||
pause();
|
pause();
|
||||||
@ -198,6 +207,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddUntilStep("player exited", () => !Player.IsCurrentScreen());
|
AddUntilStep("player exited", () => !Player.IsCurrentScreen());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void restart() => AddStep("restart", () => Player.Restart());
|
||||||
private void pause() => AddStep("pause", () => Player.Pause());
|
private void pause() => AddStep("pause", () => Player.Pause());
|
||||||
private void resume() => AddStep("resume", () => Player.Resume());
|
private void resume() => AddStep("resume", () => Player.Resume());
|
||||||
|
|
||||||
|
@ -16,12 +16,12 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
{
|
{
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
{
|
{
|
||||||
typeof(HeaderFlag),
|
typeof(DismissableFlag),
|
||||||
};
|
};
|
||||||
|
|
||||||
public TestSceneRankingsHeaderFlag()
|
public TestSceneRankingsHeaderFlag()
|
||||||
{
|
{
|
||||||
HeaderFlag flag;
|
DismissableFlag flag;
|
||||||
SpriteText text;
|
SpriteText text;
|
||||||
|
|
||||||
var countryA = new Country
|
var countryA = new Country
|
||||||
@ -38,7 +38,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
|
|
||||||
AddRange(new Drawable[]
|
AddRange(new Drawable[]
|
||||||
{
|
{
|
||||||
flag = new HeaderFlag
|
flag = new DismissableFlag
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
|
@ -14,7 +14,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
{
|
{
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
{
|
{
|
||||||
typeof(HeaderFlag),
|
typeof(DismissableFlag),
|
||||||
typeof(HeaderTitle),
|
typeof(HeaderTitle),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
|
|
||||||
Add(overlay = new DialogOverlay());
|
Add(overlay = new DialogOverlay());
|
||||||
|
|
||||||
AddStep("dialog #1", () => overlay.Push(new PopupDialog
|
AddStep("dialog #1", () => overlay.Push(new TestPopupDialog
|
||||||
{
|
{
|
||||||
Icon = FontAwesome.Regular.TrashAlt,
|
Icon = FontAwesome.Regular.TrashAlt,
|
||||||
HeaderText = @"Confirm deletion of",
|
HeaderText = @"Confirm deletion of",
|
||||||
@ -37,7 +37,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
AddStep("dialog #2", () => overlay.Push(new PopupDialog
|
AddStep("dialog #2", () => overlay.Push(new TestPopupDialog
|
||||||
{
|
{
|
||||||
Icon = FontAwesome.Solid.Cog,
|
Icon = FontAwesome.Solid.Cog,
|
||||||
HeaderText = @"What do you want to do with",
|
HeaderText = @"What do you want to do with",
|
||||||
@ -71,5 +71,9 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class TestPopupDialog : PopupDialog
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,13 +13,22 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
{
|
{
|
||||||
public TestScenePopupDialog()
|
public TestScenePopupDialog()
|
||||||
{
|
{
|
||||||
var popup = new PopupDialog
|
Add(new TestPopupDialog
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
State = { Value = Framework.Graphics.Containers.Visibility.Visible },
|
State = { Value = Framework.Graphics.Containers.Visibility.Visible },
|
||||||
Icon = FontAwesome.Solid.AssistiveListeningSystems,
|
});
|
||||||
HeaderText = @"This is a test popup",
|
}
|
||||||
BodyText = "I can say lots of stuff and even wrap my words!",
|
|
||||||
|
private class TestPopupDialog : PopupDialog
|
||||||
|
{
|
||||||
|
public TestPopupDialog()
|
||||||
|
{
|
||||||
|
Icon = FontAwesome.Solid.AssistiveListeningSystems;
|
||||||
|
|
||||||
|
HeaderText = @"This is a test popup";
|
||||||
|
BodyText = "I can say lots of stuff and even wrap my words!";
|
||||||
|
|
||||||
Buttons = new PopupDialogButton[]
|
Buttons = new PopupDialogButton[]
|
||||||
{
|
{
|
||||||
new PopupDialogCancelButton
|
new PopupDialogCancelButton
|
||||||
@ -30,10 +39,8 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
{
|
{
|
||||||
Text = @"You're a fake!",
|
Text = @"You're a fake!",
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
Add(popup);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,6 @@ namespace osu.Game.Graphics.Containers
|
|||||||
private SampleChannel samplePopIn;
|
private SampleChannel samplePopIn;
|
||||||
private SampleChannel samplePopOut;
|
private SampleChannel samplePopOut;
|
||||||
|
|
||||||
protected virtual bool PlaySamplesOnStateChange => true;
|
|
||||||
|
|
||||||
protected override bool BlockNonPositionalInput => true;
|
protected override bool BlockNonPositionalInput => true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -126,12 +124,12 @@ namespace osu.Game.Graphics.Containers
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PlaySamplesOnStateChange) samplePopIn?.Play();
|
samplePopIn?.Play();
|
||||||
if (BlockScreenWideMouse && DimMainContent) game?.AddBlockingOverlay(this);
|
if (BlockScreenWideMouse && DimMainContent) game?.AddBlockingOverlay(this);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Visibility.Hidden:
|
case Visibility.Hidden:
|
||||||
if (PlaySamplesOnStateChange) samplePopOut?.Play();
|
samplePopOut?.Play();
|
||||||
if (BlockScreenWideMouse) game?.RemoveBlockingOverlay(this);
|
if (BlockScreenWideMouse) game?.RemoveBlockingOverlay(this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -13,20 +13,17 @@ using osu.Framework.Input.Events;
|
|||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Backgrounds;
|
using osu.Game.Graphics.Backgrounds;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Input.Bindings;
|
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Dialog
|
namespace osu.Game.Overlays.Dialog
|
||||||
{
|
{
|
||||||
public class PopupDialog : OsuFocusedOverlayContainer
|
public abstract class PopupDialog : VisibilityContainer
|
||||||
{
|
{
|
||||||
public static readonly float ENTER_DURATION = 500;
|
public static readonly float ENTER_DURATION = 500;
|
||||||
public static readonly float EXIT_DURATION = 200;
|
public static readonly float EXIT_DURATION = 200;
|
||||||
|
|
||||||
protected override bool BlockPositionalInput => false;
|
|
||||||
|
|
||||||
private readonly Vector2 ringSize = new Vector2(100f);
|
private readonly Vector2 ringSize = new Vector2(100f);
|
||||||
private readonly Vector2 ringMinifiedSize = new Vector2(20f);
|
private readonly Vector2 ringMinifiedSize = new Vector2(20f);
|
||||||
private readonly Vector2 buttonsEnterSpacing = new Vector2(0f, 50f);
|
private readonly Vector2 buttonsEnterSpacing = new Vector2(0f, 50f);
|
||||||
@ -90,7 +87,7 @@ namespace osu.Game.Overlays.Dialog
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PopupDialog()
|
protected PopupDialog()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
@ -202,18 +199,6 @@ namespace osu.Game.Overlays.Dialog
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool OnPressed(GlobalAction action)
|
|
||||||
{
|
|
||||||
switch (action)
|
|
||||||
{
|
|
||||||
case GlobalAction.Select:
|
|
||||||
Buttons.OfType<PopupDialogOkButton>().FirstOrDefault()?.Click();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return base.OnPressed(action);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnKeyDown(KeyDownEvent e)
|
protected override bool OnKeyDown(KeyDownEvent e)
|
||||||
{
|
{
|
||||||
if (e.Repeat) return false;
|
if (e.Repeat) return false;
|
||||||
@ -238,8 +223,6 @@ namespace osu.Game.Overlays.Dialog
|
|||||||
|
|
||||||
protected override void PopIn()
|
protected override void PopIn()
|
||||||
{
|
{
|
||||||
base.PopIn();
|
|
||||||
|
|
||||||
actionInvoked = false;
|
actionInvoked = false;
|
||||||
|
|
||||||
// Reset various animations but only if the dialog animation fully completed
|
// Reset various animations but only if the dialog animation fully completed
|
||||||
@ -263,7 +246,6 @@ namespace osu.Game.Overlays.Dialog
|
|||||||
// This is presumed to always be a sane default "cancel" action.
|
// This is presumed to always be a sane default "cancel" action.
|
||||||
buttonsContainer.Last().Click();
|
buttonsContainer.Last().Click();
|
||||||
|
|
||||||
base.PopOut();
|
|
||||||
content.FadeOut(EXIT_DURATION, Easing.InSine);
|
content.FadeOut(EXIT_DURATION, Easing.InSine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Overlays.Dialog;
|
using osu.Game.Overlays.Dialog;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Input.Bindings;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
{
|
{
|
||||||
@ -41,8 +43,6 @@ namespace osu.Game.Overlays
|
|||||||
Show();
|
Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool PlaySamplesOnStateChange => false;
|
|
||||||
|
|
||||||
protected override bool BlockNonPositionalInput => true;
|
protected override bool BlockNonPositionalInput => true;
|
||||||
|
|
||||||
private void onDialogOnStateChanged(VisibilityContainer dialog, Visibility v)
|
private void onDialogOnStateChanged(VisibilityContainer dialog, Visibility v)
|
||||||
@ -74,5 +74,17 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
this.FadeOut(PopupDialog.EXIT_DURATION, Easing.InSine);
|
this.FadeOut(PopupDialog.EXIT_DURATION, Easing.InSine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool OnPressed(GlobalAction action)
|
||||||
|
{
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case GlobalAction.Select:
|
||||||
|
currentDialog?.Buttons.OfType<PopupDialogOkButton>().FirstOrDefault()?.Click();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.OnPressed(action);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,55 +0,0 @@
|
|||||||
// 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.Graphics;
|
|
||||||
using osu.Framework.Graphics.Sprites;
|
|
||||||
using osu.Game.Users.Drawables;
|
|
||||||
using osuTK.Graphics;
|
|
||||||
using osuTK;
|
|
||||||
using osu.Framework.Input.Events;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Rankings
|
|
||||||
{
|
|
||||||
public class HeaderFlag : UpdateableFlag
|
|
||||||
{
|
|
||||||
private const int duration = 200;
|
|
||||||
|
|
||||||
public Action Action;
|
|
||||||
|
|
||||||
private readonly SpriteIcon hoverIcon;
|
|
||||||
|
|
||||||
public HeaderFlag()
|
|
||||||
{
|
|
||||||
AddInternal(hoverIcon = new SpriteIcon
|
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Depth = -1,
|
|
||||||
Alpha = 0,
|
|
||||||
Size = new Vector2(10),
|
|
||||||
Icon = FontAwesome.Solid.Times,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnHover(HoverEvent e)
|
|
||||||
{
|
|
||||||
hoverIcon.FadeIn(duration, Easing.OutQuint);
|
|
||||||
this.FadeColour(Color4.Gray, duration, Easing.OutQuint);
|
|
||||||
return base.OnHover(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnHoverLost(HoverLostEvent e)
|
|
||||||
{
|
|
||||||
base.OnHoverLost(e);
|
|
||||||
hoverIcon.FadeOut(duration, Easing.OutQuint);
|
|
||||||
this.FadeColour(Color4.White, duration, Easing.OutQuint);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
|
||||||
{
|
|
||||||
Action?.Invoke();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -22,8 +22,7 @@ namespace osu.Game.Overlays.Rankings
|
|||||||
public readonly Bindable<Country> Country = new Bindable<Country>();
|
public readonly Bindable<Country> Country = new Bindable<Country>();
|
||||||
|
|
||||||
private readonly SpriteText scopeText;
|
private readonly SpriteText scopeText;
|
||||||
private readonly Container flagPlaceholder;
|
private readonly DismissableFlag flag;
|
||||||
private readonly HeaderFlag flag;
|
|
||||||
|
|
||||||
public HeaderTitle()
|
public HeaderTitle()
|
||||||
{
|
{
|
||||||
@ -35,16 +34,12 @@ namespace osu.Game.Overlays.Rankings
|
|||||||
Spacing = new Vector2(spacing, 0),
|
Spacing = new Vector2(spacing, 0),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
flagPlaceholder = new Container
|
flag = new DismissableFlag
|
||||||
{
|
{
|
||||||
Anchor = Anchor.BottomLeft,
|
Anchor = Anchor.BottomLeft,
|
||||||
Origin = Anchor.BottomLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Margin = new MarginPadding { Bottom = flag_margin },
|
Margin = new MarginPadding { Bottom = flag_margin },
|
||||||
Child = flag = new HeaderFlag
|
Size = new Vector2(30, 20),
|
||||||
{
|
|
||||||
Size = new Vector2(30, 20),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
scopeText = new SpriteText
|
scopeText = new SpriteText
|
||||||
{
|
{
|
||||||
@ -73,16 +68,16 @@ namespace osu.Game.Overlays.Rankings
|
|||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
Scope.BindValueChanged(scope => onScopeChanged(scope.NewValue), true);
|
Scope.BindValueChanged(onScopeChanged, true);
|
||||||
Country.BindValueChanged(onCountryChanged, true);
|
Country.BindValueChanged(onCountryChanged, true);
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onScopeChanged(RankingsScope scope)
|
private void onScopeChanged(ValueChangedEvent<RankingsScope> scope)
|
||||||
{
|
{
|
||||||
scopeText.Text = scope.ToString();
|
scopeText.Text = scope.NewValue.ToString();
|
||||||
|
|
||||||
if (scope != RankingsScope.Performance)
|
if (scope.NewValue != RankingsScope.Performance)
|
||||||
Country.Value = null;
|
Country.Value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,16 +85,14 @@ namespace osu.Game.Overlays.Rankings
|
|||||||
{
|
{
|
||||||
if (country.NewValue == null)
|
if (country.NewValue == null)
|
||||||
{
|
{
|
||||||
flagPlaceholder.Hide();
|
flag.Hide();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Scope.Value = RankingsScope.Performance;
|
Scope.Value = RankingsScope.Performance;
|
||||||
|
|
||||||
if (country.OldValue == null)
|
|
||||||
flagPlaceholder.Show();
|
|
||||||
|
|
||||||
flag.Country = country.NewValue;
|
flag.Country = country.NewValue;
|
||||||
|
flag.Show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -502,15 +502,18 @@ namespace osu.Game.Screens.Play
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pauseCooldownActive && !GameplayClockContainer.IsPaused.Value)
|
// ValidForResume is false when restarting
|
||||||
// still want to block if we are within the cooldown period and not already paused.
|
if (ValidForResume)
|
||||||
return true;
|
|
||||||
|
|
||||||
if (HasFailed && ValidForResume && !FailOverlay.IsPresent)
|
|
||||||
// ValidForResume is false when restarting
|
|
||||||
{
|
{
|
||||||
failAnimation.FinishTransforms(true);
|
if (pauseCooldownActive && !GameplayClockContainer.IsPaused.Value)
|
||||||
return true;
|
// still want to block if we are within the cooldown period and not already paused.
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (HasFailed && !FailOverlay.IsPresent)
|
||||||
|
{
|
||||||
|
failAnimation.FinishTransforms(true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GameplayClockContainer.ResetLocalAdjustments();
|
GameplayClockContainer.ResetLocalAdjustments();
|
||||||
|
Loading…
Reference in New Issue
Block a user