Skip to content

Commit

Permalink
Merge pull request #26201 from iminlikewithyou/menu-button-tweaks
Browse files Browse the repository at this point in the history
Adjust menu buttons
  • Loading branch information
peppy authored Dec 31, 2023
2 parents 68b1455 + 45f6c78 commit e107338
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions osu.Game/Screens/Menu/MainMenuButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ namespace osu.Game.Screens.Menu
/// </summary>
public partial class MainMenuButton : BeatSyncedContainer, IStateful<ButtonState>
{
public const float BOUNCE_COMPRESSION = 0.9f;
public const float HOVER_SCALE = 1.2f;
public const float BOUNCE_ROTATION = 8;
public event Action<ButtonState>? StateChanged;

public readonly Key[] TriggerKeys;
Expand Down Expand Up @@ -125,8 +128,9 @@ public MainMenuButton(LocalisableString text, string sampleName, IconUsage symbo
Shadow = true,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(30),
Size = new Vector2(32),
Position = new Vector2(0, 0),
Margin = new MarginPadding { Top = -4 },
Icon = symbol
},
new OsuSpriteText
Expand All @@ -136,6 +140,7 @@ public MainMenuButton(LocalisableString text, string sampleName, IconUsage symbo
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Position = new Vector2(0, 35),
Margin = new MarginPadding { Left = -3 },
Text = text
}
}
Expand All @@ -153,14 +158,14 @@ protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint,

double duration = timingPoint.BeatLength / 2;

icon.RotateTo(rightward ? 10 : -10, duration * 2, Easing.InOutSine);
icon.RotateTo(rightward ? BOUNCE_ROTATION : -BOUNCE_ROTATION, duration * 2, Easing.InOutSine);

icon.Animate(
i => i.MoveToY(-10, duration, Easing.Out),
i => i.ScaleTo(1, duration, Easing.Out)
i => i.ScaleTo(HOVER_SCALE, duration, Easing.Out)
).Then(
i => i.MoveToY(0, duration, Easing.In),
i => i.ScaleTo(new Vector2(1, 0.9f), duration, Easing.In)
i => i.ScaleTo(new Vector2(HOVER_SCALE, HOVER_SCALE * BOUNCE_COMPRESSION), duration, Easing.In)
);

rightward = !rightward;
Expand All @@ -177,8 +182,8 @@ protected override bool OnHover(HoverEvent e)
double duration = TimeUntilNextBeat;

icon.ClearTransforms();
icon.RotateTo(rightward ? -10 : 10, duration, Easing.InOutSine);
icon.ScaleTo(new Vector2(1, 0.9f), duration, Easing.Out);
icon.RotateTo(rightward ? -BOUNCE_ROTATION : BOUNCE_ROTATION, duration, Easing.InOutSine);
icon.ScaleTo(new Vector2(HOVER_SCALE, HOVER_SCALE * BOUNCE_COMPRESSION), duration, Easing.Out);
return true;
}

Expand Down

0 comments on commit e107338

Please sign in to comment.