1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 18:47:27 +08:00

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

@ -3,7 +3,6 @@
using osu.Framework.Allocation;
using osu.Game.Tests.Visual;
using osu.Game.Tournament.Screens.Ladder.Components;
namespace osu.Game.Tournament.Tests
{

View File

@ -2,9 +2,12 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using Newtonsoft.Json;
using osu.Framework.Configuration;
using osu.Game.Tournament.Components;
using osu.Game.Tournament.Screens.Ladder.Components;
namespace osu.Game.Tournament.Screens.Ladder.Components
namespace osu.Game.Tournament
{
public class LadderInfo
{
@ -12,5 +15,8 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
public List<TournamentProgression> Progressions = new List<TournamentProgression>();
public List<TournamentGrouping> Groupings = new List<TournamentGrouping>();
public List<TournamentTeam> Teams = new List<TournamentTeam>();
[JsonIgnore]
public Bindable<MatchPairing> CurrentMatch = new Bindable<MatchPairing>();
}
}

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

@ -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;

View File

@ -23,6 +23,7 @@ using SixLabors.Primitives;
namespace osu.Game.Tournament.Screens.Ladder
{
[Cached]
public class LadderManager : CompositeDrawable, IHasContextMenu
{
public readonly List<TournamentTeam> Teams;
@ -30,6 +31,8 @@ namespace osu.Game.Tournament.Screens.Ladder
private readonly Container<Path> paths;
private readonly Container headings;
private readonly LadderInfo info;
private readonly ScrollableContainer scrollContent;
[Cached]
@ -37,6 +40,7 @@ namespace osu.Game.Tournament.Screens.Ladder
public LadderManager(LadderInfo info)
{
this.info = info;
editorInfo.Teams = Teams = info.Teams;
editorInfo.Groupings = info.Groupings;
@ -255,5 +259,14 @@ namespace osu.Game.Tournament.Screens.Ladder
}
public void Remove(MatchPairing pairing) => pairingsContainer.FirstOrDefault(p => p.Pairing == pairing)?.Remove();
public void SetCurrent(MatchPairing pairing)
{
if (info.CurrentMatch.Value != null)
info.CurrentMatch.Value.Current.Value = false;
info.CurrentMatch.Value = pairing;
info.CurrentMatch.Value.Current.Value = true;
}
}
}

View File

@ -3,7 +3,6 @@
using System;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Video;
@ -20,33 +19,42 @@ namespace osu.Game.Tournament.Screens.TeamIntro
{
public class TeamIntroScreen : OsuScreen
{
private VideoSprite background;
private Container mainContainer;
[Resolved]
private Bindable<MatchPairing> currentMatch { get; set; }
private LadderInfo ladderInfo { get; set; }
[BackgroundDependencyLoader]
private void load(Storage storage)
{
RelativeSizeAxes = Axes.Both;
background = new VideoSprite(storage.GetStream(@"BG Team - Both OWC.m4v"))
InternalChildren = new Drawable[]
{
RelativeSizeAxes = Axes.Both,
Loop = true,
new VideoSprite(storage.GetStream(@"BG Team - Both OWC.m4v"))
{
RelativeSizeAxes = Axes.Both,
Loop = true,
},
mainContainer = new Container
{
RelativeSizeAxes = Axes.Both,
}
};
currentMatch.BindValueChanged(matchChanged, true);
ladderInfo.CurrentMatch.BindValueChanged(matchChanged, true);
}
private void matchChanged(MatchPairing pairing)
{
if (pairing == null)
return;
InternalChildren = new Drawable[]
{
background,
mainContainer.Clear();
return;
}
mainContainer.Children = new Drawable[]
{
new TeamWithPlayers(pairing.Team1, true)
{
RelativeSizeAxes = Axes.Both,
@ -148,6 +156,8 @@ namespace osu.Game.Tournament.Screens.TeamIntro
AutoSizeAxes = Axes.Both,
Spacing = new Vector2(0, 5),
Padding = new MarginPadding(20),
Anchor = !left ? Anchor.CentreRight : Anchor.CentreLeft,
Origin = !left ? Anchor.CentreRight : Anchor.CentreLeft,
RelativePositionAxes = Axes.Both,

View File

@ -13,7 +13,6 @@ using osu.Game.Screens;
using osu.Game.Tournament.Screens.Drawings;
using osu.Game.Tournament.Screens.Gameplay;
using osu.Game.Tournament.Screens.Ladder;
using osu.Game.Tournament.Screens.Ladder.Components;
using osu.Game.Tournament.Screens.MapPool;
using osu.Game.Tournament.Screens.Showcase;
using osu.Game.Tournament.Screens.TeamIntro;

View File

@ -1,6 +1,8 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics;
using osu.Game.Graphics.Cursor;
using osu.Game.Tournament.Screens;
namespace osu.Game.Tournament
@ -10,7 +12,12 @@ namespace osu.Game.Tournament
protected override void LoadComplete()
{
base.LoadComplete();
Add(new TournamentSceneManager());
Add(new OsuContextMenuContainer
{
RelativeSizeAxes = Axes.Both,
Child = new TournamentSceneManager()
});
MenuCursorContainer.Cursor.Alpha = 0;
}

View File

@ -15,7 +15,6 @@ using osu.Game.Beatmaps;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API.Requests;
using osu.Game.Rulesets;
using osu.Game.Tournament.Screens.Ladder.Components;
namespace osu.Game.Tournament
{
@ -31,9 +30,6 @@ namespace osu.Game.Tournament
[Cached]
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
[Cached]
private readonly Bindable<MatchPairing> currentMatch = new Bindable<MatchPairing>();
private Bindable<Size> windowSize;
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
@ -95,6 +91,8 @@ namespace osu.Game.Tournament
foreach (var id in group.Pairings)
Ladder.Pairings.Single(p => p.ID == id).Grouping.Value = group;
Ladder.CurrentMatch.Value = Ladder.Pairings.FirstOrDefault(p => p.Current.Value);
foreach (var g in Ladder.Groupings)
foreach (var b in g.Beatmaps)
if (b.BeatmapInfo == null)
@ -106,9 +104,6 @@ namespace osu.Game.Tournament
addedInfo = true;
}
//todo: temp
currentMatch.Value = Ladder.Pairings.FirstOrDefault();
if (addedInfo)
SaveChanges();