From 5c99492f278c47138afb45f4c99c840ff05f79e0 Mon Sep 17 00:00:00 2001 From: CloneWith Date: Mon, 29 Jul 2024 00:03:06 +0800 Subject: [PATCH] Use LabelledSwitchButton for warmup and chat toggles --- .../Screens/Gameplay/GameplayScreen.cs | 36 ++++++++++++++----- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/osu.Game.Tournament/Screens/Gameplay/GameplayScreen.cs b/osu.Game.Tournament/Screens/Gameplay/GameplayScreen.cs index b2152eaf3d58..d08cfae482e8 100644 --- a/osu.Game.Tournament/Screens/Gameplay/GameplayScreen.cs +++ b/osu.Game.Tournament/Screens/Gameplay/GameplayScreen.cs @@ -7,7 +7,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Threading; -using osu.Game.Graphics.UserInterface; +using osu.Game.Graphics.UserInterfaceV2; using osu.Game.Overlays.Settings; using osu.Game.Tournament.Components; using osu.Game.Tournament.IPC; @@ -24,7 +24,8 @@ public partial class GameplayScreen : BeatmapInfoScreen private readonly BindableBool warmup = new BindableBool(); public readonly Bindable State = new Bindable(); - private OsuButton warmupButton = null!; + private LabelledSwitchButton warmupToggle = null!; + private LabelledSwitchButton chatToggle = null!; private MatchIPCInfo ipc = null!; [Resolved] @@ -95,17 +96,17 @@ private void load(MatchIPCInfo ipc) { Children = new Drawable[] { - warmupButton = new TourneyButton + warmupToggle = new LabelledSwitchButton { RelativeSizeAxes = Axes.X, - Text = "Toggle warmup", - Action = () => warmup.Toggle() + Label = "Warmup stage", + Current = warmup, }, - new TourneyButton + chatToggle = new LabelledSwitchButton { RelativeSizeAxes = Axes.X, - Text = "Toggle chat", - Action = () => { State.Value = State.Value == TourneyState.Idle ? TourneyState.Playing : TourneyState.Idle; } + Label = "Show chat", + Current = { Value = State.Value == TourneyState.Idle } }, new SettingsSlider { @@ -125,17 +126,34 @@ private void load(MatchIPCInfo ipc) LadderInfo.ChromaKeyWidth.BindValueChanged(width => chroma.Width = width.NewValue, true); + chatToggle.Current.BindValueChanged(_ => updateChat()); + warmup.BindValueChanged(w => { - warmupButton.Alpha = !w.NewValue ? 0.5f : 1; header.ShowScores = !w.NewValue; }, true); } + private void updateChat() + { + State.Value = chatToggle.Current.Value ? TourneyState.Idle : TourneyState.Playing; + updateState(); + chatToggle.Current.Value = State.Value == TourneyState.Idle; + } + + private void updateWarmup() + { + warmup.Value = warmupToggle.Current.Value; + updateState(); + warmupToggle.Current.Value = warmup.Value; + } + protected override void LoadComplete() { base.LoadComplete(); + warmupToggle.Current.BindValueChanged(_ => updateWarmup(), true); + State.BindTo(ipc.State); State.BindValueChanged(_ => updateState(), true); }