Adjust scale and outwards transition of ButtonSystem.

This commit is contained in:
Dean Herbert
2016-10-01 17:01:29 +09:00
parent 665352f706
commit 4ad618abc9
2 changed files with 78 additions and 20 deletions

View File

@ -32,15 +32,16 @@ namespace osu.Game.GameModes.Menu
private FlowContainerWithOrigin buttonFlow; private FlowContainerWithOrigin buttonFlow;
const float button_area_height = 128; const float button_area_height = 100;
const float button_width = 180f; const float button_width = 140f;
const float wedge_width = 25.6f; const float wedge_width = 20;
public const int EXIT_DELAY = 3000; public const int EXIT_DELAY = 3000;
private OsuLogo osuLogo; private OsuLogo osuLogo;
private Drawable iconFacade; private Drawable iconFacade;
private Container buttonArea; private Container buttonArea;
private Box buttonAreaBackground;
private Button backButton; private Button backButton;
private Button settingsButton; private Button settingsButton;
@ -51,9 +52,10 @@ namespace osu.Game.GameModes.Menu
public enum MenuState public enum MenuState
{ {
Initial, Initial,
Exit,
TopLevel, TopLevel,
Play, Play,
EnteringMode,
Exit,
} }
public override void Load() public override void Load()
@ -71,10 +73,13 @@ namespace osu.Game.GameModes.Menu
Alpha = 0, Alpha = 0,
Children = new Drawable[] Children = new Drawable[]
{ {
new Box buttonAreaBackground = new Box
{ {
SizeMode = InheritMode.XY, SizeMode = InheritMode.XY,
Colour = new Color4(50, 50, 50, 255) Size = new Vector2(2, 1),
Colour = new Color4(50, 50, 50, 255),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
}, },
buttonFlow = new FlowContainerWithOrigin buttonFlow = new FlowContainerWithOrigin
{ {
@ -169,11 +174,16 @@ namespace osu.Game.GameModes.Menu
MenuState lastState = state; MenuState lastState = state;
state = value; state = value;
//todo: figure a more elegant way of doing this.
buttonsTopLevel.ForEach(b => b.ContractStyle = 0);
buttonsPlay.ForEach(b => b.ContractStyle = 0);
backButton.ContractStyle = 0;
settingsButton.ContractStyle = 0;
switch (state) switch (state)
{ {
case MenuState.Initial: case MenuState.Initial:
backButton.State = Button.ButtonState.Contracted; buttonAreaBackground.ScaleTo(Vector2.One, 500, EasingTypes.Out);
buttonArea.FadeOut(500); buttonArea.FadeOut(500);
osuLogo.Delay(150); osuLogo.Delay(150);
@ -187,7 +197,7 @@ namespace osu.Game.GameModes.Menu
b.State = Button.ButtonState.Contracted; b.State = Button.ButtonState.Contracted;
break; break;
case MenuState.TopLevel: case MenuState.TopLevel:
backButton.State = Button.ButtonState.Contracted; buttonAreaBackground.ScaleTo(Vector2.One, 200, EasingTypes.Out);
osuLogo.MoveTo(buttonFlow.Position, 200, EasingTypes.In); osuLogo.MoveTo(buttonFlow.Position, 200, EasingTypes.In);
osuLogo.ScaleTo(0.5f, 200, EasingTypes.In); osuLogo.ScaleTo(0.5f, 200, EasingTypes.In);
@ -205,14 +215,26 @@ namespace osu.Game.GameModes.Menu
b.State = Button.ButtonState.Contracted; b.State = Button.ButtonState.Contracted;
break; break;
case MenuState.Play: case MenuState.Play:
backButton.State = Button.ButtonState.Expanded;
foreach (Button b in buttonsTopLevel) foreach (Button b in buttonsTopLevel)
b.State = Button.ButtonState.Exploded; b.State = Button.ButtonState.Exploded;
foreach (Button b in buttonsPlay) foreach (Button b in buttonsPlay)
b.State = Button.ButtonState.Expanded; b.State = Button.ButtonState.Expanded;
break; break;
case MenuState.EnteringMode:
buttonAreaBackground.ScaleTo(new Vector2(2, 0), 300, EasingTypes.InSine);
buttonsTopLevel.ForEach(b => b.ContractStyle = 1);
buttonsPlay.ForEach(b => b.ContractStyle = 1);
backButton.ContractStyle = 1;
settingsButton.ContractStyle = 1;
foreach (Button b in buttonsTopLevel)
b.State = Button.ButtonState.Contracted;
foreach (Button b in buttonsPlay)
b.State = Button.ButtonState.Contracted;
break;
case MenuState.Exit: case MenuState.Exit:
buttonArea.FadeOut(200); buttonArea.FadeOut(200);
@ -230,7 +252,7 @@ namespace osu.Game.GameModes.Menu
break; break;
} }
backButton.State = state >= MenuState.Play ? Button.ButtonState.Expanded : Button.ButtonState.Contracted; backButton.State = state == MenuState.Play ? Button.ButtonState.Expanded : Button.ButtonState.Contracted;
settingsButton.State = state == MenuState.TopLevel ? Button.ButtonState.Expanded : Button.ButtonState.Contracted; settingsButton.State = state == MenuState.TopLevel ? Button.ButtonState.Expanded : Button.ButtonState.Contracted;
if (lastState == MenuState.Initial) if (lastState == MenuState.Initial)
@ -273,13 +295,13 @@ namespace osu.Game.GameModes.Menu
{ {
logo = new Sprite() logo = new Sprite()
{ {
Texture = Game.Textures.Get(@"menu-osu"), Texture = Game.Textures.Get(@"Menu/logo"),
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre Origin = Anchor.Centre
}, },
ripple = new Sprite() ripple = new Sprite()
{ {
Texture = Game.Textures.Get(@"menu-osu"), Texture = Game.Textures.Get(@"Menu/logo"),
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Alpha = 0.4f Alpha = 0.4f
@ -420,7 +442,7 @@ namespace osu.Game.GameModes.Menu
icon = new TextAwesome icon = new TextAwesome
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
TextSize = 40, TextSize = 30,
Position = new Vector2(0, 0), Position = new Vector2(0, 0),
Icon = symbol Icon = symbol
}, },
@ -429,6 +451,7 @@ namespace osu.Game.GameModes.Menu
Direction = FlowDirection.HorizontalOnly, Direction = FlowDirection.HorizontalOnly,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
TextSize = 16,
Position = new Vector2(0, 35), Position = new Vector2(0, 35),
Text = text Text = text
} }
@ -576,8 +599,9 @@ namespace osu.Game.GameModes.Menu
base.Update(); base.Update();
} }
ButtonState state; public int ContractStyle;
ButtonState state;
public ButtonState State public ButtonState State
{ {
get { return state; } get { return state; }
@ -587,15 +611,25 @@ namespace osu.Game.GameModes.Menu
if (state == value) if (state == value)
return; return;
ButtonState lastState = state;
state = value; state = value;
switch (state) switch (state)
{ {
case ButtonState.Contracted: case ButtonState.Contracted:
const int contract_duration = 500; switch (ContractStyle)
box.ScaleTo(new Vector2(0, 1), contract_duration, EasingTypes.OutExpo); {
FadeOut(contract_duration); default:
box.ScaleTo(new Vector2(0, 1), 500, EasingTypes.OutExpo);
FadeOut(500);
break;
case 1:
box.ScaleTo(new Vector2(0, 1), 400, EasingTypes.InSine);
FadeOut(800);
break;
}
break;
case ButtonState.Contracted2:
break; break;
case ButtonState.Expanded: case ButtonState.Expanded:
const int expand_duration = 500; const int expand_duration = 500;
@ -616,6 +650,7 @@ namespace osu.Game.GameModes.Menu
public enum ButtonState public enum ButtonState
{ {
Contracted, Contracted,
Contracted2,
Expanded, Expanded,
Exploded Exploded
} }

View File

@ -49,5 +49,28 @@ namespace osu.Game.GameModes.Menu
} }
}; };
} }
protected override double OnSuspending(GameMode next)
{
const float length = 400;
buttons.State = ButtonSystem.MenuState.EnteringMode;
Content.FadeOut(length, EasingTypes.InSine);
Content.MoveTo(new Vector2(-800, 0), length, EasingTypes.InSine);
return base.OnSuspending(next);
}
protected override double OnResuming(GameMode last)
{
const float length = 300;
buttons.State = ButtonSystem.MenuState.TopLevel;
Content.FadeIn(length, EasingTypes.OutQuint);
Content.MoveTo(new Vector2(0, 0), length, EasingTypes.OutQuint);
return base.OnResuming(last);
}
} }
} }