mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 16:02:55 +08:00
Add warning message to screens which require a current match to be selected
This commit is contained in:
parent
6a781aedb3
commit
71f74f0e98
@ -21,12 +21,10 @@ using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tournament.Screens.MapPool
|
||||
{
|
||||
public class MapPoolScreen : TournamentScreen
|
||||
public class MapPoolScreen : TournamentMatchScreen
|
||||
{
|
||||
private readonly FillFlowContainer<FillFlowContainer<TournamentBeatmapPanel>> mapFlows;
|
||||
|
||||
private readonly Bindable<TournamentMatch> currentMatch = new Bindable<TournamentMatch>();
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private TournamentSceneManager sceneManager { get; set; }
|
||||
|
||||
@ -96,7 +94,7 @@ namespace osu.Game.Tournament.Screens.MapPool
|
||||
Action = reset
|
||||
},
|
||||
new ControlPanel.Spacer(),
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -104,15 +102,12 @@ namespace osu.Game.Tournament.Screens.MapPool
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(MatchIPCInfo ipc)
|
||||
{
|
||||
currentMatch.BindValueChanged(matchChanged);
|
||||
currentMatch.BindTo(LadderInfo.CurrentMatch);
|
||||
|
||||
ipc.Beatmap.BindValueChanged(beatmapChanged);
|
||||
}
|
||||
|
||||
private void beatmapChanged(ValueChangedEvent<BeatmapInfo> beatmap)
|
||||
{
|
||||
if (currentMatch.Value == null || currentMatch.Value.PicksBans.Count(p => p.Type == ChoiceType.Ban) < 2)
|
||||
if (CurrentMatch.Value == null || CurrentMatch.Value.PicksBans.Count(p => p.Type == ChoiceType.Ban) < 2)
|
||||
return;
|
||||
|
||||
// if bans have already been placed, beatmap changes result in a selection being made autoamtically
|
||||
@ -137,12 +132,12 @@ namespace osu.Game.Tournament.Screens.MapPool
|
||||
{
|
||||
const TeamColour roll_winner = TeamColour.Red; //todo: draw from match
|
||||
|
||||
var nextColour = (currentMatch.Value.PicksBans.LastOrDefault()?.Team ?? roll_winner) == TeamColour.Red ? TeamColour.Blue : TeamColour.Red;
|
||||
var nextColour = (CurrentMatch.Value.PicksBans.LastOrDefault()?.Team ?? roll_winner) == TeamColour.Red ? TeamColour.Blue : TeamColour.Red;
|
||||
|
||||
if (pickType == ChoiceType.Ban && currentMatch.Value.PicksBans.Count(p => p.Type == ChoiceType.Ban) >= 2)
|
||||
if (pickType == ChoiceType.Ban && CurrentMatch.Value.PicksBans.Count(p => p.Type == ChoiceType.Ban) >= 2)
|
||||
setMode(pickColour, ChoiceType.Pick);
|
||||
else
|
||||
setMode(nextColour, currentMatch.Value.PicksBans.Count(p => p.Type == ChoiceType.Ban) >= 2 ? ChoiceType.Pick : ChoiceType.Ban);
|
||||
setMode(nextColour, CurrentMatch.Value.PicksBans.Count(p => p.Type == ChoiceType.Ban) >= 2 ? ChoiceType.Pick : ChoiceType.Ban);
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
@ -156,11 +151,11 @@ namespace osu.Game.Tournament.Screens.MapPool
|
||||
addForBeatmap(map.Beatmap.OnlineBeatmapID.Value);
|
||||
else
|
||||
{
|
||||
var existing = currentMatch.Value.PicksBans.FirstOrDefault(p => p.BeatmapID == map.Beatmap.OnlineBeatmapID);
|
||||
var existing = CurrentMatch.Value.PicksBans.FirstOrDefault(p => p.BeatmapID == map.Beatmap.OnlineBeatmapID);
|
||||
|
||||
if (existing != null)
|
||||
{
|
||||
currentMatch.Value.PicksBans.Remove(existing);
|
||||
CurrentMatch.Value.PicksBans.Remove(existing);
|
||||
setNextMode();
|
||||
}
|
||||
}
|
||||
@ -173,7 +168,7 @@ namespace osu.Game.Tournament.Screens.MapPool
|
||||
|
||||
private void reset()
|
||||
{
|
||||
currentMatch.Value.PicksBans.Clear();
|
||||
CurrentMatch.Value.PicksBans.Clear();
|
||||
setNextMode();
|
||||
}
|
||||
|
||||
@ -181,18 +176,18 @@ namespace osu.Game.Tournament.Screens.MapPool
|
||||
|
||||
private void addForBeatmap(int beatmapId)
|
||||
{
|
||||
if (currentMatch.Value == null)
|
||||
if (CurrentMatch.Value == null)
|
||||
return;
|
||||
|
||||
if (currentMatch.Value.Round.Value.Beatmaps.All(b => b.BeatmapInfo.OnlineBeatmapID != beatmapId))
|
||||
if (CurrentMatch.Value.Round.Value.Beatmaps.All(b => b.BeatmapInfo.OnlineBeatmapID != beatmapId))
|
||||
// don't attempt to add if the beatmap isn't in our pool
|
||||
return;
|
||||
|
||||
if (currentMatch.Value.PicksBans.Any(p => p.BeatmapID == beatmapId))
|
||||
if (CurrentMatch.Value.PicksBans.Any(p => p.BeatmapID == beatmapId))
|
||||
// don't attempt to add if already exists.
|
||||
return;
|
||||
|
||||
currentMatch.Value.PicksBans.Add(new BeatmapChoice
|
||||
CurrentMatch.Value.PicksBans.Add(new BeatmapChoice
|
||||
{
|
||||
Team = pickColour,
|
||||
Type = pickType,
|
||||
@ -201,17 +196,22 @@ namespace osu.Game.Tournament.Screens.MapPool
|
||||
|
||||
setNextMode();
|
||||
|
||||
if (pickType == ChoiceType.Pick && currentMatch.Value.PicksBans.Any(i => i.Type == ChoiceType.Pick))
|
||||
if (pickType == ChoiceType.Pick && CurrentMatch.Value.PicksBans.Any(i => i.Type == ChoiceType.Pick))
|
||||
{
|
||||
scheduledChange?.Cancel();
|
||||
scheduledChange = Scheduler.AddDelayed(() => { sceneManager?.SetScreen(typeof(GameplayScreen)); }, 10000);
|
||||
}
|
||||
}
|
||||
|
||||
private void matchChanged(ValueChangedEvent<TournamentMatch> match)
|
||||
protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch> match)
|
||||
{
|
||||
base.CurrentMatchChanged(match);
|
||||
|
||||
mapFlows.Clear();
|
||||
|
||||
if (match.NewValue == null)
|
||||
return;
|
||||
|
||||
int totalRows = 0;
|
||||
|
||||
if (match.NewValue.Round.Value != null)
|
||||
|
34
osu.Game.Tournament/Screens/TournamentMatchScreen.cs
Normal file
34
osu.Game.Tournament/Screens/TournamentMatchScreen.cs
Normal file
@ -0,0 +1,34 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Tournament.Models;
|
||||
|
||||
namespace osu.Game.Tournament.Screens
|
||||
{
|
||||
public abstract class TournamentMatchScreen : TournamentScreen
|
||||
{
|
||||
protected readonly Bindable<TournamentMatch> CurrentMatch = new Bindable<TournamentMatch>();
|
||||
private WarningBox noMatchWarning;
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
CurrentMatch.BindTo(LadderInfo.CurrentMatch);
|
||||
CurrentMatch.BindValueChanged(CurrentMatchChanged, true);
|
||||
}
|
||||
|
||||
protected virtual void CurrentMatchChanged(ValueChangedEvent<TournamentMatch> match)
|
||||
{
|
||||
if (match.NewValue == null)
|
||||
{
|
||||
AddInternal(noMatchWarning = new WarningBox("Choose a match first from the brackets screen"));
|
||||
return;
|
||||
}
|
||||
|
||||
noMatchWarning?.Expire();
|
||||
noMatchWarning = null;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user