1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-24 20:07:25 +08:00
osu-lazer/osu.Game.Tournament/Screens/Gameplay/GameplayScreen.cs

105 lines
3.4 KiB
C#
Raw Normal View History

2018-11-06 18:23:03 +08: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-11 00:50:09 +08:00
using Microsoft.Diagnostics.Runtime.Interop;
2018-11-08 19:15:22 +08:00
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
2018-11-10 23:45:48 +08:00
using osu.Framework.Graphics.Shapes;
2018-11-08 19:15:22 +08:00
using osu.Framework.Graphics.Textures;
2018-11-11 00:50:09 +08:00
using osu.Framework.Threading;
2018-11-08 19:15:22 +08:00
using osu.Game.Graphics.UserInterface;
using osu.Game.Tournament.Components;
2018-11-10 23:45:48 +08:00
using osu.Game.Tournament.IPC;
using osu.Game.Tournament.Screens.Ladder.Components;
using OpenTK.Graphics;
2018-11-08 19:15:22 +08:00
2018-11-06 18:23:03 +08:00
namespace osu.Game.Tournament.Screens.Gameplay
{
public class GameplayScreen : BeatmapInfoScreen
{
2018-11-09 15:26:09 +08:00
private readonly BindableBool warmup = new BindableBool();
2018-11-09 15:10:58 +08:00
2018-11-10 23:45:48 +08: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 19:15:22 +08:00
[BackgroundDependencyLoader]
2018-11-10 23:45:48 +08:00
private void load(LadderInfo ladder, TextureStore textures, FileBasedIPC ipc)
2018-11-08 19:15:22 +08:00
{
2018-11-10 23:45:48 +08:00
this.ipc = ipc;
2018-11-09 15:10:58 +08:00
AddRange(new Drawable[]
2018-11-08 19:15:22 +08:00
{
2018-11-10 16:26:21 +08:00
new MatchHeader(),
// new CustomChatOverlay
// {
// Anchor = Anchor.BottomCentre,
// Origin = Anchor.BottomCentre,
// Size = new Vector2(0.4f, 1)
// },
2018-11-10 23:45:48 +08: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 15:10:58 +08:00
new ControlPanel
{
Children = new Drawable[]
2018-11-08 19:15:22 +08:00
{
2018-11-10 23:45:48 +08:00
warmupButton = new TriangleButton
2018-11-09 15:10:58 +08:00
{
2018-11-10 23:45:48 +08:00
Colour = Color4.Gray,
2018-11-09 15:10:58 +08:00
RelativeSizeAxes = Axes.X,
Text = "Toggle warmup",
2018-11-11 00:29:42 +08:00
Action = () => warmup.Toggle()
2018-11-09 15:10:58 +08:00
}
2018-11-08 19:15:22 +08:00
}
2018-11-09 15:10:58 +08:00
}
2018-11-08 19:15:22 +08:00
});
2018-11-10 23:45:48 +08:00
State.BindValueChanged(stateChanged);
State.BindTo(ipc.State);
currentMatch.BindTo(ladder.CurrentMatch);
2018-11-11 00:29:42 +08:00
warmup.BindValueChanged(w => warmupButton.Colour = !w ? Color4.White : Color4.Gray, true);
2018-11-10 23:45:48 +08:00
}
2018-11-11 00:50:09 +08:00
private ScheduledDelegate scheduledBarContract;
2018-11-10 23:45:48 +08: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 19:15:22 +08:00
2018-11-11 00:50:09 +08:00
scheduledBarContract?.Cancel();
switch (state)
2018-11-11 00:29:42 +08:00
{
2018-11-11 00:50:09 +08: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-11 00:29:42 +08:00
}
2018-11-09 15:10:58 +08:00
}
2018-11-06 18:23:03 +08:00
}
}