mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 16:12:57 +08:00
Merge pull request #25469 from Joehuu/argon-hide-counter-labels
Add ability to toggle labels on argon counter components
This commit is contained in:
commit
0a8ede6274
@ -12,43 +12,53 @@ namespace osu.Game.Localisation.SkinComponents
|
||||
/// <summary>
|
||||
/// "Sprite name"
|
||||
/// </summary>
|
||||
public static LocalisableString SpriteName => new TranslatableString(getKey(@"sprite_name"), "Sprite name");
|
||||
public static LocalisableString SpriteName => new TranslatableString(getKey(@"sprite_name"), @"Sprite name");
|
||||
|
||||
/// <summary>
|
||||
/// "The filename of the sprite"
|
||||
/// </summary>
|
||||
public static LocalisableString SpriteNameDescription => new TranslatableString(getKey(@"sprite_name_description"), "The filename of the sprite");
|
||||
public static LocalisableString SpriteNameDescription => new TranslatableString(getKey(@"sprite_name_description"), @"The filename of the sprite");
|
||||
|
||||
/// <summary>
|
||||
/// "Font"
|
||||
/// </summary>
|
||||
public static LocalisableString Font => new TranslatableString(getKey(@"font"), "Font");
|
||||
public static LocalisableString Font => new TranslatableString(getKey(@"font"), @"Font");
|
||||
|
||||
/// <summary>
|
||||
/// "The font to use."
|
||||
/// </summary>
|
||||
public static LocalisableString FontDescription => new TranslatableString(getKey(@"font_description"), "The font to use.");
|
||||
public static LocalisableString FontDescription => new TranslatableString(getKey(@"font_description"), @"The font to use.");
|
||||
|
||||
/// <summary>
|
||||
/// "Text"
|
||||
/// </summary>
|
||||
public static LocalisableString TextElementText => new TranslatableString(getKey(@"text_element_text"), "Text");
|
||||
public static LocalisableString TextElementText => new TranslatableString(getKey(@"text_element_text"), @"Text");
|
||||
|
||||
/// <summary>
|
||||
/// "The text to be displayed."
|
||||
/// </summary>
|
||||
public static LocalisableString TextElementTextDescription => new TranslatableString(getKey(@"text_element_text_description"), "The text to be displayed.");
|
||||
public static LocalisableString TextElementTextDescription => new TranslatableString(getKey(@"text_element_text_description"), @"The text to be displayed.");
|
||||
|
||||
/// <summary>
|
||||
/// "Corner radius"
|
||||
/// </summary>
|
||||
public static LocalisableString CornerRadius => new TranslatableString(getKey(@"corner_radius"), "Corner radius");
|
||||
public static LocalisableString CornerRadius => new TranslatableString(getKey(@"corner_radius"), @"Corner radius");
|
||||
|
||||
/// <summary>
|
||||
/// "How rounded the corners should be."
|
||||
/// </summary>
|
||||
public static LocalisableString CornerRadiusDescription => new TranslatableString(getKey(@"corner_radius_description"), "How rounded the corners should be.");
|
||||
public static LocalisableString CornerRadiusDescription => new TranslatableString(getKey(@"corner_radius_description"), @"How rounded the corners should be.");
|
||||
|
||||
private static string getKey(string key) => $"{prefix}:{key}";
|
||||
/// <summary>
|
||||
/// "Show label"
|
||||
/// </summary>
|
||||
public static LocalisableString ShowLabel => new TranslatableString(getKey(@"show_label"), @"Show label");
|
||||
|
||||
/// <summary>
|
||||
/// "Whether the component's label should be shown."
|
||||
/// </summary>
|
||||
public static LocalisableString ShowLabelDescription => new TranslatableString(getKey(@"show_label_description"), @"Whether the component's label should be shown.");
|
||||
|
||||
private static string getKey(string key) => $@"{prefix}:{key}";
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,14 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.LocalisationExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Localisation.SkinComponents;
|
||||
using osu.Game.Resources.Localisation.Web;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
|
||||
@ -25,20 +28,27 @@ namespace osu.Game.Screens.Play.HUD
|
||||
MaxValue = 1,
|
||||
};
|
||||
|
||||
[SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.ShowLabel), nameof(SkinnableComponentStrings.ShowLabelDescription))]
|
||||
public Bindable<bool> ShowLabel { get; } = new BindableBool(true);
|
||||
|
||||
public bool UsesFixedAnchor { get; set; }
|
||||
|
||||
protected override IHasText CreateText() => new ArgonAccuracyTextComponent
|
||||
{
|
||||
WireframeOpacity = { BindTarget = WireframeOpacity },
|
||||
ShowLabel = { BindTarget = ShowLabel },
|
||||
};
|
||||
|
||||
private partial class ArgonAccuracyTextComponent : CompositeDrawable, IHasText
|
||||
{
|
||||
private readonly ArgonCounterTextComponent wholePart;
|
||||
private readonly ArgonCounterTextComponent fractionPart;
|
||||
private readonly ArgonCounterTextComponent percentText;
|
||||
|
||||
public IBindable<float> WireframeOpacity { get; } = new BindableFloat();
|
||||
|
||||
public Bindable<bool> ShowLabel { get; } = new BindableBool();
|
||||
|
||||
public LocalisableString Text
|
||||
{
|
||||
get => wholePart.Text;
|
||||
@ -64,27 +74,37 @@ namespace osu.Game.Screens.Play.HUD
|
||||
new Container
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Child = wholePart = new ArgonCounterTextComponent(Anchor.TopRight, "ACCURACY")
|
||||
Child = wholePart = new ArgonCounterTextComponent(Anchor.TopRight, BeatmapsetsStrings.ShowScoreboardHeadersAccuracy.ToUpper())
|
||||
{
|
||||
RequiredDisplayDigits = { Value = 3 },
|
||||
WireframeOpacity = { BindTarget = WireframeOpacity }
|
||||
WireframeOpacity = { BindTarget = WireframeOpacity },
|
||||
ShowLabel = { BindTarget = ShowLabel },
|
||||
}
|
||||
},
|
||||
fractionPart = new ArgonCounterTextComponent(Anchor.TopLeft)
|
||||
{
|
||||
Margin = new MarginPadding { Top = 12f * 2f + 4f }, // +4 to account for the extra spaces above the digits.
|
||||
WireframeOpacity = { BindTarget = WireframeOpacity },
|
||||
Scale = new Vector2(0.5f),
|
||||
},
|
||||
new ArgonCounterTextComponent(Anchor.TopLeft)
|
||||
percentText = new ArgonCounterTextComponent(Anchor.TopLeft)
|
||||
{
|
||||
Text = @"%",
|
||||
Margin = new MarginPadding { Top = 12f },
|
||||
WireframeOpacity = { BindTarget = WireframeOpacity }
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
ShowLabel.BindValueChanged(s =>
|
||||
{
|
||||
fractionPart.Margin = new MarginPadding { Top = s.NewValue ? 12f * 2f + 4f : 4f }; // +4 to account for the extra spaces above the digits.
|
||||
percentText.Margin = new MarginPadding { Top = s.NewValue ? 12f : 0 };
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,13 @@
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.LocalisationExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Localisation.SkinComponents;
|
||||
using osu.Game.Resources.Localisation.Web;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
@ -29,6 +32,9 @@ namespace osu.Game.Screens.Play.HUD
|
||||
MaxValue = 1,
|
||||
};
|
||||
|
||||
[SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.ShowLabel), nameof(SkinnableComponentStrings.ShowLabelDescription))]
|
||||
public Bindable<bool> ShowLabel { get; } = new BindableBool(true);
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(ScoreProcessor scoreProcessor)
|
||||
{
|
||||
@ -53,9 +59,10 @@ namespace osu.Game.Screens.Play.HUD
|
||||
|
||||
protected override LocalisableString FormatCount(int count) => $@"{count}x";
|
||||
|
||||
protected override IHasText CreateText() => text = new ArgonCounterTextComponent(Anchor.TopLeft, "COMBO")
|
||||
protected override IHasText CreateText() => text = new ArgonCounterTextComponent(Anchor.TopLeft, MatchesStrings.MatchScoreStatsCombo.ToUpper())
|
||||
{
|
||||
WireframeOpacity = { BindTarget = WireframeOpacity },
|
||||
ShowLabel = { BindTarget = ShowLabel },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ namespace osu.Game.Screens.Play.HUD
|
||||
|
||||
public IBindable<float> WireframeOpacity { get; } = new BindableFloat();
|
||||
public Bindable<int> RequiredDisplayDigits { get; } = new BindableInt();
|
||||
public Bindable<bool> ShowLabel { get; } = new BindableBool();
|
||||
|
||||
public Container NumberContainer { get; private set; }
|
||||
|
||||
@ -56,7 +57,7 @@ namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
labelText = new OsuSpriteText
|
||||
{
|
||||
Alpha = label != null ? 1 : 0,
|
||||
Alpha = 0,
|
||||
Text = label.GetValueOrDefault(),
|
||||
Font = OsuFont.Torus.With(size: 12, weight: FontWeight.Bold),
|
||||
Margin = new MarginPadding { Left = 2.5f },
|
||||
@ -114,6 +115,7 @@ namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
base.LoadComplete();
|
||||
WireframeOpacity.BindValueChanged(v => wireframesPart.Alpha = v.NewValue, true);
|
||||
ShowLabel.BindValueChanged(s => labelText.Alpha = s.NewValue ? 1 : 0, true);
|
||||
}
|
||||
|
||||
private partial class ArgonCounterSpriteText : OsuSpriteText
|
||||
|
@ -7,6 +7,8 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Localisation.SkinComponents;
|
||||
using osu.Game.Resources.Localisation.Web;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD
|
||||
@ -24,14 +26,18 @@ namespace osu.Game.Screens.Play.HUD
|
||||
MaxValue = 1,
|
||||
};
|
||||
|
||||
[SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.ShowLabel), nameof(SkinnableComponentStrings.ShowLabelDescription))]
|
||||
public Bindable<bool> ShowLabel { get; } = new BindableBool(true);
|
||||
|
||||
public bool UsesFixedAnchor { get; set; }
|
||||
|
||||
protected override LocalisableString FormatCount(long count) => count.ToLocalisableString();
|
||||
|
||||
protected override IHasText CreateText() => new ArgonScoreTextComponent(Anchor.TopRight)
|
||||
protected override IHasText CreateText() => new ArgonScoreTextComponent(Anchor.TopRight, BeatmapsetsStrings.ShowScoreboardHeadersScore.ToUpper())
|
||||
{
|
||||
RequiredDisplayDigits = { BindTarget = RequiredDisplayDigits },
|
||||
WireframeOpacity = { BindTarget = WireframeOpacity },
|
||||
ShowLabel = { BindTarget = ShowLabel },
|
||||
};
|
||||
|
||||
private partial class ArgonScoreTextComponent : ArgonCounterTextComponent
|
||||
|
@ -214,7 +214,10 @@ namespace osu.Game.Skinning
|
||||
Size = new Vector2(380, 72),
|
||||
Position = new Vector2(4, 5)
|
||||
},
|
||||
new ArgonScoreCounter(),
|
||||
new ArgonScoreCounter
|
||||
{
|
||||
ShowLabel = { Value = false },
|
||||
},
|
||||
new ArgonHealthDisplay(),
|
||||
new BoxElement
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user