2019-01-24 08:43:03 +00:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Framework;
|
|
|
|
|
using osu.Framework.Allocation;
|
2018-04-29 17:15:09 +00:00
|
|
|
|
using osu.Framework.Audio;
|
|
|
|
|
using osu.Framework.Audio.Sample;
|
2019-02-21 10:04:31 +00:00
|
|
|
|
using osu.Framework.Bindables;
|
2019-03-26 08:18:35 +00:00
|
|
|
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-03-27 10:29:27 +00:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2018-05-14 17:27:05 +00:00
|
|
|
|
using osu.Framework.Input.Bindings;
|
2019-09-22 11:30:58 +00:00
|
|
|
|
using osu.Framework.Input.Events;
|
2018-07-03 09:18:04 +00:00
|
|
|
|
using osu.Framework.Logging;
|
2019-02-25 00:56:00 +00:00
|
|
|
|
using osu.Framework.Platform;
|
2018-04-29 17:15:09 +00:00
|
|
|
|
using osu.Framework.Threading;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Game.Graphics;
|
2019-03-26 08:18:35 +00:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2018-11-19 17:48:59 +00:00
|
|
|
|
using osu.Game.Input;
|
2018-05-14 17:27:05 +00:00
|
|
|
|
using osu.Game.Input.Bindings;
|
2018-12-04 08:43:27 +00:00
|
|
|
|
using osu.Game.Online.API;
|
2018-06-06 07:17:51 +00:00
|
|
|
|
using osu.Game.Overlays;
|
2018-12-04 08:43:27 +00:00
|
|
|
|
using osu.Game.Overlays.Notifications;
|
2018-11-20 07:51:59 +00:00
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
using osuTK.Input;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Menu
|
|
|
|
|
{
|
2018-07-03 09:18:04 +00:00
|
|
|
|
public class ButtonSystem : Container, IStateful<ButtonSystemState>, IKeyBindingHandler<GlobalAction>
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2018-07-03 09:18:04 +00:00
|
|
|
|
public event Action<ButtonSystemState> StateChanged;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-11-26 08:07:30 +00:00
|
|
|
|
private readonly IBindable<bool> isIdle = new BindableBool();
|
2018-11-26 07:32:59 +00:00
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
public Action OnEdit;
|
|
|
|
|
public Action OnExit;
|
2020-04-21 07:00:00 +00:00
|
|
|
|
public Action OnBeatmapListing;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
public Action OnSolo;
|
|
|
|
|
public Action OnSettings;
|
|
|
|
|
public Action OnMulti;
|
|
|
|
|
public Action OnChart;
|
|
|
|
|
|
|
|
|
|
public const float BUTTON_WIDTH = 140f;
|
|
|
|
|
public const float WEDGE_WIDTH = 20;
|
|
|
|
|
|
|
|
|
|
private OsuLogo logo;
|
|
|
|
|
|
2019-03-27 08:28:53 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Assign the <see cref="OsuLogo"/> that this ButtonSystem should manage the position of.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="logo">The instance of the logo to be assigned. If null, we are suspending from the screen that uses this ButtonSystem.</param>
|
2018-04-13 09:19:50 +00:00
|
|
|
|
public void SetOsuLogo(OsuLogo logo)
|
|
|
|
|
{
|
|
|
|
|
this.logo = logo;
|
|
|
|
|
|
|
|
|
|
if (this.logo != null)
|
|
|
|
|
{
|
|
|
|
|
this.logo.Action = onOsuLogo;
|
|
|
|
|
|
|
|
|
|
// osuLogo.SizeForFlow relies on loading to be complete.
|
2018-07-03 09:18:04 +00:00
|
|
|
|
buttonArea.Flow.Position = new Vector2(WEDGE_WIDTH * 2 - (BUTTON_WIDTH + this.logo.SizeForFlow / 4), 0);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
updateLogoState();
|
|
|
|
|
}
|
2019-03-26 08:18:35 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2019-03-27 02:37:16 +00:00
|
|
|
|
// We should stop tracking as the facade is now out of scope.
|
2019-04-08 06:24:09 +00:00
|
|
|
|
logoTrackingContainer.StopTracking();
|
2019-03-26 08:18:35 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-03 09:18:04 +00:00
|
|
|
|
private readonly ButtonArea buttonArea;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
private readonly Button backButton;
|
|
|
|
|
|
|
|
|
|
private readonly List<Button> buttonsTopLevel = new List<Button>();
|
|
|
|
|
private readonly List<Button> buttonsPlay = new List<Button>();
|
|
|
|
|
|
|
|
|
|
private SampleChannel sampleBack;
|
|
|
|
|
|
2019-04-05 03:02:47 +00:00
|
|
|
|
private readonly LogoTrackingContainer logoTrackingContainer;
|
2019-03-26 08:18:35 +00:00
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
public ButtonSystem()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
|
2019-04-05 03:02:47 +00:00
|
|
|
|
Child = logoTrackingContainer = new LogoTrackingContainer
|
2019-03-26 08:18:35 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Child = buttonArea = new ButtonArea()
|
|
|
|
|
};
|
2018-07-03 09:18:04 +00:00
|
|
|
|
|
2019-04-05 03:02:47 +00:00
|
|
|
|
buttonArea.AddRange(new Drawable[]
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-04-02 10:55:24 +00:00
|
|
|
|
new Button(@"settings", string.Empty, FontAwesome.Solid.Cog, new Color4(85, 85, 85, 255), () => OnSettings?.Invoke(), -WEDGE_WIDTH, Key.O),
|
2019-03-27 10:29:27 +00:00
|
|
|
|
backButton = new Button(@"back", @"button-back-select", OsuIcon.LeftCircle, new Color4(51, 58, 94, 255), () => State = ButtonSystemState.TopLevel, -WEDGE_WIDTH)
|
2018-07-03 09:18:04 +00:00
|
|
|
|
{
|
|
|
|
|
VisibleState = ButtonSystemState.Play,
|
2018-04-13 09:19:50 +00:00
|
|
|
|
},
|
2019-04-17 08:24:09 +00:00
|
|
|
|
logoTrackingContainer.LogoFacade.With(d => d.Scale = new Vector2(0.74f))
|
2018-07-03 09:18:04 +00:00
|
|
|
|
});
|
|
|
|
|
|
2019-04-05 03:02:47 +00:00
|
|
|
|
buttonArea.Flow.CentreTarget = logoTrackingContainer.LogoFacade;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-12-26 04:18:36 +00:00
|
|
|
|
[Resolved(CanBeNull = true)]
|
2018-12-04 08:43:27 +00:00
|
|
|
|
private OsuGame game { get; set; }
|
|
|
|
|
|
|
|
|
|
[Resolved]
|
2019-03-13 03:56:47 +00:00
|
|
|
|
private IAPIProvider api { get; set; }
|
2018-12-04 08:43:27 +00:00
|
|
|
|
|
2018-12-26 04:18:36 +00:00
|
|
|
|
[Resolved(CanBeNull = true)]
|
2018-12-04 08:43:27 +00:00
|
|
|
|
private NotificationOverlay notifications { get; set; }
|
2018-06-06 07:17:51 +00:00
|
|
|
|
|
2019-04-06 16:52:30 +00:00
|
|
|
|
[Resolved(CanBeNull = true)]
|
2019-04-06 16:05:13 +00:00
|
|
|
|
private LoginOverlay loginOverlay { get; set; }
|
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
[BackgroundDependencyLoader(true)]
|
2019-02-25 00:56:00 +00:00
|
|
|
|
private void load(AudioManager audio, IdleTracker idleTracker, GameHost host)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-04-02 10:55:24 +00:00
|
|
|
|
buttonsPlay.Add(new Button(@"solo", @"button-solo-select", FontAwesome.Solid.User, new Color4(102, 68, 204, 255), () => OnSolo?.Invoke(), WEDGE_WIDTH, Key.P));
|
|
|
|
|
buttonsPlay.Add(new Button(@"multi", @"button-generic-select", FontAwesome.Solid.Users, new Color4(94, 63, 186, 255), onMulti, 0, Key.M));
|
2019-03-27 10:29:27 +00:00
|
|
|
|
buttonsPlay.Add(new Button(@"chart", @"button-generic-select", OsuIcon.Charts, new Color4(80, 53, 160, 255), () => OnChart?.Invoke()));
|
2019-02-25 12:41:41 +00:00
|
|
|
|
buttonsPlay.ForEach(b => b.VisibleState = ButtonSystemState.Play);
|
|
|
|
|
|
2019-03-27 10:29:27 +00:00
|
|
|
|
buttonsTopLevel.Add(new Button(@"play", @"button-play-select", OsuIcon.Logo, new Color4(102, 68, 204, 255), () => State = ButtonSystemState.Play, WEDGE_WIDTH, Key.P));
|
|
|
|
|
buttonsTopLevel.Add(new Button(@"osu!editor", @"button-generic-select", OsuIcon.EditCircle, new Color4(238, 170, 0, 255), () => OnEdit?.Invoke(), 0, Key.E));
|
2020-04-21 07:00:00 +00:00
|
|
|
|
buttonsTopLevel.Add(new Button(@"osu!direct", @"button-direct-select", OsuIcon.ChevronDownCircle, new Color4(165, 204, 0, 255), () => OnBeatmapListing?.Invoke(), 0, Key.D));
|
2019-02-25 12:41:41 +00:00
|
|
|
|
|
2019-02-25 00:56:00 +00:00
|
|
|
|
if (host.CanExit)
|
2019-03-27 10:29:27 +00:00
|
|
|
|
buttonsTopLevel.Add(new Button(@"exit", string.Empty, OsuIcon.CrossCircle, new Color4(238, 51, 153, 255), () => OnExit?.Invoke(), 0, Key.Q));
|
2019-02-25 00:56:00 +00:00
|
|
|
|
|
|
|
|
|
buttonArea.AddRange(buttonsPlay);
|
|
|
|
|
buttonArea.AddRange(buttonsTopLevel);
|
|
|
|
|
|
2019-03-26 08:18:35 +00:00
|
|
|
|
buttonArea.ForEach(b =>
|
|
|
|
|
{
|
|
|
|
|
if (b is Button)
|
|
|
|
|
{
|
|
|
|
|
b.Origin = Anchor.CentreLeft;
|
|
|
|
|
b.Anchor = Anchor.CentreLeft;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2019-02-22 08:51:39 +00:00
|
|
|
|
isIdle.ValueChanged += idle => updateIdleState(idle.NewValue);
|
2018-12-04 08:43:27 +00:00
|
|
|
|
|
2018-11-26 07:50:41 +00:00
|
|
|
|
if (idleTracker != null) isIdle.BindTo(idleTracker.IsIdle);
|
2018-11-26 07:32:59 +00:00
|
|
|
|
|
2019-05-28 08:06:01 +00:00
|
|
|
|
sampleBack = audio.Samples.Get(@"Menu/button-back-select");
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-12-04 08:43:27 +00:00
|
|
|
|
private void onMulti()
|
|
|
|
|
{
|
|
|
|
|
if (!api.IsLoggedIn)
|
|
|
|
|
{
|
2018-12-26 04:18:36 +00:00
|
|
|
|
notifications?.Post(new SimpleNotification
|
2018-12-04 08:43:27 +00:00
|
|
|
|
{
|
|
|
|
|
Text = "You gotta be logged in to multi 'yo!",
|
2019-04-06 16:05:13 +00:00
|
|
|
|
Icon = FontAwesome.Solid.Globe,
|
|
|
|
|
Activated = () =>
|
|
|
|
|
{
|
2019-04-06 16:52:30 +00:00
|
|
|
|
loginOverlay?.Show();
|
2019-04-06 16:05:13 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2018-12-04 08:43:27 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
2018-12-26 04:18:36 +00:00
|
|
|
|
|
2018-12-04 08:43:27 +00:00
|
|
|
|
OnMulti?.Invoke();
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-26 07:32:59 +00:00
|
|
|
|
private void updateIdleState(bool isIdle)
|
|
|
|
|
{
|
2019-05-31 05:06:13 +00:00
|
|
|
|
if (isIdle && State != ButtonSystemState.Exit && State != ButtonSystemState.EnteringMode)
|
2018-11-26 07:32:59 +00:00
|
|
|
|
State = ButtonSystemState.Initial;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-22 11:30:58 +00:00
|
|
|
|
protected override bool OnKeyDown(KeyDownEvent e)
|
|
|
|
|
{
|
|
|
|
|
if (State == ButtonSystemState.Initial)
|
|
|
|
|
{
|
2019-09-24 06:09:08 +00:00
|
|
|
|
if (buttonsTopLevel.Any(b => e.Key == b.TriggerKey))
|
2019-09-22 11:30:58 +00:00
|
|
|
|
{
|
2019-09-22 12:42:32 +00:00
|
|
|
|
logo?.Click();
|
2019-09-22 11:30:58 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return base.OnKeyDown(e);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-14 17:27:05 +00:00
|
|
|
|
public bool OnPressed(GlobalAction action)
|
2018-04-29 17:15:09 +00:00
|
|
|
|
{
|
2018-05-14 17:27:05 +00:00
|
|
|
|
switch (action)
|
|
|
|
|
{
|
|
|
|
|
case GlobalAction.Back:
|
2018-05-21 14:09:00 +00:00
|
|
|
|
return goBack();
|
2019-04-01 03:16:05 +00:00
|
|
|
|
|
2018-07-03 09:37:21 +00:00
|
|
|
|
case GlobalAction.Select:
|
2018-09-18 09:05:25 +00:00
|
|
|
|
logo?.Click();
|
2018-07-03 09:37:21 +00:00
|
|
|
|
return true;
|
2019-04-01 03:16:05 +00:00
|
|
|
|
|
2018-05-21 14:09:00 +00:00
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-22 04:22:34 +00:00
|
|
|
|
public void OnReleased(GlobalAction action)
|
|
|
|
|
{
|
|
|
|
|
}
|
2018-07-03 09:18:04 +00:00
|
|
|
|
|
2018-05-21 14:09:00 +00:00
|
|
|
|
private bool goBack()
|
|
|
|
|
{
|
|
|
|
|
switch (State)
|
|
|
|
|
{
|
2018-07-03 09:18:04 +00:00
|
|
|
|
case ButtonSystemState.TopLevel:
|
|
|
|
|
State = ButtonSystemState.Initial;
|
|
|
|
|
sampleBack?.Play();
|
2018-05-21 14:09:00 +00:00
|
|
|
|
return true;
|
2019-04-01 03:16:05 +00:00
|
|
|
|
|
2018-07-03 09:18:04 +00:00
|
|
|
|
case ButtonSystemState.Play:
|
2018-09-18 09:05:25 +00:00
|
|
|
|
backButton.Click();
|
2018-05-21 14:09:00 +00:00
|
|
|
|
return true;
|
2019-04-01 03:16:05 +00:00
|
|
|
|
|
2018-05-14 17:27:05 +00:00
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2018-04-29 17:15:09 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
private bool onOsuLogo()
|
|
|
|
|
{
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
return true;
|
2019-04-01 03:16:05 +00:00
|
|
|
|
|
2018-07-03 09:18:04 +00:00
|
|
|
|
case ButtonSystemState.Initial:
|
|
|
|
|
State = ButtonSystemState.TopLevel;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
return true;
|
2019-04-01 03:16:05 +00:00
|
|
|
|
|
2018-07-03 09:18:04 +00:00
|
|
|
|
case ButtonSystemState.TopLevel:
|
2018-09-18 09:05:25 +00:00
|
|
|
|
buttonsTopLevel.First().Click();
|
2018-04-13 09:19:50 +00:00
|
|
|
|
return false;
|
2019-04-01 03:16:05 +00:00
|
|
|
|
|
2018-07-03 09:18:04 +00:00
|
|
|
|
case ButtonSystemState.Play:
|
2018-09-18 09:05:25 +00:00
|
|
|
|
buttonsPlay.First().Click();
|
2018-04-13 09:19:50 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-03 09:18:04 +00:00
|
|
|
|
private ButtonSystemState state = ButtonSystemState.Initial;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-09-26 05:01:15 +00:00
|
|
|
|
public override bool HandleNonPositionalInput => state != ButtonSystemState.Exit;
|
|
|
|
|
public override bool HandlePositionalInput => state != ButtonSystemState.Exit;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-07-03 09:18:04 +00:00
|
|
|
|
public ButtonSystemState State
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-02-28 04:58:19 +00:00
|
|
|
|
get => state;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (state == value) return;
|
|
|
|
|
|
2018-07-03 09:18:04 +00:00
|
|
|
|
ButtonSystemState lastState = state;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
state = value;
|
|
|
|
|
|
2018-08-23 02:20:20 +00:00
|
|
|
|
if (game != null)
|
|
|
|
|
game.OverlayActivationMode.Value = state == ButtonSystemState.Exit ? OverlayActivation.Disabled : OverlayActivation.All;
|
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
updateLogoState(lastState);
|
|
|
|
|
|
2018-07-03 09:18:04 +00:00
|
|
|
|
Logger.Log($"{nameof(ButtonSystem)}'s state changed from {lastState} to {state}");
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-07-03 09:18:04 +00:00
|
|
|
|
using (buttonArea.BeginDelayedSequence(lastState == ButtonSystemState.Initial ? 150 : 0, true))
|
|
|
|
|
{
|
|
|
|
|
buttonArea.ButtonSystemState = state;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-07-03 09:18:04 +00:00
|
|
|
|
foreach (var b in buttonArea.Children.OfType<Button>())
|
|
|
|
|
b.ButtonSystemState = state;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StateChanged?.Invoke(State);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ScheduledDelegate logoDelayedAction;
|
|
|
|
|
|
2018-07-03 09:18:04 +00:00
|
|
|
|
private void updateLogoState(ButtonSystemState lastState = ButtonSystemState.Initial)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
if (logo == null) return;
|
|
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
2018-07-03 09:18:04 +00:00
|
|
|
|
case ButtonSystemState.Exit:
|
|
|
|
|
case ButtonSystemState.Initial:
|
2018-05-30 10:50:00 +00:00
|
|
|
|
logoDelayedAction?.Cancel();
|
2018-04-13 09:19:50 +00:00
|
|
|
|
logoDelayedAction = Scheduler.AddDelayed(() =>
|
2020-02-15 02:54:29 +00:00
|
|
|
|
{
|
|
|
|
|
logoTrackingContainer.StopTracking();
|
2018-05-21 15:24:57 +00:00
|
|
|
|
|
2020-02-15 02:54:29 +00:00
|
|
|
|
game?.Toolbar.Hide();
|
2018-06-06 07:17:51 +00:00
|
|
|
|
|
2020-02-15 02:54:29 +00:00
|
|
|
|
logo.ClearTransforms(targetMember: nameof(Position));
|
|
|
|
|
logo.MoveTo(new Vector2(0.5f), 800, Easing.OutExpo);
|
|
|
|
|
logo.ScaleTo(1, 800, Easing.OutExpo);
|
|
|
|
|
}, buttonArea.Alpha * 150);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
break;
|
2019-04-01 03:16:05 +00:00
|
|
|
|
|
2018-07-03 09:18:04 +00:00
|
|
|
|
case ButtonSystemState.TopLevel:
|
|
|
|
|
case ButtonSystemState.Play:
|
2018-04-13 09:19:50 +00:00
|
|
|
|
switch (lastState)
|
|
|
|
|
{
|
2018-07-03 09:18:04 +00:00
|
|
|
|
case ButtonSystemState.TopLevel: // coming from toplevel to play
|
2018-05-30 10:50:00 +00:00
|
|
|
|
break;
|
2019-04-01 03:16:05 +00:00
|
|
|
|
|
2018-07-03 09:18:04 +00:00
|
|
|
|
case ButtonSystemState.Initial:
|
2018-05-30 10:50:00 +00:00
|
|
|
|
logo.ClearTransforms(targetMember: nameof(Position));
|
|
|
|
|
|
|
|
|
|
bool impact = logo.Scale.X > 0.6f;
|
|
|
|
|
|
2018-07-03 09:18:04 +00:00
|
|
|
|
if (lastState == ButtonSystemState.Initial)
|
2018-05-30 10:50:00 +00:00
|
|
|
|
logo.ScaleTo(0.5f, 200, Easing.In);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-04-08 06:24:09 +00:00
|
|
|
|
logoTrackingContainer.StartTracking(logo, lastState == ButtonSystemState.EnteringMode ? 0 : 200, Easing.In);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-05-30 10:50:00 +00:00
|
|
|
|
logoDelayedAction?.Cancel();
|
2018-04-13 09:19:50 +00:00
|
|
|
|
logoDelayedAction = Scheduler.AddDelayed(() =>
|
|
|
|
|
{
|
2018-05-31 06:17:59 +00:00
|
|
|
|
if (impact)
|
|
|
|
|
logo.Impact();
|
2018-06-06 07:17:51 +00:00
|
|
|
|
|
2018-08-23 02:20:20 +00:00
|
|
|
|
game?.Toolbar.Show();
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}, 200);
|
|
|
|
|
break;
|
2019-04-01 03:16:05 +00:00
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
default:
|
2018-05-30 10:50:00 +00:00
|
|
|
|
logo.ClearTransforms(targetMember: nameof(Position));
|
2019-04-08 06:24:09 +00:00
|
|
|
|
logoTrackingContainer.StartTracking(logo, 0, Easing.In);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
logo.ScaleTo(0.5f, 200, Easing.OutQuint);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2018-04-29 17:15:09 +00:00
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
break;
|
2019-04-01 03:16:05 +00:00
|
|
|
|
|
2018-07-03 09:18:04 +00:00
|
|
|
|
case ButtonSystemState.EnteringMode:
|
2019-07-05 07:07:17 +00:00
|
|
|
|
logoTrackingContainer.StartTracking(logo, lastState == ButtonSystemState.Initial ? MainMenu.FADE_OUT_DURATION : 0, Easing.InSine);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-03 09:18:04 +00:00
|
|
|
|
public enum ButtonSystemState
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2018-07-03 09:18:04 +00:00
|
|
|
|
Exit,
|
2018-04-13 09:19:50 +00:00
|
|
|
|
Initial,
|
|
|
|
|
TopLevel,
|
|
|
|
|
Play,
|
|
|
|
|
EnteringMode,
|
|
|
|
|
}
|
|
|
|
|
}
|