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.
|
2018-11-06 18:23:03 +08:00
|
|
|
|
2018-11-08 19:15:22 +08:00
|
|
|
using osu.Framework.Allocation;
|
2019-03-02 12:40:43 +08:00
|
|
|
using osu.Framework.Bindables;
|
2018-11-08 19:15:22 +08:00
|
|
|
using osu.Framework.Graphics;
|
2018-11-15 20:28:42 +08:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-11-10 23:45:48 +08:00
|
|
|
using osu.Framework.Graphics.Shapes;
|
2020-03-06 15:06:23 +08:00
|
|
|
using osu.Framework.Platform;
|
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;
|
2019-06-18 13:51:48 +08:00
|
|
|
using osu.Game.Tournament.Models;
|
2018-11-15 20:28:42 +08:00
|
|
|
using osu.Game.Tournament.Screens.Gameplay.Components;
|
2018-11-18 07:30:17 +08:00
|
|
|
using osu.Game.Tournament.Screens.MapPool;
|
|
|
|
using osu.Game.Tournament.Screens.TeamWin;
|
2018-11-22 09:25:30 +08:00
|
|
|
using osuTK.Graphics;
|
2018-11-08 19:15:22 +08:00
|
|
|
|
2018-11-06 18:23:03 +08:00
|
|
|
namespace osu.Game.Tournament.Screens.Gameplay
|
|
|
|
{
|
2020-03-06 15:06:23 +08:00
|
|
|
public class GameplayScreen : BeatmapInfoScreen, IProvideVideo
|
2018-11-06 18:23:03 +08:00
|
|
|
{
|
2018-11-09 15:26:09 +08:00
|
|
|
private readonly BindableBool warmup = new BindableBool();
|
2018-11-09 15:10:58 +08:00
|
|
|
|
2019-06-18 13:57:05 +08:00
|
|
|
private readonly Bindable<TournamentMatch> currentMatch = new Bindable<TournamentMatch>();
|
2018-11-10 23:45:48 +08:00
|
|
|
|
|
|
|
public readonly Bindable<TourneyState> State = new Bindable<TourneyState>();
|
2019-06-18 16:17:46 +08:00
|
|
|
private OsuButton warmupButton;
|
2018-11-15 20:28:42 +08:00
|
|
|
private MatchIPCInfo ipc;
|
|
|
|
|
2019-06-14 15:57:29 +08:00
|
|
|
[Resolved(canBeNull: true)]
|
2018-11-18 07:30:17 +08:00
|
|
|
private TournamentSceneManager sceneManager { get; set; }
|
|
|
|
|
2019-06-14 15:57:29 +08:00
|
|
|
[Resolved]
|
2019-06-18 12:44:38 +08:00
|
|
|
private TournamentMatchChatDisplay chat { get; set; }
|
2019-06-14 15:57:29 +08:00
|
|
|
|
2018-11-08 19:15:22 +08:00
|
|
|
[BackgroundDependencyLoader]
|
2020-03-06 15:06:23 +08:00
|
|
|
private void load(LadderInfo ladder, MatchIPCInfo ipc, Storage storage)
|
2018-11-08 19:15:22 +08:00
|
|
|
{
|
2018-11-10 23:45:48 +08:00
|
|
|
this.ipc = ipc;
|
2018-11-17 20:27:02 +08:00
|
|
|
|
2019-02-02 17:29:20 +08:00
|
|
|
AddRangeInternal(new Drawable[]
|
2018-11-08 19:15:22 +08:00
|
|
|
{
|
2020-03-06 17:38:29 +08:00
|
|
|
new TourneyVideo("gameplay")
|
2020-03-06 15:06:23 +08:00
|
|
|
{
|
|
|
|
Loop = true,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
2020-03-07 13:46:40 +08:00
|
|
|
header = new MatchHeader(),
|
2018-11-22 14:42:10 +08:00
|
|
|
new Container
|
2018-11-10 23:45:48 +08:00
|
|
|
{
|
2018-11-15 20:28:42 +08:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2020-03-08 17:16:32 +08:00
|
|
|
Y = 110,
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
2018-11-15 20:28:42 +08:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2018-11-22 14:42:10 +08:00
|
|
|
new Box
|
|
|
|
{
|
|
|
|
// chroma key area for stable gameplay
|
|
|
|
Name = "chroma",
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2020-03-07 11:51:11 +08:00
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
2018-11-22 14:42:10 +08:00
|
|
|
Height = 512,
|
|
|
|
Colour = new Color4(0, 255, 0, 255),
|
|
|
|
},
|
2018-11-15 20:28:42 +08:00
|
|
|
}
|
2018-11-10 23:45:48 +08:00
|
|
|
},
|
2018-11-17 14:44:56 +08:00
|
|
|
scoreDisplay = new MatchScoreDisplay
|
|
|
|
{
|
2020-03-07 15:22:52 +08:00
|
|
|
Y = -147,
|
2018-11-17 14:44:56 +08:00
|
|
|
Anchor = Anchor.BottomCentre,
|
2020-03-07 15:22:52 +08:00
|
|
|
Origin = Anchor.TopCentre,
|
2018-11-17 14:44:56 +08:00
|
|
|
},
|
2018-11-09 15:10:58 +08:00
|
|
|
new ControlPanel
|
|
|
|
{
|
|
|
|
Children = new Drawable[]
|
2018-11-08 19:15:22 +08:00
|
|
|
{
|
2019-11-08 16:00:47 +08:00
|
|
|
warmupButton = new TourneyButton
|
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-16 17:14:42 +08:00
|
|
|
},
|
2019-11-08 16:00:47 +08:00
|
|
|
new TourneyButton
|
2018-11-16 17:14:42 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Text = "Toggle chat",
|
|
|
|
Action = () => { State.Value = State.Value == TourneyState.Idle ? TourneyState.Playing : TourneyState.Idle; }
|
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.BindTo(ipc.State);
|
2018-11-16 18:43:54 +08:00
|
|
|
State.BindValueChanged(stateChanged, true);
|
2018-11-10 23:45:48 +08:00
|
|
|
|
2019-03-02 15:32:11 +08:00
|
|
|
currentMatch.BindValueChanged(m =>
|
|
|
|
{
|
|
|
|
warmup.Value = m.NewValue.Team1Score.Value + m.NewValue.Team2Score.Value == 0;
|
|
|
|
scheduledOperation?.Cancel();
|
|
|
|
});
|
|
|
|
|
2018-11-10 23:45:48 +08:00
|
|
|
currentMatch.BindTo(ladder.CurrentMatch);
|
2018-11-11 00:29:42 +08:00
|
|
|
|
2020-03-07 13:46:40 +08:00
|
|
|
warmup.BindValueChanged(w =>
|
|
|
|
{
|
|
|
|
warmupButton.Alpha = !w.NewValue ? 0.5f : 1;
|
|
|
|
header.ShowScores = !w.NewValue;
|
|
|
|
}, true);
|
2018-11-10 23:45:48 +08:00
|
|
|
}
|
|
|
|
|
2018-11-18 07:30:17 +08:00
|
|
|
private ScheduledDelegate scheduledOperation;
|
2018-11-17 14:44:56 +08:00
|
|
|
private MatchScoreDisplay scoreDisplay;
|
2018-11-11 00:50:09 +08:00
|
|
|
|
2018-11-18 07:30:17 +08:00
|
|
|
private TourneyState lastState;
|
2020-03-07 13:46:40 +08:00
|
|
|
private MatchHeader header;
|
2018-11-18 07:30:17 +08:00
|
|
|
|
2019-03-02 12:40:43 +08:00
|
|
|
private void stateChanged(ValueChangedEvent<TourneyState> state)
|
2018-11-10 23:45:48 +08:00
|
|
|
{
|
2018-11-22 16:33:48 +08:00
|
|
|
try
|
2018-11-10 23:45:48 +08:00
|
|
|
{
|
2019-03-02 12:40:43 +08:00
|
|
|
if (state.NewValue == TourneyState.Ranking)
|
2018-11-22 16:33:48 +08:00
|
|
|
{
|
|
|
|
if (warmup.Value) return;
|
2018-11-10 23:45:48 +08:00
|
|
|
|
2019-03-02 12:40:43 +08:00
|
|
|
if (ipc.Score1.Value > ipc.Score2.Value)
|
2018-11-22 16:33:48 +08:00
|
|
|
currentMatch.Value.Team1Score.Value++;
|
|
|
|
else
|
|
|
|
currentMatch.Value.Team2Score.Value++;
|
|
|
|
}
|
2018-11-08 19:15:22 +08:00
|
|
|
|
2018-11-22 16:33:48 +08:00
|
|
|
scheduledOperation?.Cancel();
|
2018-11-11 00:50:09 +08:00
|
|
|
|
2018-11-22 16:33:48 +08:00
|
|
|
void expand()
|
2018-11-17 14:44:56 +08:00
|
|
|
{
|
2020-03-07 15:29:11 +08:00
|
|
|
chat?.Contract();
|
2018-11-22 16:33:48 +08:00
|
|
|
|
|
|
|
using (BeginDelayedSequence(300, true))
|
|
|
|
{
|
|
|
|
scoreDisplay.FadeIn(100);
|
|
|
|
SongBar.Expanded = true;
|
|
|
|
}
|
2018-11-17 14:44:56 +08:00
|
|
|
}
|
2018-11-17 14:31:03 +08:00
|
|
|
|
2018-11-22 16:33:48 +08:00
|
|
|
void contract()
|
|
|
|
{
|
|
|
|
SongBar.Expanded = false;
|
|
|
|
scoreDisplay.FadeOut(100);
|
2019-06-14 15:57:29 +08:00
|
|
|
using (chat?.BeginDelayedSequence(500))
|
2020-03-07 15:29:11 +08:00
|
|
|
chat?.Expand();
|
2018-11-22 16:33:48 +08:00
|
|
|
}
|
2018-11-17 14:31:03 +08:00
|
|
|
|
2019-03-02 12:40:43 +08:00
|
|
|
switch (state.NewValue)
|
2018-11-22 16:33:48 +08:00
|
|
|
{
|
|
|
|
case TourneyState.Idle:
|
|
|
|
contract();
|
2018-11-18 07:30:17 +08:00
|
|
|
|
2019-03-02 15:32:11 +08:00
|
|
|
const float delay_before_progression = 4000;
|
|
|
|
|
|
|
|
// if we've returned to idle and the last screen was ranking
|
|
|
|
// we should automatically proceed after a short delay
|
2018-11-22 16:33:48 +08:00
|
|
|
if (lastState == TourneyState.Ranking && !warmup.Value)
|
|
|
|
{
|
2019-03-02 12:40:43 +08:00
|
|
|
if (currentMatch.Value?.Completed.Value == true)
|
2019-03-02 15:32:11 +08:00
|
|
|
scheduledOperation = Scheduler.AddDelayed(() => { sceneManager?.SetScreen(typeof(TeamWinScreen)); }, delay_before_progression);
|
2019-03-02 12:40:43 +08:00
|
|
|
else if (currentMatch.Value?.Completed.Value == false)
|
2019-03-02 15:32:11 +08:00
|
|
|
scheduledOperation = Scheduler.AddDelayed(() => { sceneManager?.SetScreen(typeof(MapPoolScreen)); }, delay_before_progression);
|
2018-11-22 16:33:48 +08:00
|
|
|
}
|
2018-11-18 07:30:17 +08:00
|
|
|
|
2018-11-22 16:33:48 +08:00
|
|
|
break;
|
2019-05-15 11:08:23 +08:00
|
|
|
|
2018-11-22 16:33:48 +08:00
|
|
|
case TourneyState.Ranking:
|
|
|
|
scheduledOperation = Scheduler.AddDelayed(contract, 10000);
|
|
|
|
break;
|
2019-05-15 11:08:23 +08:00
|
|
|
|
2018-11-22 16:33:48 +08:00
|
|
|
default:
|
2020-03-07 15:29:11 +08:00
|
|
|
chat.Contract();
|
2018-11-22 16:33:48 +08:00
|
|
|
expand();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
finally
|
|
|
|
{
|
2019-03-02 12:40:43 +08:00
|
|
|
lastState = state.NewValue;
|
2018-11-11 00:29:42 +08:00
|
|
|
}
|
2018-11-09 15:10:58 +08:00
|
|
|
}
|
2018-11-06 18:23:03 +08:00
|
|
|
}
|
|
|
|
}
|