mirror of
https://github.com/ppy/osu
synced 2024-12-16 20:05:41 +00:00
Merge pull request #1393 from swoolcock/revert-to-default-glow
Added an indicator to the left of settings to revert to default
This commit is contained in:
commit
5ddc6b8ac2
@ -28,6 +28,7 @@ namespace osu.Game.Overlays.KeyBinding
|
||||
this.variant = variant;
|
||||
|
||||
FlowContent.Spacing = new Vector2(0, 1);
|
||||
FlowContent.Padding = new MarginPadding { Left = SettingsOverlay.CONTENT_MARGINS, Right = SettingsOverlay.CONTENT_MARGINS };
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
|
@ -23,9 +23,8 @@ namespace osu.Game.Overlays.Settings.Sections.Audio
|
||||
Bindable = config.GetBindable<double>(OsuSetting.AudioOffset),
|
||||
KeyboardStep = 100f
|
||||
},
|
||||
new OsuButton
|
||||
new SettingsButton
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Text = "Offset wizard"
|
||||
}
|
||||
};
|
||||
|
@ -6,7 +6,6 @@ using System.Runtime;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Overlays.Settings.Sections.Debug
|
||||
{
|
||||
@ -24,9 +23,8 @@ namespace osu.Game.Overlays.Settings.Sections.Debug
|
||||
LabelText = "Active mode",
|
||||
Bindable = config.GetBindable<GCLatencyMode>(DebugSetting.ActiveGCMode)
|
||||
},
|
||||
new OsuButton
|
||||
new SettingsButton
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Text = "Force garbage collection",
|
||||
Action = GC.Collect
|
||||
},
|
||||
|
@ -230,15 +230,13 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
||||
LabelText = "Stay logged in",
|
||||
Bindable = config.GetBindable<bool>(OsuSetting.SavePassword),
|
||||
},
|
||||
new OsuButton
|
||||
new SettingsButton
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Text = "Sign in",
|
||||
Action = performLogin
|
||||
},
|
||||
new OsuButton
|
||||
new SettingsButton
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Text = "Register new account",
|
||||
//Action = registerLink
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Overlays.Settings.Sections.General
|
||||
{
|
||||
@ -23,9 +22,8 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
||||
LabelText = "Release stream",
|
||||
Bindable = config.GetBindable<ReleaseStream>(OsuSetting.ReleaseStream),
|
||||
},
|
||||
new OsuButton
|
||||
new SettingsButton
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Text = "Open osu! folder",
|
||||
Action = storage.OpenInNativeExplorer,
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
{
|
||||
@ -14,9 +13,8 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuButton
|
||||
new SettingsButton
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Text = "Key Configuration",
|
||||
Action = keyConfig.ToggleVisibility
|
||||
},
|
||||
|
@ -23,9 +23,8 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
importButton = new OsuButton
|
||||
importButton = new SettingsButton
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Text = "Import beatmaps from stable",
|
||||
Action = () =>
|
||||
{
|
||||
@ -33,9 +32,8 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
||||
Task.Run(() => beatmaps.ImportFromStable()).ContinueWith(t => Schedule(() => importButton.Enabled.Value = true));
|
||||
}
|
||||
},
|
||||
deleteButton = new OsuButton
|
||||
deleteButton = new SettingsButton
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Text = "Delete ALL beatmaps",
|
||||
Action = () =>
|
||||
{
|
||||
@ -43,9 +41,8 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
||||
Task.Run(() => beatmaps.DeleteAll()).ContinueWith(t => Schedule(() => deleteButton.Enabled.Value = true));
|
||||
}
|
||||
},
|
||||
restoreButton = new OsuButton
|
||||
restoreButton = new SettingsButton
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Text = "Restore all hidden difficulties",
|
||||
Action = () =>
|
||||
{
|
||||
|
17
osu.Game/Overlays/Settings/SettingsButton.cs
Normal file
17
osu.Game/Overlays/Settings/SettingsButton.cs
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Overlays.Settings
|
||||
{
|
||||
public class SettingsButton : OsuButton
|
||||
{
|
||||
public SettingsButton()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Padding = new MarginPadding { Left = SettingsOverlay.CONTENT_MARGINS, Right = SettingsOverlay.CONTENT_MARGINS };
|
||||
}
|
||||
}
|
||||
}
|
@ -2,17 +2,24 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
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;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Overlays.Settings
|
||||
{
|
||||
public abstract class SettingsItem<T> : FillFlowContainer, IFilterable
|
||||
public abstract class SettingsItem<T> : Container, IFilterable
|
||||
{
|
||||
protected abstract Drawable CreateControl();
|
||||
|
||||
@ -20,8 +27,28 @@ namespace osu.Game.Overlays.Settings
|
||||
|
||||
private IHasCurrentValue<T> controlWithCurrent => Control as IHasCurrentValue<T>;
|
||||
|
||||
protected override Container<Drawable> Content => FlowContent;
|
||||
|
||||
protected readonly FillFlowContainer FlowContent;
|
||||
|
||||
private SpriteText text;
|
||||
|
||||
private readonly RestoreDefaultValueButton<T> restoreDefaultValueButton = new RestoreDefaultValueButton<T>();
|
||||
|
||||
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; }
|
||||
@ -51,6 +78,11 @@ namespace osu.Game.Overlays.Settings
|
||||
{
|
||||
bindable = value;
|
||||
controlWithCurrent?.Current.BindTo(bindable);
|
||||
if (ShowsDefaultIndicator)
|
||||
{
|
||||
restoreDefaultValueButton.Bindable.BindTo(bindable);
|
||||
restoreDefaultValueButton.Bindable.TriggerChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,13 +101,94 @@ namespace osu.Game.Overlays.Settings
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Padding = new MarginPadding { Right = 5 };
|
||||
Padding = new MarginPadding { Right = SettingsOverlay.CONTENT_MARGINS };
|
||||
|
||||
FlowContent = new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Padding = new MarginPadding { Left = SettingsOverlay.CONTENT_MARGINS, Right = 5 },
|
||||
};
|
||||
|
||||
if ((Control = CreateControl()) != null)
|
||||
{
|
||||
if (controlWithCurrent != null)
|
||||
controlWithCurrent.Current.DisabledChanged += disabled => { Colour = disabled ? Color4.Gray : Color4.White; };
|
||||
Add(Control);
|
||||
FlowContent.Add(Control);
|
||||
}
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
AddInternal(FlowContent);
|
||||
|
||||
if (restoreDefaultValueButton != null)
|
||||
{
|
||||
if (!restoreDefaultValueColour.HasValue)
|
||||
restoreDefaultValueColour = colours.Yellow;
|
||||
restoreDefaultValueButton.SetButtonColour(RestoreDefaultValueColour);
|
||||
AddInternal(restoreDefaultValueButton);
|
||||
}
|
||||
}
|
||||
|
||||
private class RestoreDefaultValueButton<T> : Box, IHasTooltip
|
||||
{
|
||||
internal readonly Bindable<T> Bindable = new Bindable<T>();
|
||||
|
||||
private Color4 buttonColour;
|
||||
|
||||
private bool hovering;
|
||||
|
||||
public RestoreDefaultValueButton()
|
||||
{
|
||||
Bindable.ValueChanged += value => UpdateState();
|
||||
Bindable.DisabledChanged += disabled => UpdateState();
|
||||
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
Width = SettingsOverlay.CONTENT_MARGINS;
|
||||
Alpha = 0f;
|
||||
}
|
||||
|
||||
public string TooltipText => "Revert to default";
|
||||
|
||||
public override bool HandleInput => true;
|
||||
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true;
|
||||
|
||||
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) => true;
|
||||
|
||||
protected override bool OnClick(InputState state)
|
||||
{
|
||||
if (!Bindable.Disabled)
|
||||
Bindable.SetDefault();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
{
|
||||
hovering = true;
|
||||
UpdateState();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(InputState state)
|
||||
{
|
||||
hovering = false;
|
||||
UpdateState();
|
||||
}
|
||||
|
||||
internal void SetButtonColour(Color4 buttonColour)
|
||||
{
|
||||
this.buttonColour = buttonColour;
|
||||
UpdateState();
|
||||
}
|
||||
|
||||
internal void UpdateState()
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,8 +69,6 @@ namespace osu.Game.Overlays.Settings
|
||||
Padding = new MarginPadding
|
||||
{
|
||||
Top = 20 + border_size,
|
||||
Left = SettingsOverlay.CONTENT_MARGINS,
|
||||
Right = SettingsOverlay.CONTENT_MARGINS,
|
||||
Bottom = 10,
|
||||
},
|
||||
RelativeSizeAxes = Axes.X,
|
||||
@ -81,7 +79,8 @@ namespace osu.Game.Overlays.Settings
|
||||
{
|
||||
TextSize = header_size,
|
||||
Text = Header,
|
||||
Colour = colours.Yellow
|
||||
Colour = colours.Yellow,
|
||||
Margin = new MarginPadding { Left = SettingsOverlay.CONTENT_MARGINS, Right = SettingsOverlay.CONTENT_MARGINS }
|
||||
},
|
||||
FlowContent
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ namespace osu.Game.Overlays.Settings
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = Header.ToUpper(),
|
||||
Margin = new MarginPadding { Bottom = 10 },
|
||||
Margin = new MarginPadding { Bottom = 10, Left = SettingsOverlay.CONTENT_MARGINS, Right = SettingsOverlay.CONTENT_MARGINS },
|
||||
Font = @"Exo2.0-Black",
|
||||
},
|
||||
FlowContent
|
||||
|
@ -289,6 +289,7 @@
|
||||
<Compile Include="Migrations\OsuDbContextModelSnapshot.cs" />
|
||||
<Compile Include="Online\API\Requests\GetBeatmapSetRequest.cs" />
|
||||
<Compile Include="Online\API\Requests\GetBeatmapSetsResponse.cs" />
|
||||
<Compile Include="Overlays\Settings\SettingsButton.cs" />
|
||||
<Compile Include="Screens\Edit\Screens\Compose\Timeline\BeatmapWaveformGraph.cs" />
|
||||
<Compile Include="Beatmaps\Drawables\DifficultyColouredContainer.cs" />
|
||||
<Compile Include="Beatmaps\Drawables\DifficultyIcon.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user