mirror of
https://github.com/ppy/osu.git
synced 2025-01-27 13:23:05 +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:
commit
e566b8a3d4
@ -127,9 +127,13 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
|
|
||||||
AddAssert("room type is head to head", () => client.Room?.Settings.MatchType == MatchType.HeadToHead);
|
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));
|
AddStep("change to team vs", () => client.ChangeSettings(matchType: MatchType.TeamVersus));
|
||||||
|
|
||||||
AddAssert("room type is team vs", () => client.Room?.Settings.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)
|
private void createRoom(Func<Room> room)
|
||||||
|
@ -29,52 +29,51 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private OsuColour colours { get; set; }
|
private OsuColour colours { get; set; }
|
||||||
|
|
||||||
|
private OsuClickableContainer clickableContent;
|
||||||
|
|
||||||
public TeamDisplay(MultiplayerRoomUser user)
|
public TeamDisplay(MultiplayerRoomUser user)
|
||||||
{
|
{
|
||||||
this.user = user;
|
this.user = user;
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Y;
|
RelativeSizeAxes = Axes.Y;
|
||||||
Width = 15;
|
|
||||||
|
AutoSizeAxes = Axes.X;
|
||||||
|
|
||||||
Margin = new MarginPadding { Horizontal = 3 };
|
Margin = new MarginPadding { Horizontal = 3 };
|
||||||
|
|
||||||
Alpha = 0;
|
|
||||||
Scale = new Vector2(0, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(AudioManager audio)
|
private void load(AudioManager audio)
|
||||||
{
|
{
|
||||||
box = new Container
|
InternalChild = clickableContent = new OsuClickableContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
Width = 15,
|
||||||
CornerRadius = 5,
|
Alpha = 0,
|
||||||
Masking = true,
|
|
||||||
Scale = new Vector2(0, 1),
|
Scale = new Vector2(0, 1),
|
||||||
Anchor = Anchor.Centre,
|
RelativeSizeAxes = Axes.Y,
|
||||||
Origin = Anchor.Centre,
|
Action = changeTeam,
|
||||||
Child = new Box
|
Child = box = new Container
|
||||||
{
|
{
|
||||||
Colour = Color4.White,
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
CornerRadius = 5,
|
||||||
|
Masking = true,
|
||||||
|
Scale = new Vector2(0, 1),
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = 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)
|
if (Client.LocalUser?.Equals(user) == true)
|
||||||
{
|
{
|
||||||
InternalChild = new OsuClickableContainer
|
clickableContent.Action = changeTeam;
|
||||||
{
|
clickableContent.TooltipText = "Change team";
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
TooltipText = "Change team",
|
|
||||||
Action = changeTeam,
|
|
||||||
Child = box
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
InternalChild = box;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sampleTeamSwap = audio.Samples.Get(@"Multiplayer/team-swap");
|
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()
|
protected override void OnRoomUpdated()
|
||||||
{
|
{
|
||||||
@ -102,28 +101,28 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
|
|||||||
|
|
||||||
int? newTeam = (userRoomState as TeamVersusUserState)?.TeamID;
|
int? newTeam = (userRoomState as TeamVersusUserState)?.TeamID;
|
||||||
|
|
||||||
if (newTeam == displayedTeam)
|
if (newTeam == DisplayedTeam)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// only play the sample if an already valid team changes to another valid team.
|
// 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.
|
// 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();
|
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);
|
box.ScaleTo(new Vector2(box.Scale.X < 0 ? 1 : -1, 1), duration, Easing.OutQuint);
|
||||||
|
|
||||||
this.ScaleTo(Vector2.One, duration, Easing.OutQuint);
|
clickableContent.ScaleTo(Vector2.One, duration, Easing.OutQuint);
|
||||||
this.FadeIn(duration);
|
clickableContent.FadeIn(duration);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.ScaleTo(new Vector2(0, 1), duration, Easing.OutQuint);
|
clickableContent.ScaleTo(new Vector2(0, 1), duration, Easing.OutQuint);
|
||||||
this.FadeOut(duration);
|
clickableContent.FadeOut(duration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user