Add automation of map pool and win screen workflows

This commit is contained in:
Dean Herbert
2018-11-18 08:30:17 +09:00
parent 70739ae5a0
commit e6529eac3e
2 changed files with 49 additions and 35 deletions

View File

@ -13,6 +13,8 @@ using osu.Game.Tournament.Components;
using osu.Game.Tournament.IPC; using osu.Game.Tournament.IPC;
using osu.Game.Tournament.Screens.Gameplay.Components; using osu.Game.Tournament.Screens.Gameplay.Components;
using osu.Game.Tournament.Screens.Ladder.Components; using osu.Game.Tournament.Screens.Ladder.Components;
using osu.Game.Tournament.Screens.MapPool;
using osu.Game.Tournament.Screens.TeamWin;
using OpenTK.Graphics; using OpenTK.Graphics;
namespace osu.Game.Tournament.Screens.Gameplay namespace osu.Game.Tournament.Screens.Gameplay
@ -30,6 +32,9 @@ namespace osu.Game.Tournament.Screens.Gameplay
private readonly Color4 red = new Color4(186, 0, 18, 255); private readonly Color4 red = new Color4(186, 0, 18, 255);
private readonly Color4 blue = new Color4(17, 136, 170, 255); private readonly Color4 blue = new Color4(17, 136, 170, 255);
[Resolved]
private TournamentSceneManager sceneManager { get; set; }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(LadderInfo ladder, TextureStore textures, MatchIPCInfo ipc, MatchChatDisplay chat) private void load(LadderInfo ladder, TextureStore textures, MatchIPCInfo ipc, MatchChatDisplay chat)
{ {
@ -119,10 +124,12 @@ namespace osu.Game.Tournament.Screens.Gameplay
warmup.BindValueChanged(w => warmupButton.Alpha = !w ? 0.5f : 1, true); warmup.BindValueChanged(w => warmupButton.Alpha = !w ? 0.5f : 1, true);
} }
private ScheduledDelegate scheduledBarContract; private ScheduledDelegate scheduledOperation;
private MatchChatDisplay chat; private MatchChatDisplay chat;
private MatchScoreDisplay scoreDisplay; private MatchScoreDisplay scoreDisplay;
private TourneyState lastState;
private void stateChanged(TourneyState state) private void stateChanged(TourneyState state)
{ {
if (state == TourneyState.Ranking) if (state == TourneyState.Ranking)
@ -135,7 +142,7 @@ namespace osu.Game.Tournament.Screens.Gameplay
currentMatch.Value.Team2Score.Value++; currentMatch.Value.Team2Score.Value++;
} }
scheduledBarContract?.Cancel(); scheduledOperation?.Cancel();
void expand() void expand()
{ {
@ -160,15 +167,26 @@ namespace osu.Game.Tournament.Screens.Gameplay
{ {
case TourneyState.Idle: case TourneyState.Idle:
contract(); contract();
if (lastState == TourneyState.Ranking)
{
if (currentMatch.Value?.Completed == true)
scheduledOperation = Scheduler.AddDelayed(() => { sceneManager?.SetScreen(typeof(TeamWinScreen)); }, 4000);
else if (currentMatch.Value?.Completed == false)
scheduledOperation = Scheduler.AddDelayed(() => { sceneManager?.SetScreen(typeof(MapPoolScreen)); }, 4000);
}
break; break;
case TourneyState.Ranking: case TourneyState.Ranking:
scheduledBarContract = Scheduler.AddDelayed(contract, 10000); scheduledOperation = Scheduler.AddDelayed(contract, 10000);
break; break;
default: default:
chat.Expand(); chat.Expand();
expand(); expand();
break; break;
} }
lastState = state;
} }
} }
} }

View File

