mirror of
https://github.com/ppy/osu.git
synced 2025-03-05 22:42:54 +08:00
Merge branch 'master' into realtime-pp-display
This commit is contained in:
commit
36be041846
@ -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,14 +124,14 @@ 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() },
|
||||||
Type = { Value = MatchType.HeadToHead },
|
Type = { Value = MatchType.HeadToHead },
|
||||||
}));
|
}));
|
||||||
|
|
||||||
AddUntilStep("wait for panel load", () => drawableRoom.ChildrenOfType<RecentParticipantsList>().Any());
|
AddUntilStep("wait for panel load", () => drawableRoom.ChildrenOfType<DrawableRoomParticipantsList>().Any());
|
||||||
|
|
||||||
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));
|
||||||
|
|
||||||
@ -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 };
|
||||||
|
|
||||||
|
@ -13,16 +13,27 @@ using osu.Game.Users.Drawables;
|
|||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Multiplayer
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
{
|
{
|
||||||
public class TestSceneRecentParticipantsList : OnlinePlayTestScene
|
public class TestSceneDrawableRoomParticipantsList : OnlinePlayTestScene
|
||||||
{
|
{
|
||||||
private RecentParticipantsList list;
|
private DrawableRoomParticipantsList list;
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public new void Setup() => Schedule(() =>
|
public new void Setup() => Schedule(() =>
|
||||||
{
|
{
|
||||||
SelectedRoom.Value = new Room { Name = { Value = "test room" } };
|
SelectedRoom.Value = new Room
|
||||||
|
{
|
||||||
|
Name = { Value = "test room" },
|
||||||
|
Host =
|
||||||
|
{
|
||||||
|
Value = new User
|
||||||
|
{
|
||||||
|
Id = 2,
|
||||||
|
Username = "peppy",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Child = list = new RecentParticipantsList
|
Child = list = new DrawableRoomParticipantsList
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
@ -40,19 +51,19 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
});
|
});
|
||||||
|
|
||||||
AddStep("set 8 circles", () => list.NumberOfCircles = 8);
|
AddStep("set 8 circles", () => list.NumberOfCircles = 8);
|
||||||
AddAssert("0 hidden users", () => list.ChildrenOfType<RecentParticipantsList.HiddenUserCount>().Single().Count == 0);
|
AddAssert("0 hidden users", () => list.ChildrenOfType<DrawableRoomParticipantsList.HiddenUserCount>().Single().Count == 0);
|
||||||
|
|
||||||
AddStep("add one more user", () => addUser(9));
|
AddStep("add one more user", () => addUser(9));
|
||||||
AddAssert("2 hidden users", () => list.ChildrenOfType<RecentParticipantsList.HiddenUserCount>().Single().Count == 2);
|
AddAssert("2 hidden users", () => list.ChildrenOfType<DrawableRoomParticipantsList.HiddenUserCount>().Single().Count == 2);
|
||||||
|
|
||||||
AddStep("remove first user", () => removeUserAt(0));
|
AddStep("remove first user", () => removeUserAt(0));
|
||||||
AddAssert("0 hidden users", () => list.ChildrenOfType<RecentParticipantsList.HiddenUserCount>().Single().Count == 0);
|
AddAssert("0 hidden users", () => list.ChildrenOfType<DrawableRoomParticipantsList.HiddenUserCount>().Single().Count == 0);
|
||||||
|
|
||||||
AddStep("add one more user", () => addUser(9));
|
AddStep("add one more user", () => addUser(9));
|
||||||
AddAssert("2 hidden users", () => list.ChildrenOfType<RecentParticipantsList.HiddenUserCount>().Single().Count == 2);
|
AddAssert("2 hidden users", () => list.ChildrenOfType<DrawableRoomParticipantsList.HiddenUserCount>().Single().Count == 2);
|
||||||
|
|
||||||
AddStep("remove last user", () => removeUserAt(8));
|
AddStep("remove last user", () => removeUserAt(8));
|
||||||
AddAssert("0 hidden users", () => list.ChildrenOfType<RecentParticipantsList.HiddenUserCount>().Single().Count == 0);
|
AddAssert("0 hidden users", () => list.ChildrenOfType<DrawableRoomParticipantsList.HiddenUserCount>().Single().Count == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -69,9 +80,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
AddStep("remove user", () => removeUserAt(0));
|
AddStep("remove user", () => removeUserAt(0));
|
||||||
int remainingUsers = 7 - i;
|
int remainingUsers = 8 - i;
|
||||||
|
|
||||||
int displayedUsers = remainingUsers > 3 ? 2 : remainingUsers;
|
int displayedUsers = remainingUsers > 4 ? 3 : remainingUsers;
|
||||||
AddAssert($"{displayedUsers} avatars displayed", () => list.ChildrenOfType<UpdateableAvatar>().Count() == displayedUsers);
|
AddAssert($"{displayedUsers} avatars displayed", () => list.ChildrenOfType<UpdateableAvatar>().Count() == displayedUsers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,12 +97,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
});
|
});
|
||||||
|
|
||||||
AddStep("set 3 circles", () => list.NumberOfCircles = 3);
|
AddStep("set 3 circles", () => list.NumberOfCircles = 3);
|
||||||
AddAssert("2 users displayed", () => list.ChildrenOfType<UpdateableAvatar>().Count() == 2);
|
AddAssert("3 users displayed", () => list.ChildrenOfType<UpdateableAvatar>().Count() == 3);
|
||||||
AddAssert("48 hidden users", () => list.ChildrenOfType<RecentParticipantsList.HiddenUserCount>().Single().Count == 48);
|
AddAssert("48 hidden users", () => list.ChildrenOfType<DrawableRoomParticipantsList.HiddenUserCount>().Single().Count == 48);
|
||||||
|
|
||||||
AddStep("set 10 circles", () => list.NumberOfCircles = 10);
|
AddStep("set 10 circles", () => list.NumberOfCircles = 10);
|
||||||
AddAssert("9 users displayed", () => list.ChildrenOfType<UpdateableAvatar>().Count() == 9);
|
AddAssert("10 users displayed", () => list.ChildrenOfType<UpdateableAvatar>().Count() == 10);
|
||||||
AddAssert("41 hidden users", () => list.ChildrenOfType<RecentParticipantsList.HiddenUserCount>().Single().Count == 41);
|
AddAssert("41 hidden users", () => list.ChildrenOfType<DrawableRoomParticipantsList.HiddenUserCount>().Single().Count == 41);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -104,24 +115,24 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
});
|
});
|
||||||
|
|
||||||
AddStep("remove from start", () => removeUserAt(0));
|
AddStep("remove from start", () => removeUserAt(0));
|
||||||
AddAssert("3 circles displayed", () => list.ChildrenOfType<UpdateableAvatar>().Count() == 3);
|
AddAssert("4 circles displayed", () => list.ChildrenOfType<UpdateableAvatar>().Count() == 4);
|
||||||
AddAssert("46 hidden users", () => list.ChildrenOfType<RecentParticipantsList.HiddenUserCount>().Single().Count == 46);
|
AddAssert("46 hidden users", () => list.ChildrenOfType<DrawableRoomParticipantsList.HiddenUserCount>().Single().Count == 46);
|
||||||
|
|
||||||
AddStep("remove from end", () => removeUserAt(SelectedRoom.Value.RecentParticipants.Count - 1));
|
AddStep("remove from end", () => removeUserAt(SelectedRoom.Value.RecentParticipants.Count - 1));
|
||||||
AddAssert("3 circles displayed", () => list.ChildrenOfType<UpdateableAvatar>().Count() == 3);
|
AddAssert("4 circles displayed", () => list.ChildrenOfType<UpdateableAvatar>().Count() == 4);
|
||||||
AddAssert("45 hidden users", () => list.ChildrenOfType<RecentParticipantsList.HiddenUserCount>().Single().Count == 45);
|
AddAssert("45 hidden users", () => list.ChildrenOfType<DrawableRoomParticipantsList.HiddenUserCount>().Single().Count == 45);
|
||||||
|
|
||||||
AddRepeatStep("remove 45 users", () => removeUserAt(0), 45);
|
AddRepeatStep("remove 45 users", () => removeUserAt(0), 45);
|
||||||
AddAssert("3 circles displayed", () => list.ChildrenOfType<UpdateableAvatar>().Count() == 3);
|
AddAssert("4 circles displayed", () => list.ChildrenOfType<UpdateableAvatar>().Count() == 4);
|
||||||
AddAssert("0 hidden users", () => list.ChildrenOfType<RecentParticipantsList.HiddenUserCount>().Single().Count == 0);
|
AddAssert("0 hidden users", () => list.ChildrenOfType<DrawableRoomParticipantsList.HiddenUserCount>().Single().Count == 0);
|
||||||
AddAssert("hidden users bubble hidden", () => list.ChildrenOfType<RecentParticipantsList.HiddenUserCount>().Single().Alpha < 0.5f);
|
AddAssert("hidden users bubble hidden", () => list.ChildrenOfType<DrawableRoomParticipantsList.HiddenUserCount>().Single().Alpha < 0.5f);
|
||||||
|
|
||||||
AddStep("remove another user", () => removeUserAt(0));
|
AddStep("remove another user", () => removeUserAt(0));
|
||||||
AddAssert("2 circles displayed", () => list.ChildrenOfType<UpdateableAvatar>().Count() == 2);
|
AddAssert("3 circles displayed", () => list.ChildrenOfType<UpdateableAvatar>().Count() == 3);
|
||||||
AddAssert("0 hidden users", () => list.ChildrenOfType<RecentParticipantsList.HiddenUserCount>().Single().Count == 0);
|
AddAssert("0 hidden users", () => list.ChildrenOfType<DrawableRoomParticipantsList.HiddenUserCount>().Single().Count == 0);
|
||||||
|
|
||||||
AddRepeatStep("remove the remaining two users", () => removeUserAt(0), 2);
|
AddRepeatStep("remove the remaining two users", () => removeUserAt(0), 2);
|
||||||
AddAssert("0 circles displayed", () => !list.ChildrenOfType<UpdateableAvatar>().Any());
|
AddAssert("1 circle displayed", () => list.ChildrenOfType<UpdateableAvatar>().Count() == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addUser(int id)
|
private void addUser(int id)
|
@ -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;
|
||||||
@ -38,7 +39,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
private readonly Bindable<RoomCategory> roomCategory = new Bindable<RoomCategory>();
|
private readonly Bindable<RoomCategory> roomCategory = new Bindable<RoomCategory>();
|
||||||
private readonly Bindable<bool> hasPassword = new Bindable<bool>();
|
private readonly Bindable<bool> hasPassword = new Bindable<bool>();
|
||||||
|
|
||||||
private RecentParticipantsList recentParticipantsList;
|
private DrawableRoomParticipantsList drawableRoomParticipantsList;
|
||||||
private RoomSpecialCategoryPill specialCategoryPill;
|
private RoomSpecialCategoryPill specialCategoryPill;
|
||||||
private PasswordProtectedIcon passwordIcon;
|
private PasswordProtectedIcon passwordIcon;
|
||||||
private EndDateInfo endDateInfo;
|
private EndDateInfo endDateInfo;
|
||||||
@ -136,7 +137,8 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
{
|
{
|
||||||
new FillFlowContainer
|
new FillFlowContainer
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
Direction = FillDirection.Vertical,
|
Direction = FillDirection.Vertical,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
@ -166,13 +168,14 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
},
|
},
|
||||||
new FillFlowContainer
|
new FillFlowContainer
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
Padding = new MarginPadding { Top = 3 },
|
Padding = new MarginPadding { Top = 3 },
|
||||||
Direction = FillDirection.Vertical,
|
Direction = FillDirection.Vertical,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new RoomNameText(),
|
new RoomNameText(),
|
||||||
new RoomHostText(),
|
new RoomStatusText()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -217,7 +220,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
ButtonsContainer,
|
ButtonsContainer,
|
||||||
recentParticipantsList = new RecentParticipantsList
|
drawableRoomParticipantsList = new DrawableRoomParticipantsList
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreRight,
|
Anchor = Anchor.CentreRight,
|
||||||
Origin = Anchor.CentreRight,
|
Origin = Anchor.CentreRight,
|
||||||
@ -280,8 +283,8 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
{
|
{
|
||||||
numberOfAvatars = value;
|
numberOfAvatars = value;
|
||||||
|
|
||||||
if (recentParticipantsList != null)
|
if (drawableRoomParticipantsList != null)
|
||||||
recentParticipantsList.NumberOfCircles = value;
|
drawableRoomParticipantsList.NumberOfCircles = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,38 +307,87 @@ 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 SpriteText statusText;
|
||||||
|
private LinkFlowContainer beatmapText;
|
||||||
|
|
||||||
|
public RoomStatusText()
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.X;
|
||||||
|
AutoSizeAxes = Axes.Y;
|
||||||
|
Width = 0.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
InternalChild = hostText = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 16))
|
InternalChild = new GridContainer
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
ColumnDimensions = new[]
|
||||||
|
{
|
||||||
|
new Dimension(GridSizeMode.AutoSize),
|
||||||
|
},
|
||||||
|
RowDimensions = new[]
|
||||||
|
{
|
||||||
|
new Dimension(GridSizeMode.AutoSize)
|
||||||
|
},
|
||||||
|
Content = new[]
|
||||||
|
{
|
||||||
|
new Drawable[]
|
||||||
|
{
|
||||||
|
statusText = new OsuSpriteText
|
||||||
|
{
|
||||||
|
Font = OsuFont.Default.With(size: 16),
|
||||||
|
Colour = colours.Lime1
|
||||||
|
},
|
||||||
|
beatmapText = new LinkFlowContainer(s =>
|
||||||
|
{
|
||||||
|
s.Font = OsuFont.Default.With(size: 16);
|
||||||
|
s.Colour = colours.Lime1;
|
||||||
|
})
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
{
|
||||||
|
beatmapText.Clear();
|
||||||
|
|
||||||
|
if (Type.Value == MatchType.Playlists)
|
||||||
{
|
{
|
||||||
hostText.Clear();
|
statusText.Text = "Ready to play";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (host.NewValue != null)
|
if (item.NewValue?.Beatmap.Value != null)
|
||||||
{
|
{
|
||||||
hostText.AddText("hosted by ");
|
statusText.Text = "Currently playing ";
|
||||||
hostText.AddUserLink(host.NewValue);
|
beatmapText.AddLink(item.NewValue.Beatmap.Value.ToRomanisableString(),
|
||||||
}
|
LinkAction.OpenBeatmap,
|
||||||
}, true);
|
item.NewValue.Beatmap.Value.OnlineBeatmapID.ToString(),
|
||||||
|
creationParameters: s =>
|
||||||
|
{
|
||||||
|
s.Truncate = true;
|
||||||
|
s.RelativeSizeAxes = Axes.X;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,11 +4,13 @@
|
|||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
@ -17,16 +19,18 @@ using osuTK;
|
|||||||
|
|
||||||
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||||
{
|
{
|
||||||
public class RecentParticipantsList : OnlinePlayComposite
|
public class DrawableRoomParticipantsList : OnlinePlayComposite
|
||||||
{
|
{
|
||||||
private const float avatar_size = 36;
|
private const float avatar_size = 36;
|
||||||
|
|
||||||
private FillFlowContainer<CircularAvatar> avatarFlow;
|
private FillFlowContainer<CircularAvatar> avatarFlow;
|
||||||
|
|
||||||
|
private CircularAvatar hostAvatar;
|
||||||
|
private LinkFlowContainer hostText;
|
||||||
private HiddenUserCount hiddenUsers;
|
private HiddenUserCount hiddenUsers;
|
||||||
private OsuSpriteText totalCount;
|
private OsuSpriteText totalCount;
|
||||||
|
|
||||||
public RecentParticipantsList()
|
public DrawableRoomParticipantsList()
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.X;
|
AutoSizeAxes = Axes.X;
|
||||||
Height = 60;
|
Height = 60;
|
||||||
@ -51,42 +55,98 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
},
|
},
|
||||||
new FillFlowContainer
|
new FillFlowContainer
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
RelativeSizeAxes = Axes.Y,
|
||||||
Origin = Anchor.Centre,
|
AutoSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Direction = FillDirection.Horizontal,
|
|
||||||
Spacing = new Vector2(4),
|
|
||||||
Padding = new MarginPadding { Right = 16 },
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new SpriteIcon
|
new FillFlowContainer
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
RelativeSizeAxes = Axes.Y,
|
||||||
Origin = Anchor.CentreLeft,
|
AutoSizeAxes = Axes.X,
|
||||||
Size = new Vector2(16),
|
Spacing = new Vector2(8),
|
||||||
Margin = new MarginPadding { Left = 8 },
|
Padding = new MarginPadding
|
||||||
Icon = FontAwesome.Solid.User,
|
{
|
||||||
|
Left = 8,
|
||||||
|
Right = 16
|
||||||
|
},
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
hostAvatar = new CircularAvatar
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
},
|
||||||
|
hostText = new LinkFlowContainer
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
AutoSizeAxes = Axes.Both
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
totalCount = new OsuSpriteText
|
new Container
|
||||||
{
|
{
|
||||||
Font = OsuFont.Default.With(weight: FontWeight.Bold),
|
RelativeSizeAxes = Axes.Y,
|
||||||
Anchor = Anchor.CentreLeft,
|
AutoSizeAxes = Axes.X,
|
||||||
Origin = Anchor.CentreLeft,
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Masking = true,
|
||||||
|
CornerRadius = 10,
|
||||||
|
Shear = new Vector2(0.2f, 0),
|
||||||
|
Child = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = colours.Background3,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
Spacing = new Vector2(4),
|
||||||
|
Padding = new MarginPadding
|
||||||
|
{
|
||||||
|
Left = 8,
|
||||||
|
Right = 16
|
||||||
|
},
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new SpriteIcon
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
Size = new Vector2(16),
|
||||||
|
Icon = FontAwesome.Solid.User,
|
||||||
|
},
|
||||||
|
totalCount = new OsuSpriteText
|
||||||
|
{
|
||||||
|
Font = OsuFont.Default.With(weight: FontWeight.Bold),
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
},
|
||||||
|
avatarFlow = new FillFlowContainer<CircularAvatar>
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
Spacing = new Vector2(4),
|
||||||
|
Margin = new MarginPadding { Left = 4 },
|
||||||
|
},
|
||||||
|
hiddenUsers = new HiddenUserCount
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
avatarFlow = new FillFlowContainer<CircularAvatar>
|
|
||||||
{
|
|
||||||
Anchor = Anchor.CentreLeft,
|
|
||||||
Origin = Anchor.CentreLeft,
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Direction = FillDirection.Horizontal,
|
|
||||||
Spacing = new Vector2(4),
|
|
||||||
Margin = new MarginPadding { Left = 4 },
|
|
||||||
},
|
|
||||||
hiddenUsers = new HiddenUserCount
|
|
||||||
{
|
|
||||||
Anchor = Anchor.CentreLeft,
|
|
||||||
Origin = Anchor.CentreLeft,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -102,6 +162,8 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
updateHiddenUsers();
|
updateHiddenUsers();
|
||||||
totalCount.Text = ParticipantCount.Value.ToString();
|
totalCount.Text = ParticipantCount.Value.ToString();
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
|
Host.BindValueChanged(onHostChanged, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int numberOfCircles = 4;
|
private int numberOfCircles = 4;
|
||||||
@ -194,6 +256,18 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onHostChanged(ValueChangedEvent<User> host)
|
||||||
|
{
|
||||||
|
hostAvatar.User = host.NewValue;
|
||||||
|
hostText.Clear();
|
||||||
|
|
||||||
|
if (host.NewValue != null)
|
||||||
|
{
|
||||||
|
hostText.AddText("hosted by ");
|
||||||
|
hostText.AddUserLink(host.NewValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class CircularAvatar : CompositeDrawable
|
private class CircularAvatar : CompositeDrawable
|
||||||
{
|
{
|
||||||
public User User
|
public User User
|
@ -12,7 +12,7 @@ using osuTK;
|
|||||||
|
|
||||||
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
||||||
{
|
{
|
||||||
public class BeatmapSelectionControl : RoomSubScreenComposite
|
public class BeatmapSelectionControl : OnlinePlayComposite
|
||||||
{
|
{
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private MultiplayerMatchSubScreen matchSubScreen { get; set; }
|
private MultiplayerMatchSubScreen matchSubScreen { get; set; }
|
||||||
|
@ -65,8 +65,11 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
[Resolved(typeof(Room))]
|
[Resolved(typeof(Room))]
|
||||||
protected Bindable<TimeSpan?> Duration { get; private set; }
|
protected Bindable<TimeSpan?> Duration { get; private set; }
|
||||||
|
|
||||||
|
[Resolved(CanBeNull = true)]
|
||||||
|
private IBindable<PlaylistItem> subScreenSelectedItem { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The currently selected item in the <see cref="RoomSubScreen"/>, or the first item from <see cref="Playlist"/>
|
/// The currently selected item in the <see cref="RoomSubScreen"/>, or the last item from <see cref="Playlist"/>
|
||||||
/// if this <see cref="OnlinePlayComposite"/> is not within a <see cref="RoomSubScreen"/>.
|
/// if this <see cref="OnlinePlayComposite"/> is not within a <see cref="RoomSubScreen"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected readonly Bindable<PlaylistItem> SelectedItem = new Bindable<PlaylistItem>();
|
protected readonly Bindable<PlaylistItem> SelectedItem = new Bindable<PlaylistItem>();
|
||||||
@ -75,12 +78,13 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
|
subScreenSelectedItem?.BindValueChanged(_ => UpdateSelectedItem());
|
||||||
Playlist.BindCollectionChanged((_, __) => UpdateSelectedItem(), true);
|
Playlist.BindCollectionChanged((_, __) => UpdateSelectedItem(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void UpdateSelectedItem()
|
protected virtual void UpdateSelectedItem()
|
||||||
{
|
=> SelectedItem.Value = RoomID.Value == null || subScreenSelectedItem == null
|
||||||
SelectedItem.Value = Playlist.FirstOrDefault();
|
? Playlist.LastOrDefault()
|
||||||
}
|
: subScreenSelectedItem.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,38 +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.Bindables;
|
|
||||||
using osu.Game.Online.Rooms;
|
|
||||||
using osu.Game.Screens.OnlinePlay.Match;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.OnlinePlay
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// An <see cref="OnlinePlayComposite"/> with additional logic tracking the currently-selected <see cref="PlaylistItem"/> inside a <see cref="RoomSubScreen"/>.
|
|
||||||
/// </summary>
|
|
||||||
public class RoomSubScreenComposite : OnlinePlayComposite
|
|
||||||
{
|
|
||||||
[Resolved]
|
|
||||||
private IBindable<PlaylistItem> subScreenSelectedItem { get; set; }
|
|
||||||
|
|
||||||
protected override void LoadComplete()
|
|
||||||
{
|
|
||||||
base.LoadComplete();
|
|
||||||
|
|
||||||
subScreenSelectedItem.BindValueChanged(_ => UpdateSelectedItem(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void UpdateSelectedItem()
|
|
||||||
{
|
|
||||||
if (RoomID.Value == null)
|
|
||||||
{
|
|
||||||
// If the room hasn't been created yet, fall-back to the base logic.
|
|
||||||
base.UpdateSelectedItem();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SelectedItem.Value = subScreenSelectedItem.Value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user