1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-21 20:12:57 +08:00

Move header setting to FullscreenOverlay

This commit is contained in:
Dean Herbert 2020-09-03 16:27:31 +09:00
parent dbf44fbaf2
commit 7bcbac6f45
11 changed files with 54 additions and 58 deletions

View File

@ -12,7 +12,7 @@ namespace osu.Game.Tests.Visual.Online
[TestFixture] [TestFixture]
public class TestSceneFullscreenOverlay : OsuTestScene public class TestSceneFullscreenOverlay : OsuTestScene
{ {
private FullscreenOverlay overlay; private FullscreenOverlay<OverlayHeader> overlay;
protected override void LoadComplete() protected override void LoadComplete()
{ {
@ -38,10 +38,10 @@ namespace osu.Game.Tests.Visual.Online
AddAssert("fire count 3", () => fireCount == 3); AddAssert("fire count 3", () => fireCount == 3);
} }
private class TestFullscreenOverlay : FullscreenOverlay private class TestFullscreenOverlay : FullscreenOverlay<OverlayHeader>
{ {
public TestFullscreenOverlay() public TestFullscreenOverlay()
: base(OverlayColourScheme.Pink) : base(OverlayColourScheme.Pink, null)
{ {
Children = new Drawable[] Children = new Drawable[]
{ {

View File

@ -24,7 +24,7 @@ using osuTK;
namespace osu.Game.Overlays namespace osu.Game.Overlays
{ {
public class BeatmapListingOverlay : FullscreenOverlay public class BeatmapListingOverlay : FullscreenOverlay<BeatmapListingHeader>
{ {
[Resolved] [Resolved]
private PreviewTrackManager previewTrackManager { get; set; } private PreviewTrackManager previewTrackManager { get; set; }
@ -38,7 +38,7 @@ namespace osu.Game.Overlays
private OverlayScrollContainer resultScrollContainer; private OverlayScrollContainer resultScrollContainer;
public BeatmapListingOverlay() public BeatmapListingOverlay()
: base(OverlayColourScheme.Blue) : base(OverlayColourScheme.Blue, new BeatmapListingHeader())
{ {
} }
@ -65,7 +65,7 @@ namespace osu.Game.Overlays
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Children = new Drawable[] Children = new Drawable[]
{ {
new BeatmapListingHeader(), Header,
filterControl = new BeatmapListingFilterControl filterControl = new BeatmapListingFilterControl
{ {
SearchStarted = onSearchStarted, SearchStarted = onSearchStarted,

View File

@ -19,7 +19,7 @@ using osuTK;
namespace osu.Game.Overlays namespace osu.Game.Overlays
{ {
public class BeatmapSetOverlay : FullscreenOverlay public class BeatmapSetOverlay : FullscreenOverlay<OverlayHeader> // we don't provide a standard header for now.
{ {
public const float X_PADDING = 40; public const float X_PADDING = 40;
public const float Y_PADDING = 25; public const float Y_PADDING = 25;
@ -39,7 +39,7 @@ namespace osu.Game.Overlays
private readonly Box background; private readonly Box background;
public BeatmapSetOverlay() public BeatmapSetOverlay()
: base(OverlayColourScheme.Blue) : base(OverlayColourScheme.Blue, null)
{ {
OverlayScrollContainer scroll; OverlayScrollContainer scroll;
Info info; Info info;

View File

@ -21,14 +21,12 @@ using osu.Game.Overlays.Changelog;
namespace osu.Game.Overlays namespace osu.Game.Overlays
{ {
public class ChangelogOverlay : FullscreenOverlay public class ChangelogOverlay : FullscreenOverlay<ChangelogHeader>
{ {
public readonly Bindable<APIChangelogBuild> Current = new Bindable<APIChangelogBuild>(); public readonly Bindable<APIChangelogBuild> Current = new Bindable<APIChangelogBuild>();
private Container<ChangelogContent> content; private Container<ChangelogContent> content;
protected new ChangelogHeader Header;
private SampleChannel sampleBack; private SampleChannel sampleBack;
private List<APIChangelogBuild> builds; private List<APIChangelogBuild> builds;
@ -36,7 +34,7 @@ namespace osu.Game.Overlays
protected List<APIUpdateStream> Streams; protected List<APIUpdateStream> Streams;
public ChangelogOverlay() public ChangelogOverlay()
: base(OverlayColourScheme.Purple) : base(OverlayColourScheme.Purple, new ChangelogHeader())
{ {
} }
@ -61,11 +59,11 @@ namespace osu.Game.Overlays
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Children = new Drawable[] Children = new Drawable[]
{ {
base.Header = Header = new ChangelogHeader Header.With(h =>
{ {
ListingSelected = ShowListing, h.ListingSelected = ShowListing;
Build = { BindTarget = Current } h.Build.BindTarget = Current;
}, }),
content = new Container<ChangelogContent> content = new Container<ChangelogContent>
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,

View File

@ -15,17 +15,21 @@ using osu.Game.Overlays.Dashboard.Friends;
namespace osu.Game.Overlays namespace osu.Game.Overlays
{ {
public class DashboardOverlay : FullscreenOverlay public class DashboardOverlay : FullscreenOverlay<DashboardOverlayHeader>
{ {
private CancellationTokenSource cancellationToken; private CancellationTokenSource cancellationToken;
private Container content; private Container content;
private DashboardOverlayHeader header;
private LoadingLayer loading; private LoadingLayer loading;
private OverlayScrollContainer scrollFlow; private OverlayScrollContainer scrollFlow;
public DashboardOverlay() public DashboardOverlay()
: base(OverlayColourScheme.Purple) : base(OverlayColourScheme.Purple, new DashboardOverlayHeader
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Depth = -float.MaxValue
})
{ {
} }
@ -50,12 +54,7 @@ namespace osu.Game.Overlays
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Children = new Drawable[] Children = new Drawable[]
{ {
Header = header = new DashboardOverlayHeader Header,
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Depth = -float.MaxValue
},
content = new Container content = new Container
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
@ -72,7 +71,7 @@ namespace osu.Game.Overlays
{ {
base.LoadComplete(); base.LoadComplete();
header.Current.BindValueChanged(onTabChanged); Header.Current.BindValueChanged(onTabChanged);
} }
private bool displayUpdateRequired = true; private bool displayUpdateRequired = true;
@ -84,7 +83,7 @@ namespace osu.Game.Overlays
// We don't want to create a new display on every call, only when exiting from fully closed state. // We don't want to create a new display on every call, only when exiting from fully closed state.
if (displayUpdateRequired) if (displayUpdateRequired)
{ {
header.Current.TriggerChange(); Header.Current.TriggerChange();
displayUpdateRequired = false; displayUpdateRequired = false;
} }
} }
@ -136,7 +135,7 @@ namespace osu.Game.Overlays
if (State.Value == Visibility.Hidden) if (State.Value == Visibility.Hidden)
return; return;
header.Current.TriggerChange(); Header.Current.TriggerChange();
} }
protected override void Dispose(bool isDisposing) protected override void Dispose(bool isDisposing)

View File

@ -12,13 +12,14 @@ using osuTK.Graphics;
namespace osu.Game.Overlays namespace osu.Game.Overlays
{ {
public abstract class FullscreenOverlay : WaveOverlayContainer, IOnlineComponent, INamedOverlayComponent public abstract class FullscreenOverlay<T> : WaveOverlayContainer, IOnlineComponent, INamedOverlayComponent
where T : OverlayHeader
{ {
public virtual string IconTexture => Header?.Title.IconTexture ?? string.Empty; public virtual string IconTexture => Header?.Title.IconTexture ?? string.Empty;
public virtual string Title => Header?.Title.Title ?? string.Empty; public virtual string Title => Header?.Title.Title ?? string.Empty;
public virtual string Description => Header?.Title.Description ?? string.Empty; public virtual string Description => Header?.Title.Description ?? string.Empty;
public OverlayHeader Header { get; protected set; } public T Header { get; }
[Resolved] [Resolved]
protected IAPIProvider API { get; private set; } protected IAPIProvider API { get; private set; }
@ -26,8 +27,10 @@ namespace osu.Game.Overlays
[Cached] [Cached]
protected readonly OverlayColourProvider ColourProvider; protected readonly OverlayColourProvider ColourProvider;
protected FullscreenOverlay(OverlayColourScheme colourScheme) protected FullscreenOverlay(OverlayColourScheme colourScheme, T header)
{ {
Header = header;
ColourProvider = new OverlayColourProvider(colourScheme); ColourProvider = new OverlayColourProvider(colourScheme);
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;

View File

@ -13,7 +13,7 @@ using osu.Game.Overlays.News.Displays;
namespace osu.Game.Overlays namespace osu.Game.Overlays
{ {
public class NewsOverlay : FullscreenOverlay public class NewsOverlay : FullscreenOverlay<NewsHeader>
{ {
private readonly Bindable<string> article = new Bindable<string>(null); private readonly Bindable<string> article = new Bindable<string>(null);
@ -22,7 +22,7 @@ namespace osu.Game.Overlays
private OverlayScrollContainer scrollFlow; private OverlayScrollContainer scrollFlow;
public NewsOverlay() public NewsOverlay()
: base(OverlayColourScheme.Purple) : base(OverlayColourScheme.Purple, new NewsHeader())
{ {
} }
@ -47,10 +47,10 @@ namespace osu.Game.Overlays
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Children = new Drawable[] Children = new Drawable[]
{ {
Header = new NewsHeader Header.With(h =>
{ {
ShowFrontPage = ShowFrontPage h.ShowFrontPage = ShowFrontPage;
}, }),
content = new Container content = new Container
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
@ -109,16 +109,14 @@ namespace osu.Game.Overlays
cancellationToken?.Cancel(); cancellationToken?.Cancel();
loading.Show(); loading.Show();
var header = (NewsHeader)Header;
if (e.NewValue == null) if (e.NewValue == null)
{ {
header.SetFrontPage(); Header.SetFrontPage();
LoadDisplay(new FrontPageDisplay()); LoadDisplay(new FrontPageDisplay());
return; return;
} }
header.SetArticle(e.NewValue); Header.SetArticle(e.NewValue);
LoadDisplay(Empty()); LoadDisplay(Empty());
} }

View File

@ -17,7 +17,7 @@ using osuTK.Graphics;
namespace osu.Game.Overlays namespace osu.Game.Overlays
{ {
/// <summary> /// <summary>
/// <see cref="OsuScrollContainer"/> which provides <see cref="ScrollToTopButton"/>. Mostly used in <see cref="FullscreenOverlay"/>. /// <see cref="OsuScrollContainer"/> which provides <see cref="ScrollToTopButton"/>. Mostly used in <see cref="FullscreenOverlay{T}"/>.
/// </summary> /// </summary>
public class OverlayScrollContainer : OsuScrollContainer public class OverlayScrollContainer : OsuScrollContainer
{ {

View File

@ -9,7 +9,7 @@ using osu.Game.Online.API;
namespace osu.Game.Overlays namespace osu.Game.Overlays
{ {
/// <summary> /// <summary>
/// A subview containing online content, to be displayed inside a <see cref="FullscreenOverlay"/>. /// A subview containing online content, to be displayed inside a <see cref="FullscreenOverlay{T}"/>.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// Automatically performs a data fetch on load. /// Automatically performs a data fetch on load.

View File

@ -17,17 +17,16 @@ using osu.Game.Overlays.Rankings.Tables;
namespace osu.Game.Overlays namespace osu.Game.Overlays
{ {
public class RankingsOverlay : FullscreenOverlay public class RankingsOverlay : FullscreenOverlay<RankingsOverlayHeader>
{ {
protected Bindable<Country> Country => header.Country; protected Bindable<Country> Country => Header.Country;
protected Bindable<RankingsScope> Scope => header.Current; protected Bindable<RankingsScope> Scope => Header.Current;
private readonly OverlayScrollContainer scrollFlow; private readonly OverlayScrollContainer scrollFlow;
private readonly Container contentContainer; private readonly Container contentContainer;
private readonly LoadingLayer loading; private readonly LoadingLayer loading;
private readonly Box background; private readonly Box background;
private readonly RankingsOverlayHeader header;
private APIRequest lastRequest; private APIRequest lastRequest;
private CancellationTokenSource cancellationToken; private CancellationTokenSource cancellationToken;
@ -36,7 +35,12 @@ namespace osu.Game.Overlays
private IAPIProvider api { get; set; } private IAPIProvider api { get; set; }
public RankingsOverlay() public RankingsOverlay()
: base(OverlayColourScheme.Green) : base(OverlayColourScheme.Green, new RankingsOverlayHeader
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Depth = -float.MaxValue
})
{ {
Children = new Drawable[] Children = new Drawable[]
{ {
@ -55,12 +59,7 @@ namespace osu.Game.Overlays
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Children = new Drawable[] Children = new Drawable[]
{ {
Header = header = new RankingsOverlayHeader Header,
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Depth = -float.MaxValue
},
new Container new Container
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
@ -97,7 +96,7 @@ namespace osu.Game.Overlays
{ {
base.LoadComplete(); base.LoadComplete();
header.Ruleset.BindTo(ruleset); Header.Ruleset.BindTo(ruleset);
Country.BindValueChanged(_ => Country.BindValueChanged(_ =>
{ {

View File

@ -17,19 +17,18 @@ using osuTK;
namespace osu.Game.Overlays namespace osu.Game.Overlays
{ {
public class UserProfileOverlay : FullscreenOverlay public class UserProfileOverlay : FullscreenOverlay<ProfileHeader>
{ {
private ProfileSection lastSection; private ProfileSection lastSection;
private ProfileSection[] sections; private ProfileSection[] sections;
private GetUserRequest userReq; private GetUserRequest userReq;
protected new ProfileHeader Header;
private ProfileSectionsContainer sectionsContainer; private ProfileSectionsContainer sectionsContainer;
private ProfileSectionTabControl tabs; private ProfileSectionTabControl tabs;
public const float CONTENT_X_MARGIN = 70; public const float CONTENT_X_MARGIN = 70;
public UserProfileOverlay() public UserProfileOverlay()
: base(OverlayColourScheme.Pink) : base(OverlayColourScheme.Pink, new ProfileHeader())
{ {
} }
@ -77,7 +76,7 @@ namespace osu.Game.Overlays
Add(sectionsContainer = new ProfileSectionsContainer Add(sectionsContainer = new ProfileSectionsContainer
{ {
ExpandableHeader = base.Header = Header = new ProfileHeader(), ExpandableHeader = Header,
FixedHeader = tabs, FixedHeader = tabs,
HeaderBackground = new Box HeaderBackground = new Box
{ {