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
|
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2016-12-06 09:56:20 +00:00
|
|
|
|
using System;
|
2023-10-20 10:22:00 +00:00
|
|
|
|
using System.Linq;
|
2016-10-08 03:53:46 +00:00
|
|
|
|
using osu.Framework;
|
2016-12-05 12:09:41 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Audio;
|
|
|
|
|
using osu.Framework.Audio.Sample;
|
2020-06-23 04:49:18 +00:00
|
|
|
|
using osu.Framework.Audio.Track;
|
2016-10-08 03:53:46 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-06-20 05:54:23 +00:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2017-01-31 09:53:52 +00:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2018-11-20 07:51:59 +00:00
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
using osuTK.Input;
|
2017-03-04 18:42:37 +00:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2017-07-09 09:23:34 +00:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2019-04-02 05:51:28 +00:00
|
|
|
|
using osu.Framework.Graphics.Effects;
|
2019-03-27 10:29:27 +00:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2018-10-02 03:02:47 +00:00
|
|
|
|
using osu.Framework.Input.Events;
|
2021-04-20 08:06:26 +00:00
|
|
|
|
using osu.Framework.Localisation;
|
2017-07-09 09:23:34 +00:00
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2016-11-14 08:23:33 +00:00
|
|
|
|
namespace osu.Game.Screens.Menu
|
2016-10-08 03:53:46 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Button designed specifically for the osu!next main menu.
|
|
|
|
|
/// In order to correctly flow, we have to use a negative margin on the parent container (due to the parallelogram shape).
|
|
|
|
|
/// </summary>
|
2022-03-25 06:12:39 +00:00
|
|
|
|
public partial class MainMenuButton : BeatSyncedContainer, IStateful<ButtonState>
|
2016-10-08 03:53:46 +00:00
|
|
|
|
{
|
2017-09-04 00:10:04 +00:00
|
|
|
|
public event Action<ButtonState> StateChanged;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2023-10-20 10:22:00 +00:00
|
|
|
|
public readonly Key[] TriggerKeys;
|
2019-09-22 11:30:58 +00:00
|
|
|
|
|
2017-03-23 04:41:50 +00:00
|
|
|
|
private readonly Container iconText;
|
|
|
|
|
private readonly Container box;
|
|
|
|
|
private readonly Box boxHoverLayer;
|
2017-08-03 05:36:21 +00:00
|
|
|
|
private readonly SpriteIcon icon;
|
2017-06-28 17:19:04 +00:00
|
|
|
|
private readonly string sampleName;
|
2018-07-03 09:18:04 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The menu state for which we are visible for.
|
|
|
|
|
/// </summary>
|
2018-07-06 08:53:01 +00:00
|
|
|
|
public ButtonSystemState VisibleState = ButtonSystemState.TopLevel;
|
2018-07-03 09:18:04 +00:00
|
|
|
|
|
2017-03-23 04:41:50 +00:00
|
|
|
|
private readonly Action clickAction;
|
2021-01-19 08:11:40 +00:00
|
|
|
|
private Sample sampleClick;
|
|
|
|
|
private Sample sampleHover;
|
2023-11-08 13:18:33 +00:00
|
|
|
|
private SampleChannel sampleChannel;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-09-26 05:01:15 +00:00
|
|
|
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => box.ReceivePositionalInputAt(screenSpacePos);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2023-10-20 10:22:00 +00:00
|
|
|
|
public MainMenuButton(LocalisableString text, string sampleName, IconUsage symbol, Color4 colour, Action clickAction = null, float extraWidth = 0, params Key[] triggerKeys)
|
2016-10-08 03:53:46 +00:00
|
|
|
|
{
|
2017-06-28 17:19:04 +00:00
|
|
|
|
this.sampleName = sampleName;
|
2016-10-08 03:53:46 +00:00
|
|
|
|
this.clickAction = clickAction;
|
2023-10-20 10:22:00 +00:00
|
|
|
|
TriggerKeys = triggerKeys;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2016-10-22 08:50:42 +00:00
|
|
|
|
AutoSizeAxes = Axes.Both;
|
2016-10-08 03:53:46 +00:00
|
|
|
|
Alpha = 0;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-07-03 09:18:04 +00:00
|
|
|
|
Vector2 boxSize = new Vector2(ButtonSystem.BUTTON_WIDTH + Math.Abs(extraWidth), ButtonArea.BUTTON_AREA_HEIGHT);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2016-10-08 03:53:46 +00:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2016-11-30 05:38:45 +00:00
|
|
|
|
box = new Container
|
2016-11-12 17:34:36 +00:00
|
|
|
|
{
|
2019-04-05 09:21:54 +00:00
|
|
|
|
// box needs to be always present to ensure the button is always sized correctly for flow
|
|
|
|
|
AlwaysPresent = true,
|
2016-11-30 05:38:45 +00:00
|
|
|
|
Masking = true,
|
2017-02-04 10:06:26 +00:00
|
|
|
|
MaskingSmoothness = 2,
|
2017-06-12 03:48:47 +00:00
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
2016-11-30 05:38:45 +00:00
|
|
|
|
{
|
|
|
|
|
Type = EdgeEffectType.Shadow,
|
2017-01-10 18:44:40 +00:00
|
|
|
|
Colour = Color4.Black.Opacity(0.2f),
|
2016-11-30 05:38:45 +00:00
|
|
|
|
Roundness = 5,
|
|
|
|
|
Radius = 8,
|
|
|
|
|
},
|
2016-11-12 17:34:36 +00:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Scale = new Vector2(0, 1),
|
|
|
|
|
Size = boxSize,
|
2017-02-07 07:15:45 +00:00
|
|
|
|
Shear = new Vector2(ButtonSystem.WEDGE_WIDTH / boxSize.Y, 0),
|
2017-06-07 11:53:37 +00:00
|
|
|
|
Children = new[]
|
2016-11-30 05:38:45 +00:00
|
|
|
|
{
|
2017-03-09 06:52:40 +00:00
|
|
|
|
new Box
|
2017-02-07 11:29:26 +00:00
|
|
|
|
{
|
|
|
|
|
EdgeSmoothness = new Vector2(1.5f, 0),
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = colour,
|
|
|
|
|
},
|
|
|
|
|
boxHoverLayer = new Box
|
2016-11-30 05:38:45 +00:00
|
|
|
|
{
|
2017-02-04 10:06:26 +00:00
|
|
|
|
EdgeSmoothness = new Vector2(1.5f, 0),
|
2016-11-30 05:38:45 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2019-08-21 04:29:50 +00:00
|
|
|
|
Blending = BlendingParameters.Additive,
|
2017-02-07 11:29:26 +00:00
|
|
|
|
Colour = Color4.White,
|
|
|
|
|
Alpha = 0,
|
2016-11-30 05:38:45 +00:00
|
|
|
|
},
|
|
|
|
|
}
|
2016-11-12 17:34:36 +00:00
|
|
|
|
},
|
|
|
|
|
iconText = new Container
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Position = new Vector2(extraWidth / 2, 0),
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Children = new Drawable[]
|
2016-10-08 03:53:46 +00:00
|
|
|
|
{
|
2017-08-03 05:36:21 +00:00
|
|
|
|
icon = new SpriteIcon
|
2016-11-12 17:34:36 +00:00
|
|
|
|
{
|
2016-11-30 04:15:34 +00:00
|
|
|
|
Shadow = true,
|
2016-11-12 17:34:36 +00:00
|
|
|
|
Anchor = Anchor.Centre,
|
2017-03-06 08:06:48 +00:00
|
|
|
|
Origin = Anchor.Centre,
|
2017-08-03 05:36:21 +00:00
|
|
|
|
Size = new Vector2(30),
|
2016-11-12 17:34:36 +00:00
|
|
|
|
Position = new Vector2(0, 0),
|
|
|
|
|
Icon = symbol
|
|
|
|
|
},
|
2017-01-31 09:53:52 +00:00
|
|
|
|
new OsuSpriteText
|
2016-10-08 03:53:46 +00:00
|
|
|
|
{
|
2016-11-30 04:15:34 +00:00
|
|
|
|
Shadow = true,
|
2017-02-26 20:32:43 +00:00
|
|
|
|
AllowMultiline = false,
|
2016-11-12 17:34:36 +00:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Position = new Vector2(0, 35),
|
|
|
|
|
Text = text
|
2016-10-08 03:53:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-11-12 17:34:36 +00:00
|
|
|
|
}
|
2016-10-08 03:53:46 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-09-15 06:24:31 +00:00
|
|
|
|
private bool rightward;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-06-23 04:49:18 +00:00
|
|
|
|
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes)
|
2016-10-08 03:53:46 +00:00
|
|
|
|
{
|
2017-07-09 09:23:34 +00:00
|
|
|
|
base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-07-09 09:23:34 +00:00
|
|
|
|
if (!IsHovered) return;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-07-09 09:23:34 +00:00
|
|
|
|
double duration = timingPoint.BeatLength / 2;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-07-22 18:50:25 +00:00
|
|
|
|
icon.RotateTo(rightward ? 10 : -10, duration * 2, Easing.InOutSine);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-07-16 14:37:59 +00:00
|
|
|
|
icon.Animate(
|
2017-07-22 18:50:25 +00:00
|
|
|
|
i => i.MoveToY(-10, duration, Easing.Out),
|
|
|
|
|
i => i.ScaleTo(1, duration, Easing.Out)
|
2017-07-16 14:37:59 +00:00
|
|
|
|
).Then(
|
2017-07-22 18:50:25 +00:00
|
|
|
|
i => i.MoveToY(0, duration, Easing.In),
|
|
|
|
|
i => i.ScaleTo(new Vector2(1, 0.9f), duration, Easing.In)
|
2017-07-16 14:37:59 +00:00
|
|
|
|
);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-09-15 06:24:31 +00:00
|
|
|
|
rightward = !rightward;
|
2017-07-09 09:23:34 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-10-02 03:02:47 +00:00
|
|
|
|
protected override bool OnHover(HoverEvent e)
|
2017-07-09 09:23:34 +00:00
|
|
|
|
{
|
|
|
|
|
if (State != ButtonState.Expanded) return true;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-07-09 09:23:34 +00:00
|
|
|
|
sampleHover?.Play();
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-07-22 18:50:25 +00:00
|
|
|
|
box.ScaleTo(new Vector2(1.5f, 1), 500, Easing.OutElastic);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-07-09 09:23:34 +00:00
|
|
|
|
double duration = TimeUntilNextBeat;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-07-09 09:23:34 +00:00
|
|
|
|
icon.ClearTransforms();
|
2017-09-15 06:24:31 +00:00
|
|
|
|
icon.RotateTo(rightward ? -10 : 10, duration, Easing.InOutSine);
|
2017-07-22 18:50:25 +00:00
|
|
|
|
icon.ScaleTo(new Vector2(1, 0.9f), duration, Easing.Out);
|
2016-10-08 03:53:46 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-10-02 03:02:47 +00:00
|
|
|
|
protected override void OnHoverLost(HoverLostEvent e)
|
2016-10-08 03:53:46 +00:00
|
|
|
|
{
|
2017-02-25 12:12:39 +00:00
|
|
|
|
icon.ClearTransforms();
|
2017-07-22 18:50:25 +00:00
|
|
|
|
icon.RotateTo(0, 500, Easing.Out);
|
|
|
|
|
icon.MoveTo(Vector2.Zero, 500, Easing.Out);
|
|
|
|
|
icon.ScaleTo(Vector2.One, 200, Easing.Out);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2016-10-08 03:53:46 +00:00
|
|
|
|
if (State == ButtonState.Expanded)
|
2017-07-22 18:50:25 +00:00
|
|
|
|
box.ScaleTo(new Vector2(1, 1), 500, Easing.OutElastic);
|
2016-10-08 03:53:46 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2016-12-05 12:09:41 +00:00
|
|
|
|
[BackgroundDependencyLoader]
|
2018-08-30 22:04:40 +00:00
|
|
|
|
private void load(AudioManager audio)
|
2016-12-05 12:09:41 +00:00
|
|
|
|
{
|
2019-05-28 08:06:01 +00:00
|
|
|
|
sampleHover = audio.Samples.Get(@"Menu/button-hover");
|
2022-04-15 11:31:59 +00:00
|
|
|
|
sampleClick = audio.Samples.Get(!string.IsNullOrEmpty(sampleName) ? $@"Menu/{sampleName}" : @"UI/button-select");
|
2016-12-05 12:09:41 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-10-02 03:02:47 +00:00
|
|
|
|
protected override bool OnMouseDown(MouseDownEvent e)
|
2017-02-07 11:29:26 +00:00
|
|
|
|
{
|
2017-07-22 18:50:25 +00:00
|
|
|
|
boxHoverLayer.FadeTo(0.1f, 1000, Easing.OutQuint);
|
2018-10-02 03:02:47 +00:00
|
|
|
|
return base.OnMouseDown(e);
|
2017-02-07 11:29:26 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-01-20 09:17:21 +00:00
|
|
|
|
protected override void OnMouseUp(MouseUpEvent e)
|
2017-02-07 11:29:26 +00:00
|
|
|
|
{
|
2017-07-22 18:50:25 +00:00
|
|
|
|
boxHoverLayer.FadeTo(0, 1000, Easing.OutQuint);
|
2020-01-20 09:17:21 +00:00
|
|
|
|
base.OnMouseUp(e);
|
2017-02-07 11:29:26 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-10-02 03:02:47 +00:00
|
|
|
|
protected override bool OnClick(ClickEvent e)
|
2016-10-08 03:53:46 +00:00
|
|
|
|
{
|
|
|
|
|
trigger();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-10-02 03:02:47 +00:00
|
|
|
|
protected override bool OnKeyDown(KeyDownEvent e)
|
2016-10-08 03:53:46 +00:00
|
|
|
|
{
|
2022-03-25 06:13:22 +00:00
|
|
|
|
if (e.Repeat || e.ControlPressed || e.ShiftPressed || e.AltPressed || e.SuperPressed)
|
2017-03-03 05:08:37 +00:00
|
|
|
|
return false;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2023-10-20 10:22:00 +00:00
|
|
|
|
if (TriggerKeys.Contains(e.Key))
|
2016-10-08 03:53:46 +00:00
|
|
|
|
{
|
|
|
|
|
trigger();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2016-10-08 03:53:46 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2016-10-08 03:53:46 +00:00
|
|
|
|
private void trigger()
|
|
|
|
|
{
|
2023-11-08 13:18:33 +00:00
|
|
|
|
sampleChannel = sampleClick?.GetChannel();
|
|
|
|
|
sampleChannel?.Play();
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-02-07 13:19:36 +00:00
|
|
|
|
clickAction?.Invoke();
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-02-25 12:12:39 +00:00
|
|
|
|
boxHoverLayer.ClearTransforms();
|
2017-02-07 11:29:26 +00:00
|
|
|
|
boxHoverLayer.Alpha = 0.9f;
|
2017-07-22 18:50:25 +00:00
|
|
|
|
boxHoverLayer.FadeOut(800, Easing.OutExpo);
|
2016-10-08 03:53:46 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-09-26 05:01:15 +00:00
|
|
|
|
public override bool HandleNonPositionalInput => state == ButtonState.Expanded;
|
|
|
|
|
public override bool HandlePositionalInput => state != ButtonState.Exploded && box.Scale.X >= 0.8f;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2023-11-08 13:18:33 +00:00
|
|
|
|
public void StopSamplePlayback() => sampleChannel?.Stop();
|
|
|
|
|
|
2016-10-08 03:53:46 +00:00
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
2019-11-20 12:19:49 +00:00
|
|
|
|
iconText.Alpha = Math.Clamp((box.Scale.X - 0.5f) / 0.3f, 0, 1);
|
2016-10-08 03:53:46 +00:00
|
|
|
|
base.Update();
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2016-10-08 03:53:46 +00:00
|
|
|
|
public int ContractStyle;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-03-07 01:59:19 +00:00
|
|
|
|
private ButtonState state;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2016-10-08 03:53:46 +00:00
|
|
|
|
public ButtonState State
|
|
|
|
|
{
|
2019-02-28 04:58:19 +00:00
|
|
|
|
get => state;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-06-07 11:53:37 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
2016-10-08 03:53:46 +00:00
|
|
|
|
if (state == value)
|
|
|
|
|
return;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2016-10-08 03:53:46 +00:00
|
|
|
|
state = value;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2016-10-08 03:53:46 +00:00
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case ButtonState.Contracted:
|
|
|
|
|
switch (ContractStyle)
|
|
|
|
|
{
|
|
|
|
|
default:
|
2017-07-22 18:50:25 +00:00
|
|
|
|
box.ScaleTo(new Vector2(0, 1), 500, Easing.OutExpo);
|
2017-07-14 16:18:12 +00:00
|
|
|
|
this.FadeOut(500);
|
2016-10-08 03:53:46 +00:00
|
|
|
|
break;
|
2019-04-01 03:44:46 +00:00
|
|
|
|
|
2016-10-08 03:53:46 +00:00
|
|
|
|
case 1:
|
2017-07-22 18:50:25 +00:00
|
|
|
|
box.ScaleTo(new Vector2(0, 1), 400, Easing.InSine);
|
2017-07-14 16:18:12 +00:00
|
|
|
|
this.FadeOut(800);
|
2016-10-08 03:53:46 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2018-07-03 09:18:04 +00:00
|
|
|
|
|
2016-10-08 03:53:46 +00:00
|
|
|
|
break;
|
2019-04-01 03:44:46 +00:00
|
|
|
|
|
2016-10-08 03:53:46 +00:00
|
|
|
|
case ButtonState.Expanded:
|
|
|
|
|
const int expand_duration = 500;
|
2017-07-22 18:50:25 +00:00
|
|
|
|
box.ScaleTo(new Vector2(1, 1), expand_duration, Easing.OutExpo);
|
2017-07-14 16:18:12 +00:00
|
|
|
|
this.FadeIn(expand_duration / 6f);
|
2016-10-08 03:53:46 +00:00
|
|
|
|
break;
|
2019-04-01 03:44:46 +00:00
|
|
|
|
|
2016-10-08 03:53:46 +00:00
|
|
|
|
case ButtonState.Exploded:
|
|
|
|
|
const int explode_duration = 200;
|
2017-07-22 18:50:25 +00:00
|
|
|
|
box.ScaleTo(new Vector2(2, 1), explode_duration, Easing.OutExpo);
|
2017-07-14 16:18:12 +00:00
|
|
|
|
this.FadeOut(explode_duration / 4f * 3);
|
2016-10-08 03:53:46 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-09-04 00:10:04 +00:00
|
|
|
|
StateChanged?.Invoke(State);
|
2016-10-08 03:53:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-03 09:18:04 +00:00
|
|
|
|
|
|
|
|
|
public ButtonSystemState ButtonSystemState
|
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
ContractStyle = 0;
|
|
|
|
|
|
|
|
|
|
switch (value)
|
|
|
|
|
{
|
|
|
|
|
case ButtonSystemState.Initial:
|
|
|
|
|
State = ButtonState.Contracted;
|
|
|
|
|
break;
|
2019-04-01 03:44:46 +00:00
|
|
|
|
|
2018-07-03 09:18:04 +00:00
|
|
|
|
case ButtonSystemState.EnteringMode:
|
|
|
|
|
ContractStyle = 1;
|
|
|
|
|
State = ButtonState.Contracted;
|
|
|
|
|
break;
|
2019-04-01 03:44:46 +00:00
|
|
|
|
|
2018-07-03 09:18:04 +00:00
|
|
|
|
default:
|
2018-07-06 08:53:01 +00:00
|
|
|
|
if (value == VisibleState)
|
2018-07-03 09:18:04 +00:00
|
|
|
|
State = ButtonState.Expanded;
|
|
|
|
|
else if (value < VisibleState)
|
|
|
|
|
State = ButtonState.Contracted;
|
|
|
|
|
else
|
|
|
|
|
State = ButtonState.Exploded;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-10-08 03:53:46 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2016-10-08 03:53:46 +00:00
|
|
|
|
public enum ButtonState
|
|
|
|
|
{
|
|
|
|
|
Contracted,
|
|
|
|
|
Expanded,
|
|
|
|
|
Exploded
|
|
|
|
|
}
|
|
|
|
|
}
|