Update remaining screens to also show the warning message

This commit is contained in:
Dean Herbert 2021-07-17 00:14:48 +09:00
parent 0a13e033ea
commit e8595871de
6 changed files with 52 additions and 44 deletions

View File

@ -11,7 +11,7 @@
namespace osu.Game.Tournament.Screens
{
public abstract class BeatmapInfoScreen : TournamentScreen
public abstract class BeatmapInfoScreen : TournamentMatchScreen
{
protected readonly SongBar SongBar;

View File

@ -24,8 +24,6 @@ public class GameplayScreen : BeatmapInfoScreen, IProvideVideo
{
private readonly BindableBool warmup = new BindableBool();
private readonly Bindable<TournamentMatch> currentMatch = new Bindable<TournamentMatch>();
public readonly Bindable<TourneyState> State = new Bindable<TourneyState>();
private OsuButton warmupButton;
private MatchIPCInfo ipc;
@ -131,14 +129,6 @@ private void load(LadderInfo ladder, MatchIPCInfo ipc, Storage storage)
ladder.ChromaKeyWidth.BindValueChanged(width => chroma.Width = width.NewValue, true);
currentMatch.BindValueChanged(m =>
{
warmup.Value = m.NewValue.Team1Score.Value + m.NewValue.Team2Score.Value == 0;
scheduledOperation?.Cancel();
});
currentMatch.BindTo(ladder.CurrentMatch);
warmup.BindValueChanged(w =>
{
warmupButton.Alpha = !w.NewValue ? 0.5f : 1;
@ -146,6 +136,17 @@ private void load(LadderInfo ladder, MatchIPCInfo ipc, Storage storage)
}, true);
}
protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch> match)
{
base.CurrentMatchChanged(match);
if (match.NewValue == null)
return;
warmup.Value = match.NewValue.Team1Score.Value + match.NewValue.Team2Score.Value == 0;
scheduledOperation?.Cancel();
}
private ScheduledDelegate scheduledOperation;
private MatchScoreDisplay scoreDisplay;
@ -161,9 +162,9 @@ private void stateChanged(ValueChangedEvent<TourneyState> state)
if (warmup.Value) return;
if (ipc.Score1.Value > ipc.Score2.Value)
currentMatch.Value.Team1Score.Value++;
CurrentMatch.Value.Team1Score.Value++;
else
currentMatch.Value.Team2Score.Value++;
CurrentMatch.Value.Team2Score.Value++;
}
scheduledOperation?.Cancel();
@ -198,9 +199,9 @@ void contract()
// we should automatically proceed after a short delay
if (lastState == TourneyState.Ranking && !warmup.Value)
{
if (currentMatch.Value?.Completed.Value == true)
if (CurrentMatch.Value?.Completed.Value == true)
scheduledOperation = Scheduler.AddDelayed(() => { sceneManager?.SetScreen(typeof(TeamWinScreen)); }, delay_before_progression);
else if (currentMatch.Value?.Completed.Value == false)
else if (CurrentMatch.Value?.Completed.Value == false)
scheduledOperation = Scheduler.AddDelayed(() => { sceneManager?.SetScreen(typeof(MapPoolScreen)); }, delay_before_progression);
}

View File

@ -2,10 +2,12 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Tournament.Components;
using osu.Framework.Graphics.Shapes;
using osu.Game.Tournament.Models;
using osuTK.Graphics;
namespace osu.Game.Tournament.Screens.Showcase
@ -39,5 +41,11 @@ private void load()
}
});
}
protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch> match)
{
// showcase screen doesn't care about a match being selected.
// base call intentionally omitted to not show match warning.
}
}
}

View File

