mirror of
https://github.com/osukey/osukey.git
synced 2025-08-02 22:26:41 +09:00
Merge pull request #14534 from peppy/fix-tournament-startup-crash
Fix tournament client crashing at startup when osu!(stalble) is at ranking screen
This commit is contained in:
@ -4,8 +4,10 @@
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Tournament.Components;
|
||||
using osu.Game.Tournament.IPC;
|
||||
using osu.Game.Tournament.Screens.Gameplay;
|
||||
using osu.Game.Tournament.Screens.Gameplay.Components;
|
||||
|
||||
@ -16,16 +18,26 @@ namespace osu.Game.Tournament.Tests.Screens
|
||||
[Cached]
|
||||
private TournamentMatchChatDisplay chat = new TournamentMatchChatDisplay { Width = 0.5f };
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
[Test]
|
||||
public void TestStartupState([Values] TourneyState state)
|
||||
{
|
||||
Add(new GameplayScreen());
|
||||
Add(chat);
|
||||
AddStep("set state", () => IPCInfo.State.Value = state);
|
||||
createScreen();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestStartupStateNoCurrentMatch([Values] TourneyState state)
|
||||
{
|
||||
AddStep("set null current", () => Ladder.CurrentMatch.Value = null);
|
||||
AddStep("set state", () => IPCInfo.State.Value = state);
|
||||
createScreen();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestWarmup()
|
||||
{
|
||||
createScreen();
|
||||
|
||||
checkScoreVisibility(false);
|
||||
|
||||
toggleWarmup();
|
||||
@ -35,6 +47,20 @@ namespace osu.Game.Tournament.Tests.Screens
|
||||
checkScoreVisibility(false);
|
||||
}
|
||||
|
||||
private void createScreen()
|
||||
{
|
||||
AddStep("setup screen", () =>
|
||||
{
|
||||
Remove(chat);
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new GameplayScreen(),
|
||||
chat,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void checkScoreVisibility(bool visible)
|
||||
=> AddUntilStep($"scores {(visible ? "shown" : "hidden")}",
|
||||
() => this.ChildrenOfType<TeamScore>().All(score => score.Alpha == (visible ? 1 : 0)));
|
||||
|
@ -2,7 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Tournament.Screens.TeamWin;
|
||||
|
||||
@ -10,19 +10,22 @@ namespace osu.Game.Tournament.Tests.Screens
|
||||
{
|
||||
public class TestSceneTeamWinScreen : TournamentTestScene
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
[Test]
|
||||
public void TestBasic()
|
||||
{
|
||||
var match = Ladder.CurrentMatch.Value;
|
||||
AddStep("set up match", () =>
|
||||
{
|
||||
var match = Ladder.CurrentMatch.Value;
|
||||
|
||||
match.Round.Value = Ladder.Rounds.FirstOrDefault(g => g.Name.Value == "Finals");
|
||||
match.Completed.Value = true;
|
||||
match.Round.Value = Ladder.Rounds.FirstOrDefault(g => g.Name.Value == "Finals");
|
||||
match.Completed.Value = true;
|
||||
});
|
||||
|
||||
Add(new TeamWinScreen
|
||||
AddStep("create screen", () => Add(new TeamWinScreen
|
||||
{
|
||||
FillMode = FillMode.Fit,
|
||||
FillAspectRatio = 16 / 9f
|
||||
});
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,8 @@ namespace osu.Game.Tournament.Tests
|
||||
{
|
||||
public abstract class TournamentTestScene : OsuTestScene
|
||||
{
|
||||
private TournamentMatch match;
|
||||
|
||||
[Cached]
|
||||
protected LadderInfo Ladder { get; private set; } = new LadderInfo();
|
||||
|
||||
@ -33,19 +35,23 @@ namespace osu.Game.Tournament.Tests
|
||||
{
|
||||
Ladder.Ruleset.Value ??= rulesetStore.AvailableRulesets.First();
|
||||
|
||||
TournamentMatch match = CreateSampleMatch();
|
||||
match = CreateSampleMatch();
|
||||
|
||||
Ladder.Rounds.Add(match.Round.Value);
|
||||
Ladder.Matches.Add(match);
|
||||
Ladder.Teams.Add(match.Team1.Value);
|
||||
Ladder.Teams.Add(match.Team2.Value);
|
||||
|
||||
Ladder.CurrentMatch.Value = match;
|
||||
|
||||
Ruleset.BindTo(Ladder.Ruleset);
|
||||
Dependencies.CacheAs(new StableInfo(storage));
|
||||
}
|
||||
|
||||
[SetUpSteps]
|
||||
public virtual void SetUpSteps()
|
||||
{
|
||||
AddStep("set current match", () => Ladder.CurrentMatch.Value = match);
|
||||
}
|
||||
|
||||
public static TournamentMatch CreateSampleMatch() => new TournamentMatch
|
||||
{
|
||||
Team1 =
|
||||
|
@ -20,6 +20,6 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
|
||||
}
|
||||
|
||||
private void matchChanged(ValueChangedEvent<TournamentMatch> match) =>
|
||||
Text.Text = match.NewValue.Round.Value?.Name.Value ?? "Unknown Round";
|
||||
Text.Text = match.NewValue?.Round.Value?.Name.Value ?? "Unknown Round";
|
||||
}
|
||||
}
|
||||
|
@ -124,9 +124,6 @@ namespace osu.Game.Tournament.Screens.Gameplay
|
||||
}
|
||||
});
|
||||
|
||||
State.BindTo(ipc.State);
|
||||
State.BindValueChanged(stateChanged, true);
|
||||
|
||||
ladder.ChromaKeyWidth.BindValueChanged(width => chroma.Width = width.NewValue, true);
|
||||
|
||||
warmup.BindValueChanged(w =>
|
||||
@ -136,6 +133,14 @@ namespace osu.Game.Tournament.Screens.Gameplay
|
||||
}, true);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
State.BindTo(ipc.State);
|
||||
State.BindValueChanged(stateChanged, true);
|
||||
}
|
||||
|
||||
protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch> match)
|
||||
{
|
||||
base.CurrentMatchChanged(match);
|
||||
@ -159,7 +164,7 @@ namespace osu.Game.Tournament.Screens.Gameplay
|
||||
{
|
||||
if (state.NewValue == TourneyState.Ranking)
|
||||
{
|
||||
if (warmup.Value) return;
|
||||
if (warmup.Value || CurrentMatch.Value == null) return;
|
||||
|
||||
if (ipc.Score1.Value > ipc.Score2.Value)
|
||||
CurrentMatch.Value.Team1Score.Value++;
|
||||
|
Reference in New Issue
Block a user