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

Centralise fullscreen overlay logic

This commit is contained in:
Dean Herbert 2019-05-14 14:18:06 +09:00
parent ebfcc8b3ec
commit cb2b14e501
6 changed files with 70 additions and 82 deletions

View File

@ -4,10 +4,8 @@
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;
@ -19,11 +17,10 @@ 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;
@ -46,24 +43,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[]
{

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,58 @@
// 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.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 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,64 +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();
@ -154,7 +121,7 @@ namespace osu.Game.Overlays
{
userReq = new GetUserRequest(user.Id);
userReq.Success += userLoadComplete;
api.Queue(userReq);
API.Queue(userReq);
}
else
{