1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 23:12:56 +08:00

Allow the osu! logo to be proxied locally into scenes

This commit is contained in:
Dean Herbert 2023-07-14 19:19:14 +09:00
parent 1051982bc5
commit 85c780ae5b
3 changed files with 50 additions and 2 deletions

View File

@ -950,9 +950,9 @@ namespace osu.Game
if (!args?.Any(a => a == @"--no-version-overlay") ?? true) if (!args?.Any(a => a == @"--no-version-overlay") ?? true)
loadComponentSingleFile(versionManager = new VersionManager { Depth = int.MinValue }, ScreenContainer.Add); loadComponentSingleFile(versionManager = new VersionManager { Depth = int.MinValue }, ScreenContainer.Add);
loadComponentSingleFile(osuLogo, logo => loadComponentSingleFile(osuLogo, _ =>
{ {
logoContainer.Add(logo); osuLogo.SetupDefaultContainer(logoContainer);
// Loader has to be created after the logo has finished loading as Loader performs logo transformations on entering. // Loader has to be created after the logo has finished loading as Loader performs logo transformations on entering.
ScreenStack.Push(CreateLoader().With(l => l.RelativeSizeAxes = Axes.Both)); ScreenStack.Push(CreateLoader().With(l => l.RelativeSizeAxes = Axes.Both));

View File

@ -8,6 +8,7 @@ using System.Diagnostics;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Framework.Logging; using osu.Framework.Logging;
@ -85,6 +86,7 @@ namespace osu.Game.Screens.Menu
private ParallaxContainer buttonsContainer; private ParallaxContainer buttonsContainer;
private SongTicker songTicker; private SongTicker songTicker;
private Container logoTarget;
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader(true)]
private void load(BeatmapListingOverlay beatmapListing, SettingsOverlay settings, OsuConfigManager config, SessionStatics statics) private void load(BeatmapListingOverlay beatmapListing, SettingsOverlay settings, OsuConfigManager config, SessionStatics statics)
@ -129,6 +131,7 @@ namespace osu.Game.Screens.Menu
} }
} }
}, },
logoTarget = new Container { RelativeSizeAxes = Axes.Both, },
sideFlashes = new MenuSideFlashes(), sideFlashes = new MenuSideFlashes(),
songTicker = new SongTicker songTicker = new SongTicker
{ {
@ -208,6 +211,8 @@ namespace osu.Game.Screens.Menu
logo.FadeColour(Color4.White, 100, Easing.OutQuint); logo.FadeColour(Color4.White, 100, Easing.OutQuint);
logo.FadeIn(100, Easing.OutQuint); logo.FadeIn(100, Easing.OutQuint);
logo.ProxyToContainer(logoTarget);
if (resuming) if (resuming)
{ {
Buttons.State = ButtonSystemState.TopLevel; Buttons.State = ButtonSystemState.TopLevel;
@ -245,6 +250,8 @@ namespace osu.Game.Screens.Menu
var seq = logo.FadeOut(300, Easing.InSine) var seq = logo.FadeOut(300, Easing.InSine)
.ScaleTo(0.2f, 300, Easing.InSine); .ScaleTo(0.2f, 300, Easing.InSine);
logo.ReturnProxy();
seq.OnComplete(_ => Buttons.SetOsuLogo(null)); seq.OnComplete(_ => Buttons.SetOsuLogo(null));
seq.OnAbort(_ => Buttons.SetOsuLogo(null)); seq.OnAbort(_ => Buttons.SetOsuLogo(null));
} }

View File

@ -435,5 +435,46 @@ namespace osu.Game.Screens.Menu
logoBounceContainer.MoveTo(Vector2.Zero, 800, Easing.OutElastic); logoBounceContainer.MoveTo(Vector2.Zero, 800, Easing.OutElastic);
base.OnDragEnd(e); base.OnDragEnd(e);
} }
private Container defaultProxyTarget;
private Container currentProxyTarget;
private Drawable proxy;
public Drawable ProxyToContainer(Container c)
{
if (currentProxyTarget != null)
throw new InvalidOperationException("Previous proxy usage was not returned");
if (defaultProxyTarget == null)
throw new InvalidOperationException($"{nameof(SetupDefaultContainer)} must be called first");
currentProxyTarget = c;
defaultProxyTarget.Remove(proxy, false);
currentProxyTarget.Add(proxy);
return proxy;
}
public void ReturnProxy()
{
if (currentProxyTarget == null)
throw new InvalidOperationException("No usage to return");
if (defaultProxyTarget == null)
throw new InvalidOperationException($"{nameof(SetupDefaultContainer)} must be called first");
currentProxyTarget.Remove(proxy, false);
currentProxyTarget = null;
defaultProxyTarget.Add(proxy);
}
public void SetupDefaultContainer(Container container)
{
defaultProxyTarget = container;
defaultProxyTarget.Add(this);
defaultProxyTarget.Add(proxy = CreateProxy());
}
} }
} }