diff --git a/osu.Game/Localisation/SkinComponents/SkinnableComponentStrings.cs b/osu.Game/Localisation/SkinComponents/SkinnableComponentStrings.cs
index 66abf2bfd5..35ed1ea55c 100644
--- a/osu.Game/Localisation/SkinComponents/SkinnableComponentStrings.cs
+++ b/osu.Game/Localisation/SkinComponents/SkinnableComponentStrings.cs
@@ -79,6 +79,11 @@ namespace osu.Game.Localisation.SkinComponents
///
public static LocalisableString TextColourDescription => new TranslatableString(getKey(@"text_colour_description"), @"The colour of the text.");
+ ///
+ /// "Text weight"
+ ///
+ public static LocalisableString TextWeight => new TranslatableString(getKey(@"text_weight"), @"Text weight");
+
///
/// "Use relative size"
///
diff --git a/osu.Game/Skinning/FontAdjustableSkinComponent.cs b/osu.Game/Skinning/FontAdjustableSkinComponent.cs
index 0821edf7fc..f2d8c9e440 100644
--- a/osu.Game/Skinning/FontAdjustableSkinComponent.cs
+++ b/osu.Game/Skinning/FontAdjustableSkinComponent.cs
@@ -1,13 +1,16 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Configuration;
using osu.Game.Graphics;
+using osu.Game.Graphics.UserInterface;
using osu.Game.Localisation.SkinComponents;
+using osu.Game.Overlays.Settings;
namespace osu.Game.Skinning
{
@@ -21,6 +24,9 @@ namespace osu.Game.Skinning
[SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.Font), nameof(SkinnableComponentStrings.FontDescription))]
public Bindable Font { get; } = new Bindable(Typeface.Torus);
+ [SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.TextWeight), SettingControlType = typeof(WeightDropdown))]
+ public Bindable TextWeight { get; } = new Bindable(FontWeight.Regular);
+
[SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.TextColour), nameof(SkinnableComponentStrings.TextColourDescription))]
public BindableColour4 TextColour { get; } = new BindableColour4(Colour4.White);
@@ -35,16 +41,69 @@ namespace osu.Game.Skinning
{
base.LoadComplete();
- Font.BindValueChanged(e =>
- {
- // We only have bold weight for venera, so let's force that.
- FontWeight fontWeight = e.NewValue == Typeface.Venera ? FontWeight.Bold : FontWeight.Regular;
-
- FontUsage f = OsuFont.GetFont(e.NewValue, weight: fontWeight);
- SetFont(f);
- }, true);
+ Font.BindValueChanged(_ => updateFont());
+ TextWeight.BindValueChanged(_ => updateFont(), true);
TextColour.BindValueChanged(e => SetTextColour(e.NewValue), true);
}
+
+ private void updateFont() => SetFont(OsuFont.GetFont(Font.Value, weight: TextWeight.Value));
+
+ private partial class WeightDropdown : SettingsDropdown
+ {
+ public FontAdjustableSkinComponent FontComponent => (FontAdjustableSkinComponent)SettingSourceObject;
+ protected override OsuDropdown CreateDropdown() => new DropdownControl(this);
+
+ private new partial class DropdownControl : SettingsDropdown.DropdownControl
+ {
+ private readonly WeightDropdown settingsDropdown;
+
+ private IBindable font = null!;
+
+ public DropdownControl(WeightDropdown settingsDropdown)
+ {
+ this.settingsDropdown = settingsDropdown;
+ }
+
+ protected override void LoadComplete()
+ {
+ base.LoadComplete();
+
+ font = settingsDropdown.FontComponent.Font.GetBoundCopy();
+ font.BindValueChanged(_ => updateItems(), true);
+ }
+
+ private void updateItems()
+ {
+ ClearItems();
+
+ switch (font.Value)
+ {
+ case Typeface.Venera:
+ AddDropdownItem(FontWeight.Light);
+ AddDropdownItem(FontWeight.Bold);
+ AddDropdownItem(FontWeight.Black);
+
+ Current.Default = FontWeight.Bold;
+
+ if (!Items.Contains(Current.Value))
+ Current.SetDefault();
+ break;
+
+ default:
+ AddDropdownItem(FontWeight.Light);
+ AddDropdownItem(FontWeight.Regular);
+ AddDropdownItem(FontWeight.SemiBold);
+ AddDropdownItem(FontWeight.Bold);
+
+ Current.Default = FontWeight.Regular;
+
+ if (!Items.Contains(Current.Value))
+ Current.SetDefault();
+ break;
+ }
+ }
+ }
+ }
}
}