mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 12:57:36 +08:00
Add grouping configuration
This commit is contained in:
parent
ad63ff2d06
commit
1644775f7b
@ -1,12 +1,15 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// 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 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
|
||||
private OsuTextBox textboxTeam1;
|
||||
private OsuTextBox textboxTeam2;
|
||||
private SettingsDropdown<TournamentGrouping> groupingDropdown;
|
||||
|
||||
[Resolved]
|
||||
private LadderEditorInfo editorInfo { get; set; } = null;
|
||||
@ -28,6 +32,8 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
{
|
||||
var teamEntries = editorInfo.Teams;
|
||||
|
||||
var groupingOptions = editorInfo.Groupings.Select(g => new KeyValuePair<string, TournamentGrouping>(g.Name, g)).Prepend(new KeyValuePair<string, TournamentGrouping>("None", new TournamentGrouping()));
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new PlayerCheckbox
|
||||
@ -67,6 +73,11 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
},
|
||||
},
|
||||
textboxTeam2 = new OsuTextBox { RelativeSizeAxes = Axes.X, Height = 20 },
|
||||
groupingDropdown = new SettingsDropdown<TournamentGrouping>
|
||||
{
|
||||
Bindable = new Bindable<TournamentGrouping>(),
|
||||
Items = groupingOptions
|
||||
},
|
||||
// new Container
|
||||
// {
|
||||
// RelativeSizeAxes = Axes.X,
|
||||
@ -99,6 +110,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
{
|
||||
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 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
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;
|
||||
|
@ -25,6 +25,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
|
||||
public readonly Bindable<bool> Completed = new Bindable<bool>();
|
||||
|
||||
[JsonIgnore]
|
||||
public readonly Bindable<TournamentGrouping> Grouping = new Bindable<TournamentGrouping>();
|
||||
|
||||
[JsonIgnore]
|
||||
|
@ -1,15 +1,17 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// 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<int> Pairings = new List<int>();
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ namespace osu.Game.Tournament.Screens.Ladder
|
||||
{
|
||||
public readonly BindableBool EditingEnabled = new BindableBool();
|
||||
public List<TournamentTeam> Teams = new List<TournamentTeam>();
|
||||
public List<TournamentGrouping> Groupings = new List<TournamentGrouping>();
|
||||
public readonly Bindable<MatchPairing> Selected = new Bindable<MatchPairing>();
|
||||
}
|
||||
|
||||
@ -36,6 +37,7 @@ namespace osu.Game.Tournament.Screens.Ladder
|
||||
public LadderManager(LadderInfo info, List<TournamentTeam> teams)
|
||||
{
|
||||
editorInfo.Teams = Teams = teams;
|
||||
editorInfo.Groupings = info.Groupings;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
@ -75,19 +77,27 @@ namespace osu.Game.Tournament.Screens.Ladder
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user