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.
|
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2023-03-21 13:26:51 +08:00
|
|
|
|
using System;
|
2021-06-07 17:18:18 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2021-01-18 15:48:12 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2022-11-03 14:43:06 +08:00
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
2022-12-26 01:57:42 +08:00
|
|
|
|
using osu.Game.Graphics.Cursor;
|
2021-01-18 15:48:12 +08:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2021-02-18 17:04:41 +08:00
|
|
|
|
using osu.Game.Online;
|
2021-01-18 15:48:12 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays
|
|
|
|
|
{
|
2021-01-18 16:13:38 +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;
|
|
|
|
|
|
2021-06-07 17:18:18 +08:00
|
|
|
|
[Cached]
|
2021-01-18 15:48:12 +08:00
|
|
|
|
protected readonly OverlayScrollContainer ScrollFlow;
|
2021-06-07 17:18:18 +08:00
|
|
|
|
|
2021-01-18 15:48:12 +08:00
|
|
|
|
protected readonly LoadingLayer Loading;
|
2023-03-21 13:26:51 +08:00
|
|
|
|
private readonly Container loadingContainer;
|
2021-01-18 15:48:12 +08:00
|
|
|
|
private readonly Container content;
|
|
|
|
|
|
2021-02-18 17:04:41 +08:00
|
|
|
|
protected OnlineOverlay(OverlayColourScheme colourScheme, bool requiresSignIn = true)
|
2021-01-18 15:48:12 +08:00
|
|
|
|
: base(colourScheme)
|
|
|
|
|
{
|
2021-02-18 17:04:41 +08:00
|
|
|
|
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,
|
2022-12-27 07:37:46 +08:00
|
|
|
|
Child = new OsuContextMenuContainer
|
2021-01-21 12:50:41 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2022-12-27 07:37:46 +08:00
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Child = new PopoverContainer
|
2021-01-21 12:50:41 +08:00
|
|
|
|
{
|
2022-12-27 07:37:46 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Child = new FillFlowContainer
|
2021-01-21 12:50:41 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2022-12-26 01:57:42 +08:00
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2022-12-27 07:37:46 +08:00
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Children = new Drawable[]
|
2022-12-26 01:57:42 +08:00
|
|
|
|
{
|
2022-12-27 07:37:46 +08:00
|
|
|
|
Header.With(h => h.Depth = float.MinValue),
|
|
|
|
|
content = new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y
|
|
|
|
|
}
|
2022-12-26 01:57:42 +08:00
|
|
|
|
}
|
2021-01-21 12:50:41 +08:00
|
|
|
|
}
|
2022-12-27 07:37:46 +08:00
|
|
|
|
},
|
2021-01-21 12:50:41 +08:00
|
|
|
|
}
|
2021-01-18 15:48:12 +08:00
|
|
|
|
},
|
2023-03-21 13:26:51 +08:00
|
|
|
|
loadingContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Child = Loading = new LoadingLayer(true),
|
|
|
|
|
}
|
2021-01-18 15:48:12 +08:00
|
|
|
|
});
|
2021-02-18 17:04:41 +08:00
|
|
|
|
|
|
|
|
|
base.Content.Add(mainContent);
|
2021-01-18 15:48:12 +08:00
|
|
|
|
}
|
2023-03-21 13:26:51 +08:00
|
|
|
|
|
|
|
|
|
protected override void UpdateAfterChildren()
|
|
|
|
|
{
|
|
|
|
|
base.UpdateAfterChildren();
|
|
|
|
|
|
2023-03-25 09:42:34 +08:00
|
|
|
|
// don't block header by applying padding equal to the visible header height
|
2023-03-21 13:26:51 +08:00
|
|
|
|
loadingContainer.Padding = new MarginPadding { Top = Math.Max(0, Header.Height - ScrollFlow.Current) };
|
|
|
|
|
}
|
2021-01-18 15:48:12 +08:00
|
|
|
|
}
|
|
|
|
|
}
|