mirror of
https://github.com/osukey/osukey.git
synced 2025-07-28 22:00:02 +09:00
RestoreDefaultValueButton implements OsuButton
This commit is contained in:
@ -131,9 +131,8 @@ namespace osu.Game.Overlays.KeyBinding
|
|||||||
|
|
||||||
IsDefault.BindValueChanged(isDefault =>
|
IsDefault.BindValueChanged(isDefault =>
|
||||||
{
|
{
|
||||||
if (isDefault.NewValue && !computeIsDefaultValue())
|
if (isDefault.NewValue)
|
||||||
{
|
{
|
||||||
RestoreDefaults();
|
|
||||||
finalise();
|
finalise();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -65,6 +65,7 @@ namespace osu.Game.Overlays.KeyBinding
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
restoreDefaultButton.Action = () => { KeyBindingRow.RestoreDefaults(); };
|
||||||
restoreDefaultButton.Current = KeyBindingRow.IsDefault;
|
restoreDefaultButton.Current = KeyBindingRow.IsDefault;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,17 +6,16 @@ using osu.Framework.Bindables;
|
|||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Graphics.Cursor;
|
using osu.Framework.Graphics.Cursor;
|
||||||
using osu.Framework.Graphics.Effects;
|
using osu.Framework.Graphics.Effects;
|
||||||
using osu.Framework.Graphics.Shapes;
|
|
||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
{
|
{
|
||||||
public class RestoreDefaultValueButton<T> : Container, IHasTooltip, IHasCurrentValue<T>
|
public class RestoreDefaultValueButton<T> : OsuButton, IHasTooltip, IHasCurrentValue<T>
|
||||||
{
|
{
|
||||||
public override bool IsPresent => base.IsPresent || Scheduler.HasPendingTasks;
|
public override bool IsPresent => base.IsPresent || Scheduler.HasPendingTasks;
|
||||||
|
|
||||||
@ -34,34 +33,30 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
public RestoreDefaultValueButton()
|
public RestoreDefaultValueButton()
|
||||||
{
|
{
|
||||||
|
Height = 1;
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Y;
|
RelativeSizeAxes = Axes.Y;
|
||||||
Width = SettingsPanel.CONTENT_MARGINS;
|
Width = SettingsPanel.CONTENT_MARGINS;
|
||||||
Padding = new MarginPadding { Vertical = 1.5f };
|
|
||||||
Alpha = 0f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colour)
|
private void load(OsuColour colour)
|
||||||
{
|
{
|
||||||
|
BackgroundColour = colour.Yellow;
|
||||||
buttonColour = colour.Yellow;
|
buttonColour = colour.Yellow;
|
||||||
|
Content.Width = 0.33f;
|
||||||
Child = new Container
|
Content.CornerRadius = 3;
|
||||||
|
Content.EdgeEffect = new EdgeEffectParameters
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Colour = buttonColour.Opacity(0.1f),
|
||||||
Origin = Anchor.Centre,
|
Type = EdgeEffectType.Glow,
|
||||||
RelativeSizeAxes = Axes.Both,
|
Radius = 2,
|
||||||
CornerRadius = 3,
|
|
||||||
Masking = true,
|
|
||||||
Colour = buttonColour,
|
|
||||||
EdgeEffect = new EdgeEffectParameters
|
|
||||||
{
|
|
||||||
Colour = buttonColour.Opacity(0.1f),
|
|
||||||
Type = EdgeEffectType.Glow,
|
|
||||||
Radius = 2,
|
|
||||||
},
|
|
||||||
Width = 0.33f,
|
|
||||||
Child = new Box { RelativeSizeAxes = Axes.Both },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Padding = new MarginPadding { Vertical = 1.5f };
|
||||||
|
Alpha = 0f;
|
||||||
|
|
||||||
|
Action += () => { if (!current.Disabled) current.SetDefault(); };
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
@ -77,13 +72,6 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
public string TooltipText => "revert to default";
|
public string TooltipText => "revert to default";
|
||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
|
||||||
{
|
|
||||||
if (!current.Disabled)
|
|
||||||
current.SetDefault();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnHover(HoverEvent e)
|
protected override bool OnHover(HoverEvent e)
|
||||||
{
|
{
|
||||||
hovering = true;
|
hovering = true;
|
||||||
|
Reference in New Issue
Block a user