mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 12:33:01 +08:00
Merge pull request #9611 from EVAST9919/remove-social
Remove SocialOverlay component as never being used
This commit is contained in:
commit
89d04f797f
@ -1,84 +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 NUnit.Framework;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneSocialOverlay : OsuTestScene
|
||||
{
|
||||
protected override bool UseOnlineAPI => true;
|
||||
|
||||
public TestSceneSocialOverlay()
|
||||
{
|
||||
SocialOverlay s = new SocialOverlay
|
||||
{
|
||||
Users = new[]
|
||||
{
|
||||
new User
|
||||
{
|
||||
Username = @"flyte",
|
||||
Id = 3103765,
|
||||
Country = new Country { FlagName = @"JP" },
|
||||
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c1.jpg",
|
||||
},
|
||||
new User
|
||||
{
|
||||
Username = @"Cookiezi",
|
||||
Id = 124493,
|
||||
Country = new Country { FlagName = @"KR" },
|
||||
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c2.jpg",
|
||||
},
|
||||
new User
|
||||
{
|
||||
Username = @"Angelsim",
|
||||
Id = 1777162,
|
||||
Country = new Country { FlagName = @"KR" },
|
||||
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
|
||||
},
|
||||
new User
|
||||
{
|
||||
Username = @"Rafis",
|
||||
Id = 2558286,
|
||||
Country = new Country { FlagName = @"PL" },
|
||||
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c4.jpg",
|
||||
},
|
||||
new User
|
||||
{
|
||||
Username = @"hvick225",
|
||||
Id = 50265,
|
||||
Country = new Country { FlagName = @"TW" },
|
||||
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c5.jpg",
|
||||
},
|
||||
new User
|
||||
{
|
||||
Username = @"peppy",
|
||||
Id = 2,
|
||||
Country = new Country { FlagName = @"AU" },
|
||||
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg"
|
||||
},
|
||||
new User
|
||||
{
|
||||
Username = @"filsdelama",
|
||||
Id = 2831793,
|
||||
Country = new Country { FlagName = @"FR" },
|
||||
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c7.jpg"
|
||||
},
|
||||
new User
|
||||
{
|
||||
Username = @"_index",
|
||||
Id = 652457,
|
||||
Country = new Country { FlagName = @"RU" },
|
||||
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c8.jpg"
|
||||
},
|
||||
},
|
||||
};
|
||||
Add(s);
|
||||
|
||||
AddStep(@"toggle", s.ToggleVisibility);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,33 +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.Extensions.Color4Extensions;
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Overlays.SearchableList;
|
||||
|
||||
namespace osu.Game.Overlays.Social
|
||||
{
|
||||
public class FilterControl : SearchableListFilterControl<SocialSortCriteria, SortDirection>
|
||||
{
|
||||
protected override Color4 BackgroundColour => Color4Extensions.FromHex(@"47253a");
|
||||
protected override SocialSortCriteria DefaultTab => SocialSortCriteria.Rank;
|
||||
protected override SortDirection DefaultCategory => SortDirection.Ascending;
|
||||
|
||||
public FilterControl()
|
||||
{
|
||||
Tabs.Margin = new MarginPadding { Top = 10 };
|
||||
}
|
||||
}
|
||||
|
||||
public enum SocialSortCriteria
|
||||
{
|
||||
Rank,
|
||||
Name,
|
||||
Location,
|
||||
//[Description("Time Zone")]
|
||||
//TimeZone,
|
||||
//[Description("World Map")]
|
||||
//WorldMap,
|
||||
}
|
||||
}
|
@ -1,67 +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.Game.Overlays.SearchableList;
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using System.ComponentModel;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Overlays.Social
|
||||
{
|
||||
public class Header : SearchableListHeader<SocialTab>
|
||||
{
|
||||
private OsuSpriteText browser;
|
||||
|
||||
protected override Color4 BackgroundColour => Color4Extensions.FromHex(@"38202e");
|
||||
|
||||
protected override SocialTab DefaultTab => SocialTab.AllPlayers;
|
||||
protected override IconUsage Icon => FontAwesome.Solid.Users;
|
||||
|
||||
protected override Drawable CreateHeaderText()
|
||||
{
|
||||
return new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Children = new[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = "social ",
|
||||
Font = OsuFont.GetFont(size: 25),
|
||||
},
|
||||
browser = new OsuSpriteText
|
||||
{
|
||||
Text = "browser",
|
||||
Font = OsuFont.GetFont(size: 25, weight: FontWeight.Light),
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
browser.Colour = colours.Pink;
|
||||
}
|
||||
}
|
||||
|
||||
public enum SocialTab
|
||||
{
|
||||
[Description("All Players")]
|
||||
AllPlayers,
|
||||
|
||||
[Description("Friends")]
|
||||
Friends,
|
||||
//[Description("Team Members")]
|
||||
//TeamMembers,
|
||||
//[Description("Chat Channels")]
|
||||
//ChatChannels,
|
||||
}
|
||||
}
|
@ -1,242 +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 System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Bindables;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
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;
|
||||
using System.Threading;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Threading;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
public class SocialOverlay : SearchableListOverlay<SocialTab, SocialSortCriteria, SortDirection>
|
||||
{
|
||||
private readonly LoadingSpinner loading;
|
||||
private FillFlowContainer<UserPanel> panels;
|
||||
|
||||
protected override Color4 BackgroundColour => Color4Extensions.FromHex(@"60284b");
|
||||
protected override Color4 TrianglesColourLight => Color4Extensions.FromHex(@"672b51");
|
||||
protected override Color4 TrianglesColourDark => Color4Extensions.FromHex(@"5c2648");
|
||||
|
||||
protected override SearchableListHeader<SocialTab> CreateHeader() => new Header();
|
||||
protected override SearchableListFilterControl<SocialSortCriteria, SortDirection> CreateFilterControl() => new FilterControl();
|
||||
|
||||
private User[] users = Array.Empty<User>();
|
||||
|
||||
public User[] Users
|
||||
{
|
||||
get => users;
|
||||
set
|
||||
{
|
||||
if (users == value)
|
||||
return;
|
||||
|
||||
users = value ?? Array.Empty<User>();
|
||||
|
||||
if (LoadState >= LoadState.Ready)
|
||||
recreatePanels();
|
||||
}
|
||||
}
|
||||
|
||||
public SocialOverlay()
|
||||
: base(OverlayColourScheme.Pink)
|
||||
{
|
||||
Add(loading = new LoadingSpinner());
|
||||
|
||||
Filter.Search.Current.ValueChanged += text =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(text.NewValue))
|
||||
{
|
||||
// force searching in players until searching for friends is supported
|
||||
Header.Tabs.Current.Value = SocialTab.AllPlayers;
|
||||
|
||||
if (Filter.Tabs.Current.Value != SocialSortCriteria.Rank)
|
||||
Filter.Tabs.Current.Value = SocialSortCriteria.Rank;
|
||||
}
|
||||
};
|
||||
|
||||
Header.Tabs.Current.ValueChanged += _ => queueUpdate();
|
||||
Filter.Tabs.Current.ValueChanged += _ => onFilterUpdate();
|
||||
|
||||
Filter.DisplayStyleControl.DisplayStyle.ValueChanged += _ => recreatePanels();
|
||||
Filter.Dropdown.Current.ValueChanged += _ => recreatePanels();
|
||||
|
||||
currentQuery.BindTo(Filter.Search.Current);
|
||||
currentQuery.ValueChanged += query =>
|
||||
{
|
||||
queryChangedDebounce?.Cancel();
|
||||
|
||||
if (string.IsNullOrEmpty(query.NewValue))
|
||||
queueUpdate();
|
||||
else
|
||||
queryChangedDebounce = Scheduler.AddDelayed(updateSearch, 500);
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
recreatePanels();
|
||||
}
|
||||
|
||||
private APIRequest getUsersRequest;
|
||||
|
||||
private readonly Bindable<string> currentQuery = new Bindable<string>();
|
||||
|
||||
private ScheduledDelegate queryChangedDebounce;
|
||||
|
||||
private void queueUpdate() => Scheduler.AddOnce(updateSearch);
|
||||
|
||||
private CancellationTokenSource loadCancellation;
|
||||
|
||||
private void updateSearch()
|
||||
{
|
||||
queryChangedDebounce?.Cancel();
|
||||
|
||||
if (!IsLoaded)
|
||||
return;
|
||||
|
||||
Users = null;
|
||||
clearPanels();
|
||||
getUsersRequest?.Cancel();
|
||||
|
||||
if (API?.IsLoggedIn != true)
|
||||
return;
|
||||
|
||||
switch (Header.Tabs.Current.Value)
|
||||
{
|
||||
case SocialTab.Friends:
|
||||
var friendRequest = new GetFriendsRequest(); // TODO filter arguments?
|
||||
friendRequest.Success += users => Users = users.ToArray();
|
||||
API.Queue(getUsersRequest = friendRequest);
|
||||
break;
|
||||
|
||||
default:
|
||||
var userRequest = new GetUsersRequest(); // TODO filter arguments!
|
||||
userRequest.Success += res => Users = res.Users.Select(r => r.User).ToArray();
|
||||
API.Queue(getUsersRequest = userRequest);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void recreatePanels()
|
||||
{
|
||||
clearPanels();
|
||||
|
||||
if (Users == null)
|
||||
{
|
||||
loading.Hide();
|
||||
return;
|
||||
}
|
||||
|
||||
IEnumerable<User> sortedUsers = Users;
|
||||
|
||||
switch (Filter.Tabs.Current.Value)
|
||||
{
|
||||
case SocialSortCriteria.Location:
|
||||
sortedUsers = sortedUsers.OrderBy(u => u.Country.FullName);
|
||||
break;
|
||||
|
||||
case SocialSortCriteria.Name:
|
||||
sortedUsers = sortedUsers.OrderBy(u => u.Username);
|
||||
break;
|
||||
}
|
||||
|
||||
if (Filter.Dropdown.Current.Value == SortDirection.Descending)
|
||||
sortedUsers = sortedUsers.Reverse();
|
||||
|
||||
var newPanels = new FillFlowContainer<UserPanel>
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Spacing = new Vector2(10f),
|
||||
Margin = new MarginPadding { Top = 10 },
|
||||
ChildrenEnumerable = sortedUsers.Select(u =>
|
||||
{
|
||||
UserPanel panel;
|
||||
|
||||
switch (Filter.DisplayStyleControl.DisplayStyle.Value)
|
||||
{
|
||||
case PanelDisplayStyle.Grid:
|
||||
panel = new UserGridPanel(u)
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Width = 290,
|
||||
};
|
||||
break;
|
||||
|
||||
default:
|
||||
panel = new UserListPanel(u);
|
||||
break;
|
||||
}
|
||||
|
||||
panel.Status.BindTo(u.Status);
|
||||
panel.Activity.BindTo(u.Activity);
|
||||
return panel;
|
||||
})
|
||||
};
|
||||
|
||||
LoadComponentAsync(newPanels, f =>
|
||||
{
|
||||
if (panels != null)
|
||||
ScrollFlow.Remove(panels);
|
||||
|
||||
loading.Hide();
|
||||
ScrollFlow.Add(panels = newPanels);
|
||||
}, (loadCancellation = new CancellationTokenSource()).Token);
|
||||
}
|
||||
|
||||
private void onFilterUpdate()
|
||||
{
|
||||
if (Filter.Tabs.Current.Value == SocialSortCriteria.Rank)
|
||||
{
|
||||
queueUpdate();
|
||||
return;
|
||||
}
|
||||
|
||||
recreatePanels();
|
||||
}
|
||||
|
||||
private void clearPanels()
|
||||
{
|
||||
loading.Show();
|
||||
|
||||
loadCancellation?.Cancel();
|
||||
|
||||
if (panels != null)
|
||||
{
|
||||
panels.Expire();
|
||||
panels = null;
|
||||
}
|
||||
}
|
||||
|
||||
public override void APIStateChanged(IAPIProvider api, APIState state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case APIState.Online:
|
||||
queueUpdate();
|
||||
break;
|
||||
|
||||
default:
|
||||
Users = null;
|
||||
clearPanels();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user