osu/osu.Game.Tournament/Screens/Gameplay/GameplayScreen.cs

105 lines
3.4 KiB
C#
Raw Normal View History

2018-11-06 10:23:03 +00:00
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
2018-11-10 16:50:09 +00:00
using Microsoft.Diagnostics.Runtime.Interop;
2018-11-08 11:15:22 +00:00
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
2018-11-10 15:45:48 +00:00
using osu.Framework.Graphics.Shapes;
2018-11-08 11:15:22 +00:00
using osu.Framework.Graphics.Textures;
2018-11-10 16:50:09 +00:00
using osu.Framework.Threading;
2018-11-08 11:15:22 +00:00
using osu.Game.Graphics.UserInterface;
using osu.Game.Tournament.Components;
2018-11-10 15:45:48 +00:00
using osu.Game.Tournament.IPC;
using osu.Game.Tournament.Screens.Ladder.Components;
using OpenTK.Graphics;
2018-11-08 11:15:22 +00:00
2018-11-06 10:23:03 +00:00
namespace osu.Game.Tournament.Screens.Gameplay
{
public class GameplayScreen : BeatmapInfoScreen
{
2018-11-09 07:26:09 +00:00
private readonly BindableBool warmup = new BindableBool();
2018-11-09 07:10:58 +00:00
2018-11-10 15:45:48 +00:00
private readonly Bindable<MatchPairing> currentMatch = new Bindable<MatchPairing>();
public readonly Bindable<TourneyState> State = new Bindable<TourneyState>();
private TriangleButton warmupButton;
private FileBasedIPC ipc;
2018-11-08 11:15:22 +00:00
[BackgroundDependencyLoader]
2018-11-10 15:45:48 +00:00
private void load(LadderInfo ladder, TextureStore textures, FileBasedIPC ipc)
2018-11-08 11:15:22 +00:00
{
2018-11-10 15:45:48 +00:00
this.ipc = ipc;
2018-11-09 07:10:58 +00:00
AddRange(new Drawable[]
2018-11-08 11:15:22 +00:00
{
2018-11-10 08:26:21 +00:00
new MatchHeader(),
// new CustomChatOverlay
// {
// Anchor = Anchor.BottomCentre,
// Origin = Anchor.BottomCentre,
// Size = new Vector2(0.4f, 1)
// },
2018-11-10 15:45:48 +00:00
new Box
{
RelativeSizeAxes = Axes.Both,
Height = 720 / 1080f,
Colour = new Color4(0, 255, 0, 255),
Anchor = Anchor.Centre,
Origin= Anchor.Centre,
},
2018-11-09 07:10:58 +00:00
new ControlPanel
{
Children = new Drawable[]
2018-11-08 11:15:22 +00:00
{
2018-11-10 15:45:48 +00:00
warmupButton = new TriangleButton
2018-11-09 07:10:58 +00:00
{
2018-11-10 15:45:48 +00:00
Colour = Color4.Gray,
2018-11-09 07:10:58 +00:00
RelativeSizeAxes = Axes.X,
Text = "Toggle warmup",
2018-11-10 16:29:42 +00:00
Action = () => warmup.Toggle()
2018-11-09 07:10:58 +00:00
}
2018-11-08 11:15:22 +00:00
}
2018-11-09 07:10:58 +00:00
}
2018-11-08 11:15:22 +00:00
});
2018-11-10 15:45:48 +00:00
State.BindValueChanged(stateChanged);
State.BindTo(ipc.State);
currentMatch.BindTo(ladder.CurrentMatch);
2018-11-10 16:29:42 +00:00
warmup.BindValueChanged(w => warmupButton.Colour = !w ? Color4.White : Color4.Gray, true);
2018-11-10 15:45:48 +00:00
}
2018-11-10 16:50:09 +00:00
private ScheduledDelegate scheduledBarContract;
2018-11-10 15:45:48 +00:00
private void stateChanged(TourneyState state)
{
if (state == TourneyState.Ranking)
{
if (warmup.Value) return;
if (ipc.Score1 > ipc.Score2)
currentMatch.Value.Team1Score.Value++;
else
currentMatch.Value.Team2Score.Value++;
}
2018-11-08 11:15:22 +00:00
2018-11-10 16:50:09 +00:00
scheduledBarContract?.Cancel();
switch (state)
2018-11-10 16:29:42 +00:00
{
2018-11-10 16:50:09 +00:00
case TourneyState.Idle:
// show chat
SongBar.Expanded = false;
break;
case TourneyState.Ranking:
scheduledBarContract = Scheduler.AddDelayed(() => SongBar.Expanded = false, 15000);
break;
default:
SongBar.Expanded = true;
break;
2018-11-10 16:29:42 +00:00
}
2018-11-09 07:10:58 +00:00
}
2018-11-06 10:23:03 +00:00
}
}