2022-04-20 14:05:07 +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.
|
|
|
|
|
2024-07-10 16:54:04 +08:00
|
|
|
using System;
|
2022-04-20 14:05:07 +08:00
|
|
|
using osu.Framework.Allocation;
|
2024-06-29 15:17:40 +08:00
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2022-04-20 14:05:07 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2022-04-21 15:15:10 +08:00
|
|
|
using osu.Framework.Input.Events;
|
2022-04-20 14:05:07 +08:00
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2024-06-29 13:35:48 +08:00
|
|
|
using osu.Game.Screens.Footer;
|
2022-04-20 14:05:07 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Mods
|
|
|
|
{
|
|
|
|
/// <summary>
|
2024-06-29 13:35:48 +08:00
|
|
|
/// A sheared overlay which provides a header and basic animations.
|
|
|
|
/// Exposes <see cref="TopLevelContent"/> and <see cref="MainAreaContent"/> as valid targets for content.
|
2022-04-20 14:05:07 +08:00
|
|
|
/// </summary>
|
2022-11-24 13:32:20 +08:00
|
|
|
public abstract partial class ShearedOverlayContainer : OsuFocusedOverlayContainer
|
2022-04-20 14:05:07 +08:00
|
|
|
{
|
2024-06-29 13:35:48 +08:00
|
|
|
public const float PADDING = 14;
|
2022-04-20 15:28:52 +08:00
|
|
|
|
2022-04-20 14:05:07 +08:00
|
|
|
[Cached]
|
2024-06-29 13:35:48 +08:00
|
|
|
public readonly OverlayColourProvider ColourProvider;
|
2022-04-20 14:05:07 +08:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The overlay's header.
|
|
|
|
/// </summary>
|
2024-06-29 15:17:40 +08:00
|
|
|
protected ShearedOverlayHeader Header { get; private set; } = null!;
|
2022-04-20 14:05:07 +08:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The overlay's footer.
|
|
|
|
/// </summary>
|
2024-07-10 12:54:27 +08:00
|
|
|
protected Container Footer { get; private set; } = null!;
|
2022-04-20 14:05:07 +08:00
|
|
|
|
2024-06-29 15:17:40 +08:00
|
|
|
[Resolved]
|
|
|
|
private ScreenFooter? footer { get; set; }
|
2024-06-29 13:35:48 +08:00
|
|
|
|
2022-04-20 14:05:07 +08:00
|
|
|
/// <summary>
|
|
|
|
/// A container containing all content, including the header and footer.
|
|
|
|
/// May be used for overlay-wide animations.
|
|
|
|
/// </summary>
|
2024-06-29 15:17:40 +08:00
|
|
|
protected Container TopLevelContent { get; private set; } = null!;
|
2022-04-20 14:05:07 +08:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// A container for content that is to be displayed between the header and footer.
|
|
|
|
/// </summary>
|
2024-06-29 15:17:40 +08:00
|
|
|
protected Container MainAreaContent { get; private set; } = null!;
|
2022-04-20 14:05:07 +08:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// A container for content that is to be displayed inside the footer.
|
|
|
|
/// </summary>
|
2024-07-10 12:54:27 +08:00
|
|
|
protected Container FooterContent { get; private set; } = null!;
|
2022-04-20 14:05:07 +08:00
|
|
|
|
|
|
|
protected override bool StartHidden => true;
|
|
|
|
|
|
|
|
protected override bool BlockNonPositionalInput => true;
|
|
|
|
|
2024-06-29 15:17:40 +08:00
|
|
|
// ShearedOverlayContainers are placed at a layer within the screen container as they rely on ScreenFooter which must be placed there.
|
|
|
|
// Therefore, dimming must be managed locally, since DimMainContent dims the entire screen layer.
|
|
|
|
protected sealed override bool DimMainContent => false;
|
|
|
|
|
2022-05-05 04:17:40 +08:00
|
|
|
protected ShearedOverlayContainer(OverlayColourScheme colourScheme)
|
2022-04-20 14:05:07 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
2022-05-05 04:17:40 +08:00
|
|
|
ColourProvider = new OverlayColourProvider(colourScheme);
|
2022-04-20 14:05:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
Child = TopLevelContent = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2024-06-29 15:17:40 +08:00
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = ColourProvider.Background6.Opacity(0.75f),
|
|
|
|
},
|
2022-04-20 14:50:57 +08:00
|
|
|
Header = new ShearedOverlayHeader
|
2022-04-20 14:05:07 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Depth = float.MinValue,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
Close = Hide
|
|
|
|
},
|
|
|
|
MainAreaContent = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Padding = new MarginPadding
|
|
|
|
{
|
2022-04-20 14:50:57 +08:00
|
|
|
Top = ShearedOverlayHeader.HEIGHT,
|
2024-06-30 09:22:59 +08:00
|
|
|
Bottom = ScreenFooter.HEIGHT + PADDING,
|
2022-04-20 14:05:07 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-06-29 13:35:48 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Creates content to be displayed on the game-wide footer.
|
|
|
|
/// </summary>
|
2024-07-10 16:12:52 +08:00
|
|
|
public virtual VisibilityContainer? CreateFooterContent() => null;
|
2024-06-29 13:35:48 +08:00
|
|
|
|
2024-06-29 13:42:17 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Invoked when the back button in the footer is pressed.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>Whether the back button should not close the overlay.</returns>
|
|
|
|
public virtual bool OnBackButton() => false;
|
|
|
|
|
2022-04-21 15:15:10 +08:00
|
|
|
protected override bool OnClick(ClickEvent e)
|
|
|
|
{
|
|
|
|
if (State.Value == Visibility.Visible)
|
|
|
|
{
|
|
|
|
Hide();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return base.OnClick(e);
|
|
|
|
}
|
|
|
|
|
2024-07-10 16:54:04 +08:00
|
|
|
private IDisposable? activeOverlayRegistration;
|
2024-06-29 13:39:34 +08:00
|
|
|
private bool hideFooterOnPopOut;
|
|
|
|
|
2022-04-20 14:05:07 +08:00
|
|
|
protected override void PopIn()
|
|
|
|
{
|
|
|
|
const double fade_in_duration = 400;
|
|
|
|
|
|
|
|
this.FadeIn(fade_in_duration, Easing.OutQuint);
|
|
|
|
|
|
|
|
Header.MoveToY(0, fade_in_duration, Easing.OutQuint);
|
2024-06-29 13:35:48 +08:00
|
|
|
|
2024-06-30 09:22:59 +08:00
|
|
|
if (footer != null)
|
2024-06-29 13:35:48 +08:00
|
|
|
{
|
2024-07-10 16:54:04 +08:00
|
|
|
activeOverlayRegistration = footer.RegisterActiveOverlayContainer(this);
|
2024-06-29 13:39:34 +08:00
|
|
|
|
|
|
|
if (footer.State.Value == Visibility.Hidden)
|
|
|
|
{
|
|
|
|
footer.Show();
|
|
|
|
hideFooterOnPopOut = true;
|
|
|
|
}
|
2024-06-29 13:35:48 +08:00
|
|
|
}
|
2022-04-20 14:05:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
{
|
|
|
|
const double fade_out_duration = 500;
|
|
|
|
|
|
|
|
base.PopOut();
|
|
|
|
this.FadeOut(fade_out_duration, Easing.OutQuint);
|
|
|
|
|
|
|
|
Header.MoveToY(-Header.DrawHeight, fade_out_duration, Easing.OutQuint);
|
2024-06-29 13:35:48 +08:00
|
|
|
|
2024-06-30 09:22:59 +08:00
|
|
|
if (footer != null)
|
2024-06-29 13:35:48 +08:00
|
|
|
{
|
2024-07-10 16:54:04 +08:00
|
|
|
activeOverlayRegistration?.Dispose();
|
|
|
|
activeOverlayRegistration = null;
|
2024-06-29 13:39:34 +08:00
|
|
|
|
|
|
|
if (hideFooterOnPopOut)
|
|
|
|
{
|
|
|
|
footer.Hide();
|
|
|
|
hideFooterOnPopOut = false;
|
|
|
|
}
|
2024-06-29 13:35:48 +08:00
|
|
|
}
|
2022-04-20 14:05:07 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|