1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 18:07:24 +08: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:
Dean Herbert 2017-10-24 10:55:52 +09:00 committed by GitHub
commit 5ddc6b8ac2
12 changed files with 147 additions and 28 deletions

View File

@ -28,6 +28,7 @@ namespace osu.Game.Overlays.KeyBinding
this.variant = variant; this.variant = variant;
FlowContent.Spacing = new Vector2(0, 1); FlowContent.Spacing = new Vector2(0, 1);
FlowContent.Padding = new MarginPadding { Left = SettingsOverlay.CONTENT_MARGINS, Right = SettingsOverlay.CONTENT_MARGINS };
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]

View File

@ -23,9 +23,8 @@ namespace osu.Game.Overlays.Settings.Sections.Audio
Bindable = config.GetBindable<double>(OsuSetting.AudioOffset), Bindable = config.GetBindable<double>(OsuSetting.AudioOffset),
KeyboardStep = 100f KeyboardStep = 100f
}, },
new OsuButton new SettingsButton
{ {
RelativeSizeAxes = Axes.X,
Text = "Offset wizard" Text = "Offset wizard"
} }
}; };

View File

@ -6,7 +6,6 @@ using System.Runtime;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Settings.Sections.Debug namespace osu.Game.Overlays.Settings.Sections.Debug
{ {
@ -24,9 +23,8 @@ namespace osu.Game.Overlays.Settings.Sections.Debug
LabelText = "Active mode", LabelText = "Active mode",
Bindable = config.GetBindable<GCLatencyMode>(DebugSetting.ActiveGCMode) Bindable = config.GetBindable<GCLatencyMode>(DebugSetting.ActiveGCMode)
}, },
new OsuButton new SettingsButton
{ {
RelativeSizeAxes = Axes.X,
Text = "Force garbage collection", Text = "Force garbage collection",
Action = GC.Collect Action = GC.Collect
}, },

View File

@ -230,15 +230,13 @@ namespace osu.Game.Overlays.Settings.Sections.General
LabelText = "Stay logged in", LabelText = "Stay logged in",
Bindable = config.GetBindable<bool>(OsuSetting.SavePassword), Bindable = config.GetBindable<bool>(OsuSetting.SavePassword),
}, },
new OsuButton new SettingsButton
{ {
RelativeSizeAxes = Axes.X,
Text = "Sign in", Text = "Sign in",
Action = performLogin Action = performLogin
}, },
new OsuButton new SettingsButton
{ {
RelativeSizeAxes = Axes.X,
Text = "Register new account", Text = "Register new account",
//Action = registerLink //Action = registerLink
} }

View File

@ -5,7 +5,6 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Settings.Sections.General namespace osu.Game.Overlays.Settings.Sections.General
{ {
@ -23,9 +22,8 @@ namespace osu.Game.Overlays.Settings.Sections.General
LabelText = "Release stream", LabelText = "Release stream",
Bindable = config.GetBindable<ReleaseStream>(OsuSetting.ReleaseStream), Bindable = config.GetBindable<ReleaseStream>(OsuSetting.ReleaseStream),
}, },
new OsuButton new SettingsButton
{ {
RelativeSizeAxes = Axes.X,
Text = "Open osu! folder", Text = "Open osu! folder",
Action = storage.OpenInNativeExplorer, Action = storage.OpenInNativeExplorer,
} }

View File

