mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 14:46:38 +09:00
Merge remote-tracking branch 'upstream/master' into chat-mention
This commit is contained in:
13
osu.Game/Overlays/Settings/ISettingsItem.cs
Normal file
13
osu.Game/Overlays/Settings/ISettingsItem.cs
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.Settings
|
||||
{
|
||||
public interface ISettingsItem : IDrawable, IDisposable
|
||||
{
|
||||
event Action SettingChanged;
|
||||
}
|
||||
}
|
@ -323,8 +323,6 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
||||
Colour = Color4.Black.Opacity(0.25f),
|
||||
Radius = 4,
|
||||
};
|
||||
|
||||
ItemsContainer.Padding = new MarginPadding();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
|
@ -16,7 +16,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
new SettingsButton
|
||||
{
|
||||
Text = "Key configuration",
|
||||
TooltipText = "Change global shortcut keys and gameplay bindings",
|
||||
TooltipText = "change global shortcut keys and gameplay bindings",
|
||||
Action = keyConfig.ToggleVisibility
|
||||
},
|
||||
};
|
||||
|
@ -87,7 +87,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
|
||||
private class SensitivitySlider : OsuSliderBar<double>
|
||||
{
|
||||
public override string TooltipText => Current.Disabled ? "Enable raw input to adjust sensitivity" : $"{base.TooltipText}x";
|
||||
public override string TooltipText => Current.Disabled ? "enable raw input to adjust sensitivity" : $"{base.TooltipText}x";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
@ -20,7 +21,7 @@ using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays.Settings
|
||||
{
|
||||
public abstract class SettingsItem<T> : Container, IFilterable
|
||||
public abstract class SettingsItem<T> : Container, IFilterable, ISettingsItem
|
||||
{
|
||||
protected abstract Drawable CreateControl();
|
||||
|
||||
@ -34,8 +35,6 @@ namespace osu.Game.Overlays.Settings
|
||||
|
||||
private SpriteText text;
|
||||
|
||||
private readonly RestoreDefaultValueButton restoreDefaultButton;
|
||||
|
||||
public bool ShowsDefaultIndicator = true;
|
||||
|
||||
public virtual string LabelText
|
||||
@ -70,8 +69,12 @@ namespace osu.Game.Overlays.Settings
|
||||
|
||||
public bool FilteringActive { get; set; }
|
||||
|
||||
public event Action SettingChanged;
|
||||
|
||||
protected SettingsItem()
|
||||
{
|
||||
RestoreDefaultValueButton restoreDefaultButton;
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Padding = new MarginPadding { Right = SettingsPanel.CONTENT_MARGINS };
|
||||
@ -87,13 +90,12 @@ namespace osu.Game.Overlays.Settings
|
||||
Child = Control = CreateControl()
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
// all bindable logic is in constructor intentionally to support "CreateSettingsControls" being used in a context it is
|
||||
// never loaded, but requires bindable storage.
|
||||
if (controlWithCurrent != null)
|
||||
{
|
||||
controlWithCurrent.Current.ValueChanged += _ => SettingChanged?.Invoke();
|
||||
controlWithCurrent.Current.DisabledChanged += disabled => { Colour = disabled ? Color4.Gray : Color4.White; };
|
||||
|
||||
if (ShowsDefaultIndicator)
|
||||
@ -113,6 +115,7 @@ namespace osu.Game.Overlays.Settings
|
||||
bindable = value;
|
||||
bindable.ValueChanged += _ => UpdateState();
|
||||
bindable.DisabledChanged += _ => UpdateState();
|
||||
bindable.DefaultChanged += _ => UpdateState();
|
||||
UpdateState();
|
||||
}
|
||||
}
|
||||
@ -158,11 +161,7 @@ namespace osu.Game.Overlays.Settings
|
||||
UpdateState();
|
||||
}
|
||||
|
||||
public string TooltipText => "Revert to default";
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e) => true;
|
||||
|
||||
protected override bool OnMouseUp(MouseUpEvent e) => true;
|
||||
public string TooltipText => "revert to default";
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
|
@ -12,11 +12,11 @@ namespace osu.Game.Overlays.Settings
|
||||
{
|
||||
}
|
||||
|
||||
public class SettingsSlider<T, U> : SettingsItem<T>
|
||||
where T : struct, IEquatable<T>, IComparable<T>, IConvertible
|
||||
where U : OsuSliderBar<T>, new()
|
||||
public class SettingsSlider<TValue, TSlider> : SettingsItem<TValue>
|
||||
where TValue : struct, IEquatable<TValue>, IComparable<TValue>, IConvertible
|
||||
where TSlider : OsuSliderBar<TValue>, new()
|
||||
{
|
||||
protected override Drawable CreateControl() => new U
|
||||
protected override Drawable CreateControl() => new TSlider
|
||||
{
|
||||
Margin = new MarginPadding { Top = 5, Bottom = 5 },
|
||||
RelativeSizeAxes = Axes.X
|
||||
@ -24,14 +24,14 @@ namespace osu.Game.Overlays.Settings
|
||||
|
||||
public bool TransferValueOnCommit
|
||||
{
|
||||
get => ((U)Control).TransferValueOnCommit;
|
||||
set => ((U)Control).TransferValueOnCommit = value;
|
||||
get => ((TSlider)Control).TransferValueOnCommit;
|
||||
set => ((TSlider)Control).TransferValueOnCommit = value;
|
||||
}
|
||||
|
||||
public float KeyboardStep
|
||||
{
|
||||
get => ((U)Control).KeyboardStep;
|
||||
set => ((U)Control).KeyboardStep = value;
|
||||
get => ((TSlider)Control).KeyboardStep;
|
||||
set => ((TSlider)Control).KeyboardStep = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user