mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 11:42:56 +08:00
Remove unnecessary inheritance to OverlayView
This commit is contained in:
parent
5e4f667cff
commit
9c22753f3f
@ -20,7 +20,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
[Cached]
|
||||
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
|
||||
|
||||
private TestFriendDisplay display;
|
||||
private FriendDisplay display;
|
||||
|
||||
[SetUp]
|
||||
public void Setup() => Schedule(() =>
|
||||
@ -28,7 +28,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
Child = new BasicScrollContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = display = new TestFriendDisplay()
|
||||
Child = display = new FriendDisplay()
|
||||
};
|
||||
});
|
||||
|
||||
@ -41,7 +41,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
[Test]
|
||||
public void TestOnline()
|
||||
{
|
||||
AddStep("Fetch online", () => display?.Fetch());
|
||||
// No need to do anything, fetch is performed automatically.
|
||||
}
|
||||
|
||||
private List<User> getUsers() => new List<User>
|
||||
@ -76,10 +76,5 @@ namespace osu.Game.Tests.Visual.Online
|
||||
LastVisit = DateTimeOffset.Now
|
||||
}
|
||||
};
|
||||
|
||||
private class TestFriendDisplay : FriendDisplay
|
||||
{
|
||||
public void Fetch() => PerformFetch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,16 +5,18 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Users;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays.Dashboard.Friends
|
||||
{
|
||||
public class FriendDisplay : OverlayView<List<User>>
|
||||
public class FriendDisplay : CompositeDrawable
|
||||
{
|
||||
private List<User> users = new List<User>();
|
||||
|
||||
@ -39,8 +41,16 @@ namespace osu.Game.Overlays.Dashboard.Friends
|
||||
private Container itemsPlaceholder;
|
||||
private LoadingLayer loading;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
private readonly IBindableList<User> apiFriends = new BindableList<User>();
|
||||
|
||||
public FriendDisplay()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(OverlayColourProvider colourProvider, IAPIProvider api)
|
||||
{
|
||||
InternalChild = new FillFlowContainer
|
||||
{
|
||||
@ -130,6 +140,9 @@ namespace osu.Game.Overlays.Dashboard.Friends
|
||||
|
||||
background.Colour = colourProvider.Background4;
|
||||
controlBackground.Colour = colourProvider.Background5;
|
||||
|
||||
apiFriends.BindTo(api.Friends);
|
||||
apiFriends.BindCollectionChanged((_, __) => Schedule(() => Users = apiFriends.ToList()), true);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -141,13 +154,6 @@ namespace osu.Game.Overlays.Dashboard.Friends
|
||||
userListToolbar.SortCriteria.BindValueChanged(_ => recreatePanels());
|
||||
}
|
||||
|
||||
protected override void PerformFetch()
|
||||
{
|
||||
base.PerformFetch();
|
||||
|
||||
Users = API.Friends.ToList();
|
||||
}
|
||||
|
||||
private void recreatePanels()
|
||||
{
|
||||
if (!users.Any())
|
||||
|
Loading…
Reference in New Issue
Block a user