2019-03-04 04:24:19 +00: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 10:23:03 +00:00
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
#nullable disable
|
|
|
|
|
2018-11-08 11:15:22 +00:00
|
|
|
using osu.Framework.Allocation;
|
2019-03-02 04:40:43 +00:00
|
|
|
using osu.Framework.Bindables;
|
2018-11-08 11:15:22 +00:00
|
|
|
using osu.Framework.Graphics;
|
2018-11-15 12:28:42 +00:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-11-10 15:45:48 +00:00
|
|
|
using osu.Framework.Graphics.Shapes;
|
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;
|
2020-03-23 02:47:24 +00:00
|
|
|
using osu.Game.Overlays.Settings;
|
2018-11-08 11:15:22 +00:00
|
|
|
using osu.Game.Tournament.Components;
|
2018-11-10 15:45:48 +00:00
|
|
|
using osu.Game.Tournament.IPC;
|
2019-06-18 05:51:48 +00:00
|
|
|
using osu.Game.Tournament.Models;
|
2018-11-15 12:28:42 +00:00
|
|
|
using osu.Game.Tournament.Screens.Gameplay.Components;
|
2018-11-17 23:30:17 +00:00
|
|
|
using osu.Game.Tournament.Screens.MapPool;
|
|
|
|
using osu.Game.Tournament.Screens.TeamWin;
|
2018-11-22 01:25:30 +00:00
|
|
|
using osuTK.Graphics;
|
2018-11-08 11:15:22 +00:00
|
|
|
|
2018-11-06 10:23:03 +00:00
|
|
|
namespace osu.Game.Tournament.Screens.Gameplay
|
|
|
|
{
|
2022-07-11 11:42:04 +00:00
|
|
|
public partial class GameplayScreen : BeatmapInfoScreen
|
2018-11-06 10:23:03 +00:00
|
|
|
{
|
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
|
|
|
public readonly Bindable<TourneyState> State = new Bindable<TourneyState>();
|
2019-06-18 08:17:46 +00:00
|
|
|
private OsuButton warmupButton;
|
2018-11-15 12:28:42 +00:00
|
|
|
private MatchIPCInfo ipc;
|
|
|
|
|
2019-06-14 07:57:29 +00:00
|
|
|
[Resolved(canBeNull: true)]
|
2018-11-17 23:30:17 +00:00
|
|
|
private TournamentSceneManager sceneManager { get; set; }
|
|
|
|
|
2019-06-14 07:57:29 +00:00
|
|
|
[Resolved]
|
2019-06-18 04:44:38 +00:00
|
|
|
private TournamentMatchChatDisplay chat { get; set; }
|
2019-06-14 07:57:29 +00:00
|
|
|
|
2020-05-07 05:49:58 +00:00
|
|
|
private Drawable chroma;
|
2020-03-23 02:47:24 +00:00
|
|
|
|
2018-11-08 11:15:22 +00:00
|
|
|
[BackgroundDependencyLoader]
|
2022-01-15 00:06:39 +00:00
|
|
|
private void load(LadderInfo ladder, MatchIPCInfo ipc)
|
2018-11-08 11:15:22 +00:00
|
|
|
{
|
2018-11-10 15:45:48 +00:00
|
|
|
this.ipc = ipc;
|
2018-11-17 12:27:02 +00:00
|
|
|
|
2019-02-02 09:29:20 +00:00
|
|
|
AddRangeInternal(new Drawable[]
|
2018-11-08 11:15:22 +00:00
|
|
|
{
|
2020-03-06 09:38:29 +00:00
|
|
|
new TourneyVideo("gameplay")
|
2020-03-06 07:06:23 +00:00
|
|
|
{
|
|
|
|
Loop = true,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
2020-03-12 05:26:22 +00:00
|
|
|
header = new MatchHeader
|
|
|
|
{
|
|
|
|
ShowLogo = false
|
|
|
|
},
|
2018-11-22 06:42:10 +00:00
|
|
|
new Container
|
2018-11-10 15:45:48 +00:00
|
|
|
{
|
2018-11-15 12:28:42 +00:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2020-03-08 09:16:32 +00:00
|
|
|
Y = 110,
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
2020-05-07 05:49:58 +00:00
|
|
|
Children = new[]
|
2018-11-15 12:28:42 +00:00
|
|
|
{
|
2020-05-07 05:49:58 +00:00
|
|
|
chroma = new Container
|
2018-11-22 06:42:10 +00:00
|
|
|
{
|
2020-03-07 03:51:11 +00:00
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
2018-11-22 06:42:10 +00:00
|
|
|
Height = 512,
|
2020-05-07 05:49:58 +00:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new ChromaArea
|
|
|
|
{
|
|
|
|
Name = "Left chroma",
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Width = 0.5f,
|
|
|
|
},
|
|
|
|
new ChromaArea
|
|
|
|
{
|
|
|
|
Name = "Right chroma",
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
Width = 0.5f,
|
|
|
|
}
|
|
|
|
}
|
2018-11-22 06:42:10 +00:00
|
|
|
},
|
2018-11-15 12:28:42 +00:00
|
|
|
}
|
2018-11-10 15:45:48 +00:00
|
|
|
},
|
2021-08-05 08:53:38 +00:00
|
|
|
scoreDisplay = new TournamentMatchScoreDisplay
|
2018-11-17 06:44:56 +00:00
|
|
|
{
|
2020-03-07 07:22:52 +00:00
|
|
|
Y = -147,
|
2018-11-17 06:44:56 +00:00
|
|
|
Anchor = Anchor.BottomCentre,
|
2020-03-07 07:22:52 +00:00
|
|
|
Origin = Anchor.TopCentre,
|
2018-11-17 06:44:56 +00:00
|
|
|
},
|
2018-11-09 07:10:58 +00:00
|
|
|
new ControlPanel
|
|
|
|
{
|
|
|
|
Children = new Drawable[]
|
2018-11-08 11:15:22 +00:00
|
|
|
{
|
2019-11-08 08:00:47 +00:00
|
|
|
warmupButton = new TourneyButton
|
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-16 09:14:42 +00:00
|
|
|
},
|
2019-11-08 08:00:47 +00:00
|
|
|
new TourneyButton
|
2018-11-16 09:14:42 +00:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Text = "Toggle chat",
|
|
|
|
Action = () => { State.Value = State.Value == TourneyState.Idle ? TourneyState.Playing : TourneyState.Idle; }
|
2020-03-23 02:47:24 +00:00
|
|
|
},
|
|
|
|
new SettingsSlider<int>
|
|
|
|
{
|
2020-05-07 05:49:58 +00:00
|
|
|
LabelText = "Chroma width",
|
2020-10-06 08:18:41 +00:00
|
|
|
Current = LadderInfo.ChromaKeyWidth,
|
2020-03-23 02:47:24 +00:00
|
|
|
KeyboardStep = 1,
|
2020-05-07 05:49:58 +00:00
|
|
|
},
|
|
|
|
new SettingsSlider<int>
|
|
|
|
{
|
|
|
|
LabelText = "Players per team",
|
2020-10-06 08:18:41 +00:00
|
|
|
Current = LadderInfo.PlayersPerTeam,
|
2020-05-07 05:49:58 +00:00
|
|
|
KeyboardStep = 1,
|
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
|
|
|
|
2020-03-23 02:47:24 +00:00
|
|
|
ladder.ChromaKeyWidth.BindValueChanged(width => chroma.Width = width.NewValue, true);
|
|
|
|
|
2020-03-07 05:46:40 +00:00
|
|
|
warmup.BindValueChanged(w =>
|
|
|
|
{
|
|
|
|
warmupButton.Alpha = !w.NewValue ? 0.5f : 1;
|
|
|
|
header.ShowScores = !w.NewValue;
|
|
|
|
}, true);
|
2018-11-10 15:45:48 +00:00
|
|
|
}
|
|
|
|
|
2021-08-28 05:15:42 +00:00
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
State.BindTo(ipc.State);
|
|
|
|
State.BindValueChanged(stateChanged, true);
|
|
|
|
}
|
|
|
|
|
2021-07-16 15:14:48 +00:00
|
|
|
protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch> match)
|
|
|
|
{
|
|
|
|
base.CurrentMatchChanged(match);
|
|
|
|
|
|
|
|
if (match.NewValue == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
warmup.Value = match.NewValue.Team1Score.Value + match.NewValue.Team2Score.Value == 0;
|
|
|
|
scheduledOperation?.Cancel();
|
|
|
|
}
|
|
|
|
|
2018-11-17 23:30:17 +00:00
|
|
|
private ScheduledDelegate scheduledOperation;
|
2021-08-05 08:53:38 +00:00
|
|
|
private TournamentMatchScoreDisplay scoreDisplay;
|
2018-11-10 16:50:09 +00:00
|
|
|
|
2018-11-17 23:30:17 +00:00
|
|
|
private TourneyState lastState;
|
2020-03-07 05:46:40 +00:00
|
|
|
private MatchHeader header;
|
2018-11-17 23:30:17 +00:00
|
|
|
|
2019-03-02 04:40:43 +00:00
|
|
|
private void stateChanged(ValueChangedEvent<TourneyState> state)
|
2018-11-10 15:45:48 +00:00
|
|
|
{
|
2018-11-22 08:33:48 +00:00
|
|
|
try
|
2018-11-10 15:45:48 +00:00
|
|
|
{
|
2019-03-02 04:40:43 +00:00
|
|
|
if (state.NewValue == TourneyState.Ranking)
|
2018-11-22 08:33:48 +00:00
|
|
|
{
|
2021-08-28 07:22:12 +00:00
|
|
|
if (warmup.Value || CurrentMatch.Value == null) return;
|
2018-11-10 15:45:48 +00:00
|
|
|
|
2019-03-02 04:40:43 +00:00
|
|
|
if (ipc.Score1.Value > ipc.Score2.Value)
|
2021-07-16 15:14:48 +00:00
|
|
|
CurrentMatch.Value.Team1Score.Value++;
|
2018-11-22 08:33:48 +00:00
|
|
|
else
|
2021-07-16 15:14:48 +00:00
|
|
|
CurrentMatch.Value.Team2Score.Value++;
|
2018-11-22 08:33:48 +00:00
|
|
|
}
|
2018-11-08 11:15:22 +00:00
|
|
|
|
2018-11-22 08:33:48 +00:00
|
|
|
scheduledOperation?.Cancel();
|
2018-11-10 16:50:09 +00:00
|
|
|
|
2018-11-22 08:33:48 +00:00
|
|
|
void expand()
|
2018-11-17 06:44:56 +00:00
|
|
|
{
|
2020-03-07 07:29:11 +00:00
|
|
|
chat?.Contract();
|
2018-11-22 08:33:48 +00:00
|
|
|
|
2021-07-05 15:52:39 +00:00
|
|
|
using (BeginDelayedSequence(300))
|
2018-11-22 08:33:48 +00:00
|
|
|
{
|
|
|
|
scoreDisplay.FadeIn(100);
|
|
|
|
SongBar.Expanded = true;
|
|
|
|
}
|
2018-11-17 06:44:56 +00:00
|
|
|
}
|
2018-11-17 06:31:03 +00:00
|
|
|
|
2018-11-22 08:33:48 +00:00
|
|
|
void contract()
|
|
|
|
{
|
|
|
|
SongBar.Expanded = false;
|
|
|
|
scoreDisplay.FadeOut(100);
|
2019-06-14 07:57:29 +00:00
|
|
|
using (chat?.BeginDelayedSequence(500))
|
2020-03-07 07:29:11 +00:00
|
|
|
chat?.Expand();
|
2018-11-22 08:33:48 +00:00
|
|
|
}
|
2018-11-17 06:31:03 +00:00
|
|
|
|
2019-03-02 04:40:43 +00:00
|
|
|
switch (state.NewValue)
|
2018-11-22 08:33:48 +00:00
|
|
|
{
|
|
|
|
case TourneyState.Idle:
|
|
|
|
contract();
|
2018-11-17 23:30:17 +00:00
|
|
|
|
2022-08-31 04:44:06 +00:00
|
|
|
if (LadderInfo.AutoProgressScreens.Value)
|
2018-11-22 08:33:48 +00:00
|
|
|
{
|
2022-08-31 04:44:06 +00: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
|
|
|
|
if (lastState == TourneyState.Ranking && !warmup.Value)
|
|
|
|
{
|
|
|
|
if (CurrentMatch.Value?.Completed.Value == true)
|
|
|
|
scheduledOperation = Scheduler.AddDelayed(() => { sceneManager?.SetScreen(typeof(TeamWinScreen)); }, delay_before_progression);
|
|
|
|
else if (CurrentMatch.Value?.Completed.Value == false)
|
|
|
|
scheduledOperation = Scheduler.AddDelayed(() => { sceneManager?.SetScreen(typeof(MapPoolScreen)); }, delay_before_progression);
|
|
|
|
}
|
2018-11-22 08:33:48 +00:00
|
|
|
}
|
2018-11-17 23:30:17 +00:00
|
|
|
|
2018-11-22 08:33:48 +00:00
|
|
|
break;
|
2019-05-15 03:08:23 +00:00
|
|
|
|
2018-11-22 08:33:48 +00:00
|
|
|
case TourneyState.Ranking:
|
|
|
|
scheduledOperation = Scheduler.AddDelayed(contract, 10000);
|
|
|
|
break;
|
2019-05-15 03:08:23 +00:00
|
|
|
|
2018-11-22 08:33:48 +00:00
|
|
|
default:
|
2020-03-07 07:29:11 +00:00
|
|
|
chat.Contract();
|
2018-11-22 08:33:48 +00:00
|
|
|
expand();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
finally
|
|
|
|
{
|
2019-03-02 04:40:43 +00:00
|
|
|
lastState = state.NewValue;
|
2018-11-10 16:29:42 +00:00
|
|
|
}
|
2018-11-09 07:10:58 +00:00
|
|
|
}
|
2020-05-07 05:49:58 +00:00
|
|
|
|
|
|
|
private partial class ChromaArea : CompositeDrawable
|
|
|
|
{
|
|
|
|
[Resolved]
|
|
|
|
private LadderInfo ladder { get; set; }
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
// chroma key area for stable gameplay
|
|
|
|
Colour = new Color4(0, 255, 0, 255);
|
|
|
|
|
|
|
|
ladder.PlayersPerTeam.BindValueChanged(performLayout, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void performLayout(ValueChangedEvent<int> playerCount)
|
|
|
|
{
|
|
|
|
switch (playerCount.NewValue)
|
|
|
|
{
|
|
|
|
case 3:
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Width = 0.5f,
|
|
|
|
Height = 0.5f,
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
},
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
Height = 0.5f,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
InternalChild = new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
};
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-11-06 10:23:03 +00:00
|
|
|
}
|
|
|
|
}
|