mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 21:02:54 +08:00
Allow the osu! logo to be proxied locally into scenes
This commit is contained in:
parent
1051982bc5
commit
85c780ae5b
@ -950,9 +950,9 @@ namespace osu.Game
|
||||
if (!args?.Any(a => a == @"--no-version-overlay") ?? true)
|
||||
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.
|
||||
ScreenStack.Push(CreateLoader().With(l => l.RelativeSizeAxes = Axes.Both));
|
||||
|
@ -8,6 +8,7 @@ using System.Diagnostics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Logging;
|
||||
@ -85,6 +86,7 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
private ParallaxContainer buttonsContainer;
|
||||
private SongTicker songTicker;
|
||||
private Container logoTarget;
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
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(),
|
||||
songTicker = new SongTicker
|
||||
{
|
||||
@ -208,6 +211,8 @@ namespace osu.Game.Screens.Menu
|
||||
logo.FadeColour(Color4.White, 100, Easing.OutQuint);
|
||||
logo.FadeIn(100, Easing.OutQuint);
|
||||
|
||||
logo.ProxyToContainer(logoTarget);
|
||||
|
||||
if (resuming)
|
||||
{
|
||||
Buttons.State = ButtonSystemState.TopLevel;
|
||||
@ -245,6 +250,8 @@ namespace osu.Game.Screens.Menu
|
||||
var seq = logo.FadeOut(300, Easing.InSine)
|
||||
.ScaleTo(0.2f, 300, Easing.InSine);
|
||||
|
||||
logo.ReturnProxy();
|
||||
|
||||
seq.OnComplete(_ => Buttons.SetOsuLogo(null));
|
||||
seq.OnAbort(_ => Buttons.SetOsuLogo(null));
|
||||
}
|
||||
|
@ -435,5 +435,46 @@ namespace osu.Game.Screens.Menu
|
||||
logoBounceContainer.MoveTo(Vector2.Zero, 800, Easing.OutElastic);
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user