diff --git a/osu.Game/Screens/Menu/Button.cs b/osu.Game/Screens/Menu/Button.cs index 15fce73a3b..7e1db73205 100644 --- a/osu.Game/Screens/Menu/Button.cs +++ b/osu.Game/Screens/Menu/Button.cs @@ -27,6 +27,8 @@ public class Button : Container, IStateful { private Container iconText; private Container box; + private Box boxColourLayer; + private Box boxHoverLayer; private Color4 colour; private TextAwesome icon; private string internalName; @@ -72,16 +74,24 @@ public Button(string text, string internalName, FontAwesome symbol, Color4 colou }, Anchor = Anchor.Centre, Origin = Anchor.Centre, - Colour = colour, Scale = new Vector2(0, 1), Size = boxSize, Shear = new Vector2(ButtonSystem.WEDGE_WIDTH / boxSize.Y, 0), - Children = new Drawable[] + Children = new [] { - new Box + boxColourLayer = new Box { EdgeSmoothness = new Vector2(1.5f, 0), RelativeSizeAxes = Axes.Both, + Colour = colour, + }, + boxHoverLayer = new Box + { + EdgeSmoothness = new Vector2(1.5f, 0), + RelativeSizeAxes = Axes.Both, + BlendingMode = BlendingMode.Additive, + Colour = Color4.White, + Alpha = 0, }, } }, @@ -228,6 +238,18 @@ private void load(AudioManager audio) } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) + { + boxHoverLayer.FadeTo(0.1f, 1000, EasingTypes.OutQuint); + return base.OnMouseDown(state, args); + } + + protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) + { + boxHoverLayer.FadeTo(0, 1000, EasingTypes.OutQuint); + return base.OnMouseUp(state, args); + } + + protected override bool OnClick(InputState state) { trigger(); return true; @@ -235,7 +257,7 @@ protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { - base.OnKeyDown(state, args); + if (args.Repeat) return false; if (triggerKey == args.Key && triggerKey != Key.Unknown) { @@ -250,9 +272,11 @@ private void trigger() { sampleClick.Play(); - box.FlashColour(Color4.White, 500, EasingTypes.OutExpo); - clickAction?.Invoke(); + + boxHoverLayer.ClearTransformations(); + boxHoverLayer.Alpha = 0.9f; + boxHoverLayer.FadeOut(800, EasingTypes.OutExpo); } public override bool HandleInput => state != ButtonState.Exploded && box.Scale.X >= 0.8f; diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index a2c6f60bb4..67802ab2f3 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -85,7 +85,7 @@ public ButtonSystem() Children = new[] { settingsButton = new Button(@"settings", @"options", FontAwesome.fa_gear, new Color4(85, 85, 85, 255), () => OnSettings?.Invoke(), -WEDGE_WIDTH, Key.O), - backButton = new Button(@"back", @"back", FontAwesome.fa_osu_left_o, new Color4(51, 58, 94, 255), onBack, -WEDGE_WIDTH, Key.Escape), + backButton = new Button(@"back", @"back", FontAwesome.fa_osu_left_o, new Color4(51, 58, 94, 255), onBack, -WEDGE_WIDTH), iconFacade = new Container //need a container to make the osu! icon flow properly. { Size = new Vector2(0, BUTTON_AREA_HEIGHT) @@ -132,17 +132,26 @@ protected override void LoadComplete() protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { + if (args.Repeat) return false; + switch (args.Key) { case Key.Space: osuLogo.TriggerClick(state); return true; case Key.Escape: - if (State == MenuState.Initial) - return false; + switch (State) + { + case MenuState.TopLevel: + State = MenuState.Initial; + return true; + case MenuState.Play: + backButton.TriggerClick(); + return true; + } - State = MenuState.Initial; - return true; + + return false; } return false; @@ -172,10 +181,10 @@ private void onOsuLogo() State = MenuState.TopLevel; return; case MenuState.TopLevel: - buttonsTopLevel.First().TriggerMouseDown(); + buttonsTopLevel.First().TriggerClick(); return; case MenuState.Play: - buttonsPlay.First().TriggerMouseDown(); + buttonsPlay.First().TriggerClick(); return; } } @@ -207,7 +216,7 @@ public MenuState State { case MenuState.Initial: buttonAreaBackground.ScaleTo(Vector2.One, 500, EasingTypes.Out); - buttonArea.FadeOut(500); + buttonArea.FadeOut(300); osuLogo.Delay(150); osuLogo.MoveTo(Vector2.Zero, 800, EasingTypes.OutExpo); @@ -220,6 +229,8 @@ public MenuState State b.State = ButtonState.Contracted; break; case MenuState.TopLevel: + buttonArea.Flush(true); + buttonAreaBackground.ScaleTo(Vector2.One, 200, EasingTypes.Out); osuLogo.MoveTo(buttonFlow.DrawPosition, 200, EasingTypes.In); @@ -288,6 +299,8 @@ 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(); } diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index 258e20a8bd..9a715c17be 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -65,9 +65,10 @@ private void load(OsuGame game) buttons.OnSettings = game.ToggleOptions; } - protected override void LoadComplete() + protected override void OnEntering(GameMode last) { - base.LoadComplete(); + + base.OnEntering(last); buttons.FadeInFromZero(500); } diff --git a/osu.Game/Screens/Menu/OsuLogo.cs b/osu.Game/Screens/Menu/OsuLogo.cs index 25f6f4055e..c18659b445 100644 --- a/osu.Game/Screens/Menu/OsuLogo.cs +++ b/osu.Game/Screens/Menu/OsuLogo.cs @@ -4,6 +4,8 @@ using System; using System.Diagnostics; using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Framework.Audio.Sample; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; @@ -32,6 +34,8 @@ public partial class OsuLogo : Container private Container logoHoverContainer; private MenuVisualisation vis; + private AudioSample sampleClick; + private Container colourAndTriangles; public Action Action; @@ -166,8 +170,9 @@ public OsuLogo() } [BackgroundDependencyLoader] - private void load(TextureStore textures) + private void load(TextureStore textures, AudioManager audio) { + sampleClick = audio.Sample.Get(@"Menu/menuhit"); logo.Texture = textures.Get(@"Menu/logo"); ripple.Texture = textures.Get(@"Menu/logo"); } @@ -200,6 +205,8 @@ protected override bool OnClick(InputState state) { if (!Interactive) return false; + sampleClick.Play(); + flashLayer.ClearTransformations(); flashLayer.Alpha = 0.4f; flashLayer.FadeOut(1500, EasingTypes.OutExpo);