Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for displaying "system title" on main menu #26172

Merged
merged 12 commits into from
Dec 28, 2023
Prev Previous commit
Next Next commit
Adjust animation and add delay to URL open
  • Loading branch information
peppy committed Dec 28, 2023
commit c70e7d340da905d081eb87863ea9588021816453
37 changes: 32 additions & 5 deletions osu.Game/Screens/Menu/SystemTitle.cs
Original file line number Diff line number Diff line change
@@ -12,6 +12,8 @@
using osu.Framework.Graphics.Textures;
using osu.Framework.Input.Events;
using osu.Framework.Platform;
using osu.Framework.Threading;
using osu.Game.Graphics.Containers;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;

@@ -25,36 +27,61 @@ public partial class SystemTitle : CompositeDrawable
private CancellationTokenSource? cancellationTokenSource;
private SystemTitleImage? currentImage;

private ScheduledDelegate? openUrlAction;

[BackgroundDependencyLoader]
private void load(GameHost? gameHost)
{
Anchor = Anchor.BottomCentre;
Origin = Anchor.BottomCentre;
AutoSizeAxes = Axes.Both;

InternalChild = content = new ClickableContainer
InternalChild = content = new OsuClickableContainer
{
AutoSizeAxes = Axes.Both,
Action = () =>
{
if (!string.IsNullOrEmpty(Current.Value?.Url))
gameHost?.OpenUrlExternally(Current.Value.Url);
// Delay slightly to allow animation to play out.
openUrlAction?.Cancel();
openUrlAction = Scheduler.AddDelayed(() =>
{
if (!string.IsNullOrEmpty(Current.Value?.Url))
gameHost?.OpenUrlExternally(Current.Value.Url);
}, 250);
}
};
}

protected override bool OnHover(HoverEvent e)
{
content.ScaleTo(1.1f, 500, Easing.OutBounce);
content.ScaleTo(1.05f, 2000, Easing.OutQuint);
return base.OnHover(e);
}

protected override void OnHoverLost(HoverLostEvent e)
{
content.ScaleTo(1f, 500, Easing.OutBounce);
content.ScaleTo(1f, 500, Easing.OutQuint);
base.OnHoverLost(e);
}

protected override bool OnClick(ClickEvent e)
{
//hover.FlashColour(FlashColour, 800, Easing.OutQuint);
return base.OnClick(e);
}

protected override bool OnMouseDown(MouseDownEvent e)
{
content.ScaleTo(0.95f, 500, Easing.OutQuint);
return base.OnMouseDown(e);
}

protected override void OnMouseUp(MouseUpEvent e)
{
content.ScaleTo(1, 500, Easing.OutElastic);
base.OnMouseUp(e);
}

protected override void LoadComplete()
{
base.LoadComplete();