mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 20:07:29 +08:00
Add host under room title
This commit is contained in:
parent
4ac812de86
commit
aba09b20a5
@ -8,6 +8,7 @@ using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Online.Rooms.RoomStatuses;
|
||||
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
||||
using osu.Game.Users;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Multiplayer
|
||||
@ -27,27 +28,31 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
createDrawableRoom(new Room
|
||||
{
|
||||
Name = { Value = "Room name: Open - ending in 1 day" },
|
||||
Name = { Value = "Room 1" },
|
||||
Status = { Value = new RoomStatusOpen() },
|
||||
EndDate = { Value = DateTimeOffset.Now.AddDays(1) }
|
||||
EndDate = { Value = DateTimeOffset.Now.AddDays(1) },
|
||||
Host = { Value = new User { Username = "peppy", Id = 2 } }
|
||||
}),
|
||||
createDrawableRoom(new Room
|
||||
{
|
||||
Name = { Value = "Room name: Playing - ending in 1 day" },
|
||||
Name = { Value = "Room 2" },
|
||||
Status = { Value = new RoomStatusPlaying() },
|
||||
EndDate = { Value = DateTimeOffset.Now.AddDays(1) }
|
||||
EndDate = { Value = DateTimeOffset.Now.AddDays(1) },
|
||||
Host = { Value = new User { Username = "peppy", Id = 2 } }
|
||||
}),
|
||||
createDrawableRoom(new Room
|
||||
{
|
||||
Name = { Value = "Room name: Ended" },
|
||||
Name = { Value = "Room 3" },
|
||||
Status = { Value = new RoomStatusEnded() },
|
||||
EndDate = { Value = DateTimeOffset.Now }
|
||||
EndDate = { Value = DateTimeOffset.Now },
|
||||
Host = { Value = new User { Username = "peppy", Id = 2 } }
|
||||
}),
|
||||
createDrawableRoom(new Room
|
||||
{
|
||||
Name = { Value = "Room name: Open" },
|
||||
Name = { Value = "Room 4" },
|
||||
Status = { Value = new RoomStatusOpen() },
|
||||
Category = { Value = RoomCategory.Realtime }
|
||||
Category = { Value = RoomCategory.Realtime },
|
||||
Host = { Value = new User { Username = "peppy", Id = 2 } }
|
||||
}),
|
||||
}
|
||||
};
|
||||
|
@ -187,11 +187,17 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
},
|
||||
}
|
||||
},
|
||||
new RoomName
|
||||
new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Font = OsuFont.GetFont(size: 28)
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new RoomNameText(),
|
||||
new RoomHostText()
|
||||
}
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
@ -262,11 +268,16 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
|
||||
protected override bool ShouldBeConsideredForInput(Drawable child) => state == SelectionState.Selected;
|
||||
|
||||
private class RoomName : OsuSpriteText
|
||||
private class RoomNameText : OsuSpriteText
|
||||
{
|
||||
[Resolved(typeof(Room), nameof(Online.Rooms.Room.Name))]
|
||||
private Bindable<string> name { get; set; }
|
||||
|
||||
public RoomNameText()
|
||||
{
|
||||
Font = OsuFont.GetFont(size: 24);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
@ -274,6 +285,41 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
}
|
||||
}
|
||||
|
||||
private class RoomHostText : OnlinePlayComposite
|
||||
{
|
||||
private LinkFlowContainer hostText;
|
||||
|
||||
public RoomHostText()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
InternalChild = hostText = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 14))
|
||||
{
|
||||
AutoSizeAxes = Axes.Both
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Host.BindValueChanged(host =>
|
||||
{
|
||||
hostText.Clear();
|
||||
|
||||
if (host.NewValue != null)
|
||||
{
|
||||
hostText.AddText("hosted by ");
|
||||
hostText.AddUserLink(host.NewValue);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
|
||||
public MenuItem[] ContextMenuItems => new MenuItem[]
|
||||
{
|
||||
new OsuMenuItem("Create copy", MenuItemType.Standard, () =>
|
||||
|
Loading…
Reference in New Issue
Block a user