@ -18,12 +18,10 @@
namespace osu.Game.Tournament.Screens.TeamIntro
{
public class SeedingScreen : TournamentScreen, IProvideVideo
public class SeedingScreen : TournamentMatchScreen, IProvideVideo
{
private Container mainContainer;
private readonly Bindable<TournamentMatch> currentMatch = new Bindable<TournamentMatch>();
private readonly Bindable<TournamentTeam> currentTeam = new Bindable<TournamentTeam>();
[BackgroundDependencyLoader]
@ -50,13 +48,13 @@ private void load(Storage storage)
{
RelativeSizeAxes = Axes.X,
Text = "Show first team",
Action = () => currentTeam.Value = currentMatch.Value.Team1.Value,
Action = () => currentTeam.Value = CurrentMatch.Value.Team1.Value,
},
new TourneyButton
{
RelativeSizeAxes = Axes.X,
Text = "Show second team",
Action = () => currentTeam.Value = currentMatch.Value.Team2.Value,
Action = () => currentTeam.Value = CurrentMatch.Value.Team2.Value,
},
new SettingsTeamDropdown(LadderInfo.Teams)
{
@ -67,9 +65,6 @@ private void load(Storage storage)
}
};
currentMatch.BindValueChanged(matchChanged);
currentMatch.BindTo(LadderInfo.CurrentMatch);
currentTeam.BindValueChanged(teamChanged, true);
}
@ -84,8 +79,15 @@ private void teamChanged(ValueChangedEvent<TournamentTeam> team)
showTeam(team.NewValue);
}
private void matchChanged(ValueChangedEvent<TournamentMatch> match) =>
currentTeam.Value = currentMatch.Value.Team1.Value;
protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch> match)
{
base.CurrentMatchChanged(match);
if (match.NewValue == null)
return;
currentTeam.Value = match.NewValue.Team1.Value;
}
private void showTeam(TournamentTeam team)
{

View File

@ -12,12 +12,10 @@
namespace osu.Game.Tournament.Screens.TeamIntro
{
public class TeamIntroScreen : TournamentScreen, IProvideVideo
public class TeamIntroScreen : TournamentMatchScreen, IProvideVideo
{
private Container mainContainer;
private readonly Bindable<TournamentMatch> currentMatch = new Bindable<TournamentMatch>();
[BackgroundDependencyLoader]
private void load(Storage storage)
{
@ -35,18 +33,16 @@ private void load(Storage storage)
RelativeSizeAxes = Axes.Both,
}
};
currentMatch.BindValueChanged(matchChanged);
currentMatch.BindTo(LadderInfo.CurrentMatch);
}
private void matchChanged(ValueChangedEvent<TournamentMatch> match)
protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch> match)
{
base.CurrentMatchChanged(match);
mainContainer.Clear();
if (match.NewValue == null)
{
mainContainer.Clear();
return;
}
const float y_flag_offset = 292;

View File

@ -13,11 +13,10 @@
namespace osu.Game.Tournament.Screens.TeamWin
{
public class TeamWinScreen : TournamentScreen, IProvideVideo
public class TeamWinScreen : TournamentMatchScreen, IProvideVideo
{
private Container mainContainer;
private readonly Bindable<TournamentMatch> currentMatch = new Bindable<TournamentMatch>();
private readonly Bindable<bool> currentCompleted = new Bindable<bool>();
private TourneyVideo blueWinVideo;
@ -48,17 +47,19 @@ private void load(LadderInfo ladder, Storage storage)
}
};
currentMatch.BindValueChanged(matchChanged);
currentMatch.BindTo(ladder.CurrentMatch);
currentCompleted.BindValueChanged(_ => update());
}
private void matchChanged(ValueChangedEvent<TournamentMatch> match)
protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch> match)
{
currentCompleted.UnbindBindings();
currentCompleted.BindTo(match.NewValue.Completed);
base.CurrentMatchChanged(match);
currentCompleted.UnbindBindings();
if (match.NewValue == null)
return;
currentCompleted.BindTo(match.NewValue.Completed);
update();
}
@ -66,7 +67,7 @@ private void matchChanged(ValueChangedEvent<TournamentMatch> match)
private void update() => Schedule(() =>
{
var match = currentMatch.Value;
var match = CurrentMatch.Value;
if (match.Winner == null)
{