Add ability to select current match

This commit is contained in:
Dean Herbert
2018-11-07 01:20:32 +09:00
parent 555d63165b
commit a0d64c1b13
10 changed files with 88 additions and 24 deletions

View File

@ -20,6 +20,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
public readonly MatchPairing Pairing;
private readonly FillFlowContainer<DrawableMatchTeam> flow;
private readonly Drawable selectionBox;
private readonly Drawable currentMatchSelectionBox;
private Bindable<MatchPairing> globalSelection;
[Resolved(CanBeNull = true)]
@ -49,6 +50,18 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
Colour = Color4.YellowGreen,
Child = new Box { RelativeSizeAxes = Axes.Both }
},
currentMatchSelectionBox = new Container
{
CornerRadius = 5,
Masking = true,
Scale = new Vector2(1.05f),
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Alpha = 0,
Colour = Color4.OrangeRed,
Child = new Box { RelativeSizeAxes = Axes.Both }
},
flow = new FillFlowContainer<DrawableMatchTeam>
{
AutoSizeAxes = Axes.Both,
@ -65,10 +78,19 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
pairing.Progression.BindValueChanged(_ => updateProgression());
pairing.LosersProgression.BindValueChanged(_ => updateProgression());
pairing.Losers.BindValueChanged(_ => updateTeams());
pairing.Current.BindValueChanged(_ => updateCurrentMatch(), true);
updateTeams();
}
private void updateCurrentMatch()
{
if (Pairing.Current.Value)
currentMatchSelectionBox.Show();
else
currentMatchSelectionBox.Hide();
}
private bool selected;
public bool Selected
@ -144,7 +166,8 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
var instaWinAmount = Pairing.Grouping.Value.BestOf / 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 > 0
&& (Pairing.Team1Score + Pairing.Team2Score >= Pairing.Grouping.Value.BestOf || Pairing.Team1Score > instaWinAmount || Pairing.Team2Score > instaWinAmount);
}
protected override void LoadComplete()

View File

@ -126,10 +126,16 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
}
//TODO: use OnClick instead once we have per-button clicks.
protected override bool OnMouseUp(MouseUpEvent e)
protected override bool OnClick(ClickEvent e)
{
if (Team == null || editorInfo.EditingEnabled) return false;
if (!pairing.Current.Value)
{
manager.SetCurrent(pairing);
return true;
}
if (e.Button == MouseButton.Left)
{
if (score.Value == null)
@ -176,6 +182,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
return new MenuItem[]
{
new OsuMenuItem("Set as current", MenuItemType.Standard, () => manager.SetCurrent(pairing)),
new OsuMenuItem("Join with", MenuItemType.Standard, () => manager.RequestJoin(pairing, false)),
new OsuMenuItem("Join with (loser)", MenuItemType.Standard, () => manager.RequestJoin(pairing, true)),
new OsuMenuItem("Remove", MenuItemType.Destructive, () => manager.Remove(pairing)),

View File

@ -1,16 +0,0 @@
// 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 osu.Game.Tournament.Components;
namespace osu.Game.Tournament.Screens.Ladder.Components
{
public class LadderInfo
{
public List<MatchPairing> Pairings = new List<MatchPairing>();
public List<TournamentProgression> Progressions = new List<TournamentProgression>();
public List<TournamentGrouping> Groupings = new List<TournamentGrouping>();
public List<TournamentTeam> Teams = new List<TournamentTeam>();
}
}

View File

@ -43,6 +43,11 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
[JsonIgnore]
public readonly Bindable<MatchPairing> LosersProgression = new Bindable<MatchPairing>();
/// <summary>
/// Should not be set directly. Use LadderInfo.CurrentMatch.Value = this instead.
/// </summary>
public readonly Bindable<bool> Current = new Bindable<bool>();
public readonly Bindable<DateTimeOffset> Date = new Bindable<DateTimeOffset>();
public Point Position;