diff --git a/osu.Game.Tournament/Screens/Ladder/Components/LadderSettings.cs b/osu.Game.Tournament/Screens/Ladder/Components/LadderSettings.cs index 7532cee0f0..379bb36c09 100644 --- a/osu.Game.Tournament/Screens/Ladder/Components/LadderSettings.cs +++ b/osu.Game.Tournament/Screens/Ladder/Components/LadderSettings.cs @@ -1,12 +1,15 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; +using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; +using osu.Game.Overlays.Settings; using osu.Game.Screens.Play.PlayerSettings; namespace osu.Game.Tournament.Screens.Ladder.Components @@ -19,6 +22,7 @@ public class LadderEditorSettings : PlayerSettingsGroup private OsuTextBox textboxTeam1; private OsuTextBox textboxTeam2; + private SettingsDropdown groupingDropdown; [Resolved] private LadderEditorInfo editorInfo { get; set; } = null; @@ -28,6 +32,8 @@ private void load() { var teamEntries = editorInfo.Teams; + var groupingOptions = editorInfo.Groupings.Select(g => new KeyValuePair(g.Name, g)).Prepend(new KeyValuePair("None", new TournamentGrouping())); + Children = new Drawable[] { new PlayerCheckbox @@ -67,6 +73,11 @@ private void load() }, }, textboxTeam2 = new OsuTextBox { RelativeSizeAxes = Axes.X, Height = 20 }, + groupingDropdown = new SettingsDropdown + { + Bindable = new Bindable(), + Items = groupingOptions + }, // new Container // { // RelativeSizeAxes = Axes.X, @@ -99,6 +110,7 @@ private void load() { textboxTeam1.Text = selection?.Team1.Value?.Acronym; textboxTeam2.Text = selection?.Team2.Value?.Acronym; + groupingDropdown.Bindable.Value = selection?.Grouping.Value ?? groupingOptions.First().Value; }; textboxTeam1.OnCommit = (val, newText) => @@ -113,6 +125,12 @@ private void load() editorInfo.Selected.Value.Team2.Value = teamEntries.FirstOrDefault(t => t.Acronym == val.Text); }; + groupingDropdown.Bindable.ValueChanged += grouping => + { + if (editorInfo.Selected.Value != null) + editorInfo.Selected.Value.Grouping.Value = grouping; + }; + // sliderBestOf.Bindable.ValueChanged += val => // { // if (editorInfo.Selected.Value != null) editorInfo.Selected.Value.BestOf.Value = (int)val; diff --git a/osu.Game.Tournament/Screens/Ladder/Components/MatchPairing.cs b/osu.Game.Tournament/Screens/Ladder/Components/MatchPairing.cs index 0bdfb5c300..a97354a1c4 100644 --- a/osu.Game.Tournament/Screens/Ladder/Components/MatchPairing.cs +++ b/osu.Game.Tournament/Screens/Ladder/Components/MatchPairing.cs @@ -25,6 +25,7 @@ public class MatchPairing public readonly Bindable Completed = new Bindable(); + [JsonIgnore] public readonly Bindable Grouping = new Bindable(); [JsonIgnore] diff --git a/osu.Game.Tournament/Screens/Ladder/Components/TournamentGrouping.cs b/osu.Game.Tournament/Screens/Ladder/Components/TournamentGrouping.cs index 0178885307..675bf5fc4f 100644 --- a/osu.Game.Tournament/Screens/Ladder/Components/TournamentGrouping.cs +++ b/osu.Game.Tournament/Screens/Ladder/Components/TournamentGrouping.cs @@ -1,15 +1,17 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Collections.Generic; + namespace osu.Game.Tournament.Screens.Ladder.Components { public class TournamentGrouping { - public int ID; - public string Name; public string Description; public int BestOf; + + public List Pairings = new List(); } } diff --git a/osu.Game.Tournament/Screens/Ladder/LadderManager.cs b/osu.Game.Tournament/Screens/Ladder/LadderManager.cs index 2cf7e00314..8939e72be2 100644 --- a/osu.Game.Tournament/Screens/Ladder/LadderManager.cs +++ b/osu.Game.Tournament/Screens/Ladder/LadderManager.cs @@ -21,6 +21,7 @@ public class LadderEditorInfo { public readonly BindableBool EditingEnabled = new BindableBool(); public List Teams = new List(); + public List Groupings = new List(); public readonly Bindable Selected = new Bindable(); } @@ -36,6 +37,7 @@ public class LadderManager : CompositeDrawable, IHasContextMenu public LadderManager(LadderInfo info, List teams) { editorInfo.Teams = Teams = teams; + editorInfo.Groupings = info.Groupings; RelativeSizeAxes = Axes.Both; @@ -75,19 +77,27 @@ public LadderManager(LadderInfo info, List teams) foreach (var pairing in info.Pairings) addPairing(pairing); + + foreach (var group in info.Groupings) + foreach (var id in group.Pairings) + info.Pairings.Single(p => p.ID == id).Grouping.Value = group; } public LadderInfo CreateInfo() { var pairings = pairingsContainer.Select(p => p.Pairing).ToList(); + foreach (var g in editorInfo.Groupings) + g.Pairings = pairings.Where(p => p.Grouping.Value == g).Select(p => p.ID).ToList(); + return new LadderInfo { Pairings = pairings, Progressions = pairings .Where(p => p.Progression.Value != null) .Select(p => (p.ID, p.Progression.Value.ID)) - .ToList() + .ToList(), + Groupings = editorInfo.Groupings }; }