mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Make the osu! logo shared game-wide
There should only ever be one osu! logo. It is now passed around between screens in a superfluous manner.
This commit is contained in:
@ -39,12 +39,25 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
//todo: make these non-internal somehow.
|
||||
internal const float BUTTON_AREA_HEIGHT = 100;
|
||||
|
||||
internal const float BUTTON_WIDTH = 140f;
|
||||
internal const float WEDGE_WIDTH = 20;
|
||||
|
||||
public const int EXIT_DELAY = 3000;
|
||||
private OsuLogo logo;
|
||||
|
||||
public void SetOsuLogo(OsuLogo logo)
|
||||
{
|
||||
this.logo = logo;
|
||||
|
||||
if (this.logo != null)
|
||||
{
|
||||
this.logo.Action = onOsuLogo;
|
||||
|
||||
// osuLogo.SizeForFlow relies on loading to be complete.
|
||||
buttonFlow.Position = new Vector2(WEDGE_WIDTH * 2 - (BUTTON_WIDTH + this.logo.SizeForFlow / 4), 0);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly OsuLogo osuLogo;
|
||||
private readonly Drawable iconFacade;
|
||||
private readonly Container buttonArea;
|
||||
private readonly Box buttonAreaBackground;
|
||||
@ -99,12 +112,6 @@ namespace osu.Game.Screens.Menu
|
||||
}
|
||||
}
|
||||
},
|
||||
osuLogo = new OsuLogo
|
||||
{
|
||||
Action = onOsuLogo,
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
}
|
||||
};
|
||||
|
||||
buttonsPlay.Add(new Button(@"solo", @"select-6", FontAwesome.fa_user, new Color4(102, 68, 204, 255), () => OnSolo?.Invoke(), WEDGE_WIDTH, Key.P));
|
||||
@ -127,14 +134,6 @@ namespace osu.Game.Screens.Menu
|
||||
sampleBack = audio.Sample.Get(@"Menu/select-4");
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
// osuLogo.SizeForFlow relies on loading to be complete.
|
||||
buttonFlow.Position = new Vector2(WEDGE_WIDTH * 2 - (BUTTON_WIDTH + osuLogo.SizeForFlow / 4), 0);
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
{
|
||||
if (args.Repeat) return false;
|
||||
@ -142,7 +141,7 @@ namespace osu.Game.Screens.Menu
|
||||
switch (args.Key)
|
||||
{
|
||||
case Key.Space:
|
||||
osuLogo.TriggerOnClick(state);
|
||||
logo.TriggerOnClick(state);
|
||||
return true;
|
||||
case Key.Escape:
|
||||
switch (State)
|
||||
@ -215,24 +214,31 @@ namespace osu.Game.Screens.Menu
|
||||
backButton.ContractStyle = 0;
|
||||
settingsButton.ContractStyle = 0;
|
||||
|
||||
bool fromInitial = lastState == MenuState.Initial;
|
||||
|
||||
if (state == MenuState.TopLevel)
|
||||
buttonArea.FinishTransforms(true);
|
||||
|
||||
using (buttonArea.BeginDelayedSequence(fromInitial ? 150 : 0, true))
|
||||
using (buttonArea.BeginDelayedSequence(lastState == MenuState.Initial ? 150 : 0, true))
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case MenuState.Exit:
|
||||
case MenuState.Initial:
|
||||
trackingPosition = false;
|
||||
|
||||
buttonAreaBackground.ScaleTo(Vector2.One, 500, Easing.Out);
|
||||
buttonArea.FadeOut(300);
|
||||
|
||||
osuLogo.Delay(150)
|
||||
.Schedule(() => toolbar?.Hide())
|
||||
.ScaleTo(1, 800, Easing.OutExpo)
|
||||
.MoveTo(Vector2.Zero, 800, Easing.OutExpo);
|
||||
logo?.Delay(150)
|
||||
.Schedule(() =>
|
||||
{
|
||||
toolbar?.Hide();
|
||||
|
||||
logo.ClearTransforms(targetMember: nameof(Position));
|
||||
logo.RelativePositionAxes = Axes.Both;
|
||||
|
||||
logo.MoveTo(new Vector2(0.5f), 800, Easing.OutExpo);
|
||||
logo.ScaleTo(1, 800, Easing.OutExpo);
|
||||
});
|
||||
|
||||
foreach (Button b in buttonsTopLevel)
|
||||
b.State = ButtonState.Contracted;
|
||||
@ -240,27 +246,40 @@ namespace osu.Game.Screens.Menu
|
||||
foreach (Button b in buttonsPlay)
|
||||
b.State = ButtonState.Contracted;
|
||||
|
||||
if (state == MenuState.Exit)
|
||||
{
|
||||
osuLogo.RotateTo(20, EXIT_DELAY * 1.5f);
|
||||
osuLogo.FadeOut(EXIT_DELAY);
|
||||
}
|
||||
else if (lastState == MenuState.TopLevel)
|
||||
if (state != MenuState.Exit && lastState == MenuState.TopLevel)
|
||||
sampleBack?.Play();
|
||||
break;
|
||||
case MenuState.TopLevel:
|
||||
buttonAreaBackground.ScaleTo(Vector2.One, 200, Easing.Out);
|
||||
|
||||
var sequence = osuLogo
|
||||
.ScaleTo(0.5f, 200, Easing.In)
|
||||
.MoveTo(buttonFlow.DrawPosition, 200, Easing.In);
|
||||
logo.ClearTransforms(targetMember: nameof(Position));
|
||||
logo.RelativePositionAxes = Axes.None;
|
||||
|
||||
if (fromInitial && osuLogo.Scale.X > 0.5f)
|
||||
sequence.OnComplete(o =>
|
||||
{
|
||||
o.Impact();
|
||||
toolbar?.Show();
|
||||
});
|
||||
trackingPosition = true;
|
||||
|
||||
switch (lastState)
|
||||
{
|
||||
case MenuState.Initial:
|
||||
logo.ScaleTo(0.5f, 200, Easing.In);
|
||||
|
||||
trackingPosition = false;
|
||||
logo
|
||||
.MoveTo(iconTrackingPosition, lastState == MenuState.EnteringMode ? 0 : 200, Easing.In)
|
||||
.OnComplete(o =>
|
||||
{
|
||||
trackingPosition = true;
|
||||
|
||||
if (logo.Scale.X > 0.5f)
|
||||
{
|
||||
o.Impact();
|
||||
toolbar?.Show();
|
||||
}
|
||||
});
|
||||
break;
|
||||
default:
|
||||
logo.ScaleTo(0.5f, 200, Easing.OutQuint);
|
||||
break;
|
||||
}
|
||||
|
||||
buttonArea.FadeIn(300);
|
||||
|
||||
@ -280,6 +299,8 @@ namespace osu.Game.Screens.Menu
|
||||
case MenuState.EnteringMode:
|
||||
buttonAreaBackground.ScaleTo(new Vector2(2, 0), 300, Easing.InSine);
|
||||
|
||||
trackingPosition = true;
|
||||
|
||||
buttonsTopLevel.ForEach(b => b.ContractStyle = 1);
|
||||
buttonsPlay.ForEach(b => b.ContractStyle = 1);
|
||||
backButton.ContractStyle = 1;
|
||||
@ -301,15 +322,26 @@ namespace osu.Game.Screens.Menu
|
||||
}
|
||||
}
|
||||
|
||||
private Vector2 iconTrackingPosition => logo.Parent.ToLocalSpace(iconFacade.ScreenSpaceDrawQuad.Centre);
|
||||
|
||||
private bool trackingPosition;
|
||||
|
||||
public void SetLogoTracking(bool value) => trackingPosition = value;
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
//if (OsuGame.IdleTime > 6000 && State != MenuState.Exit)
|
||||
// State = MenuState.Initial;
|
||||
|
||||
osuLogo.Interactive = Alpha > 0.2f;
|
||||
|
||||
iconFacade.Width = osuLogo.SizeForFlow * 0.5f;
|
||||
base.Update();
|
||||
|
||||
if (logo != null)
|
||||
{
|
||||
if (trackingPosition)
|
||||
logo.Position = iconTrackingPosition;
|
||||
|
||||
iconFacade.Width = logo.SizeForFlow * 0.5f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user