1
0
mirror of https://github.com/ppy/osu.git synced 2026-06-03 19:24:24 +08:00

Rename everything to start with

This commit is contained in:
Bartłomiej Dach
2025-08-18 12:46:53 +02:00
Unverified
parent fe612d465b
commit 777ab61143
3 changed files with 77 additions and 86 deletions
@@ -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
+45 -44
View File
@@ -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.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<float> HitPositionSize { get; } = new BindableNumber<float>(7f)
[SettingSource(typeof(AimErrorMeterStrings), nameof(AimErrorMeterStrings.HitMarkerSize), nameof(AimErrorMeterStrings.HitMarkerSizeDescription))]
public BindableNumber<float> HitMarkerSize { get; } = new BindableNumber<float>(7f)
{
MinValue = 0f,
MaxValue = 12f,
Precision = 1f
};
[SettingSource(typeof(AimErrorMeterStrings), nameof(AimErrorMeterStrings.HitPositionStyle), nameof(AimErrorMeterStrings.HitPositionStyleDescription))]
public Bindable<HitStyle> HitPositionStyle { get; } = new Bindable<HitStyle>();
[SettingSource(typeof(AimErrorMeterStrings), nameof(AimErrorMeterStrings.HitMarkerStyle), nameof(AimErrorMeterStrings.HitMarkerStyleDescription))]
public Bindable<MarkerStyle> HitMarkerStyle { get; } = new Bindable<MarkerStyle>();
[SettingSource(typeof(AimErrorMeterStrings), nameof(AimErrorMeterStrings.AverageSize), nameof(AimErrorMeterStrings.AverageSizeDescription))]
public BindableNumber<float> AverageSize { get; } = new BindableNumber<float>(12f)
[SettingSource(typeof(AimErrorMeterStrings), nameof(AimErrorMeterStrings.AverageMarkerSize), nameof(AimErrorMeterStrings.AverageMarkerSizeDescription))]
public BindableNumber<float> AverageMarkerSize { get; } = new BindableNumber<float>(12f)
{
MinValue = 7f,
MaxValue = 25f,
Precision = 1f
};
[SettingSource(typeof(AimErrorMeterStrings), nameof(AimErrorMeterStrings.AverageStyle), nameof(AimErrorMeterStrings.AverageStyleDescription))]
public Bindable<HitStyle> AverageStyle { get; } = new Bindable<HitStyle>(HitStyle.Plus);
[SettingSource(typeof(AimErrorMeterStrings), nameof(AimErrorMeterStrings.AverageMarkerStyle), nameof(AimErrorMeterStrings.AverageMarkerStyleDescription))]
public Bindable<MarkerStyle> AverageMarkerStyle { get; } = new Bindable<MarkerStyle>(MarkerStyle.Plus);
[SettingSource(typeof(AimErrorMeterStrings), nameof(AimErrorMeterStrings.PositionStyle), nameof(AimErrorMeterStrings.PositionStyleDescription))]
public Bindable<MappingStyle> PositionMappingStyle { get; } = new Bindable<MappingStyle>();
[SettingSource(typeof(AimErrorMeterStrings), nameof(AimErrorMeterStrings.PositionDisplayStyle), nameof(AimErrorMeterStrings.PositionDisplayStyleDescription))]
public Bindable<PositionDisplay> PositionDisplayStyle { get; } = new Bindable<PositionDisplay>();
// 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<HitPosition> hitPositionPool = new DrawablePool<HitPosition>(30);
private Container hitPositionContainer = null!;
private readonly DrawablePool<HitPositionMarker> hitPositionPool = new DrawablePool<HitPositionMarker>(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<float> HitPointSize = new BindableFloat();
public readonly Bindable<HitStyle> HitPointStyle = new Bindable<HitStyle>();
public readonly BindableNumber<float> MarkerSize = new BindableFloat();
public readonly Bindable<MarkerStyle> Style = new Bindable<MarkerStyle>();
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,
}
}
}
@@ -10,75 +10,65 @@ namespace osu.Game.Localisation.HUD
private const string prefix = @"osu.Game.Resources.Localisation.HUD.AimErrorMeterStrings";
/// <summary>
/// "Hit position size"
/// "Hit marker size"
/// </summary>
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");
/// <summary>
/// "How big of hit position should be."
/// "Controls the size of the markers displayed after every hit."
/// </summary>
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.");
/// <summary>
/// "Hit position style"
/// "Hit marker style"
/// </summary>
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");
/// <summary>
/// "The style of hit position."
/// "The visual style of the hit markers."
/// </summary>
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.");
/// <summary>
/// "Average position size"
/// "Average position marker size"
/// </summary>
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");
/// <summary>
/// "How big of average position should be."
/// "Controls the size of the marker showing average hit position."
/// </summary>
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.");
/// <summary>
/// "Average position style"
/// "Average position marker style"
/// </summary>
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");
/// <summary>
/// "The style of average position."
/// "The visual style of the average position marker."
/// </summary>
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.");
/// <summary>
/// "Position mapping"
/// "Position display style"
/// </summary>
public static LocalisableString PositionStyle => new TranslatableString(getKey("position_style"), "Position mapping");
public static LocalisableString PositionDisplayStyle => new TranslatableString(getKey(@"position_style"), @"Position display style");
/// <summary>
/// "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)."
/// </summary>
public static LocalisableString PositionStyleDescription => new TranslatableString(getKey("position_style_description"), "Should hit point relative of last object");
/// <summary>
/// "X"
/// </summary>
public static LocalisableString StyleX => new TranslatableString(getKey("style_x"), "X");
/// <summary>
/// "+"
/// </summary>
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).");
/// <summary>
/// "Absolute"
/// </summary>
public static LocalisableString Absolute => new TranslatableString(getKey("absolute"), "Absolute");
public static LocalisableString Absolute => new TranslatableString(getKey(@"absolute"), @"Absolute");
/// <summary>
/// "Relative"
/// "Normalised"
/// </summary>
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}";
}
}