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), Spacing = new Vector2(10),
Children = new Drawable[] Children = new Drawable[]
{ {
createDrawableRoom(new Room createLoungeRoom(new Room
{ {
Name = { Value = "Flyte's Trash Playlist" }, Name = { Value = "Multiplayer room" },
Status = { Value = new RoomStatusOpen() }, Status = { Value = new RoomStatusOpen() },
EndDate = { Value = DateTimeOffset.Now.AddDays(1) }, EndDate = { Value = DateTimeOffset.Now.AddDays(1) },
Type = { Value = MatchType.HeadToHead },
Playlist = Playlist =
{ {
new PlaylistItem 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() }, Status = { Value = new RoomStatusPlaying() },
EndDate = { Value = DateTimeOffset.Now.AddDays(1) }, EndDate = { Value = DateTimeOffset.Now.AddDays(1) },
Playlist = 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() }, Status = { Value = new RoomStatusEnded() },
EndDate = { Value = DateTimeOffset.Now }, EndDate = { Value = DateTimeOffset.Now },
}), }),
createDrawableRoom(new Room createLoungeRoom(new Room
{ {
Name = { Value = "Room 4 (spotlight)" }, Name = { Value = "Spotlight room" },
Status = { Value = new RoomStatusOpen() }, Status = { Value = new RoomStatusOpen() },
Category = { Value = RoomCategory.Spotlight }, Category = { Value = RoomCategory.Spotlight },
}), }),
@ -123,7 +124,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
DrawableRoom drawableRoom = null; DrawableRoom drawableRoom = null;
Room room = 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" }, Name = { Value = "Room with password" },
Status = { Value = new RoomStatusOpen() }, 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)); 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 }; 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;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Online.Chat;
using osu.Game.Online.Rooms; using osu.Game.Online.Rooms;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Screens.OnlinePlay.Components; using osu.Game.Screens.OnlinePlay.Components;
@ -172,7 +173,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
Children = new Drawable[] Children = new Drawable[]
{ {
new RoomNameText(), 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; AutoSizeAxes = Axes.Both;
} }
@ -316,26 +320,37 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() 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() protected override void LoadComplete()
{ {
base.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) linkFlow.Clear();
{
hostText.AddText("hosted by "); if (item.NewValue?.Beatmap.Value != null)
hostText.AddUserLink(host.NewValue); {
} linkFlow.AddText("Currently playing ");
}, true); linkFlow.AddLink(item.NewValue.Beatmap.Value.ToRomanisableString(), LinkAction.OpenBeatmap, item.NewValue.Beatmap.Value.OnlineBeatmapID.ToString());
}
} }
} }