@ -2,7 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Settings.Sections.Input namespace osu.Game.Overlays.Settings.Sections.Input
{ {
@ -14,9 +13,8 @@ namespace osu.Game.Overlays.Settings.Sections.Input
{ {
Children = new Drawable[] Children = new Drawable[]
{ {
new OsuButton new SettingsButton
{ {
RelativeSizeAxes = Axes.X,
Text = "Key Configuration", Text = "Key Configuration",
Action = keyConfig.ToggleVisibility Action = keyConfig.ToggleVisibility
}, },

View File

@ -23,9 +23,8 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
{ {
Children = new Drawable[] Children = new Drawable[]
{ {
importButton = new OsuButton importButton = new SettingsButton
{ {
RelativeSizeAxes = Axes.X,
Text = "Import beatmaps from stable", Text = "Import beatmaps from stable",
Action = () => Action = () =>
{ {
@ -33,9 +32,8 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
Task.Run(() => beatmaps.ImportFromStable()).ContinueWith(t => Schedule(() => importButton.Enabled.Value = true)); Task.Run(() => beatmaps.ImportFromStable()).ContinueWith(t => Schedule(() => importButton.Enabled.Value = true));
} }
}, },
deleteButton = new OsuButton deleteButton = new SettingsButton
{ {
RelativeSizeAxes = Axes.X,
Text = "Delete ALL beatmaps", Text = "Delete ALL beatmaps",
Action = () => Action = () =>
{ {
@ -43,9 +41,8 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
Task.Run(() => beatmaps.DeleteAll()).ContinueWith(t => Schedule(() => deleteButton.Enabled.Value = true)); 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", Text = "Restore all hidden difficulties",
Action = () => Action = () =>
{ {

View 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 };
}
}
}

View File

@ -2,17 +2,24 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Allocation;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
namespace osu.Game.Overlays.Settings namespace osu.Game.Overlays.Settings
{ {
public abstract class SettingsItem<T> : FillFlowContainer, IFilterable public abstract class SettingsItem<T> : Container, IFilterable
{ {
protected abstract Drawable CreateControl(); protected abstract Drawable CreateControl();
@ -20,8 +27,28 @@ namespace osu.Game.Overlays.Settings
private IHasCurrentValue<T> controlWithCurrent => Control as IHasCurrentValue<T>; private IHasCurrentValue<T> controlWithCurrent => Control as IHasCurrentValue<T>;
protected override Container<Drawable> Content => FlowContent;
protected readonly FillFlowContainer FlowContent;
private SpriteText text; 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 public virtual string LabelText
{ {
get { return text?.Text ?? string.Empty; } get { return text?.Text ?? string.Empty; }
@ -51,6 +78,11 @@ namespace osu.Game.Overlays.Settings
{ {
bindable = value; bindable = value;
controlWithCurrent?.Current.BindTo(bindable); 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; RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y; 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 ((Control = CreateControl()) != null)
{ {
if (controlWithCurrent != null) if (controlWithCurrent != null)
controlWithCurrent.Current.DisabledChanged += disabled => { Colour = disabled ? Color4.Gray : Color4.White; }; 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);
} }
} }
} }

View File

@ -69,8 +69,6 @@ namespace osu.Game.Overlays.Settings
Padding = new MarginPadding Padding = new MarginPadding
{ {
Top = 20 + border_size, Top = 20 + border_size,
Left = SettingsOverlay.CONTENT_MARGINS,
Right = SettingsOverlay.CONTENT_MARGINS,
Bottom = 10, Bottom = 10,
}, },
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
@ -81,7 +79,8 @@ namespace osu.Game.Overlays.Settings
{ {
TextSize = header_size, TextSize = header_size,
Text = Header, Text = Header,
Colour = colours.Yellow Colour = colours.Yellow,
Margin = new MarginPadding { Left = SettingsOverlay.CONTENT_MARGINS, Right = SettingsOverlay.CONTENT_MARGINS }
}, },
FlowContent FlowContent
} }

View File

@ -52,7 +52,7 @@ namespace osu.Game.Overlays.Settings
new OsuSpriteText new OsuSpriteText
{ {
Text = Header.ToUpper(), 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", Font = @"Exo2.0-Black",
}, },
FlowContent FlowContent

View File

@ -289,6 +289,7 @@
<Compile Include="Migrations\OsuDbContextModelSnapshot.cs" /> <Compile Include="Migrations\OsuDbContextModelSnapshot.cs" />
<Compile Include="Online\API\Requests\GetBeatmapSetRequest.cs" /> <Compile Include="Online\API\Requests\GetBeatmapSetRequest.cs" />
<Compile Include="Online\API\Requests\GetBeatmapSetsResponse.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="Screens\Edit\Screens\Compose\Timeline\BeatmapWaveformGraph.cs" />
<Compile Include="Beatmaps\Drawables\DifficultyColouredContainer.cs" /> <Compile Include="Beatmaps\Drawables\DifficultyColouredContainer.cs" />
<Compile Include="Beatmaps\Drawables\DifficultyIcon.cs" /> <Compile Include="Beatmaps\Drawables\DifficultyIcon.cs" />