mirror of
https://github.com/ppy/osu
synced 2024-12-25 08:12:41 +00:00
Extract participants list from the room inspector
This commit is contained in:
parent
80fd9485a9
commit
c75a774297
@ -0,0 +1,20 @@
|
||||
// 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.Graphics;
|
||||
using osu.Game.Screens.Multi.Components;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
public class TestSceneParticipantsList : MultiplayerTestScene
|
||||
{
|
||||
protected override bool UseOnlineAPI => true;
|
||||
|
||||
public TestSceneParticipantsList()
|
||||
{
|
||||
Room.RoomID.Value = 7;
|
||||
|
||||
Add(new ParticipantsList { RelativeSizeAxes = Axes.Both });
|
||||
}
|
||||
}
|
||||
}
|
119
osu.Game/Screens/Multi/Components/ParticipantsList.cs
Normal file
119
osu.Game/Screens/Multi/Components/ParticipantsList.cs
Normal file
@ -0,0 +1,119 @@
|
||||
// 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 System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Users;
|
||||
using osu.Game.Users.Drawables;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Multi.Components
|
||||
{
|
||||
public class ParticipantsList : MultiplayerComposite
|
||||
{
|
||||
private readonly FillFlowContainer fill;
|
||||
|
||||
public ParticipantsList()
|
||||
{
|
||||
InternalChild = new OsuScrollContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = fill = new FillFlowContainer
|
||||
{
|
||||
Spacing = new Vector2(10),
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Full,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
RoomID.BindValueChanged(_ => updateParticipants(), true);
|
||||
}
|
||||
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
private GetRoomScoresRequest request;
|
||||
|
||||
private void updateParticipants()
|
||||
{
|
||||
var roomId = RoomID.Value ?? 0;
|
||||
|
||||
request?.Cancel();
|
||||
|
||||
// nice little progressive fade
|
||||
int time = 500;
|
||||
|
||||
foreach (var c in fill.Children)
|
||||
{
|
||||
c.Delay(500 - time).FadeOut(time, Easing.Out);
|
||||
time = Math.Max(20, time - 20);
|
||||
c.Expire();
|
||||
}
|
||||
|
||||
if (roomId == 0) return;
|
||||
|
||||
request = new GetRoomScoresRequest(roomId);
|
||||
request.Success += scores => Schedule(() =>
|
||||
{
|
||||
if (roomId != RoomID.Value)
|
||||
return;
|
||||
|
||||
fill.Clear();
|
||||
foreach (var s in scores)
|
||||
fill.Add(new UserTile(s.User));
|
||||
|
||||
fill.FadeInFromZero(1000, Easing.OutQuint);
|
||||
});
|
||||
|
||||
api.Queue(request);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
request?.Cancel();
|
||||
base.Dispose(isDisposing);
|
||||
}
|
||||
|
||||
private class UserTile : CompositeDrawable, IHasTooltip
|
||||
{
|
||||
private readonly User user;
|
||||
|
||||
public string TooltipText => user.Username;
|
||||
|
||||
public UserTile(User user)
|
||||
{
|
||||
this.user = user;
|
||||
Size = new Vector2(70f);
|
||||
CornerRadius = 5f;
|
||||
Masking = true;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = OsuColour.FromHex(@"27252d"),
|
||||
},
|
||||
new UpdateableAvatar
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
User = user,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,25 +1,18 @@
|
||||
// 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 System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Screens.Multi.Components;
|
||||
using osu.Game.Users;
|
||||
using osu.Game.Users.Drawables;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -160,9 +153,11 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
||||
},
|
||||
new Drawable[]
|
||||
{
|
||||
new MatchParticipants
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding { Horizontal = 10 },
|
||||
Child = new ParticipantsList { RelativeSizeAxes = Axes.Both }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -219,107 +214,5 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
||||
status.BindValueChanged(s => Text = s.NewValue.Message, true);
|
||||
}
|
||||
}
|
||||
|
||||
private class MatchParticipants : MultiplayerComposite
|
||||
{
|
||||
private readonly FillFlowContainer fill;
|
||||
|
||||
public MatchParticipants()
|
||||
{
|
||||
Padding = new MarginPadding { Horizontal = 10 };
|
||||
|
||||
InternalChild = new OsuScrollContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = fill = new FillFlowContainer
|
||||
{
|
||||
Spacing = new Vector2(10),
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Full,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
RoomID.BindValueChanged(_ => updateParticipants(), true);
|
||||
}
|
||||
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
private GetRoomScoresRequest request;
|
||||
|
||||
private void updateParticipants()
|
||||
{
|
||||
var roomId = RoomID.Value ?? 0;
|
||||
|
||||
request?.Cancel();
|
||||
|
||||
// nice little progressive fade
|
||||
int time = 500;
|
||||
|
||||
foreach (var c in fill.Children)
|
||||
{
|
||||
c.Delay(500 - time).FadeOut(time, Easing.Out);
|
||||
time = Math.Max(20, time - 20);
|
||||
c.Expire();
|
||||
}
|
||||
|
||||
if (roomId == 0) return;
|
||||
|
||||
request = new GetRoomScoresRequest(roomId);
|
||||
request.Success += scores =>
|
||||
{
|
||||
if (roomId != RoomID.Value)
|
||||
return;
|
||||
|
||||
fill.Clear();
|
||||
foreach (var s in scores)
|
||||
fill.Add(new UserTile(s.User));
|
||||
|
||||
fill.FadeInFromZero(1000, Easing.OutQuint);
|
||||
};
|
||||
|
||||
api.Queue(request);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
request?.Cancel();
|
||||
base.Dispose(isDisposing);
|
||||
}
|
||||
|
||||
private class UserTile : CompositeDrawable, IHasTooltip
|
||||
{
|
||||
private readonly User user;
|
||||
|
||||
public string TooltipText => user.Username;
|
||||
|
||||
public UserTile(User user)
|
||||
{
|
||||
this.user = user;
|
||||
Size = new Vector2(70f);
|
||||
CornerRadius = 5f;
|
||||
Masking = true;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = OsuColour.FromHex(@"27252d"),
|
||||
},
|
||||
new UpdateableAvatar
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
User = user,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user