mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 10:02:59 +08:00
Add ability to select current match
This commit is contained in:
parent
555d63165b
commit
a0d64c1b13
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Game.Tests.Visual;
|
using osu.Game.Tests.Visual;
|
||||||
using osu.Game.Tournament.Screens.Ladder.Components;
|
|
||||||
|
|
||||||
namespace osu.Game.Tournament.Tests
|
namespace osu.Game.Tournament.Tests
|
||||||
{
|
{
|
||||||
|
@ -2,9 +2,12 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
using osu.Game.Tournament.Components;
|
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
|
public class LadderInfo
|
||||||
{
|
{
|
||||||
@ -12,5 +15,8 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
|||||||
public List<TournamentProgression> Progressions = new List<TournamentProgression>();
|
public List<TournamentProgression> Progressions = new List<TournamentProgression>();
|
||||||
public List<TournamentGrouping> Groupings = new List<TournamentGrouping>();
|
public List<TournamentGrouping> Groupings = new List<TournamentGrouping>();
|
||||||
public List<TournamentTeam> Teams = new List<TournamentTeam>();
|
public List<TournamentTeam> Teams = new List<TournamentTeam>();
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public Bindable<MatchPairing> CurrentMatch = new Bindable<MatchPairing>();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -20,6 +20,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
|||||||
public readonly MatchPairing Pairing;
|
public readonly MatchPairing Pairing;
|
||||||
private readonly FillFlowContainer<DrawableMatchTeam> flow;
|
private readonly FillFlowContainer<DrawableMatchTeam> flow;
|
||||||
private readonly Drawable selectionBox;
|
private readonly Drawable selectionBox;
|
||||||
|
private readonly Drawable currentMatchSelectionBox;
|
||||||
private Bindable<MatchPairing> globalSelection;
|
private Bindable<MatchPairing> globalSelection;
|
||||||
|
|
||||||
[Resolved(CanBeNull = true)]
|
[Resolved(CanBeNull = true)]
|
||||||
@ -49,6 +50,18 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
|||||||
Colour = Color4.YellowGreen,
|
Colour = Color4.YellowGreen,
|
||||||
Child = new Box { RelativeSizeAxes = Axes.Both }
|
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>
|
flow = new FillFlowContainer<DrawableMatchTeam>
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
@ -65,10 +78,19 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
|||||||
pairing.Progression.BindValueChanged(_ => updateProgression());
|
pairing.Progression.BindValueChanged(_ => updateProgression());
|
||||||
pairing.LosersProgression.BindValueChanged(_ => updateProgression());
|
pairing.LosersProgression.BindValueChanged(_ => updateProgression());
|
||||||
pairing.Losers.BindValueChanged(_ => updateTeams());
|
pairing.Losers.BindValueChanged(_ => updateTeams());
|
||||||
|
pairing.Current.BindValueChanged(_ => updateCurrentMatch(), true);
|
||||||
|
|
||||||
updateTeams();
|
updateTeams();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateCurrentMatch()
|
||||||
|
{
|
||||||
|
if (Pairing.Current.Value)
|
||||||
|
currentMatchSelectionBox.Show();
|
||||||
|
else
|
||||||
|
currentMatchSelectionBox.Hide();
|
||||||
|
}
|
||||||
|
|
||||||
private bool selected;
|
private bool selected;
|
||||||
|
|
||||||
public bool Selected
|
public bool Selected
|
||||||
@ -144,7 +166,8 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
|||||||
|
|
||||||
var instaWinAmount = Pairing.Grouping.Value.BestOf / 2;
|
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()
|
protected override void LoadComplete()
|
||||||
|
@ -126,10 +126,16 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO: use OnClick instead once we have per-button clicks.
|
//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 (Team == null || editorInfo.EditingEnabled) return false;
|
||||||
|
|
||||||
|
if (!pairing.Current.Value)
|
||||||
|
{
|
||||||
|
manager.SetCurrent(pairing);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (e.Button == MouseButton.Left)
|
if (e.Button == MouseButton.Left)
|
||||||
{
|
{
|
||||||
if (score.Value == null)
|
if (score.Value == null)
|
||||||
@ -176,6 +182,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
|||||||
|
|
||||||
return new MenuItem[]
|
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", MenuItemType.Standard, () => manager.RequestJoin(pairing, false)),
|
||||||
new OsuMenuItem("Join with (loser)", MenuItemType.Standard, () => manager.RequestJoin(pairing, true)),
|
new OsuMenuItem("Join with (loser)", MenuItemType.Standard, () => manager.RequestJoin(pairing, true)),
|
||||||
new OsuMenuItem("Remove", MenuItemType.Destructive, () => manager.Remove(pairing)),
|
new OsuMenuItem("Remove", MenuItemType.Destructive, () => manager.Remove(pairing)),
|
||||||
|
@ -43,6 +43,11 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
|||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public readonly Bindable<MatchPairing> LosersProgression = new Bindable<MatchPairing>();
|
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 readonly Bindable<DateTimeOffset> Date = new Bindable<DateTimeOffset>();
|
||||||
|
|
||||||
public Point Position;
|
public Point Position;
|
||||||
|
@ -23,6 +23,7 @@ using SixLabors.Primitives;
|
|||||||
|
|
||||||
namespace osu.Game.Tournament.Screens.Ladder
|
namespace osu.Game.Tournament.Screens.Ladder
|
||||||
{
|
{
|
||||||
|
[Cached]
|
||||||
public class LadderManager : CompositeDrawable, IHasContextMenu
|
public class LadderManager : CompositeDrawable, IHasContextMenu
|
||||||
{
|
{
|
||||||
public readonly List<TournamentTeam> Teams;
|
public readonly List<TournamentTeam> Teams;
|
||||||
@ -30,6 +31,8 @@ namespace osu.Game.Tournament.Screens.Ladder
|
|||||||
private readonly Container<Path> paths;
|
private readonly Container<Path> paths;
|
||||||
private readonly Container headings;
|
private readonly Container headings;
|
||||||
|
|
||||||
|
private readonly LadderInfo info;
|
||||||
|
|
||||||
private readonly ScrollableContainer scrollContent;
|
private readonly ScrollableContainer scrollContent;
|
||||||
|
|
||||||
[Cached]
|
[Cached]
|
||||||
@ -37,6 +40,7 @@ namespace osu.Game.Tournament.Screens.Ladder
|
|||||||
|
|
||||||
public LadderManager(LadderInfo info)
|
public LadderManager(LadderInfo info)
|
||||||
{
|
{
|
||||||
|
this.info = info;
|
||||||
editorInfo.Teams = Teams = info.Teams;
|
editorInfo.Teams = Teams = info.Teams;
|
||||||
editorInfo.Groupings = info.Groupings;
|
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 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Configuration;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Video;
|
using osu.Framework.Graphics.Video;
|
||||||
@ -20,33 +19,42 @@ namespace osu.Game.Tournament.Screens.TeamIntro
|
|||||||
{
|
{
|
||||||
public class TeamIntroScreen : OsuScreen
|
public class TeamIntroScreen : OsuScreen
|
||||||
{
|
{
|
||||||
private VideoSprite background;
|
private Container mainContainer;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private Bindable<MatchPairing> currentMatch { get; set; }
|
private LadderInfo ladderInfo { get; set; }
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(Storage storage)
|
private void load(Storage storage)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
background = new VideoSprite(storage.GetStream(@"BG Team - Both OWC.m4v"))
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
new VideoSprite(storage.GetStream(@"BG Team - Both OWC.m4v"))
|
||||||
Loop = true,
|
{
|
||||||
|
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)
|
private void matchChanged(MatchPairing pairing)
|
||||||
{
|
{
|
||||||
if (pairing == null)
|
if (pairing == null)
|
||||||
return;
|
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
|
||||||
{
|
{
|
||||||
background,
|
mainContainer.Clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mainContainer.Children = new Drawable[]
|
||||||
|
{
|
||||||
new TeamWithPlayers(pairing.Team1, true)
|
new TeamWithPlayers(pairing.Team1, true)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
@ -148,6 +156,8 @@ namespace osu.Game.Tournament.Screens.TeamIntro
|
|||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
Spacing = new Vector2(0, 5),
|
Spacing = new Vector2(0, 5),
|
||||||
Padding = new MarginPadding(20),
|
Padding = new MarginPadding(20),
|
||||||
|
|
||||||
|
|
||||||
Anchor = !left ? Anchor.CentreRight : Anchor.CentreLeft,
|
Anchor = !left ? Anchor.CentreRight : Anchor.CentreLeft,
|
||||||
Origin = !left ? Anchor.CentreRight : Anchor.CentreLeft,
|
Origin = !left ? Anchor.CentreRight : Anchor.CentreLeft,
|
||||||
RelativePositionAxes = Axes.Both,
|
RelativePositionAxes = Axes.Both,
|
||||||
|
@ -13,7 +13,6 @@ using osu.Game.Screens;
|
|||||||
using osu.Game.Tournament.Screens.Drawings;
|
using osu.Game.Tournament.Screens.Drawings;
|
||||||
using osu.Game.Tournament.Screens.Gameplay;
|
using osu.Game.Tournament.Screens.Gameplay;
|
||||||
using osu.Game.Tournament.Screens.Ladder;
|
using osu.Game.Tournament.Screens.Ladder;
|
||||||
using osu.Game.Tournament.Screens.Ladder.Components;
|
|
||||||
using osu.Game.Tournament.Screens.MapPool;
|
using osu.Game.Tournament.Screens.MapPool;
|
||||||
using osu.Game.Tournament.Screens.Showcase;
|
using osu.Game.Tournament.Screens.Showcase;
|
||||||
using osu.Game.Tournament.Screens.TeamIntro;
|
using osu.Game.Tournament.Screens.TeamIntro;
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// 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;
|
using osu.Game.Tournament.Screens;
|
||||||
|
|
||||||
namespace osu.Game.Tournament
|
namespace osu.Game.Tournament
|
||||||
@ -10,7 +12,12 @@ namespace osu.Game.Tournament
|
|||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
Add(new TournamentSceneManager());
|
|
||||||
|
Add(new OsuContextMenuContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Child = new TournamentSceneManager()
|
||||||
|
});
|
||||||
|
|
||||||
MenuCursorContainer.Cursor.Alpha = 0;
|
MenuCursorContainer.Cursor.Alpha = 0;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ using osu.Game.Beatmaps;
|
|||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Tournament.Screens.Ladder.Components;
|
|
||||||
|
|
||||||
namespace osu.Game.Tournament
|
namespace osu.Game.Tournament
|
||||||
{
|
{
|
||||||
@ -31,9 +30,6 @@ namespace osu.Game.Tournament
|
|||||||
[Cached]
|
[Cached]
|
||||||
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
|
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
|
||||||
|
|
||||||
[Cached]
|
|
||||||
private readonly Bindable<MatchPairing> currentMatch = new Bindable<MatchPairing>();
|
|
||||||
|
|
||||||
private Bindable<Size> windowSize;
|
private Bindable<Size> windowSize;
|
||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
@ -95,6 +91,8 @@ namespace osu.Game.Tournament
|
|||||||
foreach (var id in group.Pairings)
|
foreach (var id in group.Pairings)
|
||||||
Ladder.Pairings.Single(p => p.ID == id).Grouping.Value = group;
|
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 g in Ladder.Groupings)
|
||||||
foreach (var b in g.Beatmaps)
|
foreach (var b in g.Beatmaps)
|
||||||
if (b.BeatmapInfo == null)
|
if (b.BeatmapInfo == null)
|
||||||
@ -106,9 +104,6 @@ namespace osu.Game.Tournament
|
|||||||
addedInfo = true;
|
addedInfo = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo: temp
|
|
||||||
currentMatch.Value = Ladder.Pairings.FirstOrDefault();
|
|
||||||
|
|
||||||
if (addedInfo)
|
if (addedInfo)
|
||||||
SaveChanges();
|
SaveChanges();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user