diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneAimErrorMeter.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneAimErrorMeter.cs index b6e4c43478..b1ad2b2296 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneAimErrorMeter.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneAimErrorMeter.cs @@ -36,15 +36,15 @@ namespace osu.Game.Rulesets.Osu.Tests { base.LoadComplete(); - AddSliderStep("Hit position size", 0f, 12f, 7f, t => + AddSliderStep("Hit marker size", 0f, 12f, 7f, t => { if (aimErrorMeter.IsNotNull()) - aimErrorMeter.HitPositionSize.Value = t; + aimErrorMeter.HitMarkerSize.Value = t; }); - AddSliderStep("Average position size", 1f, 25f, 7f, t => + AddSliderStep("Average position marker size", 1f, 25f, 7f, t => { if (aimErrorMeter.IsNotNull()) - aimErrorMeter.AverageSize.Value = t; + aimErrorMeter.AverageMarkerSize.Value = t; }); } @@ -139,10 +139,10 @@ namespace osu.Game.Rulesets.Osu.Tests [Test] public void TestDifferentStyle() { - AddStep("Switch hit position style to +", () => aimErrorMeter.HitPositionStyle.Value = AimErrorMeter.HitStyle.Plus); - AddStep("Switch hit position style to x", () => aimErrorMeter.HitPositionStyle.Value = AimErrorMeter.HitStyle.X); - AddStep("Switch average position style to +", () => aimErrorMeter.AverageStyle.Value = AimErrorMeter.HitStyle.Plus); - AddStep("Switch average position style to x", () => aimErrorMeter.AverageStyle.Value = AimErrorMeter.HitStyle.X); + AddStep("Switch hit position marker style to +", () => aimErrorMeter.HitMarkerStyle.Value = AimErrorMeter.MarkerStyle.Plus); + AddStep("Switch hit position marker style to x", () => aimErrorMeter.HitMarkerStyle.Value = AimErrorMeter.MarkerStyle.X); + AddStep("Switch average position marker style to +", () => aimErrorMeter.AverageMarkerStyle.Value = AimErrorMeter.MarkerStyle.Plus); + AddStep("Switch average position marker style to x", () => aimErrorMeter.AverageMarkerStyle.Value = AimErrorMeter.MarkerStyle.X); } private partial class TestAimErrorMeter : AimErrorMeter diff --git a/osu.Game.Rulesets.Osu/HUD/AimErrorMeter.cs b/osu.Game.Rulesets.Osu/HUD/AimErrorMeter.cs index 8bf9381907..0938bd31be 100644 --- a/osu.Game.Rulesets.Osu/HUD/AimErrorMeter.cs +++ b/osu.Game.Rulesets.Osu/HUD/AimErrorMeter.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.ComponentModel; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; @@ -24,46 +25,47 @@ using osu.Game.Rulesets.Scoring; using osu.Game.Screens.Play.HUD.HitErrorMeters; using osuTK; using osuTK.Graphics; +using Container = osu.Framework.Graphics.Containers.Container; namespace osu.Game.Rulesets.Osu.HUD { [Cached] public partial class AimErrorMeter : HitErrorMeter { - [SettingSource(typeof(AimErrorMeterStrings), nameof(AimErrorMeterStrings.HitPositionSize), nameof(AimErrorMeterStrings.HitPositionSizeDescription))] - public BindableNumber HitPositionSize { get; } = new BindableNumber(7f) + [SettingSource(typeof(AimErrorMeterStrings), nameof(AimErrorMeterStrings.HitMarkerSize), nameof(AimErrorMeterStrings.HitMarkerSizeDescription))] + public BindableNumber HitMarkerSize { get; } = new BindableNumber(7f) { MinValue = 0f, MaxValue = 12f, Precision = 1f }; - [SettingSource(typeof(AimErrorMeterStrings), nameof(AimErrorMeterStrings.HitPositionStyle), nameof(AimErrorMeterStrings.HitPositionStyleDescription))] - public Bindable HitPositionStyle { get; } = new Bindable(); + [SettingSource(typeof(AimErrorMeterStrings), nameof(AimErrorMeterStrings.HitMarkerStyle), nameof(AimErrorMeterStrings.HitMarkerStyleDescription))] + public Bindable HitMarkerStyle { get; } = new Bindable(); - [SettingSource(typeof(AimErrorMeterStrings), nameof(AimErrorMeterStrings.AverageSize), nameof(AimErrorMeterStrings.AverageSizeDescription))] - public BindableNumber AverageSize { get; } = new BindableNumber(12f) + [SettingSource(typeof(AimErrorMeterStrings), nameof(AimErrorMeterStrings.AverageMarkerSize), nameof(AimErrorMeterStrings.AverageMarkerSizeDescription))] + public BindableNumber AverageMarkerSize { get; } = new BindableNumber(12f) { MinValue = 7f, MaxValue = 25f, Precision = 1f }; - [SettingSource(typeof(AimErrorMeterStrings), nameof(AimErrorMeterStrings.AverageStyle), nameof(AimErrorMeterStrings.AverageStyleDescription))] - public Bindable AverageStyle { get; } = new Bindable(HitStyle.Plus); + [SettingSource(typeof(AimErrorMeterStrings), nameof(AimErrorMeterStrings.AverageMarkerStyle), nameof(AimErrorMeterStrings.AverageMarkerStyleDescription))] + public Bindable AverageMarkerStyle { get; } = new Bindable(MarkerStyle.Plus); - [SettingSource(typeof(AimErrorMeterStrings), nameof(AimErrorMeterStrings.PositionStyle), nameof(AimErrorMeterStrings.PositionStyleDescription))] - public Bindable PositionMappingStyle { get; } = new Bindable(); + [SettingSource(typeof(AimErrorMeterStrings), nameof(AimErrorMeterStrings.PositionDisplayStyle), nameof(AimErrorMeterStrings.PositionDisplayStyleDescription))] + public Bindable PositionDisplayStyle { get; } = new Bindable(); // used for calculate relative position. private Vector2? lastObjectPosition; - private Container averagePositionContainer = null!; - private Container averagePositionRotateContainer = null!; + private Container averagePositionMarker = null!; + private Container averagePositionMarkerRotationContainer = null!; private Vector2 averagePosition; - private readonly DrawablePool hitPositionPool = new DrawablePool(30); - private Container hitPositionContainer = null!; + private readonly DrawablePool hitPositionPool = new DrawablePool(30); + private Container hitPositionMarkerContainer = null!; private Container arrowBackgroundContainer = null!; private UprightAspectMaintainingContainer rotateFixedContainer = null!; @@ -221,18 +223,18 @@ namespace osu.Game.Rulesets.Osu.HUD Origin = Anchor.Centre, Children = new Drawable[] { - hitPositionContainer = new Container + hitPositionMarkerContainer = new Container { RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre, Origin = Anchor.Centre }, - averagePositionContainer = new UprightAspectMaintainingContainer + averagePositionMarker = new UprightAspectMaintainingContainer { RelativePositionAxes = Axes.Both, Anchor = Anchor.Centre, Origin = Anchor.Centre, - Child = averagePositionRotateContainer = new Container + Child = averagePositionMarkerRotationContainer = new Container { RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre, @@ -278,15 +280,15 @@ namespace osu.Game.Rulesets.Osu.HUD objectRadius = OsuHitObject.OBJECT_RADIUS * LegacyRulesetExtensions.CalculateScaleFromCircleSize(newDifficulty.CircleSize, true); - AverageSize.BindValueChanged(size => averagePositionContainer.Size = new Vector2(size.NewValue), true); - AverageStyle.BindValueChanged(style => averagePositionRotateContainer.Rotation = style.NewValue == HitStyle.Plus ? 0 : 45, true); + AverageMarkerSize.BindValueChanged(size => averagePositionMarker.Size = new Vector2(size.NewValue), true); + AverageMarkerStyle.BindValueChanged(style => averagePositionMarkerRotationContainer.Rotation = style.NewValue == MarkerStyle.Plus ? 0 : 45, true); - PositionMappingStyle.BindValueChanged(s => + PositionDisplayStyle.BindValueChanged(s => { // reset hit position to let it re-stat in the new mode Clear(); - if (s.NewValue == MappingStyle.Relative) + if (s.NewValue == PositionDisplay.Normalised) { arrowBackgroundContainer.FadeIn(100); rotateFixedContainer.Remove(mainContainer, false); @@ -309,12 +311,12 @@ namespace osu.Game.Rulesets.Osu.HUD if (circleJudgement.CursorPositionAtHit == null) return; - if (hitPositionContainer.Count > max_concurrent_judgements) + if (hitPositionMarkerContainer.Count > max_concurrent_judgements) { const double quick_fade_time = 300; // check with a bit of lenience to avoid precision error in comparison. - var old = hitPositionContainer.FirstOrDefault(j => j.LifetimeEnd > Clock.CurrentTime + quick_fade_time * 1.1); + var old = hitPositionMarkerContainer.FirstOrDefault(j => j.LifetimeEnd > Clock.CurrentTime + quick_fade_time * 1.1); if (old != null) { @@ -326,7 +328,7 @@ namespace osu.Game.Rulesets.Osu.HUD // the Vector2 for component is X (-0.5, 0.5), Y (-0.5, 0.5) Vector2 hitPosition; - if (PositionMappingStyle.Value == MappingStyle.Relative && lastObjectPosition != null) + if (PositionDisplayStyle.Value == PositionDisplay.Normalised && lastObjectPosition != null) { // let local center in (0.5, 0.5) to prevent localRadius in calculate will get zero. // then manual subtraction 0.5 to match component mapping. @@ -347,10 +349,10 @@ namespace osu.Game.Rulesets.Osu.HUD drawableHit.Y = hitPosition.Y; drawableHit.Colour = getColourForPosition(hitPosition); - hitPositionContainer.Add(drawableHit); + hitPositionMarkerContainer.Add(drawableHit); }); - averagePositionContainer.MoveTo(averagePosition = (hitPosition + averagePosition) / 2, 800, Easing.OutQuint); + averagePositionMarker.MoveTo(averagePosition = (hitPosition + averagePosition) / 2, 800, Easing.OutQuint); lastObjectPosition = ((OsuHitObject)circleJudgement.HitObject).StackedPosition; } @@ -374,28 +376,27 @@ namespace osu.Game.Rulesets.Osu.HUD public override void Clear() { - averagePositionContainer.MoveTo(averagePosition = Vector2.Zero, 800, Easing.OutQuint); + averagePositionMarker.MoveTo(averagePosition = Vector2.Zero, 800, Easing.OutQuint); lastObjectPosition = null; - foreach (var h in hitPositionContainer) + foreach (var h in hitPositionMarkerContainer) { h.ClearTransforms(); h.Expire(); } } - private partial class HitPosition : PoolableDrawable + private partial class HitPositionMarker : PoolableDrawable { [Resolved] private AimErrorMeter aimErrorMeter { get; set; } = null!; - public readonly BindableNumber HitPointSize = new BindableFloat(); - - public readonly Bindable HitPointStyle = new Bindable(); + public readonly BindableNumber MarkerSize = new BindableFloat(); + public readonly Bindable Style = new Bindable(); private readonly Container content; - public HitPosition() + public HitPositionMarker() { RelativePositionAxes = Axes.Both; @@ -439,10 +440,10 @@ namespace osu.Game.Rulesets.Osu.HUD { base.LoadComplete(); - HitPointSize.BindTo(aimErrorMeter.HitPositionSize); - HitPointSize.BindValueChanged(size => Size = new Vector2(size.NewValue), true); - HitPointStyle.BindTo(aimErrorMeter.HitPositionStyle); - HitPointStyle.BindValueChanged(style => content.Rotation = style.NewValue == HitStyle.X ? 0 : 45, true); + MarkerSize.BindTo(aimErrorMeter.HitMarkerSize); + MarkerSize.BindValueChanged(size => Size = new Vector2(size.NewValue), true); + Style.BindTo(aimErrorMeter.HitMarkerStyle); + Style.BindValueChanged(style => content.Rotation = style.NewValue == AimErrorMeter.MarkerStyle.X ? 0 : 45, true); } protected override void PrepareForUse() @@ -455,29 +456,29 @@ namespace osu.Game.Rulesets.Osu.HUD this .ResizeTo(new Vector2(0)) .FadeInFromZero(judgement_fade_in_duration, Easing.OutQuint) - .ResizeTo(new Vector2(HitPointSize.Value), judgement_fade_in_duration, Easing.OutQuint) + .ResizeTo(new Vector2(MarkerSize.Value), judgement_fade_in_duration, Easing.OutQuint) .Then() .FadeOut(judgement_fade_out_duration) .Expire(); } } - public enum HitStyle + public enum MarkerStyle { - [LocalisableDescription(typeof(AimErrorMeterStrings), nameof(AimErrorMeterStrings.StyleX))] + [Description("X")] X, - [LocalisableDescription(typeof(AimErrorMeterStrings), nameof(AimErrorMeterStrings.StylePlus))] + [Description("+")] Plus, } - public enum MappingStyle + public enum PositionDisplay { [LocalisableDescription(typeof(AimErrorMeterStrings), nameof(AimErrorMeterStrings.Absolute))] Absolute, - [LocalisableDescription(typeof(AimErrorMeterStrings), nameof(AimErrorMeterStrings.Relative))] - Relative, + [LocalisableDescription(typeof(AimErrorMeterStrings), nameof(AimErrorMeterStrings.Normalised))] + Normalised, } } } diff --git a/osu.Game/Localisation/HUD/AimErrorMeterStrings.cs b/osu.Game/Localisation/HUD/AimErrorMeterStrings.cs index c3db6e65a4..31d81d41e3 100644 --- a/osu.Game/Localisation/HUD/AimErrorMeterStrings.cs +++ b/osu.Game/Localisation/HUD/AimErrorMeterStrings.cs @@ -10,75 +10,65 @@ namespace osu.Game.Localisation.HUD private const string prefix = @"osu.Game.Resources.Localisation.HUD.AimErrorMeterStrings"; /// - /// "Hit position size" + /// "Hit marker size" /// - public static LocalisableString HitPositionSize => new TranslatableString(getKey(@"hit_position_size"), "Hit position size"); + public static LocalisableString HitMarkerSize => new TranslatableString(getKey(@"hit_marker_size"), @"Hit marker size"); /// - /// "How big of hit position should be." + /// "Controls the size of the markers displayed after every hit." /// - public static LocalisableString HitPositionSizeDescription => new TranslatableString(getKey("hit_point_size_description"), "How big of hit position should be."); + public static LocalisableString HitMarkerSizeDescription => new TranslatableString(getKey(@"hit_marker_size_description"), @"Controls the size of the markers displayed after every hit."); /// - /// "Hit position style" + /// "Hit marker style" /// - public static LocalisableString HitPositionStyle => new TranslatableString(getKey(@"hit_position_style"), "Hit position style"); + public static LocalisableString HitMarkerStyle => new TranslatableString(getKey(@"hit_marker_style"), @"Hit marker style"); /// - /// "The style of hit position." + /// "The visual style of the hit markers." /// - public static LocalisableString HitPositionStyleDescription => new TranslatableString(getKey("hit_position_style_description"), "The style of hit position."); + public static LocalisableString HitMarkerStyleDescription => new TranslatableString(getKey(@"hit_marker_style_description"), @"The visual style of the hit markers."); /// - /// "Average position size" + /// "Average position marker size" /// - public static LocalisableString AverageSize => new TranslatableString(getKey(@"average_size"), "Average position size"); + public static LocalisableString AverageMarkerSize => new TranslatableString(getKey(@"average_marker_size"), @"Average position marker size"); /// - /// "How big of average position should be." + /// "Controls the size of the marker showing average hit position." /// - public static LocalisableString AverageSizeDescription => new TranslatableString(getKey("average_size_description"), "How big of average position should be."); + public static LocalisableString AverageMarkerSizeDescription => new TranslatableString(getKey(@"average_marker_size_description"), @"Controls the size of the marker showing average hit position."); /// - /// "Average position style" + /// "Average position marker style" /// - public static LocalisableString AverageStyle => new TranslatableString(getKey(@"average_style"), "Average position style"); + public static LocalisableString AverageMarkerStyle => new TranslatableString(getKey(@"average_marker_style"), @"Average position marker style"); /// - /// "The style of average position." + /// "The visual style of the average position marker." /// - public static LocalisableString AverageStyleDescription => new TranslatableString(getKey("average_style_description"), "The style of average position."); + public static LocalisableString AverageMarkerStyleDescription => new TranslatableString(getKey(@"average_marker_style_description"), @"The visual style of the average position marker."); /// - /// "Position mapping" + /// "Position display style" /// - public static LocalisableString PositionStyle => new TranslatableString(getKey("position_style"), "Position mapping"); + public static LocalisableString PositionDisplayStyle => new TranslatableString(getKey(@"position_style"), @"Position display style"); /// - /// "Should hit point relative of last object" + /// "Controls whether positions displayed on the meter are absolute (as seen on screen) or normalised (relative to the direction of movement from previous object)." /// - public static LocalisableString PositionStyleDescription => new TranslatableString(getKey("position_style_description"), "Should hit point relative of last object"); - - /// - /// "X" - /// - public static LocalisableString StyleX => new TranslatableString(getKey("style_x"), "X"); - - /// - /// "+" - /// - public static LocalisableString StylePlus => new TranslatableString(getKey("style_plus"), "+"); + public static LocalisableString PositionDisplayStyleDescription => new TranslatableString(getKey(@"position_style_description"), @"Controls whether positions displayed on the meter are absolute (as seen on screen) or normalised (relative to the direction of movement from previous object)."); /// /// "Absolute" /// - public static LocalisableString Absolute => new TranslatableString(getKey("absolute"), "Absolute"); + public static LocalisableString Absolute => new TranslatableString(getKey(@"absolute"), @"Absolute"); /// - /// "Relative" + /// "Normalised" /// - public static LocalisableString Relative => new TranslatableString(getKey("relative"), "Relative"); + public static LocalisableString Normalised => new TranslatableString(getKey(@"normalised"), @"Normalised"); - private static string getKey(string key) => $"{prefix}:{key}"; + private static string getKey(string key) => $@"{prefix}:{key}"; } }