1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 15:07:44 +08:00

Merge pull request #2979 from peppy/fix-osd-fade-in

Fix OSD fade-in not correctly debouncing
This commit is contained in:
Dean Herbert 2018-07-09 19:19:09 +09:00 committed by GitHub
commit 472aed8c91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 12 deletions

View File

@ -88,7 +88,7 @@ namespace osu.Game.Tests.Visual
private class TestOnScreenDisplay : OnScreenDisplay
{
protected override void Display(Drawable toDisplay) => toDisplay.FadeIn().ResizeHeightTo(110);
protected override void DisplayTemporarily(Drawable toDisplay) => toDisplay.FadeIn().ResizeHeightTo(110);
}
}
}

View File

@ -14,6 +14,8 @@ using osu.Game.Graphics;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics.Transforms;
using osu.Framework.Threading;
using osu.Game.Configuration;
using osu.Game.Graphics.Sprites;
@ -135,7 +137,7 @@ namespace osu.Game.Overlays
/// <exception cref="InvalidOperationException">If <paramref name="configManager"/> is already being tracked from the same <paramref name="source"/>.</exception>
public void BeginTracking(object source, ITrackableConfigManager configManager)
{
if (configManager == null) throw new ArgumentNullException(nameof(configManager));
if (configManager == null) throw new ArgumentNullException(nameof(configManager));
if (trackedConfigManagers.ContainsKey((source, configManager)))
throw new InvalidOperationException($"{nameof(configManager)} is already registered.");
@ -159,7 +161,7 @@ namespace osu.Game.Overlays
/// <exception cref="InvalidOperationException">If <paramref name="configManager"/> is not being tracked from the same <see cref="source"/>.</exception>
public void StopTracking(object source, ITrackableConfigManager configManager)
{
if (configManager == null) throw new ArgumentNullException(nameof(configManager));
if (configManager == null) throw new ArgumentNullException(nameof(configManager));
if (!trackedConfigManagers.TryGetValue((source, configManager), out var existing))
throw new InvalidOperationException($"{nameof(configManager)} is not registered.");
@ -181,7 +183,7 @@ namespace osu.Game.Overlays
if (string.IsNullOrEmpty(textLine3.Text))
textLine3.Text = "NO KEY BOUND";
Display(box);
DisplayTemporarily(box);
int optionCount = 0;
int selectedOption = -1;
@ -213,15 +215,29 @@ namespace osu.Game.Overlays
});
}
protected virtual void Display(Drawable toDisplay)
private TransformSequence<Drawable> fadeIn;
private ScheduledDelegate fadeOut;
protected virtual void DisplayTemporarily(Drawable toDisplay)
{
toDisplay.Animate(
b => b.FadeIn(500, Easing.OutQuint),
b => b.ResizeHeightTo(height, 500, Easing.OutQuint)
).Then(
b => b.FadeOutFromOne(1500, Easing.InQuint),
b => b.ResizeHeightTo(height_contracted, 1500, Easing.InQuint)
);
// avoid starting a new fade-in if one is already active.
if (fadeIn == null)
{
fadeIn = toDisplay.Animate(
b => b.FadeIn(500, Easing.OutQuint),
b => b.ResizeHeightTo(height, 500, Easing.OutQuint)
);
fadeIn.Finally(_ => fadeIn = null);
}
fadeOut?.Cancel();
fadeOut = Scheduler.AddDelayed(() =>
{
toDisplay.Animate(
b => b.FadeOutFromOne(1500, Easing.InQuint),
b => b.ResizeHeightTo(height_contracted, 1500, Easing.InQuint));
}, 500);
}
private class OptionLight : Container