1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 17:17:24 +08:00
osu-lazer/osu.Game.Tournament/TournamentSceneManager.cs

169 lines
7.2 KiB
C#
Raw Normal View History

2019-03-04 12:24:19 +08: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.
using System;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Platform;
using osu.Game.Graphics.UserInterface;
2018-11-17 20:27:02 +08:00
using osu.Game.Tournament.Components;
2019-06-18 13:51:48 +08:00
using osu.Game.Tournament.Models;
using osu.Game.Tournament.Screens;
using osu.Game.Tournament.Screens.Drawings;
2019-06-18 13:51:48 +08:00
using osu.Game.Tournament.Screens.Editors;
2018-11-06 18:23:03 +08:00
using osu.Game.Tournament.Screens.Gameplay;
using osu.Game.Tournament.Screens.Ladder;
using osu.Game.Tournament.Screens.MapPool;
2018-11-11 09:13:17 +08:00
using osu.Game.Tournament.Screens.Schedule;
using osu.Game.Tournament.Screens.Showcase;
using osu.Game.Tournament.Screens.TeamIntro;
2018-11-11 09:39:04 +08:00
using osu.Game.Tournament.Screens.TeamWin;
using osuTK;
using osuTK.Graphics;
2019-06-18 13:51:48 +08:00
namespace osu.Game.Tournament
{
[Cached]
2019-06-14 16:17:47 +08:00
public class TournamentSceneManager : CompositeDrawable
{
private Container screens;
private TourneyVideo video;
2018-11-17 20:27:02 +08:00
[Cached]
2019-06-18 12:44:38 +08:00
private TournamentMatchChatDisplay chat = new TournamentMatchChatDisplay();
2018-11-17 20:27:02 +08:00
private Container chatContainer;
2019-06-14 16:17:47 +08:00
public TournamentSceneManager()
{
RelativeSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader]
private void load(LadderInfo ladder, Storage storage)
{
InternalChildren = new Drawable[]
{
new Container
{
RelativeSizeAxes = Axes.Both,
X = 200,
FillMode = FillMode.Fit,
2018-11-17 20:27:02 +08:00
FillAspectRatio = 16 / 9f,
Anchor = Anchor.TopLeft,
Origin = Anchor.TopLeft,
Size = new Vector2(0.8f, 1),
//Masking = true,
Children = new Drawable[]
{
video = new TourneyVideo(storage.GetStream("BG Logoless - OWC.m4v"))
{
Loop = true,
RelativeSizeAxes = Axes.Both,
},
screens = new Container
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
2019-09-23 03:45:23 +08:00
new SetupScreen(),
new ScheduleScreen(),
new LadderScreen(),
new LadderEditorScreen(),
2019-06-18 14:15:28 +08:00
new TeamEditorScreen(),
2019-06-18 13:44:15 +08:00
new RoundEditorScreen(),
new ShowcaseScreen(),
new MapPoolScreen(),
new TeamIntroScreen(),
new DrawingsScreen(),
new GameplayScreen(),
new TeamWinScreen()
}
},
2018-11-17 20:27:02 +08:00
chatContainer = new Container
{
RelativeSizeAxes = Axes.Both,
Child = chat
},
}
},
2018-11-17 12:39:55 +08:00
new Container
{
RelativeSizeAxes = Axes.Y,
Width = 200,
Children = new Drawable[]
{
new Box
{
Colour = Color4.Black,
RelativeSizeAxes = Axes.Both,
},
new FillFlowContainer
{
RelativeSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
2019-09-22 01:10:04 +08:00
new OsuButton { RelativeSizeAxes = Axes.X, Text = "Setup", Action = () => SetScreen(typeof(SetupScreen)) },
new Container { RelativeSizeAxes = Axes.X, Height = 50 },
2019-06-18 14:15:28 +08:00
new OsuButton { RelativeSizeAxes = Axes.X, Text = "Team Editor", Action = () => SetScreen(typeof(TeamEditorScreen)) },
2019-06-18 13:44:15 +08:00
new OsuButton { RelativeSizeAxes = Axes.X, Text = "Rounds Editor", Action = () => SetScreen(typeof(RoundEditorScreen)) },
2019-06-14 19:32:02 +08:00
new OsuButton { RelativeSizeAxes = Axes.X, Text = "Bracket Editor", Action = () => SetScreen(typeof(LadderEditorScreen)) },
2018-11-17 12:39:55 +08:00
new Container { RelativeSizeAxes = Axes.X, Height = 50 },
new OsuButton { RelativeSizeAxes = Axes.X, Text = "Drawings", Action = () => SetScreen(typeof(DrawingsScreen)) },
new OsuButton { RelativeSizeAxes = Axes.X, Text = "Showcase", Action = () => SetScreen(typeof(ShowcaseScreen)) },
2018-11-17 12:39:55 +08:00
new Container { RelativeSizeAxes = Axes.X, Height = 50 },
new OsuButton { RelativeSizeAxes = Axes.X, Text = "Schedule", Action = () => SetScreen(typeof(ScheduleScreen)) },
new OsuButton { RelativeSizeAxes = Axes.X, Text = "Bracket", Action = () => SetScreen(typeof(LadderScreen)) },
2018-11-17 12:39:55 +08:00
new Container { RelativeSizeAxes = Axes.X, Height = 50 },
new OsuButton { RelativeSizeAxes = Axes.X, Text = "TeamIntro", Action = () => SetScreen(typeof(TeamIntroScreen)) },
new OsuButton { RelativeSizeAxes = Axes.X, Text = "MapPool", Action = () => SetScreen(typeof(MapPoolScreen)) },
new OsuButton { RelativeSizeAxes = Axes.X, Text = "Gameplay", Action = () => SetScreen(typeof(GameplayScreen)) },
2018-11-17 12:39:55 +08:00
new Container { RelativeSizeAxes = Axes.X, Height = 50 },
new OsuButton { RelativeSizeAxes = Axes.X, Text = "Win", Action = () => SetScreen(typeof(TeamWinScreen)) },
2018-11-17 12:39:55 +08:00
}
},
},
},
};
SetScreen(typeof(SetupScreen));
}
public void SetScreen(Type screenType)
{
var screen = screens.FirstOrDefault(s => s.GetType() == screenType);
if (screen == null) return;
foreach (var s in screens.Children)
{
if (s == screen)
{
s.Show();
if (s is IProvideVideo)
video.FadeOut(200);
else
video.Show();
}
else
s.Hide();
}
2018-11-17 20:27:02 +08:00
switch (screen)
{
case GameplayScreen _:
case MapPoolScreen _:
chatContainer.FadeIn(100);
break;
2018-11-17 20:27:02 +08:00
default:
chatContainer.FadeOut(100);
break;
}
}
}
}