diff --git a/osu.Game.Tests/Visual/TestCaseClickableText.cs b/osu.Game.Tests/Visual/TestCaseClickableText.cs deleted file mode 100644 index 60ee764cfc..0000000000 --- a/osu.Game.Tests/Visual/TestCaseClickableText.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework.Graphics.Containers; -using osu.Game.Graphics.UserInterface; -using System; -using System.Collections.Generic; - -namespace osu.Game.Tests.Visual -{ - public class TestCaseClickableText : OsuTestCase - { - public override IReadOnlyList RequiredTypes => new[] { typeof(ClickableText), typeof(FillFlowContainer) }; - - private readonly ClickableText text; - public TestCaseClickableText() => Child = new FillFlowContainer - { - Children = new[] - { - new ClickableText { Text = "Default", }, - new ClickableText { IsEnabled = false, Text = "Disabled", }, - new ClickableText { Text = "Without sounds", IsMuted = true, }, - new ClickableText { Text = "Without click sounds", IsClickMuted = true, }, - new ClickableText { Text = "Without hover sounds", IsHoverMuted = true, }, - text = new ClickableText { Text = "Disables after click (Action)", Action = () => text.IsEnabled = false }, - new ClickableText { Text = "Has tooltip", TooltipText = "Yep", }, - } - }; - } -} diff --git a/osu.Game/Graphics/UserInterface/ClickableText.cs b/osu.Game/Graphics/UserInterface/ClickableText.cs deleted file mode 100644 index e0121ae28c..0000000000 --- a/osu.Game/Graphics/UserInterface/ClickableText.cs +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using OpenTK.Graphics; -using osu.Framework.Allocation; -using osu.Framework.Audio; -using osu.Framework.Audio.Sample; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Cursor; -using osu.Framework.Input.States; -using osu.Game.Graphics.Sprites; -using System; - -namespace osu.Game.Graphics.UserInterface -{ - // created a new class instead of using a Link in - // some kind of textflowcontainer because they aren't - // capable of having delegates/actions on click - // and (probably) can't be disabled - public class ClickableText : OsuSpriteText, IHasTooltip - { - private bool isEnabled; - private bool isMuted; - - private SampleChannel sampleHover; - private SampleChannel sampleClick; - - protected Color4 HoverColour; - protected Color4 IdleColour; - - /// - /// An action that can be set to execute after click. - /// - public Action Action; - - /// - /// If set to true, a sound will be played on click. - /// - public bool IsClickMuted; - - /// - /// If set to true, a sound will be played on hover. - /// - public bool IsHoverMuted; - - /// - /// If disabled, no sounds will be played and wont execute. - /// True by default. - /// - public bool IsEnabled - { - get { return isEnabled; } - set - { - isEnabled = value; - this.FadeTo(value ? 1 : 0.5f, 250); - } - } - - /// - /// Whether to play sounds on hover and click. Automatically sets - /// and to the same value.> - /// - public bool IsMuted { - get { return isMuted; } - set - { - IsHoverMuted = value; - IsClickMuted = value; - isMuted = value; - } - } - - /// - /// A text with sounds on hover and click, - /// an action that can be set to execute on click, - /// and a tooltip. - /// - public ClickableText() => isEnabled = true; - - public override bool HandleMouseInput => true; - - protected override bool OnHover(InputState state) - { - if (isEnabled) - { - this.FadeColour(HoverColour, 500, Easing.OutQuint); - if (!IsHoverMuted) - sampleHover?.Play(); - } - return base.OnHover(state); - } - - protected override void OnHoverLost(InputState state) - { - this.FadeColour(IdleColour, 500, Easing.OutQuint); - base.OnHoverLost(state); - } - - protected override bool OnClick(InputState state) - { - if (isEnabled) - { - if (!IsClickMuted) - sampleClick?.Play(); - Action?.Invoke(); - } - return base.OnClick(state); - } - - protected override void LoadComplete() - { - IdleColour = Colour; - base.LoadComplete(); - } - - public string TooltipText { get; set; } - - [BackgroundDependencyLoader] - private void load(AudioManager audio, OsuColour colours) - { - sampleClick = audio.Sample.Get(@"UI/generic-select-soft"); - sampleHover = audio.Sample.Get(@"UI/generic-hover-soft"); - HoverColour = colours.Yellow; - } - } -} diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 3e0023ea9a..3208f424ce 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -118,7 +118,7 @@ namespace osu.Game.Overlays.Changelog public ChangelogContentGroup(APIChangelog build, bool newDate) { - ClickableText clickableText; + OsuHoverContainer clickableBuildText; RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; Direction = FillDirection.Vertical; @@ -138,29 +138,33 @@ namespace osu.Game.Overlays.Changelog Margin = new MarginPadding { Top = 20 }, Alpha = newDate ? 1 : 0, }, - new FillFlowContainer + clickableBuildText = new OsuHoverContainer { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, Margin = new MarginPadding { Top = 20 }, - Spacing = new Vector2(5), - Children = new Drawable[] + Action = () => OnBuildSelected(build), + Child = new FillFlowContainer { - new SpriteText + Direction = FillDirection.Horizontal, + Spacing = new Vector2(5), + AutoSizeAxes = Axes.Both, + Children = new Drawable[] { - Text = build.UpdateStream.DisplayName, - TextSize = 20, // web: 18, - Font = @"Exo2.0-Medium", - }, - clickableText = new ClickableText - { - Text = build.DisplayVersion, - TextSize = 20, // web: 18, - Font = @"Exo2.0-Light", - Colour = StreamColour.FromStreamName(build.UpdateStream.Name), - Action = () => OnBuildSelected(build), + new SpriteText + { + Text = build.UpdateStream.DisplayName, + TextSize = 20, // web: 18, + Font = @"Exo2.0-Medium", + }, + new SpriteText + { + Text = build.DisplayVersion, + TextSize = 20, // web: 18, + Font = @"Exo2.0-Light", + Colour = StreamColour.FromStreamName(build.UpdateStream.Name), + }, }, } }, @@ -173,10 +177,15 @@ namespace osu.Game.Overlays.Changelog }; // we may not want double clicks to make it double the work - clickableText.Action += () => + // can be clicked again only after a delay + clickableBuildText.Action += () => { - clickableText.IsEnabled = false; - Scheduler.AddDelayed(() => clickableText.IsEnabled = true, 2000); + clickableBuildText.Action = null; + clickableBuildText.FadeTo(0.5f, 500); + Scheduler.AddDelayed(() => { + clickableBuildText.Action = () => OnBuildSelected(build); + clickableBuildText.FadeIn(500); + }, 2000); }; }