diff --git a/osu.Game/Overlays/Settings/SettingsItem.cs b/osu.Game/Overlays/Settings/SettingsItem.cs index b58b99f1e3..adb7c509c0 100644 --- a/osu.Game/Overlays/Settings/SettingsItem.cs +++ b/osu.Game/Overlays/Settings/SettingsItem.cs @@ -7,7 +7,6 @@ using OpenTK.Graphics; using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; -using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; @@ -16,6 +15,7 @@ using osu.Framework.Graphics.UserInterface; using osu.Framework.Input; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using OpenTK; namespace osu.Game.Overlays.Settings { @@ -33,22 +33,10 @@ namespace osu.Game.Overlays.Settings private SpriteText text; - private readonly RestoreDefaultValueButton restoreDefaultValueButton = new RestoreDefaultValueButton(); + private readonly RestoreDefaultValueButton restoreDefaultButton; public bool ShowsDefaultIndicator = true; - private Color4? restoreDefaultValueColour; - - public Color4 RestoreDefaultValueColour - { - get { return restoreDefaultValueColour ?? Color4.White; } - set - { - restoreDefaultValueColour = value; - restoreDefaultValueButton?.SetButtonColour(RestoreDefaultValueColour); - } - } - public virtual string LabelText { get { return text?.Text ?? string.Empty; } @@ -69,10 +57,7 @@ namespace osu.Game.Overlays.Settings public virtual Bindable Bindable { - get - { - return bindable; - } + get { return bindable; } set { @@ -80,8 +65,8 @@ namespace osu.Game.Overlays.Settings controlWithCurrent?.Current.BindTo(bindable); if (ShowsDefaultIndicator) { - restoreDefaultValueButton.Bindable = bindable.GetBoundCopy(); - restoreDefaultValueButton.Bindable.TriggerChange(); + restoreDefaultButton.Bindable = bindable.GetBoundCopy(); + restoreDefaultButton.Bindable.TriggerChange(); } } } @@ -103,38 +88,30 @@ namespace osu.Game.Overlays.Settings AutoSizeAxes = Axes.Y; Padding = new MarginPadding { Right = SettingsOverlay.CONTENT_MARGINS }; - FlowContent = new FillFlowContainer + InternalChildren = new Drawable[] { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Padding = new MarginPadding { Left = SettingsOverlay.CONTENT_MARGINS, Right = 5 }, + restoreDefaultButton = new RestoreDefaultValueButton(), + FlowContent = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Padding = new MarginPadding { Left = SettingsOverlay.CONTENT_MARGINS }, + Child = Control = CreateControl() + }, }; - - if ((Control = CreateControl()) != null) - { - if (controlWithCurrent != null) - controlWithCurrent.Current.DisabledChanged += disabled => { Colour = disabled ? Color4.Gray : Color4.White; }; - FlowContent.Add(Control); - } } [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load() { - AddInternal(FlowContent); - - if (restoreDefaultValueButton != null) - { - if (!restoreDefaultValueColour.HasValue) - restoreDefaultValueColour = colours.Yellow; - restoreDefaultValueButton.SetButtonColour(RestoreDefaultValueColour); - AddInternal(restoreDefaultValueButton); - } + if (controlWithCurrent != null) + controlWithCurrent.Current.DisabledChanged += disabled => { Colour = disabled ? Color4.Gray : Color4.White; }; } - private class RestoreDefaultValueButton : Box, IHasTooltip + private class RestoreDefaultValueButton : Container, IHasTooltip { private Bindable bindable; + public Bindable Bindable { get { return bindable; } @@ -157,6 +134,36 @@ namespace osu.Game.Overlays.Settings Alpha = 0f; } + [BackgroundDependencyLoader] + private void load(OsuColour colour) + { + buttonColour = colour.Yellow; + + Child = new Container + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + CornerRadius = 3, + Masking = true, + Colour = buttonColour, + EdgeEffect = new EdgeEffectParameters + { + Colour = buttonColour.Opacity(0.1f), + Type = EdgeEffectType.Glow, + Radius = 2, + }, + Size = new Vector2(0.33f, 0.8f), + Child = new Box { RelativeSizeAxes = Axes.Both }, + }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + UpdateState(); + } + public string TooltipText => "Revert to default"; protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true; @@ -193,9 +200,10 @@ namespace osu.Game.Overlays.Settings { if (bindable == null) return; - var colour = bindable.Disabled ? Color4.Gray : buttonColour; - this.FadeTo(bindable.IsDefault ? 0f : hovering && !bindable.Disabled ? 1f : 0.5f, 200, Easing.OutQuint); - this.FadeColour(ColourInfo.GradientHorizontal(colour.Opacity(0.8f), colour.Opacity(0)), 200, Easing.OutQuint); + + this.FadeTo(bindable.IsDefault ? 0f : + hovering && !bindable.Disabled ? 1f : 0.65f, 200, Easing.OutQuint); + this.FadeColour(bindable.Disabled ? Color4.Gray : buttonColour, 200, Easing.OutQuint); } } } diff --git a/osu.Game/Overlays/SettingsOverlay.cs b/osu.Game/Overlays/SettingsOverlay.cs index 277ed81ce8..c003046242 100644 --- a/osu.Game/Overlays/SettingsOverlay.cs +++ b/osu.Game/Overlays/SettingsOverlay.cs @@ -20,7 +20,7 @@ namespace osu.Game.Overlays { public abstract class SettingsOverlay : OsuFocusedOverlayContainer { - public const float CONTENT_MARGINS = 10; + public const float CONTENT_MARGINS = 15; public const float TRANSITION_LENGTH = 600;