1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 02:02:53 +08:00

Add room status text to DrawableRoom

This commit is contained in:
smoogipoo 2021-09-29 20:24:49 +09:00
parent 5f921c7836
commit 67d847fbd3
2 changed files with 40 additions and 24 deletions

View File

@ -43,11 +43,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
Spacing = new Vector2(10),
Children = new Drawable[]
{
createDrawableRoom(new Room
createLoungeRoom(new Room
{
Name = { Value = "Flyte's Trash Playlist" },
Name = { Value = "Multiplayer room" },
Status = { Value = new RoomStatusOpen() },
EndDate = { Value = DateTimeOffset.Now.AddDays(1) },
Type = { Value = MatchType.HeadToHead },
Playlist =
{
new PlaylistItem
@ -65,9 +66,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
}
}
}),
createDrawableRoom(new Room
createLoungeRoom(new Room
{
Name = { Value = "Room 2" },
Name = { Value = "Playlist room with multiple beatmaps" },
Status = { Value = new RoomStatusPlaying() },
EndDate = { Value = DateTimeOffset.Now.AddDays(1) },
Playlist =
@ -100,15 +101,15 @@ namespace osu.Game.Tests.Visual.Multiplayer
}
}
}),
createDrawableRoom(new Room
createLoungeRoom(new Room
{
Name = { Value = "Room 3" },
Name = { Value = "Finished room" },
Status = { Value = new RoomStatusEnded() },
EndDate = { Value = DateTimeOffset.Now },
}),
createDrawableRoom(new Room
createLoungeRoom(new Room
{
Name = { Value = "Room 4 (spotlight)" },
Name = { Value = "Spotlight room" },
Status = { Value = new RoomStatusOpen() },
Category = { Value = RoomCategory.Spotlight },
}),
@ -123,7 +124,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
DrawableRoom drawableRoom = null;
Room room = null;
AddStep("create room", () => Child = drawableRoom = createDrawableRoom(room = new Room
AddStep("create room", () => Child = drawableRoom = createLoungeRoom(room = new Room
{
Name = { Value = "Room with password" },
Status = { Value = new RoomStatusOpen() },
@ -141,7 +142,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddAssert("password icon hidden", () => Precision.AlmostEquals(0, drawableRoom.ChildrenOfType<DrawableRoom.PasswordProtectedIcon>().Single().Alpha));
}
private DrawableRoom createDrawableRoom(Room room)
private DrawableRoom createLoungeRoom(Room room)
{
room.Host.Value ??= new User { Username = "peppy", Id = 2 };

View File

@ -14,6 +14,7 @@ using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.Chat;
using osu.Game.Online.Rooms;
using osu.Game.Overlays;
using osu.Game.Screens.OnlinePlay.Components;
@ -172,7 +173,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
Children = new Drawable[]
{
new RoomNameText(),
new RoomHostText(),
new RoomStatusText()
}
}
},
@ -304,11 +305,14 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
}
}
private class RoomHostText : OnlinePlayComposite
private class RoomStatusText : OnlinePlayComposite
{
private LinkFlowContainer hostText;
[Resolved]
private OsuColour colours { get; set; }
public RoomHostText()
private LinkFlowContainer linkFlow;
public RoomStatusText()
{
AutoSizeAxes = Axes.Both;
}
@ -316,26 +320,37 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
[BackgroundDependencyLoader]
private void load()
{
InternalChild = hostText = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 16))
InternalChild = linkFlow = new LinkFlowContainer(s =>
{
AutoSizeAxes = Axes.Both
s.Font = OsuFont.Default.With(size: 16);
s.Colour = colours.Lime1;
})
{
AutoSizeAxes = Axes.Both,
};
}
protected override void LoadComplete()
{
base.LoadComplete();
SelectedItem.BindValueChanged(onSelectedItemChanged, true);
}
Host.BindValueChanged(host =>
private void onSelectedItemChanged(ValueChangedEvent<PlaylistItem> item)
{
if (Type.Value == MatchType.Playlists)
{
hostText.Clear();
linkFlow.Text = "Waiting for players";
return;
}
if (host.NewValue != null)
{
hostText.AddText("hosted by ");
hostText.AddUserLink(host.NewValue);
}
}, true);
linkFlow.Clear();
if (item.NewValue?.Beatmap.Value != null)
{
linkFlow.AddText("Currently playing ");
linkFlow.AddLink(item.NewValue.Beatmap.Value.ToRomanisableString(), LinkAction.OpenBeatmap, item.NewValue.Beatmap.Value.OnlineBeatmapID.ToString());
}
}
}