1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 14:17:26 +08:00

Add very temporary data source for social browser

This commit is contained in:
Dean Herbert 2017-06-07 20:05:43 +09:00
parent 1de296747f
commit 6a12173175
3 changed files with 69 additions and 7 deletions

View File

@ -0,0 +1,24 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using Newtonsoft.Json;
using osu.Game.Users;
namespace osu.Game.Online.API.Requests
{
public class GetUsersRequest : APIRequest<List<RankingEntry>>
{
public GetUsersRequest()
{
}
protected override string Target => $@"rankings/osu/performance";
}
public class RankingEntry
{
[JsonProperty]
public User User;
}
}

View File

@ -3,18 +3,21 @@
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Overlays.SearchableList;
using osu.Game.Overlays.Social;
using osu.Game.Users;
namespace osu.Game.Overlays
{
public class SocialOverlay : SearchableListOverlay<SocialTab, SocialSortCriteria, SortDirection>
public class SocialOverlay : SearchableListOverlay<SocialTab, SocialSortCriteria, SortDirection>, IOnlineComponent
{
private readonly FillFlowContainer<UserPanel> panelFlow;
@ -34,12 +37,17 @@ namespace osu.Game.Overlays
if (users?.Equals(value) ?? false) return;
users = value;
panelFlow.Children = users.Select(u =>
if (users == null)
panelFlow.Clear();
else
{
var p = new UserPanel(u) { Width = 300 };
p.Status.BindTo(u.Status);
return p;
});
panelFlow.Children = users.Select(u =>
{
var p = new UserPanel(u) { Width = 300 };
p.Status.BindTo(u.Status);
return p;
});
}
}
}
@ -61,11 +69,40 @@ namespace osu.Game.Overlays
},
};
}
[BackgroundDependencyLoader]
private void load(APIAccess api)
{
reloadUsers(api);
}
private void reloadUsers(APIAccess api)
{
Users = null;
// no this is not the correct data source, but it's something.
var request = new GetUsersRequest();
request.Success += res => Users = res.Select(e => e.User);
api.Queue(request);
}
public void APIStateChanged(APIAccess api, APIState state)
{
switch (state)
{
case APIState.Online:
reloadUsers(api);
break;
default:
Users = null;
break;
}
}
}
public enum SortDirection
{
Ascending,
Descending,
Ascending,
}
}

View File

@ -76,6 +76,7 @@
<Compile Include="Beatmaps\DifficultyCalculator.cs" />
<Compile Include="Graphics\UserInterface\IconButton.cs" />
<Compile Include="Configuration\SelectionRandomType.cs" />
<Compile Include="Online\API\Requests\GetUsersRequest.cs" />
<Compile Include="Online\API\Requests\PostMessageRequest.cs" />
<Compile Include="Online\Chat\ErrorMessage.cs" />
<Compile Include="Overlays\Chat\ChatTabControl.cs" />