1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-26 04:32:55 +08:00
osu-lazer/osu.Game/Overlays/OnlineOverlay.cs

95 lines
3.4 KiB
C#
Raw Normal View History

2021-01-18 15:48:12 +08:00
// 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 osu.Framework.Allocation;
2021-01-18 15:48:12 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Game.Graphics.Cursor;
2021-01-18 15:48:12 +08:00
using osu.Game.Graphics.UserInterface;
using osu.Game.Online;
2021-01-18 15:48:12 +08:00
namespace osu.Game.Overlays
{
2022-11-24 13:32:20 +08:00
public abstract partial class OnlineOverlay<T> : FullscreenOverlay<T>
2021-01-18 15:48:12 +08:00
where T : OverlayHeader
{
protected override Container<Drawable> Content => content;
[Cached]
2021-01-18 15:48:12 +08:00
protected readonly OverlayScrollContainer ScrollFlow;
2021-01-18 15:48:12 +08:00
protected readonly LoadingLayer Loading;
private readonly Container loadingContainer;
2021-01-18 15:48:12 +08:00
private readonly Container content;
protected OnlineOverlay(OverlayColourScheme colourScheme, bool requiresSignIn = true)
2021-01-18 15:48:12 +08:00
: base(colourScheme)
{
var mainContent = requiresSignIn
? new OnlineViewContainer($"Sign in to view the {Header.Title.Title}")
: new Container();
mainContent.RelativeSizeAxes = Axes.Both;
mainContent.AddRange(new Drawable[]
2021-01-18 15:48:12 +08:00
{
ScrollFlow = new OverlayScrollContainer
{
RelativeSizeAxes = Axes.Both,
ScrollbarVisible = false,
Child = new OsuContextMenuContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Child = new PopoverContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Child = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
Header.With(h => h.Depth = float.MinValue),
content = new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y
}
}
}
},
}
2021-01-18 15:48:12 +08:00
},
loadingContainer = new Container
{
RelativeSizeAxes = Axes.Both,
Child = Loading = new LoadingLayer(true),
}
2021-01-18 15:48:12 +08:00
});
base.Content.Add(mainContent);
2021-01-18 15:48:12 +08:00
}
protected override void LoadComplete()
{
base.LoadComplete();
// Ensure the scroll-to-top button is displayed above the fixed header.
AddInternal(ScrollFlow.Button.CreateProxy());
}
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();
// don't block header by applying padding equal to the visible header height
loadingContainer.Padding = new MarginPadding { Top = Math.Max(0, Header.Height - ScrollFlow.Current) };
}
2021-01-18 15:48:12 +08:00
}
}