mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 08:32:57 +08:00
Improve tournament screen transitions (#6767)
Improve tournament screen transitions
This commit is contained in:
commit
5f122d88b9
@ -23,7 +23,7 @@ using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tournament.Screens.Drawings
|
||||
{
|
||||
public class DrawingsScreen : CompositeDrawable
|
||||
public class DrawingsScreen : TournamentScreen
|
||||
{
|
||||
private const string results_filename = "drawings_results.txt";
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
using osu.Game.Tournament.Components;
|
||||
using osu.Game.Tournament.Models;
|
||||
@ -134,37 +135,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)
|
||||
{
|
||||
s.Show();
|
||||
if (s is IProvideVideo)
|
||||
video.FadeOut(200);
|
||||
else
|
||||
video.Show();
|
||||
}
|
||||
else
|
||||
s.Hide();
|
||||
scheduledHide.RunTask();
|
||||
scheduledHide.Cancel(); // see https://github.com/ppy/osu-framework/issues/2967
|
||||
scheduledHide = null;
|
||||
}
|
||||
|
||||
switch (screen)
|
||||
var lastScreen = currentScreen;
|
||||
currentScreen = target;
|
||||
|
||||
if (currentScreen 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();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user