mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 07:06:35 +09:00
Merge remote-tracking branch 'upstream/master' into collapse-graph-option
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;
|
||||
}
|
||||
}
|
@ -60,7 +60,10 @@ namespace osu.Game.Overlays.Settings.Sections.Audio
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
dropdown = new AudioDeviceSettingsDropdown()
|
||||
dropdown = new AudioDeviceSettingsDropdown
|
||||
{
|
||||
Keywords = new[] { "speaker", "headphone", "output" }
|
||||
}
|
||||
};
|
||||
|
||||
updateItems();
|
||||
|
@ -1,7 +1,10 @@
|
||||
// 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.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Configuration;
|
||||
|
||||
namespace osu.Game.Overlays.Settings.Sections.Audio
|
||||
@ -13,7 +16,7 @@ namespace osu.Game.Overlays.Settings.Sections.Audio
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
Children = new[]
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SettingsCheckbox
|
||||
{
|
||||
@ -25,6 +28,18 @@ namespace osu.Game.Overlays.Settings.Sections.Audio
|
||||
LabelText = "osu! music theme",
|
||||
Bindable = config.GetBindable<bool>(OsuSetting.MenuMusic)
|
||||
},
|
||||
new SettingsDropdown<IntroSequence>
|
||||
{
|
||||
LabelText = "Intro sequence",
|
||||
Bindable = config.GetBindable<IntroSequence>(OsuSetting.IntroSequence),
|
||||
Items = Enum.GetValues(typeof(IntroSequence)).Cast<IntroSequence>()
|
||||
},
|
||||
new SettingsDropdown<BackgroundSource>
|
||||
{
|
||||
LabelText = "Background source",
|
||||
Bindable = config.GetBindable<BackgroundSource>(OsuSetting.MenuBackgroundSource),
|
||||
Items = Enum.GetValues(typeof(BackgroundSource)).Cast<BackgroundSource>()
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
// 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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Overlays.Settings.Sections.Audio;
|
||||
@ -10,6 +12,9 @@ namespace osu.Game.Overlays.Settings.Sections
|
||||
public class AudioSection : SettingsSection
|
||||
{
|
||||
public override string Header => "Audio";
|
||||
|
||||
public override IEnumerable<string> FilterTerms => base.FilterTerms.Concat(new[] { "sound" });
|
||||
|
||||
public override IconUsage Icon => FontAwesome.Solid.VolumeUp;
|
||||
|
||||
public AudioSection()
|
||||
@ -19,7 +24,7 @@ namespace osu.Game.Overlays.Settings.Sections
|
||||
new AudioDevicesSettings(),
|
||||
new VolumeSettings(),
|
||||
new OffsetSettings(),
|
||||
new MainMenuSettings(),
|
||||
new MainMenuSettings()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -24,12 +24,7 @@ namespace osu.Game.Overlays.Settings.Sections.Debug
|
||||
new SettingsCheckbox
|
||||
{
|
||||
LabelText = "Performance logging",
|
||||
Bindable = frameworkConfig.GetBindable<bool>(FrameworkSetting.PerformanceLogging)
|
||||
},
|
||||
new SettingsCheckbox
|
||||
{
|
||||
LabelText = "Bypass caching (slow)",
|
||||
Bindable = config.GetBindable<bool>(DebugSetting.BypassCaching)
|
||||
Bindable = config.GetBindable<bool>(DebugSetting.PerformanceLogging)
|
||||
},
|
||||
new SettingsCheckbox
|
||||
{
|
||||
|
@ -1,26 +1,26 @@
|
||||
// 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.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Platform;
|
||||
|
||||
namespace osu.Game.Overlays.Settings.Sections.Debug
|
||||
{
|
||||
public class GCSettings : SettingsSubsection
|
||||
public class MemorySettings : SettingsSubsection
|
||||
{
|
||||
protected override string Header => "Garbage Collector";
|
||||
protected override string Header => "Memory";
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(FrameworkDebugConfigManager config)
|
||||
private void load(FrameworkDebugConfigManager config, GameHost host)
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SettingsButton
|
||||
{
|
||||
Text = "Force garbage collection",
|
||||
Action = GC.Collect
|
||||
Text = "Clear all caches",
|
||||
Action = host.Collect
|
||||
},
|
||||
};
|
||||
}
|
@ -17,7 +17,7 @@ namespace osu.Game.Overlays.Settings.Sections
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new GeneralSettings(),
|
||||
new GCSettings(),
|
||||
new MemorySettings(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,11 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
||||
KeyboardStep = 0.01f
|
||||
},
|
||||
new SettingsCheckbox
|
||||
{
|
||||
LabelText = "Lighten playfield during breaks",
|
||||
Bindable = config.GetBindable<bool>(OsuSetting.LightenDuringBreaks)
|
||||
},
|
||||
new SettingsCheckbox
|
||||
{
|
||||
LabelText = "Show score overlay",
|
||||
Bindable = config.GetBindable<bool>(OsuSetting.ShowInterface)
|
||||
@ -43,12 +48,18 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
||||
{
|
||||
LabelText = "Show health display even when you can't fail",
|
||||
Bindable = config.GetBindable<bool>(OsuSetting.ShowHealthDisplayWhenCantFail),
|
||||
Keywords = new[] { "hp", "bar" }
|
||||
},
|
||||
new SettingsCheckbox
|
||||
{
|
||||
LabelText = "Always show key overlay",
|
||||
Bindable = config.GetBindable<bool>(OsuSetting.KeyOverlay)
|
||||
},
|
||||
new SettingsEnumDropdown<ScoreMeterType>
|
||||
{
|
||||
LabelText = "Score meter type",
|
||||
Bindable = config.GetBindable<ScoreMeterType>(OsuSetting.ScoreMeter)
|
||||
},
|
||||
new SettingsEnumDropdown<ScoringMode>
|
||||
{
|
||||
LabelText = "Score display mode",
|
||||
|
@ -1,6 +1,8 @@
|
||||
// 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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Configuration;
|
||||
|
||||
@ -10,6 +12,8 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
||||
{
|
||||
protected override string Header => "Mods";
|
||||
|
||||
public override IEnumerable<string> FilterTerms => base.FilterTerms.Concat(new[] { "mod" });
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
@ -18,7 +22,7 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
||||
new SettingsCheckbox
|
||||
{
|
||||
LabelText = "Increase visibility of first object when visual impairment mods are enabled",
|
||||
Bindable = config.GetBindable<bool>(OsuSetting.IncreaseFirstObjectVisibility)
|
||||
Bindable = config.GetBindable<bool>(OsuSetting.IncreaseFirstObjectVisibility),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -31,13 +31,15 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
||||
{
|
||||
LabelText = "Display beatmaps from",
|
||||
Bindable = config.GetBindable<double>(OsuSetting.DisplayStarsMinimum),
|
||||
KeyboardStep = 0.1f
|
||||
KeyboardStep = 0.1f,
|
||||
Keywords = new[] { "star", "difficulty" }
|
||||
},
|
||||
new SettingsSlider<double, StarSlider>
|
||||
{
|
||||
LabelText = "up to",
|
||||
Bindable = config.GetBindable<double>(OsuSetting.DisplayStarsMaximum),
|
||||
KeyboardStep = 0.1f
|
||||
KeyboardStep = 0.1f,
|
||||
Keywords = new[] { "star", "difficulty" }
|
||||
},
|
||||
new SettingsEnumDropdown<RandomSelectAlgorithm>
|
||||
{
|
||||
|
@ -67,7 +67,7 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
||||
api?.Register(this);
|
||||
}
|
||||
|
||||
public void APIStateChanged(IAPIProvider api, APIState state)
|
||||
public void APIStateChanged(IAPIProvider api, APIState state) => Schedule(() =>
|
||||
{
|
||||
form = null;
|
||||
|
||||
@ -184,7 +184,7 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
||||
}
|
||||
|
||||
if (form != null) GetContainingInputManager()?.ChangeFocus(form);
|
||||
}
|
||||
});
|
||||
|
||||
public override bool AcceptsFocus => true;
|
||||
|
||||
@ -200,6 +200,7 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
||||
{
|
||||
private TextBox username;
|
||||
private TextBox password;
|
||||
private ShakeContainer shakeSignIn;
|
||||
private IAPIProvider api;
|
||||
|
||||
public Action RequestHide;
|
||||
@ -208,6 +209,8 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
||||
{
|
||||
if (!string.IsNullOrEmpty(username.Text) && !string.IsNullOrEmpty(password.Text))
|
||||
api.Login(username.Text, password.Text);
|
||||
else
|
||||
shakeSignIn.Shake();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(permitNulls: true)]
|
||||
@ -222,7 +225,7 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
||||
{
|
||||
username = new OsuTextBox
|
||||
{
|
||||
PlaceholderText = "email address",
|
||||
PlaceholderText = "username",
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Text = api?.ProvidedUsername ?? string.Empty,
|
||||
TabbableContentContainer = this
|
||||
@ -236,7 +239,7 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
||||
},
|
||||
new SettingsCheckbox
|
||||
{
|
||||
LabelText = "Remember email address",
|
||||
LabelText = "Remember username",
|
||||
Bindable = config.GetBindable<bool>(OsuSetting.SaveUsername),
|
||||
},
|
||||
new SettingsCheckbox
|
||||
@ -244,10 +247,23 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
||||
LabelText = "Stay signed in",
|
||||
Bindable = config.GetBindable<bool>(OsuSetting.SavePassword),
|
||||
},
|
||||
new SettingsButton
|
||||
new Container
|
||||
{
|
||||
Text = "Sign in",
|
||||
Action = performLogin
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
shakeSignIn = new ShakeContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Child = new SettingsButton
|
||||
{
|
||||
Text = "Sign in",
|
||||
Action = performLogin
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
new SettingsButton
|
||||
{
|
||||
@ -281,10 +297,8 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
||||
{
|
||||
set
|
||||
{
|
||||
var h = Header as UserDropdownHeader;
|
||||
if (h == null) return;
|
||||
|
||||
h.StatusColour = value;
|
||||
if (Header is UserDropdownHeader h)
|
||||
h.StatusColour = value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -309,8 +323,6 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
||||
Colour = Color4.Black.Opacity(0.25f),
|
||||
Radius = 4,
|
||||
};
|
||||
|
||||
ItemsContainer.Padding = new MarginPadding();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
|
@ -23,8 +23,13 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
|
||||
},
|
||||
new SettingsCheckbox
|
||||
{
|
||||
LabelText = "Rotate cursor when dragging",
|
||||
Bindable = config.GetBindable<bool>(OsuSetting.CursorRotation)
|
||||
LabelText = "Video",
|
||||
Bindable = config.GetBindable<bool>(OsuSetting.ShowVideoBackground)
|
||||
},
|
||||
new SettingsCheckbox
|
||||
{
|
||||
LabelText = "Hit Lighting",
|
||||
Bindable = config.GetBindable<bool>(OsuSetting.HitLighting)
|
||||
},
|
||||
new SettingsEnumDropdown<ScreenshotFormat>
|
||||
{
|
||||
|
@ -75,12 +75,14 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
|
||||
LabelText = "UI Scaling",
|
||||
TransferValueOnCommit = true,
|
||||
Bindable = osuConfig.GetBindable<float>(OsuSetting.UIScale),
|
||||
KeyboardStep = 0.01f
|
||||
KeyboardStep = 0.01f,
|
||||
Keywords = new[] { "scale", "letterbox" },
|
||||
},
|
||||
new SettingsEnumDropdown<ScalingMode>
|
||||
{
|
||||
LabelText = "Screen Scaling",
|
||||
Bindable = osuConfig.GetBindable<ScalingMode>(OsuSetting.Scaling),
|
||||
Keywords = new[] { "scale", "letterbox" },
|
||||
},
|
||||
scalingSettings = new FillFlowContainer<SettingsSlider<float>>
|
||||
{
|
||||
|
@ -1,26 +0,0 @@
|
||||
// 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 osu.Framework.Allocation;
|
||||
using osu.Game.Configuration;
|
||||
|
||||
namespace osu.Game.Overlays.Settings.Sections.Graphics
|
||||
{
|
||||
public class MainMenuSettings : SettingsSubsection
|
||||
{
|
||||
protected override string Header => "User Interface";
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
Children = new[]
|
||||
{
|
||||
new SettingsCheckbox
|
||||
{
|
||||
LabelText = "Parallax",
|
||||
Bindable = config.GetBindable<bool>(OsuSetting.MenuParallax)
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
// 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 osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Overlays.Settings.Sections.Graphics
|
||||
{
|
||||
public class UserInterfaceSettings : SettingsSubsection
|
||||
{
|
||||
protected override string Header => "User Interface";
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SettingsCheckbox
|
||||
{
|
||||
LabelText = "Rotate cursor when dragging",
|
||||
Bindable = config.GetBindable<bool>(OsuSetting.CursorRotation)
|
||||
},
|
||||
new SettingsCheckbox
|
||||
{
|
||||
LabelText = "Parallax",
|
||||
Bindable = config.GetBindable<bool>(OsuSetting.MenuParallax)
|
||||
},
|
||||
new SettingsSlider<float, TimeSlider>
|
||||
{
|
||||
LabelText = "Hold-to-confirm activation time",
|
||||
Bindable = config.GetBindable<float>(OsuSetting.UIHoldActivationDelay),
|
||||
KeyboardStep = 50
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
private class TimeSlider : OsuSliderBar<float>
|
||||
{
|
||||
public override string TooltipText => Current.Value.ToString("N0") + "ms";
|
||||
}
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Settings.Sections
|
||||
new RendererSettings(),
|
||||
new LayoutSettings(),
|
||||
new DetailSettings(),
|
||||
new MainMenuSettings(),
|
||||
new UserInterfaceSettings(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -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";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,16 +35,16 @@ namespace osu.Game.Overlays.Settings.Sections
|
||||
Children = new Drawable[]
|
||||
{
|
||||
skinDropdown = new SkinSettingsDropdown(),
|
||||
new SettingsSlider<double, SizeSlider>
|
||||
new SettingsSlider<float, SizeSlider>
|
||||
{
|
||||
LabelText = "Menu cursor size",
|
||||
Bindable = config.GetBindable<double>(OsuSetting.MenuCursorSize),
|
||||
Bindable = config.GetBindable<float>(OsuSetting.MenuCursorSize),
|
||||
KeyboardStep = 0.01f
|
||||
},
|
||||
new SettingsSlider<double, SizeSlider>
|
||||
new SettingsSlider<float, SizeSlider>
|
||||
{
|
||||
LabelText = "Gameplay cursor size",
|
||||
Bindable = config.GetBindable<double>(OsuSetting.GameplayCursorSize),
|
||||
Bindable = config.GetBindable<float>(OsuSetting.GameplayCursorSize),
|
||||
KeyboardStep = 0.01f
|
||||
},
|
||||
new SettingsCheckbox
|
||||
@ -95,7 +95,7 @@ namespace osu.Game.Overlays.Settings.Sections
|
||||
}
|
||||
}
|
||||
|
||||
private class SizeSlider : OsuSliderBar<double>
|
||||
private class SizeSlider : OsuSliderBar<float>
|
||||
{
|
||||
public override string TooltipText => Current.Value.ToString(@"0.##x");
|
||||
}
|
||||
@ -107,6 +107,8 @@ namespace osu.Game.Overlays.Settings.Sections
|
||||
private class SkinDropdownControl : DropdownControl
|
||||
{
|
||||
protected override string GenerateItemText(SkinInfo item) => item.ToString();
|
||||
|
||||
protected override DropdownMenu CreateMenu() => base.CreateMenu().With(m => m.MaxHeight = 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,14 @@
|
||||
// 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;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Overlays.Settings
|
||||
{
|
||||
public class SettingsEnumDropdown<T> : SettingsDropdown<T>
|
||||
where T : struct, Enum
|
||||
{
|
||||
protected override OsuDropdown<T> CreateDropdown() => new DropdownControl();
|
||||
|
||||
|
@ -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
|
||||
@ -46,38 +45,22 @@ namespace osu.Game.Overlays.Settings
|
||||
if (text == null)
|
||||
{
|
||||
// construct lazily for cases where the label is not needed (may be provided by the Control).
|
||||
Add(text = new OsuSpriteText());
|
||||
FlowContent.SetLayoutPosition(text, -1);
|
||||
FlowContent.Insert(-1, text = new OsuSpriteText());
|
||||
}
|
||||
|
||||
text.Text = value;
|
||||
}
|
||||
}
|
||||
|
||||
// hold a reference to the provided bindable so we don't have to in every settings section.
|
||||
private Bindable<T> bindable;
|
||||
|
||||
public virtual Bindable<T> Bindable
|
||||
{
|
||||
get => bindable;
|
||||
|
||||
set
|
||||
{
|
||||
if (bindable != null)
|
||||
controlWithCurrent?.Current.UnbindFrom(bindable);
|
||||
|
||||
bindable = value;
|
||||
controlWithCurrent?.Current.BindTo(bindable);
|
||||
|
||||
if (ShowsDefaultIndicator)
|
||||
{
|
||||
restoreDefaultButton.Bindable = bindable.GetBoundCopy();
|
||||
restoreDefaultButton.Bindable.TriggerChange();
|
||||
}
|
||||
}
|
||||
get => controlWithCurrent.Current;
|
||||
set => controlWithCurrent.Current = value;
|
||||
}
|
||||
|
||||
public virtual IEnumerable<string> FilterTerms => new[] { LabelText };
|
||||
public virtual IEnumerable<string> FilterTerms => Keywords == null ? new[] { LabelText } : new List<string>(Keywords) { LabelText }.ToArray();
|
||||
|
||||
public IEnumerable<string> Keywords { get; set; }
|
||||
|
||||
public bool MatchingFilter
|
||||
{
|
||||
@ -86,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 };
|
||||
@ -103,13 +90,17 @@ 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)
|
||||
restoreDefaultButton.Bindable = controlWithCurrent.Current;
|
||||
}
|
||||
}
|
||||
|
||||
private class RestoreDefaultValueButton : Container, IHasTooltip
|
||||
@ -124,6 +115,8 @@ namespace osu.Game.Overlays.Settings
|
||||
bindable = value;
|
||||
bindable.ValueChanged += _ => UpdateState();
|
||||
bindable.DisabledChanged += _ => UpdateState();
|
||||
bindable.DefaultChanged += _ => UpdateState();
|
||||
UpdateState();
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,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)
|
||||
{
|
||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Overlays.Settings
|
||||
public abstract string Header { get; }
|
||||
|
||||
public IEnumerable<IFilterable> FilterableChildren => Children.OfType<IFilterable>();
|
||||
public IEnumerable<string> FilterTerms => new[] { Header };
|
||||
public virtual IEnumerable<string> FilterTerms => new[] { Header };
|
||||
|
||||
private const int header_size = 26;
|
||||
private const int header_margin = 25;
|
||||
|
@ -8,15 +8,15 @@ using osu.Game.Graphics.UserInterface;
|
||||
namespace osu.Game.Overlays.Settings
|
||||
{
|
||||
public class SettingsSlider<T> : SettingsSlider<T, OsuSliderBar<T>>
|
||||
where T : struct, IEquatable<T>, IComparable, IConvertible
|
||||
where T : struct, IEquatable<T>, IComparable<T>, IConvertible
|
||||
{
|
||||
}
|
||||
|
||||
public class SettingsSlider<T, U> : SettingsItem<T>
|
||||
where T : struct, IEquatable<T>, IComparable, 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ namespace osu.Game.Overlays.Settings
|
||||
protected abstract string Header { get; }
|
||||
|
||||
public IEnumerable<IFilterable> FilterableChildren => Children.OfType<IFilterable>();
|
||||
public IEnumerable<string> FilterTerms => new[] { Header };
|
||||
public virtual IEnumerable<string> FilterTerms => new[] { Header };
|
||||
|
||||
public bool MatchingFilter
|
||||
{
|
||||
|
@ -12,6 +12,7 @@ namespace osu.Game.Overlays.Settings
|
||||
{
|
||||
Margin = new MarginPadding { Top = 5 },
|
||||
RelativeSizeAxes = Axes.X,
|
||||
CommitOnFocusLost = true,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -84,6 +84,7 @@ namespace osu.Game.Overlays.Settings
|
||||
Content.Anchor = Anchor.CentreLeft;
|
||||
Content.Origin = Anchor.CentreLeft;
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
ScrollbarVisible = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
// 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 osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
@ -9,21 +8,18 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Overlays.Settings
|
||||
{
|
||||
public class SidebarButton : Button
|
||||
public class SidebarButton : OsuButton
|
||||
{
|
||||
private readonly SpriteIcon drawableIcon;
|
||||
private readonly SpriteText headerText;
|
||||
private readonly Box selectionIndicator;
|
||||
private readonly Container text;
|
||||
public new Action<SettingsSection> Action;
|
||||
|
||||
private SettingsSection section;
|
||||
|
||||
@ -62,12 +58,11 @@ namespace osu.Game.Overlays.Settings
|
||||
|
||||
public SidebarButton()
|
||||
{
|
||||
BackgroundColour = OsuColour.Gray(60);
|
||||
Background.Alpha = 0;
|
||||
|
||||
Height = Sidebar.DEFAULT_WIDTH;
|
||||
RelativeSizeAxes = Axes.X;
|
||||
|
||||
BackgroundColour = Color4.Black;
|
||||
|
||||
AddRange(new Drawable[]
|
||||
{
|
||||
text = new Container
|
||||
@ -99,7 +94,6 @@ namespace osu.Game.Overlays.Settings
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
},
|
||||
new HoverClickSounds(HoverSampleSet.Loud),
|
||||
});
|
||||
}
|
||||
|
||||
@ -108,23 +102,5 @@ namespace osu.Game.Overlays.Settings
|
||||
{
|
||||
selectionIndicator.Colour = colours.Yellow;
|
||||
}
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
Action?.Invoke(section);
|
||||
return base.OnClick(e);
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
Background.FadeTo(0.4f, 200);
|
||||
return base.OnHover(e);
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
Background.FadeTo(0, 200);
|
||||
base.OnHoverLost(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user