mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 05:13:21 +08:00
Replace the ready mark display with a state display, showing all participant states
This commit is contained in:
parent
3c33ea7f1c
commit
ce806dd880
@ -20,6 +20,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
Room.RecentParticipants.Add(new User
|
Room.RecentParticipants.Add(new User
|
||||||
{
|
{
|
||||||
Username = "peppy",
|
Username = "peppy",
|
||||||
|
CurrentModeRank = 1234,
|
||||||
Id = 2
|
Id = 2
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ using NUnit.Framework;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Online.RealtimeMultiplayer;
|
using osu.Game.Online.RealtimeMultiplayer;
|
||||||
using osu.Game.Screens.Multi.RealtimeMultiplayer.Participants;
|
using osu.Game.Screens.Multi.RealtimeMultiplayer.Participants;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
@ -65,13 +66,13 @@ namespace osu.Game.Tests.Visual.RealtimeMultiplayer
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestToggleReadyState()
|
public void TestToggleReadyState()
|
||||||
{
|
{
|
||||||
AddAssert("ready mark invisible", () => !this.ChildrenOfType<ReadyMark>().Single().IsPresent);
|
AddAssert("ready mark invisible", () => !this.ChildrenOfType<StateDisplay>().Single().IsPresent);
|
||||||
|
|
||||||
AddStep("make user ready", () => Client.ChangeState(MultiplayerUserState.Ready));
|
AddStep("make user ready", () => Client.ChangeState(MultiplayerUserState.Ready));
|
||||||
AddUntilStep("ready mark visible", () => this.ChildrenOfType<ReadyMark>().Single().IsPresent);
|
AddUntilStep("ready mark visible", () => this.ChildrenOfType<StateDisplay>().Single().IsPresent);
|
||||||
|
|
||||||
AddStep("make user idle", () => Client.ChangeState(MultiplayerUserState.Idle));
|
AddStep("make user idle", () => Client.ChangeState(MultiplayerUserState.Idle));
|
||||||
AddUntilStep("ready mark invisible", () => !this.ChildrenOfType<ReadyMark>().Single().IsPresent);
|
AddUntilStep("ready mark invisible", () => !this.ChildrenOfType<StateDisplay>().Single().IsPresent);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -104,11 +105,11 @@ namespace osu.Game.Tests.Visual.RealtimeMultiplayer
|
|||||||
{
|
{
|
||||||
Id = i,
|
Id = i,
|
||||||
Username = $"User {i}",
|
Username = $"User {i}",
|
||||||
|
CurrentModeRank = RNG.Next(1, 100000),
|
||||||
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
|
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
|
||||||
});
|
});
|
||||||
|
|
||||||
if (i % 2 == 0)
|
Client.ChangeUserState(i, (MultiplayerUserState)RNG.Next(0, (int)MultiplayerUserState.Results));
|
||||||
Client.ChangeUserState(i, MultiplayerUserState.Ready);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer.Participants
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private IAPIProvider api { get; set; }
|
private IAPIProvider api { get; set; }
|
||||||
|
|
||||||
private ReadyMark readyMark;
|
private StateDisplay userStateDisplay;
|
||||||
private SpriteIcon crown;
|
private SpriteIcon crown;
|
||||||
|
|
||||||
public ParticipantPanel(MultiplayerRoomUser user)
|
public ParticipantPanel(MultiplayerRoomUser user)
|
||||||
@ -122,12 +122,11 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer.Participants
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
readyMark = new ReadyMark
|
userStateDisplay = new StateDisplay
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreRight,
|
Anchor = Anchor.CentreRight,
|
||||||
Origin = Anchor.CentreRight,
|
Origin = Anchor.CentreRight,
|
||||||
Margin = new MarginPadding { Right = 10 },
|
Margin = new MarginPadding { Right = 10 },
|
||||||
Alpha = 0
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -144,10 +143,7 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer.Participants
|
|||||||
|
|
||||||
const double fade_time = 50;
|
const double fade_time = 50;
|
||||||
|
|
||||||
if (User.State == MultiplayerUserState.Ready)
|
userStateDisplay.Status = User.State;
|
||||||
readyMark.FadeIn(fade_time);
|
|
||||||
else
|
|
||||||
readyMark.FadeOut(fade_time);
|
|
||||||
|
|
||||||
if (Room.Host?.Equals(User) == true)
|
if (Room.Host?.Equals(User) == true)
|
||||||
crown.FadeIn(fade_time);
|
crown.FadeIn(fade_time);
|
||||||
|
@ -1,51 +0,0 @@
|
|||||||
// 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.Allocation;
|
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Graphics.Sprites;
|
|
||||||
using osu.Game.Graphics;
|
|
||||||
using osu.Game.Graphics.Sprites;
|
|
||||||
using osuTK;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Multi.RealtimeMultiplayer.Participants
|
|
||||||
{
|
|
||||||
public class ReadyMark : CompositeDrawable
|
|
||||||
{
|
|
||||||
public ReadyMark()
|
|
||||||
{
|
|
||||||
AutoSizeAxes = Axes.Both;
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load()
|
|
||||||
{
|
|
||||||
InternalChild = new FillFlowContainer
|
|
||||||
{
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Spacing = new Vector2(5),
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new OsuSpriteText
|
|
||||||
{
|
|
||||||
Anchor = Anchor.CentreLeft,
|
|
||||||
Origin = Anchor.CentreLeft,
|
|
||||||
Font = OsuFont.GetFont(weight: FontWeight.Regular, size: 12),
|
|
||||||
Text = "ready",
|
|
||||||
Colour = Color4Extensions.FromHex("#DDFFFF")
|
|
||||||
},
|
|
||||||
new SpriteIcon
|
|
||||||
{
|
|
||||||
Anchor = Anchor.CentreLeft,
|
|
||||||
Origin = Anchor.CentreLeft,
|
|
||||||
Icon = FontAwesome.Solid.CheckCircle,
|
|
||||||
Size = new Vector2(12),
|
|
||||||
Colour = Color4Extensions.FromHex("#AADD00")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,128 @@
|
|||||||
|
// 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.Allocation;
|
||||||
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Online.RealtimeMultiplayer;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Multi.RealtimeMultiplayer.Participants
|
||||||
|
{
|
||||||
|
public class StateDisplay : CompositeDrawable
|
||||||
|
{
|
||||||
|
public StateDisplay()
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Both;
|
||||||
|
}
|
||||||
|
|
||||||
|
private MultiplayerUserState status;
|
||||||
|
|
||||||
|
private OsuSpriteText text;
|
||||||
|
private SpriteIcon icon;
|
||||||
|
|
||||||
|
private const double fade_time = 50;
|
||||||
|
|
||||||
|
public MultiplayerUserState Status
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == status)
|
||||||
|
return;
|
||||||
|
|
||||||
|
status = value;
|
||||||
|
|
||||||
|
if (IsLoaded)
|
||||||
|
updateStatus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
InternalChild = new FillFlowContainer
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Spacing = new Vector2(5),
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
text = new OsuSpriteText
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
Font = OsuFont.GetFont(weight: FontWeight.Regular, size: 12),
|
||||||
|
Colour = Color4Extensions.FromHex("#DDFFFF")
|
||||||
|
},
|
||||||
|
icon = new SpriteIcon
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
Icon = FontAwesome.Solid.CheckCircle,
|
||||||
|
Size = new Vector2(12),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
updateStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuColour colours { get; set; }
|
||||||
|
|
||||||
|
private void updateStatus()
|
||||||
|
{
|
||||||
|
switch (status)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
this.FadeOut(fade_time);
|
||||||
|
return;
|
||||||
|
|
||||||
|
case MultiplayerUserState.Ready:
|
||||||
|
text.Text = "ready";
|
||||||
|
icon.Icon = FontAwesome.Solid.CheckCircle;
|
||||||
|
icon.Colour = Color4Extensions.FromHex("#AADD00");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MultiplayerUserState.WaitingForLoad:
|
||||||
|
text.Text = "loading";
|
||||||
|
icon.Icon = FontAwesome.Solid.PauseCircle;
|
||||||
|
icon.Colour = colours.Yellow;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MultiplayerUserState.Loaded:
|
||||||
|
text.Text = "loaded";
|
||||||
|
icon.Icon = FontAwesome.Solid.DotCircle;
|
||||||
|
icon.Colour = colours.YellowLight;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MultiplayerUserState.Playing:
|
||||||
|
text.Text = "playing";
|
||||||
|
icon.Icon = FontAwesome.Solid.PlayCircle;
|
||||||
|
icon.Colour = colours.BlueLight;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MultiplayerUserState.FinishedPlay:
|
||||||
|
text.Text = "results pending";
|
||||||
|
icon.Icon = FontAwesome.Solid.ArrowAltCircleUp;
|
||||||
|
icon.Colour = colours.BlueLighter;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MultiplayerUserState.Results:
|
||||||
|
text.Text = "results";
|
||||||
|
icon.Icon = FontAwesome.Solid.ArrowAltCircleUp;
|
||||||
|
icon.Colour = colours.BlueLighter;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.FadeIn(fade_time);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user