2019-03-04 04:24:19 +00:00
|
|
|
// 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.
|
2018-11-06 05:49:09 +00:00
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
#nullable disable
|
|
|
|
|
2018-11-17 23:30:17 +00:00
|
|
|
using System;
|
|
|
|
using System.Linq;
|
2018-11-06 05:49:09 +00:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2022-04-01 03:44:49 +00:00
|
|
|
using osu.Framework.Input.Events;
|
2022-07-11 11:42:04 +00:00
|
|
|
using osu.Framework.Testing;
|
2019-11-08 08:26:24 +00:00
|
|
|
using osu.Framework.Threading;
|
2019-11-08 08:20:20 +00:00
|
|
|
using osu.Game.Graphics;
|
2022-04-01 03:44:49 +00:00
|
|
|
using osu.Game.Graphics.Sprites;
|
2018-11-17 12:27:02 +00:00
|
|
|
using osu.Game.Tournament.Components;
|
2019-06-18 05:51:48 +00:00
|
|
|
using osu.Game.Tournament.Screens;
|
2018-11-06 05:49:09 +00:00
|
|
|
using osu.Game.Tournament.Screens.Drawings;
|
2019-06-18 05:51:48 +00:00
|
|
|
using osu.Game.Tournament.Screens.Editors;
|
2018-11-06 10:23:03 +00:00
|
|
|
using osu.Game.Tournament.Screens.Gameplay;
|
2018-11-06 05:49:09 +00:00
|
|
|
using osu.Game.Tournament.Screens.Ladder;
|
|
|
|
using osu.Game.Tournament.Screens.MapPool;
|
2018-11-11 01:13:17 +00:00
|
|
|
using osu.Game.Tournament.Screens.Schedule;
|
2021-01-11 05:44:07 +00:00
|
|
|
using osu.Game.Tournament.Screens.Setup;
|
2018-11-06 05:49:09 +00:00
|
|
|
using osu.Game.Tournament.Screens.Showcase;
|
|
|
|
using osu.Game.Tournament.Screens.TeamIntro;
|
2018-11-11 01:39:04 +00:00
|
|
|
using osu.Game.Tournament.Screens.TeamWin;
|
2018-11-22 01:25:30 +00:00
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
2022-04-01 03:44:49 +00:00
|
|
|
using osuTK.Input;
|
2018-11-06 05:49:09 +00:00
|
|
|
|
2019-06-18 05:51:48 +00:00
|
|
|
namespace osu.Game.Tournament
|
2018-11-06 05:49:09 +00:00
|
|
|
{
|
2018-11-17 23:30:17 +00:00
|
|
|
[Cached]
|
2019-06-14 08:17:47 +00:00
|
|
|
public class TournamentSceneManager : CompositeDrawable
|
2018-11-06 05:49:09 +00:00
|
|
|
{
|
|
|
|
private Container screens;
|
2019-06-17 12:07:30 +00:00
|
|
|
private TourneyVideo video;
|
2018-11-06 05:49:09 +00:00
|
|
|
|
2020-03-13 06:44:13 +00:00
|
|
|
public const float CONTROL_AREA_WIDTH = 160;
|
|
|
|
|
|
|
|
public const float STREAM_AREA_WIDTH = 1366;
|
|
|
|
|
2020-06-24 07:57:40 +00:00
|
|
|
public const double REQUIRED_WIDTH = CONTROL_AREA_WIDTH * 2 + STREAM_AREA_WIDTH;
|
2020-03-13 06:44:13 +00:00
|
|
|
|
2018-11-17 12:27:02 +00:00
|
|
|
[Cached]
|
2019-06-18 04:44:38 +00:00
|
|
|
private TournamentMatchChatDisplay chat = new TournamentMatchChatDisplay();
|
2018-11-17 12:27:02 +00:00
|
|
|
|
|
|
|
private Container chatContainer;
|
2019-11-08 08:20:20 +00:00
|
|
|
private FillFlowContainer buttons;
|
2018-11-17 12:27:02 +00:00
|
|
|
|
2019-06-14 08:17:47 +00:00
|
|
|
public TournamentSceneManager()
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
}
|
|
|
|
|
2018-11-06 05:49:09 +00:00
|
|
|
[BackgroundDependencyLoader]
|
2022-01-15 00:06:39 +00:00
|
|
|
private void load()
|
2018-11-06 05:49:09 +00:00
|
|
|
{
|
2019-02-02 09:29:20 +00:00
|
|
|
InternalChildren = new Drawable[]
|
2018-11-06 05:49:09 +00:00
|
|
|
{
|
|
|
|
new Container
|
|
|
|
{
|
2020-03-13 06:44:13 +00:00
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
X = CONTROL_AREA_WIDTH,
|
2018-11-06 05:49:09 +00:00
|
|
|
FillMode = FillMode.Fit,
|
2018-11-17 12:27:02 +00:00
|
|
|
FillAspectRatio = 16 / 9f,
|
2018-11-06 05:49:09 +00:00
|
|
|
Anchor = Anchor.TopLeft,
|
|
|
|
Origin = Anchor.TopLeft,
|
2020-03-13 06:44:13 +00:00
|
|
|
Width = STREAM_AREA_WIDTH,
|
2018-11-06 05:49:09 +00:00
|
|
|
//Masking = true,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2020-03-06 09:38:29 +00:00
|
|
|
video = new TourneyVideo("main", true)
|
2018-11-06 05:49:09 +00:00
|
|
|
{
|
|
|
|
Loop = true,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
|
|
|
screens = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2019-09-22 19:45:23 +00:00
|
|
|
new SetupScreen(),
|
2018-11-17 23:30:17 +00:00
|
|
|
new ScheduleScreen(),
|
|
|
|
new LadderScreen(),
|
|
|
|
new LadderEditorScreen(),
|
2019-06-18 06:15:28 +00:00
|
|
|
new TeamEditorScreen(),
|
2019-06-18 05:44:15 +00:00
|
|
|
new RoundEditorScreen(),
|
2018-11-17 23:30:17 +00:00
|
|
|
new ShowcaseScreen(),
|
|
|
|
new MapPoolScreen(),
|
|
|
|
new TeamIntroScreen(),
|
2020-03-03 09:12:42 +00:00
|
|
|
new SeedingScreen(),
|
2018-11-17 23:30:17 +00:00
|
|
|
new DrawingsScreen(),
|
|
|
|
new GameplayScreen(),
|
|
|
|
new TeamWinScreen()
|
2018-11-06 05:49:09 +00:00
|
|
|
}
|
|
|
|
},
|
2018-11-17 12:27:02 +00:00
|
|
|
chatContainer = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Child = chat
|
|
|
|
},
|
2018-11-06 05:49:09 +00:00
|
|
|
}
|
|
|
|
},
|
2018-11-17 04:39:55 +00:00
|
|
|
new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
2020-03-13 06:44:13 +00:00
|
|
|
Width = CONTROL_AREA_WIDTH,
|
2018-11-17 04:39:55 +00:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
Colour = Color4.Black,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
2019-11-08 08:20:20 +00:00
|
|
|
buttons = new FillFlowContainer
|
2018-11-17 04:39:55 +00:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Vertical,
|
2020-03-13 06:44:13 +00:00
|
|
|
Spacing = new Vector2(5),
|
|
|
|
Padding = new MarginPadding(5),
|
2018-11-17 04:39:55 +00:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2019-11-08 08:20:20 +00:00
|
|
|
new ScreenButton(typeof(SetupScreen)) { Text = "Setup", RequestSelection = SetScreen },
|
|
|
|
new Separator(),
|
|
|
|
new ScreenButton(typeof(TeamEditorScreen)) { Text = "Team Editor", RequestSelection = SetScreen },
|
|
|
|
new ScreenButton(typeof(RoundEditorScreen)) { Text = "Rounds Editor", RequestSelection = SetScreen },
|
|
|
|
new ScreenButton(typeof(LadderEditorScreen)) { Text = "Bracket Editor", RequestSelection = SetScreen },
|
|
|
|
new Separator(),
|
2022-04-01 03:44:49 +00:00
|
|
|
new ScreenButton(typeof(ScheduleScreen), Key.S) { Text = "Schedule", RequestSelection = SetScreen },
|
|
|
|
new ScreenButton(typeof(LadderScreen), Key.B) { Text = "Bracket", RequestSelection = SetScreen },
|
2019-11-08 08:20:20 +00:00
|
|
|
new Separator(),
|
2022-04-01 03:44:49 +00:00
|
|
|
new ScreenButton(typeof(TeamIntroScreen), Key.I) { Text = "Team Intro", RequestSelection = SetScreen },
|
|
|
|
new ScreenButton(typeof(SeedingScreen), Key.D) { Text = "Seeding", RequestSelection = SetScreen },
|
2019-11-08 08:20:20 +00:00
|
|
|
new Separator(),
|
2022-04-01 03:44:49 +00:00
|
|
|
new ScreenButton(typeof(MapPoolScreen), Key.M) { Text = "Map Pool", RequestSelection = SetScreen },
|
|
|
|
new ScreenButton(typeof(GameplayScreen), Key.G) { Text = "Gameplay", RequestSelection = SetScreen },
|
2019-11-08 08:20:20 +00:00
|
|
|
new Separator(),
|
2022-04-01 03:44:49 +00:00
|
|
|
new ScreenButton(typeof(TeamWinScreen), Key.W) { Text = "Win", RequestSelection = SetScreen },
|
2019-11-08 08:20:20 +00:00
|
|
|
new Separator(),
|
|
|
|
new ScreenButton(typeof(DrawingsScreen)) { Text = "Drawings", RequestSelection = SetScreen },
|
|
|
|
new ScreenButton(typeof(ShowcaseScreen)) { Text = "Showcase", RequestSelection = SetScreen },
|
2018-11-17 04:39:55 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2018-11-06 05:49:09 +00:00
|
|
|
};
|
|
|
|
|
2019-11-08 08:26:24 +00:00
|
|
|
foreach (var drawable in screens)
|
|
|
|
drawable.Hide();
|
|
|
|
|
2019-09-22 19:47:51 +00:00
|
|
|
SetScreen(typeof(SetupScreen));
|
2018-11-06 05:49:09 +00:00
|
|
|
}
|
|
|
|
|
2019-11-08 08:26:24 +00:00
|
|
|
private float depth;
|
|
|
|
|
|
|
|
private Drawable currentScreen;
|
|
|
|
private ScheduledDelegate scheduledHide;
|
|
|
|
|
2020-03-03 09:12:42 +00:00
|
|
|
private Drawable temporaryScreen;
|
|
|
|
|
|
|
|
public void SetScreen(Drawable screen)
|
|
|
|
{
|
|
|
|
currentScreen?.Hide();
|
|
|
|
currentScreen = null;
|
|
|
|
|
|
|
|
screens.Add(temporaryScreen = screen);
|
|
|
|
}
|
|
|
|
|
2018-11-17 23:30:17 +00:00
|
|
|
public void SetScreen(Type screenType)
|
2018-11-06 05:49:09 +00:00
|
|
|
{
|
2020-03-03 09:12:42 +00:00
|
|
|
temporaryScreen?.Expire();
|
|
|
|
|
2019-11-08 08:26:24 +00:00
|
|
|
var target = screens.FirstOrDefault(s => s.GetType() == screenType);
|
|
|
|
|
|
|
|
if (target == null || currentScreen == target) return;
|
2018-11-17 23:30:17 +00:00
|
|
|
|
2019-11-08 08:26:24 +00:00
|
|
|
if (scheduledHide?.Completed == false)
|
2018-11-06 05:49:09 +00:00
|
|
|
{
|
2019-11-08 08:26:24 +00:00
|
|
|
scheduledHide.RunTask();
|
|
|
|
scheduledHide.Cancel(); // see https://github.com/ppy/osu-framework/issues/2967
|
|
|
|
scheduledHide = null;
|
2018-11-06 05:49:09 +00:00
|
|
|
}
|
2018-11-17 12:27:02 +00:00
|
|
|
|
2019-11-08 08:26:24 +00:00
|
|
|
var lastScreen = currentScreen;
|
|
|
|
currentScreen = target;
|
|
|
|
|
2022-07-11 11:42:04 +00:00
|
|
|
if (currentScreen.ChildrenOfType<TourneyVideo>().FirstOrDefault()?.VideoAvailable == true)
|
2019-11-08 08:26:24 +00:00
|
|
|
{
|
|
|
|
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)
|
2018-11-17 12:27:02 +00:00
|
|
|
{
|
2022-06-24 12:25:23 +00:00
|
|
|
case MapPoolScreen:
|
2019-11-08 08:26:24 +00:00
|
|
|
chatContainer.FadeIn(TournamentScreen.FADE_DELAY);
|
2020-03-08 05:46:09 +00:00
|
|
|
chatContainer.ResizeWidthTo(1, 500, Easing.OutQuint);
|
|
|
|
break;
|
|
|
|
|
2022-06-24 12:25:23 +00:00
|
|
|
case GameplayScreen:
|
2020-03-08 05:46:09 +00:00
|
|
|
chatContainer.FadeIn(TournamentScreen.FADE_DELAY);
|
|
|
|
chatContainer.ResizeWidthTo(0.5f, 500, Easing.OutQuint);
|
2018-11-17 12:27:02 +00:00
|
|
|
break;
|
2019-05-15 03:08:23 +00:00
|
|
|
|
2018-11-17 12:27:02 +00:00
|
|
|
default:
|
2019-11-08 08:26:24 +00:00
|
|
|
chatContainer.FadeOut(TournamentScreen.FADE_DELAY);
|
2018-11-17 12:27:02 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-11-08 08:20:20 +00:00
|
|
|
|
|
|
|
foreach (var s in buttons.OfType<ScreenButton>())
|
|
|
|
s.IsSelected = screenType == s.Type;
|
|
|
|
}
|
|
|
|
|
|
|
|
private class Separator : CompositeDrawable
|
|
|
|
{
|
|
|
|
public Separator()
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
Height = 20;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private class ScreenButton : TourneyButton
|
|
|
|
{
|
|
|
|
public readonly Type Type;
|
|
|
|
|
2022-04-01 03:44:49 +00:00
|
|
|
private readonly Key? shortcutKey;
|
|
|
|
|
|
|
|
public ScreenButton(Type type, Key? shortcutKey = null)
|
2019-11-08 08:20:20 +00:00
|
|
|
{
|
2022-04-01 03:44:49 +00:00
|
|
|
this.shortcutKey = shortcutKey;
|
|
|
|
|
2019-11-08 08:20:20 +00:00
|
|
|
Type = type;
|
2022-04-01 03:44:49 +00:00
|
|
|
|
2019-11-08 08:20:20 +00:00
|
|
|
BackgroundColour = OsuColour.Gray(0.2f);
|
2021-10-25 07:45:46 +00:00
|
|
|
Action = () => RequestSelection?.Invoke(type);
|
2019-11-08 08:20:20 +00:00
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
2022-04-01 03:44:49 +00:00
|
|
|
|
|
|
|
if (shortcutKey != null)
|
|
|
|
{
|
|
|
|
Add(new Container
|
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
Size = new Vector2(24),
|
|
|
|
Margin = new MarginPadding(5),
|
|
|
|
Masking = true,
|
|
|
|
CornerRadius = 4,
|
|
|
|
Alpha = 0.5f,
|
|
|
|
Blending = BlendingParameters.Additive,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
Colour = OsuColour.Gray(0.1f),
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
|
|
|
new OsuSpriteText
|
|
|
|
{
|
|
|
|
Font = OsuFont.Default.With(size: 24),
|
|
|
|
Y = -2,
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Text = shortcutKey.ToString(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override bool OnKeyDown(KeyDownEvent e)
|
|
|
|
{
|
|
|
|
if (e.Key == shortcutKey)
|
|
|
|
{
|
|
|
|
TriggerClick();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return base.OnKeyDown(e);
|
2019-11-08 08:20:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private bool isSelected;
|
|
|
|
|
|
|
|
public Action<Type> RequestSelection;
|
|
|
|
|
|
|
|
public bool IsSelected
|
|
|
|
{
|
|
|
|
get => isSelected;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (value == isSelected)
|
|
|
|
return;
|
|
|
|
|
|
|
|
isSelected = value;
|
|
|
|
BackgroundColour = isSelected ? Color4.SkyBlue : OsuColour.Gray(0.2f);
|
|
|
|
SpriteText.Colour = isSelected ? Color4.Black : Color4.White;
|
|
|
|
}
|
|
|
|
}
|
2018-11-06 05:49:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|