@ -1,6 +1,8 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -24,19 +26,10 @@ using OpenTK.Graphics;
namespace osu.Game.Tournament.Screens namespace osu.Game.Tournament.Screens
{ {
[Cached]
public class TournamentSceneManager : OsuScreen public class TournamentSceneManager : OsuScreen
{ {
private ScheduleScreen schedule;
private LadderScreen bracket;
private LadderEditorScreen bracketEditor;
private GroupingsEditorScreen groupingsEditor;
private MapPoolScreen mapPool;
private GameplayScreen gameplay;
private TeamWinScreen winner;
private TeamIntroScreen teamIntro;
private DrawingsScreen drawings;
private Container screens; private Container screens;
private ShowcaseScreen showcase;
private VideoSprite video; private VideoSprite video;
//todo: make less temporary //todo: make less temporary
@ -81,16 +74,16 @@ namespace osu.Game.Tournament.Screens
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Children = new Drawable[] Children = new Drawable[]
{ {
schedule = new ScheduleScreen(), new ScheduleScreen(),
bracket = new LadderScreen(), new LadderScreen(),
bracketEditor = new LadderEditorScreen(), new LadderEditorScreen(),
groupingsEditor = new GroupingsEditorScreen(), new GroupingsEditorScreen(),
showcase = new ShowcaseScreen(), new ShowcaseScreen(),
mapPool = new MapPoolScreen(), new MapPoolScreen(),
teamIntro = new TeamIntroScreen(), new TeamIntroScreen(),
drawings = new DrawingsScreen(), new DrawingsScreen(),
gameplay = new GameplayScreen(), new GameplayScreen(),
winner = new TeamWinScreen() new TeamWinScreen()
} }
}, },
chatContainer = new Container chatContainer = new Container
@ -117,31 +110,34 @@ namespace osu.Game.Tournament.Screens
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Children = new Drawable[] Children = new Drawable[]
{ {
new OsuButton { RelativeSizeAxes = Axes.X, Text = "Bracket Editor", Action = () => setScreen(bracketEditor) }, new OsuButton { RelativeSizeAxes = Axes.X, Text = "Bracket Editor", Action = () => SetScreen(typeof(LadderEditorScreen)) },
new OsuButton { RelativeSizeAxes = Axes.X, Text = "Groupings Editor", Action = () => setScreen(groupingsEditor) }, new OsuButton { RelativeSizeAxes = Axes.X, Text = "Groupings Editor", Action = () => SetScreen(typeof(GroupingsEditorScreen)) },
new Container { RelativeSizeAxes = Axes.X, Height = 50 }, new Container { RelativeSizeAxes = Axes.X, Height = 50 },
new OsuButton { RelativeSizeAxes = Axes.X, Text = "Drawings", Action = () => setScreen(drawings) }, new OsuButton { RelativeSizeAxes = Axes.X, Text = "Drawings", Action = () => SetScreen(typeof(DrawingsScreen)) },
new OsuButton { RelativeSizeAxes = Axes.X, Text = "Showcase", Action = () => setScreen(showcase) }, new OsuButton { RelativeSizeAxes = Axes.X, Text = "Showcase", Action = () => SetScreen(typeof(ShowcaseScreen)) },
new Container { RelativeSizeAxes = Axes.X, Height = 50 }, new Container { RelativeSizeAxes = Axes.X, Height = 50 },
new OsuButton { RelativeSizeAxes = Axes.X, Text = "Schedule", Action = () => setScreen(schedule) }, new OsuButton { RelativeSizeAxes = Axes.X, Text = "Schedule", Action = () => SetScreen(typeof(ScheduleScreen)) },
new OsuButton { RelativeSizeAxes = Axes.X, Text = "Bracket", Action = () => setScreen(bracket) }, new OsuButton { RelativeSizeAxes = Axes.X, Text = "Bracket", Action = () => SetScreen(typeof(LadderScreen)) },
new Container { RelativeSizeAxes = Axes.X, Height = 50 }, new Container { RelativeSizeAxes = Axes.X, Height = 50 },
new OsuButton { RelativeSizeAxes = Axes.X, Text = "TeamIntro", Action = () => setScreen(teamIntro) }, new OsuButton { RelativeSizeAxes = Axes.X, Text = "TeamIntro", Action = () => SetScreen(typeof(TeamIntroScreen)) },
new OsuButton { RelativeSizeAxes = Axes.X, Text = "MapPool", Action = () => setScreen(mapPool) }, new OsuButton { RelativeSizeAxes = Axes.X, Text = "MapPool", Action = () => SetScreen(typeof(MapPoolScreen)) },
new OsuButton { RelativeSizeAxes = Axes.X, Text = "Gameplay", Action = () => setScreen(gameplay) }, new OsuButton { RelativeSizeAxes = Axes.X, Text = "Gameplay", Action = () => SetScreen(typeof(GameplayScreen)) },
new Container { RelativeSizeAxes = Axes.X, Height = 50 }, new Container { RelativeSizeAxes = Axes.X, Height = 50 },
new OsuButton { RelativeSizeAxes = Axes.X, Text = "Win", Action = () => setScreen(winner) }, new OsuButton { RelativeSizeAxes = Axes.X, Text = "Win", Action = () => SetScreen(typeof(TeamWinScreen)) },
} }
}, },
}, },
}, },
}; };
setScreen(teamIntro); SetScreen(typeof(ScheduleScreen));
} }
private void setScreen(Drawable screen) public void SetScreen(Type screenType)
{ {
var screen = screens.FirstOrDefault(s => s.GetType() == screenType);
if (screen == null) return;
foreach (var s in screens.Children) foreach (var s in screens.Children)
{ {
if (s == screen) if (s == screen)