mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 21:42:58 +08:00
Merge pull request #328 from peppy/main-menu-onclick
Change main menu buttons to be activated OnClick.
This commit is contained in:
commit
82b8b5af79
@ -27,6 +27,8 @@ namespace osu.Game.Screens.Menu
|
||||
{
|
||||
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 @@ namespace osu.Game.Screens.Menu
|
||||
},
|
||||
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 @@ namespace osu.Game.Screens.Menu
|
||||
}
|
||||
|
||||
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 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
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 @@ namespace osu.Game.Screens.Menu
|
||||
{
|
||||
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;
|
||||
|
@ -85,7 +85,7 @@ namespace osu.Game.Screens.Menu
|
||||
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 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
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 @@ namespace osu.Game.Screens.Menu
|
||||
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 @@ namespace osu.Game.Screens.Menu
|
||||
{
|
||||
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 @@ namespace osu.Game.Screens.Menu
|
||||
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 @@ namespace osu.Game.Screens.Menu
|
||||
//if (OsuGame.IdleTime > 6000 && State != MenuState.Exit)
|
||||
// State = MenuState.Initial;
|
||||
|
||||
osuLogo.Interactive = Alpha > 0.2f;
|
||||
|
||||
iconFacade.Width = osuLogo.SizeForFlow * 0.5f;
|
||||
base.Update();
|
||||
}
|
||||
|
@ -65,9 +65,10 @@ namespace osu.Game.Screens.Menu
|
||||
buttons.OnSettings = game.ToggleOptions;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
protected override void OnEntering(GameMode last)
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
base.OnEntering(last);
|
||||
buttons.FadeInFromZero(500);
|
||||
}
|
||||
|
||||
|
@ -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 @@ namespace osu.Game.Screens.Menu
|
||||
private Container logoHoverContainer;
|
||||
private MenuVisualisation vis;
|
||||
|
||||
private AudioSample sampleClick;
|
||||
|
||||
private Container colourAndTriangles;
|
||||
|
||||
public Action Action;
|
||||
@ -166,8 +170,9 @@ namespace osu.Game.Screens.Menu
|
||||
}
|
||||
|
||||
[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 @@ namespace osu.Game.Screens.Menu
|
||||
{
|
||||
if (!Interactive) return false;
|
||||
|
||||
sampleClick.Play();
|
||||
|
||||
flashLayer.ClearTransformations();
|
||||
flashLayer.Alpha = 0.4f;
|
||||
flashLayer.FadeOut(1500, EasingTypes.OutExpo);
|
||||
|
Loading…
Reference in New Issue
Block a user