mirror of https://github.com/ppy/osu synced 2025-01-11 16:49:39 +00:00

Improve tournament screen transitions

This commit is contained in:
Dean Herbert 2019-11-08 17:26:24 +09:00
parent 6805c029e7
commit 7b8ed1ac9a
2 changed files with 42 additions and 24 deletions

View File

@ -10,6 +10,8 @@ namespace osu.Game.Tournament.Screens
{ {
public abstract class TournamentScreen : CompositeDrawable public abstract class TournamentScreen : CompositeDrawable
{ {
public const double FADE_DELAY = 200;
[Resolved] [Resolved]
protected LadderInfo LadderInfo { get; private set; } protected LadderInfo LadderInfo { get; private set; }
@ -18,14 +20,8 @@ namespace osu.Game.Tournament.Screens
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
} }
public override void Hide() public override void Hide() => this.FadeOut(FADE_DELAY);
{
this.FadeOut(200);
}
public override void Show() public override void Show() => this.FadeIn(FADE_DELAY);
{
this.FadeIn(200);
}
} }
} }

View File

@ -8,6 +8,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Framework.Threading;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Tournament.Components; using osu.Game.Tournament.Components;
using osu.Game.Tournament.Models; using osu.Game.Tournament.Models;
@ -130,37 +131,58 @@ namespace osu.Game.Tournament
}, },
}; };
foreach (var drawable in screens)
drawable.Hide();
SetScreen(typeof(SetupScreen)); SetScreen(typeof(SetupScreen));
} }
private float depth;
private Drawable currentScreen;
private ScheduledDelegate scheduledHide;
public void SetScreen(Type screenType) public void SetScreen(Type screenType)
{ {
var screen = screens.FirstOrDefault(s => s.GetType() == screenType); var target = screens.FirstOrDefault(s => s.GetType() == screenType);
if (screen == null) return;
foreach (var s in screens.Children) if (target == null || currentScreen == target) return;
if (scheduledHide?.Completed == false)
{ {
if (s == screen) scheduledHide.RunTask();
scheduledHide.Cancel(); // see https://github.com/ppy/osu-framework/issues/2967
scheduledHide = null;
}
var lastScreen = currentScreen;
currentScreen = target;
if (currentScreen is IProvideVideo)
{ {
s.Show();
if (s is IProvideVideo)
video.FadeOut(200); video.FadeOut(200);
// delay the hide to avoid a double-fade transition.
scheduledHide = Scheduler.AddDelayed(() => lastScreen?.Hide(), TournamentScreen.FADE_DELAY);
}
else else
{
lastScreen?.Hide();
video.Show(); video.Show();
} }
else
s.Hide();
}
switch (screen) screens.ChangeChildDepth(currentScreen, depth--);
currentScreen.Show();
switch (currentScreen)
{ {
case GameplayScreen _: case GameplayScreen _:
case MapPoolScreen _: case MapPoolScreen _:
chatContainer.FadeIn(100); chatContainer.FadeIn(TournamentScreen.FADE_DELAY);
break; break;
default: default:
chatContainer.FadeOut(100); chatContainer.FadeOut(TournamentScreen.FADE_DELAY);
break; break;
} }
} }