mirror of
https://github.com/ppy/osu.git
synced 2025-01-18 18:12:55 +08:00
Add colour customisation to skin components
This commit is contained in:
parent
6ec3f715d2
commit
e81e356d59
@ -59,6 +59,26 @@ namespace osu.Game.Localisation.SkinComponents
|
||||
/// </summary>
|
||||
public static LocalisableString ShowLabelDescription => new TranslatableString(getKey(@"show_label_description"), @"Whether the component's label should be shown.");
|
||||
|
||||
/// <summary>
|
||||
/// "Colour"
|
||||
/// </summary>
|
||||
public static LocalisableString Colour => new TranslatableString(getKey(@"colour"), @"Colour");
|
||||
|
||||
/// <summary>
|
||||
/// "The colour of the component."
|
||||
/// </summary>
|
||||
public static LocalisableString ColourDescription => new TranslatableString(getKey(@"colour_description"), @"The colour of the component.");
|
||||
|
||||
/// <summary>
|
||||
/// "Font colour"
|
||||
/// </summary>
|
||||
public static LocalisableString FontColour => new TranslatableString(getKey(@"font_colour"), @"Font colour");
|
||||
|
||||
/// <summary>
|
||||
/// "The colour of the font."
|
||||
/// </summary>
|
||||
public static LocalisableString FontColourDescription => new TranslatableString(getKey(@"font_colour_description"), @"The colour of the font.");
|
||||
|
||||
private static string getKey(string key) => $@"{prefix}:{key}";
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Localisation.HUD;
|
||||
using osu.Game.Localisation.SkinComponents;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD
|
||||
@ -28,6 +29,8 @@ namespace osu.Game.Screens.Play.HUD
|
||||
|
||||
[SettingSource(typeof(SongProgressStrings), nameof(SongProgressStrings.ShowTime), nameof(SongProgressStrings.ShowTimeDescription))]
|
||||
public Bindable<bool> ShowTime { get; } = new BindableBool(true);
|
||||
[SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.Colour), nameof(SkinnableComponentStrings.ColourDescription))]
|
||||
public new BindableColour4 Colour { get; } = new BindableColour4(Colour4.White);
|
||||
|
||||
[Resolved]
|
||||
private Player? player { get; set; }
|
||||
@ -114,6 +117,7 @@ namespace osu.Game.Screens.Play.HUD
|
||||
base.Update();
|
||||
content.Height = bar.Height + bar_height + info.Height;
|
||||
graphContainer.Height = bar.Height;
|
||||
base.Colour = Colour.Value;
|
||||
}
|
||||
|
||||
protected override void UpdateProgress(double progress, bool isIntro)
|
||||
|
@ -9,6 +9,7 @@ using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Localisation.SkinComponents;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
|
||||
@ -21,6 +22,9 @@ namespace osu.Game.Screens.Play.HUD
|
||||
[SettingSource("Inverted shear")]
|
||||
public BindableBool InvertShear { get; } = new BindableBool();
|
||||
|
||||
[SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.Colour), nameof(SkinnableComponentStrings.ColourDescription))]
|
||||
public new BindableColour4 Colour { get; } = new BindableColour4(Color4Extensions.FromHex("#66CCFF"));
|
||||
|
||||
public ArgonWedgePiece()
|
||||
{
|
||||
CornerRadius = 10f;
|
||||
@ -37,7 +41,7 @@ namespace osu.Game.Screens.Play.HUD
|
||||
InternalChild = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = ColourInfo.GradientVertical(Color4Extensions.FromHex("#66CCFF").Opacity(0.0f), Color4Extensions.FromHex("#66CCFF").Opacity(0.25f)),
|
||||
Colour = ColourInfo.GradientVertical(Colour.Value.Opacity(0.0f), Colour.Value.Opacity(0.25f)),
|
||||
};
|
||||
}
|
||||
|
||||
@ -46,6 +50,7 @@ namespace osu.Game.Screens.Play.HUD
|
||||
base.LoadComplete();
|
||||
|
||||
InvertShear.BindValueChanged(v => Shear = new Vector2(0.8f, 0f) * (v.NewValue ? -1 : 1), true);
|
||||
Colour.BindValueChanged(c => InternalChild.Colour = ColourInfo.GradientVertical(Colour.Value.Opacity(0.0f), Colour.Value.Opacity(0.25f)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ using osu.Framework.Utils;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Localisation.HUD;
|
||||
using osu.Game.Localisation.SkinComponents;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osuTK;
|
||||
|
||||
@ -35,6 +36,8 @@ namespace osu.Game.Screens.Play.HUD
|
||||
|
||||
[SettingSource(typeof(SongProgressStrings), nameof(SongProgressStrings.ShowTime), nameof(SongProgressStrings.ShowTimeDescription))]
|
||||
public Bindable<bool> ShowTime { get; } = new BindableBool(true);
|
||||
[SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.Colour), nameof(SkinnableComponentStrings.ColourDescription))]
|
||||
public new BindableColour4 Colour { get; } = new BindableColour4(Colour4.White);
|
||||
|
||||
[Resolved]
|
||||
private Player? player { get; set; }
|
||||
@ -114,6 +117,8 @@ namespace osu.Game.Screens.Play.HUD
|
||||
|
||||
if (!Precision.AlmostEquals(Height, newHeight, 5f))
|
||||
content.Height = newHeight;
|
||||
|
||||
base.Colour = Colour.Value;
|
||||
}
|
||||
|
||||
private void updateBarVisibility()
|
||||
|
@ -123,6 +123,8 @@ namespace osu.Game.Skinning.Components
|
||||
}
|
||||
|
||||
protected override void SetFont(FontUsage font) => text.Font = font.With(size: 40);
|
||||
|
||||
protected override void SetFontColour(Colour4 fontColour) => text.Colour = fontColour;
|
||||
}
|
||||
|
||||
// WARNING: DO NOT ADD ANY VALUES TO THIS ENUM ANYWHERE ELSE THAN AT THE END.
|
||||
|
@ -27,6 +27,9 @@ namespace osu.Game.Skinning.Components
|
||||
Precision = 0.01f
|
||||
};
|
||||
|
||||
[SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.Colour), nameof(SkinnableComponentStrings.ColourDescription))]
|
||||
public new BindableColour4 Colour { get; } = new BindableColour4(Colour4.White);
|
||||
|
||||
public BoxElement()
|
||||
{
|
||||
Size = new Vector2(400, 80);
|
||||
@ -48,6 +51,7 @@ namespace osu.Game.Skinning.Components
|
||||
base.Update();
|
||||
|
||||
base.CornerRadius = CornerRadius.Value * Math.Min(DrawWidth, DrawHeight);
|
||||
base.Colour = Colour.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,5 +53,7 @@ namespace osu.Game.Skinning.Components
|
||||
}
|
||||
|
||||
protected override void SetFont(FontUsage font) => text.Font = font.With(size: 40);
|
||||
|
||||
protected override void SetFontColour(Colour4 fontColour) => text.Colour = fontColour;
|
||||
}
|
||||
}
|
||||
|
@ -36,5 +36,7 @@ namespace osu.Game.Skinning.Components
|
||||
}
|
||||
|
||||
protected override void SetFont(FontUsage font) => text.Font = font.With(size: 40);
|
||||
|
||||
protected override void SetFontColour(Colour4 fontColour) => text.Colour = fontColour;
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Configuration;
|
||||
@ -20,11 +21,16 @@ namespace osu.Game.Skinning
|
||||
[SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.Font), nameof(SkinnableComponentStrings.FontDescription))]
|
||||
public Bindable<Typeface> Font { get; } = new Bindable<Typeface>(Typeface.Torus);
|
||||
|
||||
[SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.FontColour), nameof(SkinnableComponentStrings.FontColourDescription))]
|
||||
public BindableColour4 FontColour { get; } = new BindableColour4(Colour4.White);
|
||||
|
||||
/// <summary>
|
||||
/// Implement to apply the user font selection to one or more components.
|
||||
/// </summary>
|
||||
protected abstract void SetFont(FontUsage font);
|
||||
|
||||
protected abstract void SetFontColour(Colour4 fontColour);
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
@ -37,6 +43,8 @@ namespace osu.Game.Skinning
|
||||
FontUsage f = OsuFont.GetFont(e.NewValue, weight: fontWeight);
|
||||
SetFont(f);
|
||||
}, true);
|
||||
|
||||
FontColour.BindValueChanged(e => SetFontColour(e.NewValue), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user