1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 18:42:56 +08:00

Merge remote-tracking branch 'upstream/master' into exit-hide-music-controller

This commit is contained in:
Dean Herbert 2019-05-14 18:14:57 +09:00
commit a0c03d7fc3
11 changed files with 139 additions and 117 deletions

View File

@ -11,7 +11,7 @@ using osu.Game.Rulesets;
namespace osu.Game.Tests.Visual.Online
{
[TestFixture]
public class TestCaseDirect : OsuTestCase
public class TestCaseDirectOverlay : OsuTestCase
{
private DirectOverlay direct;
private RulesetStore rulesets;

View File

@ -0,0 +1,40 @@
// 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.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Game.Overlays;
using osuTK.Graphics;
namespace osu.Game.Tests.Visual.Online
{
[TestFixture]
public class TestCaseFullscreenOverlay : OsuTestCase
{
private FullscreenOverlay overlay;
protected override void LoadComplete()
{
base.LoadComplete();
Add(overlay = new TestFullscreenOverlay());
AddStep(@"toggle", overlay.ToggleVisibility);
}
private class TestFullscreenOverlay : FullscreenOverlay
{
public TestFullscreenOverlay()
{
Children = new Drawable[]
{
new Box
{
Colour = Color4.Black,
RelativeSizeAxes = Axes.Both,
},
};
}
}
}
}

View File

@ -11,19 +11,18 @@ using osu.Game.Users;
namespace osu.Game.Tests.Visual.Online
{
[TestFixture]
public class TestCaseSocial : OsuTestCase
public class TestCaseSocialOverlay : OsuTestCase
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(UserPanel),
typeof(SocialPanel),
typeof(FilterControl),
typeof(SocialOverlay),
typeof(SocialGridPanel),
typeof(SocialListPanel)
};
public TestCaseSocial()
public TestCaseSocialOverlay()
{
SocialOverlay s = new SocialOverlay
{

View File

@ -38,7 +38,7 @@ namespace osu.Game.Tests.Visual.Online
header = new ProfileHeader();
Add(header);
AddStep("Show offline dummy", () => header.User.Value = TestCaseUserProfile.TEST_USER);
AddStep("Show offline dummy", () => header.User.Value = TestCaseUserProfileOverlay.TEST_USER);
AddStep("Show null dummy", () => header.User.Value = new User
{

View File

@ -17,7 +17,7 @@ using osu.Game.Users;
namespace osu.Game.Tests.Visual.Online
{
[TestFixture]
public class TestCaseUserProfile : OsuTestCase
public class TestCaseUserProfileOverlay : OsuTestCase
{
private readonly TestUserProfileOverlay profile;
@ -27,7 +27,6 @@ namespace osu.Game.Tests.Visual.Online
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(ProfileHeader),
typeof(UserProfileOverlay),
typeof(RankGraph),
typeof(LineGraph),
typeof(SectionsContainer<>),
@ -72,7 +71,7 @@ namespace osu.Game.Tests.Visual.Online
Achievements = new User.UserAchievement[0],
};
public TestCaseUserProfile()
public TestCaseUserProfileOverlay()
{
Add(profile = new TestUserProfileOverlay());
}

View File

@ -4,26 +4,22 @@
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Overlays.BeatmapSet;
using osu.Game.Overlays.BeatmapSet.Scores;
using osu.Game.Rulesets;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Overlays
{
public class BeatmapSetOverlay : WaveOverlayContainer
public class BeatmapSetOverlay : FullscreenOverlay
{
private const int fade_duration = 300;
@ -32,7 +28,6 @@ namespace osu.Game.Overlays
private readonly Header header;
private IAPIProvider api;
private RulesetStore rulesets;
private readonly ScrollContainer scroll;
@ -46,24 +41,6 @@ namespace osu.Game.Overlays
{
Info info;
ScoresContainer scores;
Waves.FirstWaveColour = OsuColour.Gray(0.4f);
Waves.SecondWaveColour = OsuColour.Gray(0.3f);
Waves.ThirdWaveColour = OsuColour.Gray(0.2f);
Waves.FourthWaveColour = OsuColour.Gray(0.1f);
Anchor = Anchor.TopCentre;
Origin = Anchor.TopCentre;
RelativeSizeAxes = Axes.Both;
Width = 0.85f;
Masking = true;
EdgeEffect = new EdgeEffectParameters
{
Colour = Color4.Black.Opacity(0),
Type = EdgeEffectType.Shadow,
Radius = 3,
Offset = new Vector2(0f, 1f),
};
Children = new Drawable[]
{
@ -102,22 +79,15 @@ namespace osu.Game.Overlays
}
[BackgroundDependencyLoader]
private void load(IAPIProvider api, RulesetStore rulesets)
private void load(RulesetStore rulesets)
{
this.api = api;
this.rulesets = rulesets;
}
protected override void PopIn()
protected override void PopOutComplete()
{
base.PopIn();
FadeEdgeEffectTo(0.25f, WaveContainer.APPEAR_DURATION, Easing.In);
}
protected override void PopOut()
{
base.PopOut();
FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.Out).OnComplete(_ => beatmapSet.Value = null);
base.PopOutComplete();
beatmapSet.Value = null;
}
protected override bool OnClick(ClickEvent e)
@ -135,7 +105,7 @@ namespace osu.Game.Overlays
beatmapSet.Value = res.ToBeatmapSet(rulesets);
header.Picker.Beatmap.Value = header.BeatmapSet.Value.Beatmaps.First(b => b.OnlineBeatmapID == beatmapId);
};
api.Queue(req);
API.Queue(req);
Show();
}
@ -144,7 +114,7 @@ namespace osu.Game.Overlays
beatmapSet.Value = null;
var req = new GetBeatmapSetRequest(beatmapSetId);
req.Success += res => beatmapSet.Value = res.ToBeatmapSet(rulesets);
api.Queue(req);
API.Queue(req);
Show();
}

View File

@ -14,7 +14,6 @@ using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Overlays.Direct;
using osu.Game.Overlays.SearchableList;
@ -28,7 +27,6 @@ namespace osu.Game.Overlays
{
private const float panel_padding = 10f;
private IAPIProvider api;
private RulesetStore rulesets;
private readonly FillFlowContainer resultCountsContainer;
@ -87,8 +85,6 @@ namespace osu.Game.Overlays
public DirectOverlay()
{
RelativeSizeAxes = Axes.Both;
// osu!direct colours are not part of the standard palette
Waves.FirstWaveColour = OsuColour.FromHex(@"19b0e2");
@ -165,9 +161,8 @@ namespace osu.Game.Overlays
}
[BackgroundDependencyLoader]
private void load(OsuColour colours, IAPIProvider api, RulesetStore rulesets, PreviewTrackManager previewTrackManager)
private void load(OsuColour colours, RulesetStore rulesets, PreviewTrackManager previewTrackManager)
{
this.api = api;
this.rulesets = rulesets;
this.previewTrackManager = previewTrackManager;
@ -260,7 +255,7 @@ namespace osu.Game.Overlays
if (State == Visibility.Hidden)
return;
if (api == null)
if (API == null)
return;
previewTrackManager.StopAnyPlaying(this);
@ -286,7 +281,7 @@ namespace osu.Game.Overlays
});
};
api.Queue(getSetsRequest);
API.Queue(getSetsRequest);
}
private int distinctCount(List<string> list) => list.Distinct().ToArray().Length;

View File

@ -0,0 +1,75 @@
// 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.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Effects;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Online.API;
using osuTK.Graphics;
namespace osu.Game.Overlays
{
public abstract class FullscreenOverlay : WaveOverlayContainer, IOnlineComponent
{
[Resolved]
protected IAPIProvider API { get; private set; }
protected FullscreenOverlay()
{
Waves.FirstWaveColour = OsuColour.Gray(0.4f);
Waves.SecondWaveColour = OsuColour.Gray(0.3f);
Waves.ThirdWaveColour = OsuColour.Gray(0.2f);
Waves.FourthWaveColour = OsuColour.Gray(0.1f);
RelativeSizeAxes = Axes.Both;
RelativePositionAxes = Axes.Both;
Width = 0.85f;
Anchor = Anchor.TopCentre;
Origin = Anchor.TopCentre;
Masking = true;
EdgeEffect = new EdgeEffectParameters
{
Colour = Color4.Black.Opacity(0),
Type = EdgeEffectType.Shadow,
Radius = 10
};
}
protected override void PopIn()
{
base.PopIn();
FadeEdgeEffectTo(0.4f, WaveContainer.APPEAR_DURATION, Easing.Out);
}
protected override void PopOut()
{
base.PopOut();
FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.In).OnComplete(_ => PopOutComplete());
}
protected virtual void PopOutComplete()
{
}
protected override void LoadComplete()
{
base.LoadComplete();
API.Register(this);
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
API?.Unregister(this);
}
public virtual void APIStateChanged(IAPIProvider api, APIState state)
{
}
}
}

View File

@ -11,7 +11,7 @@ using osu.Game.Graphics.Containers;
namespace osu.Game.Overlays.SearchableList
{
public abstract class SearchableListOverlay : WaveOverlayContainer
public abstract class SearchableListOverlay : FullscreenOverlay
{
public static readonly float WIDTH_PADDING = 80;
}
@ -32,8 +32,6 @@ namespace osu.Game.Overlays.SearchableList
protected SearchableListOverlay()
{
RelativeSizeAxes = Axes.Both;
Children = new Drawable[]
{
new Box

View File

@ -3,7 +3,6 @@
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osuTK;
using osuTK.Graphics;
@ -20,9 +19,8 @@ using osu.Framework.Threading;
namespace osu.Game.Overlays
{
public class SocialOverlay : SearchableListOverlay<SocialTab, SocialSortCriteria, SortDirection>, IOnlineComponent
public class SocialOverlay : SearchableListOverlay<SocialTab, SocialSortCriteria, SortDirection>
{
private IAPIProvider api;
private readonly LoadingAnimation loading;
private FillFlowContainer<SocialPanel> panels;
@ -88,13 +86,6 @@ namespace osu.Game.Overlays
currentQuery.BindTo(Filter.Search.Current);
}
[BackgroundDependencyLoader]
private void load(IAPIProvider api)
{
this.api = api;
api.Register(this);
}
private void recreatePanels(PanelDisplayStyle displayStyle)
{
clearPanels();
@ -159,7 +150,7 @@ namespace osu.Game.Overlays
loading.Hide();
getUsersRequest?.Cancel();
if (api?.IsLoggedIn != true)
if (API?.IsLoggedIn != true)
return;
switch (Header.Tabs.Current.Value)
@ -167,13 +158,13 @@ namespace osu.Game.Overlays
case SocialTab.Friends:
var friendRequest = new GetFriendsRequest(); // TODO filter arguments?
friendRequest.Success += updateUsers;
api.Queue(getUsersRequest = friendRequest);
API.Queue(getUsersRequest = friendRequest);
break;
default:
var userRequest = new GetUsersRequest(); // TODO filter arguments!
userRequest.Success += response => updateUsers(response.Select(r => r.User));
api.Queue(getUsersRequest = userRequest);
API.Queue(getUsersRequest = userRequest);
break;
}
@ -196,7 +187,7 @@ namespace osu.Game.Overlays
}
}
public void APIStateChanged(IAPIProvider api, APIState state)
public override void APIStateChanged(IAPIProvider api, APIState state)
{
switch (state)
{

View File

@ -3,76 +3,31 @@
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Overlays.Profile;
using osu.Game.Overlays.Profile.Sections;
using osu.Game.Users;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Overlays
{
public class UserProfileOverlay : WaveOverlayContainer
public class UserProfileOverlay : FullscreenOverlay
{
private ProfileSection lastSection;
private ProfileSection[] sections;
private GetUserRequest userReq;
private IAPIProvider api;
protected ProfileHeader Header;
private SectionsContainer<ProfileSection> sectionsContainer;
private ProfileTabControl tabs;
public const float CONTENT_X_MARGIN = 70;
public UserProfileOverlay()
{
Waves.FirstWaveColour = OsuColour.Gray(0.4f);
Waves.SecondWaveColour = OsuColour.Gray(0.3f);
Waves.ThirdWaveColour = OsuColour.Gray(0.2f);
Waves.FourthWaveColour = OsuColour.Gray(0.1f);
RelativeSizeAxes = Axes.Both;
RelativePositionAxes = Axes.Both;
Width = 0.85f;
Anchor = Anchor.TopCentre;
Origin = Anchor.TopCentre;
Masking = true;
EdgeEffect = new EdgeEffectParameters
{
Colour = Color4.Black.Opacity(0),
Type = EdgeEffectType.Shadow,
Radius = 10
};
}
[BackgroundDependencyLoader]
private void load(IAPIProvider api)
{
this.api = api;
}
protected override void PopIn()
{
base.PopIn();
FadeEdgeEffectTo(0.5f, WaveContainer.APPEAR_DURATION, Easing.In);
}
protected override void PopOut()
{
base.PopOut();
FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.Out);
}
public void ShowUser(long userId) => ShowUser(new User { Id = userId });
public void ShowUser(User user, bool fetchOnline = true)
@ -154,7 +109,7 @@ namespace osu.Game.Overlays
{
userReq = new GetUserRequest(user.Id);
userReq.Success += userLoadComplete;
api.Queue(userReq);
API.Queue(userReq);
}
else
{