1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 20:07:25 +08: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 const double FADE_DELAY = 200;
[Resolved]
protected LadderInfo LadderInfo { get; private set; }
@ -18,14 +20,8 @@ namespace osu.Game.Tournament.Screens
RelativeSizeAxes = Axes.Both;
}
public override void Hide()
{
this.FadeOut(200);
}
public override void Hide() => this.FadeOut(FADE_DELAY);
public override void Show()
{
this.FadeIn(200);
}
public override void Show() => this.FadeIn(FADE_DELAY);
}
}

View File

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