From 389632d9325dc078605e2dfefcec03b4def93fcd Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 2 Mar 2019 13:40:43 +0900 Subject: [PATCH] Fix bindable changes --- osu.Game.Tournament/Components/DateTextBox.cs | 7 +++--- .../Components/MatchChatDisplay.cs | 8 +++---- .../Components/TournamentBeatmapPanel.cs | 6 ++--- osu.Game.Tournament/IPC/MatchIPCInfo.cs | 2 +- osu.Game.Tournament/LadderInfo.cs | 2 +- .../Screens/BeatmapInfoScreen.cs | 9 ++++---- .../Gameplay/Components/MatchHeader.cs | 14 ++++++------ .../Gameplay/Components/MatchScoreDisplay.cs | 2 +- .../Screens/Gameplay/GameplayScreen.cs | 20 ++++++++--------- .../Ladder/Components/DrawableMatchPairing.cs | 21 +++++++++--------- .../Ladder/Components/DrawableMatchTeam.cs | 16 +++++++------- .../Ladder/Components/LadderEditorInfo.cs | 2 +- .../Ladder/Components/LadderEditorSettings.cs | 22 +++++++++---------- .../Screens/Ladder/Components/MatchPairing.cs | 8 +++---- .../Ladder/Components/TournamentGrouping.cs | 2 +- .../Screens/Ladder/LadderScreen.cs | 6 ++--- .../Screens/MapPool/MapPoolScreen.cs | 14 ++++++------ .../Screens/Schedule/ScheduleScreen.cs | 10 ++++----- .../Screens/TeamIntro/TeamIntroScreen.cs | 12 +++++----- .../Screens/TeamWin/TeamWinScreen.cs | 6 ++--- osu.Game.Tournament/TournamentGameBase.cs | 1 + 21 files changed, 96 insertions(+), 94 deletions(-) diff --git a/osu.Game.Tournament/Components/DateTextBox.cs b/osu.Game.Tournament/Components/DateTextBox.cs index 171196f348..0a2485e4f3 100644 --- a/osu.Game.Tournament/Components/DateTextBox.cs +++ b/osu.Game.Tournament/Components/DateTextBox.cs @@ -2,7 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Game.Graphics.UserInterface; using osu.Game.Overlays.Settings; @@ -12,13 +12,12 @@ namespace osu.Game.Tournament.Components { public new Bindable Bindable { - get { return bindable; } - + get => bindable; set { bindable = value; bindable.BindValueChanged(dto => - base.Bindable.Value = dto.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"), true); + base.Bindable.Value = dto.NewValue.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"), true); } } diff --git a/osu.Game.Tournament/Components/MatchChatDisplay.cs b/osu.Game.Tournament/Components/MatchChatDisplay.cs index f96db186ea..33c544f83d 100644 --- a/osu.Game.Tournament/Components/MatchChatDisplay.cs +++ b/osu.Game.Tournament/Components/MatchChatDisplay.cs @@ -3,7 +3,7 @@ using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Game.Online.Chat; using osu.Game.Overlays.Chat; using osu.Game.Tournament.IPC; @@ -25,12 +25,12 @@ namespace osu.Game.Tournament.Components if (ipc != null) { chatChannel.BindTo(ipc.ChatChannel); - chatChannel.BindValueChanged(channelString => + chatChannel.BindValueChanged(c => { - if (string.IsNullOrWhiteSpace(channelString)) + if (string.IsNullOrWhiteSpace(c.NewValue)) return; - int id = int.Parse(channelString); + int id = int.Parse(c.NewValue); if (id <= 0) return; diff --git a/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs b/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs index 748f9fbdce..94aa86d5cb 100644 --- a/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs +++ b/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs @@ -6,7 +6,7 @@ using System.Collections.ObjectModel; using System.Collections.Specialized; using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -148,9 +148,9 @@ namespace osu.Game.Tournament.Components }); } - private void matchChanged(MatchPairing match) + private void matchChanged(ValueChangedEvent pairing) { - match.PicksBans.CollectionChanged += picksBansOnCollectionChanged; + pairing.NewValue.PicksBans.CollectionChanged += picksBansOnCollectionChanged; updateState(); } diff --git a/osu.Game.Tournament/IPC/MatchIPCInfo.cs b/osu.Game.Tournament/IPC/MatchIPCInfo.cs index be31df8009..cd57756f60 100644 --- a/osu.Game.Tournament/IPC/MatchIPCInfo.cs +++ b/osu.Game.Tournament/IPC/MatchIPCInfo.cs @@ -1,7 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Legacy; diff --git a/osu.Game.Tournament/LadderInfo.cs b/osu.Game.Tournament/LadderInfo.cs index c433987491..83d0f76020 100644 --- a/osu.Game.Tournament/LadderInfo.cs +++ b/osu.Game.Tournament/LadderInfo.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using Newtonsoft.Json; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Game.Tournament.Components; using osu.Game.Tournament.Screens.Ladder.Components; diff --git a/osu.Game.Tournament/Screens/BeatmapInfoScreen.cs b/osu.Game.Tournament/Screens/BeatmapInfoScreen.cs index 0b37e2fab1..b0aadc7e9e 100644 --- a/osu.Game.Tournament/Screens/BeatmapInfoScreen.cs +++ b/osu.Game.Tournament/Screens/BeatmapInfoScreen.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Legacy; @@ -30,15 +31,15 @@ namespace osu.Game.Tournament.Screens ipc.Mods.BindValueChanged(modsChanged, true); } - private void modsChanged(LegacyMods mods) + private void modsChanged(ValueChangedEvent mods) { - SongBar.Mods = mods; + SongBar.Mods = mods.NewValue; } - private void beatmapChanged(BeatmapInfo beatmap) + private void beatmapChanged(ValueChangedEvent beatmap) { SongBar.FadeInFromZero(300, Easing.OutQuint); - SongBar.Beatmap = beatmap; + SongBar.Beatmap = beatmap.NewValue; } } } diff --git a/osu.Game.Tournament/Screens/Gameplay/Components/MatchHeader.cs b/osu.Game.Tournament/Screens/Gameplay/Components/MatchHeader.cs index 25f7be1739..364d437619 100644 --- a/osu.Game.Tournament/Screens/Gameplay/Components/MatchHeader.cs +++ b/osu.Game.Tournament/Screens/Gameplay/Components/MatchHeader.cs @@ -2,7 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -73,13 +73,13 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components currentMatch.BindTo(ladder.CurrentMatch); } - private void matchChanged(MatchPairing match) + private void matchChanged(ValueChangedEvent match) { currentTeamScore.UnbindBindings(); - currentTeamScore.BindTo(teamColour == TeamColour.Red ? match.Team1Score : match.Team2Score); + currentTeamScore.BindTo(teamColour == TeamColour.Red ? match.NewValue.Team1Score : match.NewValue.Team2Score); currentTeam.UnbindBindings(); - currentTeam.BindTo(teamColour == TeamColour.Red ? match.Team1 : match.Team2); + currentTeam.BindTo(teamColour == TeamColour.Red ? match.NewValue.Team1 : match.NewValue.Team2); // team may change to same team, which means score is not in a good state. // thus we handle this manually. @@ -144,7 +144,7 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components currentTeamScore.BindTo(score); } - private void scoreChanged(int? score) => counter.CountStars = score ?? 0; + private void scoreChanged(ValueChangedEvent score) => counter.CountStars = score.NewValue ?? 0; } private class TeamDisplay : DrawableTournamentTeam @@ -204,7 +204,7 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components currentMatch.BindTo(ladder.CurrentMatch); } - private void matchChanged(MatchPairing match) + private void matchChanged(ValueChangedEvent match) { InternalChildren = new Drawable[] { @@ -218,7 +218,7 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components Anchor = Anchor.Centre, Origin = Anchor.Centre, Colour = Color4.White, - Text = match.Grouping.Value?.Name.Value ?? "Unknown Grouping", + Text = match.NewValue.Grouping.Value?.Name.Value ?? "Unknown Grouping", Font = "Aquatico-Regular", TextSize = 18, }, diff --git a/osu.Game.Tournament/Screens/Gameplay/Components/MatchScoreDisplay.cs b/osu.Game.Tournament/Screens/Gameplay/Components/MatchScoreDisplay.cs index b4eb9ef239..30cd2b2e85 100644 --- a/osu.Game.Tournament/Screens/Gameplay/Components/MatchScoreDisplay.cs +++ b/osu.Game.Tournament/Screens/Gameplay/Components/MatchScoreDisplay.cs @@ -3,7 +3,7 @@ using System; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; diff --git a/osu.Game.Tournament/Screens/Gameplay/GameplayScreen.cs b/osu.Game.Tournament/Screens/Gameplay/GameplayScreen.cs index ad0ef0f521..eb33c2fbdb 100644 --- a/osu.Game.Tournament/Screens/Gameplay/GameplayScreen.cs +++ b/osu.Game.Tournament/Screens/Gameplay/GameplayScreen.cs @@ -2,7 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -120,10 +120,10 @@ namespace osu.Game.Tournament.Screens.Gameplay State.BindTo(ipc.State); State.BindValueChanged(stateChanged, true); - currentMatch.BindValueChanged(m => warmup.Value = m.Team1Score + m.Team2Score == 0); + currentMatch.BindValueChanged(m => warmup.Value = m.NewValue.Team1Score.Value + m.NewValue.Team2Score.Value == 0); currentMatch.BindTo(ladder.CurrentMatch); - warmup.BindValueChanged(w => warmupButton.Alpha = !w ? 0.5f : 1, true); + warmup.BindValueChanged(w => warmupButton.Alpha = !w.NewValue ? 0.5f : 1, true); } private ScheduledDelegate scheduledOperation; @@ -132,15 +132,15 @@ namespace osu.Game.Tournament.Screens.Gameplay private TourneyState lastState; - private void stateChanged(TourneyState state) + private void stateChanged(ValueChangedEvent state) { try { - if (state == TourneyState.Ranking) + if (state.NewValue == TourneyState.Ranking) { if (warmup.Value) return; - if (ipc.Score1 > ipc.Score2) + if (ipc.Score1.Value > ipc.Score2.Value) currentMatch.Value.Team1Score.Value++; else currentMatch.Value.Team2Score.Value++; @@ -167,16 +167,16 @@ namespace osu.Game.Tournament.Screens.Gameplay chat.Contract(); } - switch (state) + switch (state.NewValue) { case TourneyState.Idle: contract(); if (lastState == TourneyState.Ranking && !warmup.Value) { - if (currentMatch.Value?.Completed == true) + if (currentMatch.Value?.Completed.Value == true) scheduledOperation = Scheduler.AddDelayed(() => { sceneManager?.SetScreen(typeof(TeamWinScreen)); }, 4000); - else if (currentMatch.Value?.Completed == false) + else if (currentMatch.Value?.Completed.Value == false) scheduledOperation = Scheduler.AddDelayed(() => { sceneManager?.SetScreen(typeof(MapPoolScreen)); }, 4000); } @@ -192,7 +192,7 @@ namespace osu.Game.Tournament.Screens.Gameplay } finally { - lastState = state; + lastState = state.NewValue; } } } diff --git a/osu.Game.Tournament/Screens/Ladder/Components/DrawableMatchPairing.cs b/osu.Game.Tournament/Screens/Ladder/Components/DrawableMatchPairing.cs index 58eab5bc0a..d993fbda20 100644 --- a/osu.Game.Tournament/Screens/Ladder/Components/DrawableMatchPairing.cs +++ b/osu.Game.Tournament/Screens/Ladder/Components/DrawableMatchPairing.cs @@ -2,7 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -87,7 +87,8 @@ namespace osu.Game.Tournament.Screens.Ladder.Components pairing.Position.BindValueChanged(pos => { if (IsDragged) return; - Position = new Vector2(pos.X, pos.Y); + + Position = new Vector2(pos.NewValue.X, pos.NewValue.Y); }, true); updateTeams(); @@ -127,7 +128,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components private void updateProgression() { - if (!Pairing.Completed) + if (!Pairing.Completed.Value) { // ensure we clear any of our teams from our progression. // this is not pretty logic but should suffice for now. @@ -177,10 +178,10 @@ namespace osu.Game.Tournament.Screens.Ladder.Components { if (Pairing.Grouping.Value == null) return; - var instaWinAmount = Pairing.Grouping.Value.BestOf / 2; + var instaWinAmount = Pairing.Grouping.Value.BestOf.Value / 2; - Pairing.Completed.Value = Pairing.Grouping.Value.BestOf > 0 - && (Pairing.Team1Score + Pairing.Team2Score >= Pairing.Grouping.Value.BestOf || Pairing.Team1Score > instaWinAmount || Pairing.Team2Score > instaWinAmount); + Pairing.Completed.Value = Pairing.Grouping.Value.BestOf.Value > 0 + && (Pairing.Team1Score.Value + Pairing.Team2Score.Value >= Pairing.Grouping.Value.BestOf.Value || Pairing.Team1Score.Value > instaWinAmount || Pairing.Team2Score.Value > instaWinAmount); } protected override void LoadComplete() @@ -193,7 +194,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components globalSelection = editorInfo.Selected.GetBoundCopy(); globalSelection.BindValueChanged(s => { - if (s != Pairing) Selected = false; + if (s.NewValue != Pairing) Selected = false; }); } } @@ -216,14 +217,14 @@ namespace osu.Game.Tournament.Screens.Ladder.Components var team2Match = conditional.Acronyms.Contains(Pairing.Team2Acronym); if (team1Match && team2Match) - Pairing.Date.Value = conditional.Date; + Pairing.Date.Value = conditional.Date.Value; } } Flow.Children = new[] { - new DrawableMatchTeam(Pairing.Team1, Pairing, Pairing.Losers), - new DrawableMatchTeam(Pairing.Team2, Pairing, Pairing.Losers) + new DrawableMatchTeam(Pairing.Team1.Value, Pairing, Pairing.Losers.Value), + new DrawableMatchTeam(Pairing.Team2.Value, Pairing, Pairing.Losers.Value) }; SchedulerAfterChildren.Add(() => Scheduler.Add(updateProgression)); diff --git a/osu.Game.Tournament/Screens/Ladder/Components/DrawableMatchTeam.cs b/osu.Game.Tournament/Screens/Ladder/Components/DrawableMatchTeam.cs index 461283ffed..63d15781ca 100644 --- a/osu.Game.Tournament/Screens/Ladder/Components/DrawableMatchTeam.cs +++ b/osu.Game.Tournament/Screens/Ladder/Components/DrawableMatchTeam.cs @@ -3,7 +3,7 @@ using System; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; @@ -52,7 +52,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components [Resolved(CanBeNull = true)] private LadderEditorInfo editorInfo { get; set; } - public DrawableMatchTeam(Bindable team, MatchPairing pairing, bool losers) + public DrawableMatchTeam(TournamentTeam team, MatchPairing pairing, bool losers) : base(team) { this.pairing = pairing; @@ -74,8 +74,8 @@ namespace osu.Game.Tournament.Screens.Ladder.Components isWinner = () => pairing.Winner == Team; completed.BindTo(pairing.Completed); - if (team.Value != null) - score.BindTo(team.Value == pairing.Team1.Value ? pairing.Team1Score : pairing.Team2Score); + if (team != null) + score.BindTo(team == pairing.Team1.Value ? pairing.Team1Score : pairing.Team2Score); } } @@ -133,7 +133,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components score.BindValueChanged(val => { - scoreText.Text = val?.ToString() ?? string.Empty; + scoreText.Text = val.NewValue?.ToString() ?? string.Empty; updateWinStyle(); }, true); } @@ -155,7 +155,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components { pairing.StartMatch(); } - else if (!pairing.Completed) + else if (!pairing.Completed.Value) score.Value++; } else @@ -164,7 +164,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components // don't allow changing scores if the match has a progression. can cause large data loss return false; - if (pairing.Completed && pairing.Winner != Team) + if (pairing.Completed.Value && pairing.Winner != Team) // don't allow changing scores from the non-winner return false; @@ -179,7 +179,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components private void updateWinStyle() { - bool winner = completed && isWinner?.Invoke() == true; + bool winner = completed.Value && isWinner?.Invoke() == true; background.FadeColour(winner ? colourWinner : colourNormal, winner ? 500 : 0, Easing.OutQuint); diff --git a/osu.Game.Tournament/Screens/Ladder/Components/LadderEditorInfo.cs b/osu.Game.Tournament/Screens/Ladder/Components/LadderEditorInfo.cs index 1fd9455195..6979aae295 100644 --- a/osu.Game.Tournament/Screens/Ladder/Components/LadderEditorInfo.cs +++ b/osu.Game.Tournament/Screens/Ladder/Components/LadderEditorInfo.cs @@ -1,7 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Framework.Configuration; +using osu.Framework.Bindables; namespace osu.Game.Tournament.Screens.Ladder.Components { diff --git a/osu.Game.Tournament/Screens/Ladder/Components/LadderEditorSettings.cs b/osu.Game.Tournament/Screens/Ladder/Components/LadderEditorSettings.cs index bb80a845e3..f0559e0266 100644 --- a/osu.Game.Tournament/Screens/Ladder/Components/LadderEditorSettings.cs +++ b/osu.Game.Tournament/Screens/Ladder/Components/LadderEditorSettings.cs @@ -4,7 +4,7 @@ using System; using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input.Events; @@ -93,11 +93,11 @@ namespace osu.Game.Tournament.Screens.Ladder.Components editorInfo.Selected.ValueChanged += selection => { - textboxTeam1.Text = selection?.Team1.Value?.Acronym; - textboxTeam2.Text = selection?.Team2.Value?.Acronym; - groupingDropdown.Bindable.Value = selection?.Grouping.Value ?? groupingOptions.First(); - losersCheckbox.Current.Value = selection?.Losers.Value ?? false; - dateTimeBox.Bindable.Value = selection?.Date.Value ?? DateTimeOffset.UtcNow; + textboxTeam1.Text = selection.NewValue?.Team1.Value?.Acronym; + textboxTeam2.Text = selection.NewValue?.Team2.Value?.Acronym; + groupingDropdown.Bindable.Value = selection.NewValue?.Grouping.Value ?? groupingOptions.First(); + losersCheckbox.Current.Value = selection.NewValue?.Losers.Value ?? false; + dateTimeBox.Bindable.Value = selection.NewValue?.Date.Value ?? DateTimeOffset.UtcNow; }; textboxTeam1.OnCommit = (val, newText) => @@ -116,10 +116,10 @@ namespace osu.Game.Tournament.Screens.Ladder.Components { if (editorInfo.Selected.Value != null) { - editorInfo.Selected.Value.Grouping.Value = grouping; - if (editorInfo.Selected.Value.Date.Value < grouping.StartDate.Value) + editorInfo.Selected.Value.Grouping.Value = grouping.NewValue; + if (editorInfo.Selected.Value.Date.Value < grouping.NewValue.StartDate.Value) { - editorInfo.Selected.Value.Date.Value = grouping.StartDate.Value; + editorInfo.Selected.Value.Date.Value = grouping.NewValue.StartDate.Value; editorInfo.Selected.TriggerChange(); } } @@ -128,13 +128,13 @@ namespace osu.Game.Tournament.Screens.Ladder.Components losersCheckbox.Current.ValueChanged += losers => { if (editorInfo.Selected.Value != null) - editorInfo.Selected.Value.Losers.Value = losers; + editorInfo.Selected.Value.Losers.Value = losers.NewValue; }; dateTimeBox.Bindable.ValueChanged += date => { if (editorInfo.Selected.Value != null) - editorInfo.Selected.Value.Date.Value = date; + editorInfo.Selected.Value.Date.Value = date.NewValue; }; } diff --git a/osu.Game.Tournament/Screens/Ladder/Components/MatchPairing.cs b/osu.Game.Tournament/Screens/Ladder/Components/MatchPairing.cs index 7d6acc5bd2..760f6d42f4 100644 --- a/osu.Game.Tournament/Screens/Ladder/Components/MatchPairing.cs +++ b/osu.Game.Tournament/Screens/Ladder/Components/MatchPairing.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; using Newtonsoft.Json; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Game.Tournament.Components; using SixLabors.Primitives; @@ -71,8 +71,8 @@ namespace osu.Game.Tournament.Screens.Ladder.Components public MatchPairing() { - Team1.BindValueChanged(t => Team1Acronym = t?.Acronym, true); - Team2.BindValueChanged(t => Team2Acronym = t?.Acronym, true); + Team1.BindValueChanged(t => Team1Acronym = t.NewValue?.Acronym, true); + Team2.BindValueChanged(t => Team2Acronym = t.NewValue?.Acronym, true); } public MatchPairing(TournamentTeam team1 = null, TournamentTeam team2 = null) @@ -88,7 +88,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components [JsonIgnore] public TournamentTeam Loser => !Completed.Value ? null : Team1Score.Value > Team2Score.Value ? Team2.Value : Team1.Value; - public int PointsToWin => Grouping.Value == null ? 0 : Grouping.Value.BestOf / 2 + 1; + public int PointsToWin => Grouping.Value?.BestOf.Value / 2 + 1 ?? 0; /// /// Remove scores from the match, in case of a false click or false start. diff --git a/osu.Game.Tournament/Screens/Ladder/Components/TournamentGrouping.cs b/osu.Game.Tournament/Screens/Ladder/Components/TournamentGrouping.cs index 370f0ea643..3555e4db11 100644 --- a/osu.Game.Tournament/Screens/Ladder/Components/TournamentGrouping.cs +++ b/osu.Game.Tournament/Screens/Ladder/Components/TournamentGrouping.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; using Newtonsoft.Json; -using osu.Framework.Configuration; +using osu.Framework.Bindables; namespace osu.Game.Tournament.Screens.Ladder.Components { diff --git a/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs b/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs index 36baaf0b39..7c6aabbe53 100644 --- a/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs +++ b/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs @@ -98,13 +98,13 @@ namespace osu.Game.Tournament.Screens.Ladder // clean up outdated progressions. pairing.Pairing.Progression.Value = null; else - paths.Add(new ProgressionPath(pairing, dest) { Colour = pairing.Pairing.Losers ? losersPathColour : normalPathColour }); + paths.Add(new ProgressionPath(pairing, dest) { Colour = pairing.Pairing.Losers.Value ? losersPathColour : normalPathColour }); } } foreach (var group in LadderInfo.Groupings) { - var topPairing = PairingsContainer.Where(p => !p.Pairing.Losers && p.Pairing.Grouping.Value == group).OrderBy(p => p.Y).FirstOrDefault(); + var topPairing = PairingsContainer.Where(p => !p.Pairing.Losers.Value && p.Pairing.Grouping.Value == group).OrderBy(p => p.Y).FirstOrDefault(); if (topPairing == null) continue; @@ -118,7 +118,7 @@ namespace osu.Game.Tournament.Screens.Ladder foreach (var group in LadderInfo.Groupings) { - var topPairing = PairingsContainer.Where(p => p.Pairing.Losers && p.Pairing.Grouping.Value == group).OrderBy(p => p.Y).FirstOrDefault(); + var topPairing = PairingsContainer.Where(p => p.Pairing.Losers.Value && p.Pairing.Grouping.Value == group).OrderBy(p => p.Y).FirstOrDefault(); if (topPairing == null) continue; diff --git a/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs b/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs index bed2c35b76..41368eb96e 100644 --- a/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs +++ b/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs @@ -3,7 +3,7 @@ using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input.Events; @@ -102,13 +102,13 @@ namespace osu.Game.Tournament.Screens.MapPool ipc.Beatmap.BindValueChanged(beatmapChanged); } - private void beatmapChanged(BeatmapInfo beatmap) + private void beatmapChanged(ValueChangedEvent beatmap) { if (currentMatch.Value.PicksBans.Count(p => p.Type == ChoiceType.Ban) < 2) return; - if (beatmap.OnlineBeatmapID != null) - addForBeatmap(beatmap.OnlineBeatmapID.Value); + if (beatmap.NewValue.OnlineBeatmapID != null) + addForBeatmap(beatmap.NewValue.OnlineBeatmapID.Value); } private void setMode(TeamColour colour, ChoiceType choiceType) @@ -201,16 +201,16 @@ namespace osu.Game.Tournament.Screens.MapPool } } - private void matchChanged(MatchPairing match) + private void matchChanged(ValueChangedEvent match) { mapFlows.Clear(); - if (match.Grouping.Value != null) + if (match.NewValue.Grouping.Value != null) { FillFlowContainer currentFlow = null; string currentMod = null; - foreach (var b in match.Grouping.Value.Beatmaps) + foreach (var b in match.NewValue.Grouping.Value.Beatmaps) { if (currentFlow == null || currentMod != b.Mods) { diff --git a/osu.Game.Tournament/Screens/Schedule/ScheduleScreen.cs b/osu.Game.Tournament/Screens/Schedule/ScheduleScreen.cs index f3f3667db1..def2161ea0 100644 --- a/osu.Game.Tournament/Screens/Schedule/ScheduleScreen.cs +++ b/osu.Game.Tournament/Screens/Schedule/ScheduleScreen.cs @@ -4,7 +4,7 @@ using System; using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -48,9 +48,9 @@ namespace osu.Game.Tournament.Screens.Schedule currentMatch.BindTo(ladder.CurrentMatch); } - private void matchChanged(MatchPairing pairing) + private void matchChanged(ValueChangedEvent pairing) { - if (pairing == null) + if (pairing.NewValue == null) { mainContainer.Clear(); return; @@ -113,10 +113,10 @@ namespace osu.Game.Tournament.Screens.Schedule Colour = Color4.Black, TextSize = 20 }, - new SchedulePairing(currentMatch, false), + new SchedulePairing(currentMatch.Value, false), new OsuSpriteText { - Text = "Start Time " + pairing.Date.Value.ToUniversalTime().ToString("HH:mm UTC"), + Text = "Start Time " + pairing.NewValue.Date.Value.ToUniversalTime().ToString("HH:mm UTC"), Colour = Color4.Black, TextSize = 20 }, diff --git a/osu.Game.Tournament/Screens/TeamIntro/TeamIntroScreen.cs b/osu.Game.Tournament/Screens/TeamIntro/TeamIntroScreen.cs index dc79d4aab0..a42c7775e6 100644 --- a/osu.Game.Tournament/Screens/TeamIntro/TeamIntroScreen.cs +++ b/osu.Game.Tournament/Screens/TeamIntro/TeamIntroScreen.cs @@ -2,7 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Video; @@ -46,9 +46,9 @@ namespace osu.Game.Tournament.Screens.TeamIntro currentMatch.BindTo(ladder.CurrentMatch); } - private void matchChanged(MatchPairing pairing) + private void matchChanged(ValueChangedEvent pairing) { - if (pairing == null) + if (pairing.NewValue == null) { mainContainer.Clear(); return; @@ -56,7 +56,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro mainContainer.Children = new Drawable[] { - new TeamWithPlayers(pairing.Team1, true) + new TeamWithPlayers(pairing.NewValue.Team1.Value, true) { RelativeSizeAxes = Axes.Both, Width = 0.5f, @@ -64,7 +64,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro Anchor = Anchor.Centre, Origin = Anchor.CentreRight }, - new TeamWithPlayers(pairing.Team2) + new TeamWithPlayers(pairing.NewValue.Team2.Value) { RelativeSizeAxes = Axes.Both, Width = 0.5f, @@ -72,7 +72,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro Anchor = Anchor.Centre, Origin = Anchor.CentreLeft }, - new RoundDisplay(pairing) + new RoundDisplay(pairing.NewValue) { RelativeSizeAxes = Axes.Both, Height = 0.25f, diff --git a/osu.Game.Tournament/Screens/TeamWin/TeamWinScreen.cs b/osu.Game.Tournament/Screens/TeamWin/TeamWinScreen.cs index 2e2c8e5020..f0f46f2dc8 100644 --- a/osu.Game.Tournament/Screens/TeamWin/TeamWinScreen.cs +++ b/osu.Game.Tournament/Screens/TeamWin/TeamWinScreen.cs @@ -2,7 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Video; @@ -62,10 +62,10 @@ namespace osu.Game.Tournament.Screens.TeamWin currentCompleted.BindValueChanged(_ => update()); } - private void matchChanged(MatchPairing pairing) + private void matchChanged(ValueChangedEvent pairing) { currentCompleted.UnbindBindings(); - currentCompleted.BindTo(pairing.Completed); + currentCompleted.BindTo(pairing.NewValue.Completed); update(); } diff --git a/osu.Game.Tournament/TournamentGameBase.cs b/osu.Game.Tournament/TournamentGameBase.cs index 5c9bee560e..bf6c02d064 100644 --- a/osu.Game.Tournament/TournamentGameBase.cs +++ b/osu.Game.Tournament/TournamentGameBase.cs @@ -8,6 +8,7 @@ using System.IO; using System.Linq; using Newtonsoft.Json; using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Textures;