1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 14:17:26 +08:00

Merge pull request #15551 from peppy/fix-team-display-not-displaying

Fix `TeamDisplay` not showing after changing to team versus
This commit is contained in:
Dan Balasescu 2021-11-10 15:04:33 +09:00 committed by GitHub
commit e566b8a3d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 33 deletions

View File

@ -127,9 +127,13 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddAssert("room type is head to head", () => client.Room?.Settings.MatchType == MatchType.HeadToHead);
AddUntilStep("team displays are not displaying teams", () => multiplayerScreenStack.ChildrenOfType<TeamDisplay>().All(d => d.DisplayedTeam == null));
AddStep("change to team vs", () => client.ChangeSettings(matchType: MatchType.TeamVersus));
AddAssert("room type is team vs", () => client.Room?.Settings.MatchType == MatchType.TeamVersus);
AddUntilStep("team displays are displaying teams", () => multiplayerScreenStack.ChildrenOfType<TeamDisplay>().All(d => d.DisplayedTeam != null));
}
private void createRoom(Func<Room> room)

View File

@ -29,52 +29,51 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
[Resolved]
private OsuColour colours { get; set; }
private OsuClickableContainer clickableContent;
public TeamDisplay(MultiplayerRoomUser user)
{
this.user = user;
RelativeSizeAxes = Axes.Y;
Width = 15;
AutoSizeAxes = Axes.X;
Margin = new MarginPadding { Horizontal = 3 };
Alpha = 0;
Scale = new Vector2(0, 1);
}
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
box = new Container
InternalChild = clickableContent = new OsuClickableContainer
{
RelativeSizeAxes = Axes.Both,
CornerRadius = 5,
Masking = true,
Width = 15,
Alpha = 0,
Scale = new Vector2(0, 1),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Child = new Box
RelativeSizeAxes = Axes.Y,
Action = changeTeam,
Child = box = new Container
{
Colour = Color4.White,
RelativeSizeAxes = Axes.Both,
CornerRadius = 5,
Masking = true,
Scale = new Vector2(0, 1),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Child = new Box
{
Colour = Color4.White,
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
}
}
};
if (Client.LocalUser?.Equals(user) == true)
{
InternalChild = new OsuClickableContainer
{
RelativeSizeAxes = Axes.Both,
TooltipText = "Change team",
Action = changeTeam,
Child = box
};
}
else
{
InternalChild = box;
clickableContent.Action = changeTeam;
clickableContent.TooltipText = "Change team";
}
sampleTeamSwap = audio.Samples.Get(@"Multiplayer/team-swap");
@ -88,7 +87,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
});
}
private int? displayedTeam;
public int? DisplayedTeam { get; private set; }
protected override void OnRoomUpdated()
{
@ -102,28 +101,28 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
int? newTeam = (userRoomState as TeamVersusUserState)?.TeamID;
if (newTeam == displayedTeam)
if (newTeam == DisplayedTeam)
return;
// only play the sample if an already valid team changes to another valid team.
// this avoids playing a sound for each user if the match type is changed to/from a team mode.
if (newTeam != null && displayedTeam != null)
if (newTeam != null && DisplayedTeam != null)
sampleTeamSwap?.Play();
displayedTeam = newTeam;
DisplayedTeam = newTeam;
if (displayedTeam != null)
if (DisplayedTeam != null)
{
box.FadeColour(getColourForTeam(displayedTeam.Value), duration, Easing.OutQuint);
box.FadeColour(getColourForTeam(DisplayedTeam.Value), duration, Easing.OutQuint);
box.ScaleTo(new Vector2(box.Scale.X < 0 ? 1 : -1, 1), duration, Easing.OutQuint);
this.ScaleTo(Vector2.One, duration, Easing.OutQuint);
this.FadeIn(duration);
clickableContent.ScaleTo(Vector2.One, duration, Easing.OutQuint);
clickableContent.FadeIn(duration);
}
else
{
this.ScaleTo(new Vector2(0, 1), duration, Easing.OutQuint);
this.FadeOut(duration);
clickableContent.ScaleTo(new Vector2(0, 1), duration, Easing.OutQuint);
clickableContent.FadeOut(duration);
}
}