mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 17:43:05 +08:00
Add "(snapped)" to the tooltip when snap-rotating in the editor
This commit is contained in:
parent
f72dd86b42
commit
580d5745c0
@ -99,6 +99,16 @@ namespace osu.Game.Localisation
|
||||
/// </summary>
|
||||
public static LocalisableString TimelineTicks => new TranslatableString(getKey(@"timeline_ticks"), @"Ticks");
|
||||
|
||||
/// <summary>
|
||||
/// "0.0°"
|
||||
/// </summary>
|
||||
public static LocalisableString RotationFormatUnsnapped => new TranslatableString(getKey(@"rotation_format_unsnapped"), @"0.0°");
|
||||
|
||||
/// <summary>
|
||||
/// "0.0° (snapped)"
|
||||
/// </summary>
|
||||
public static LocalisableString RotationFormatSnapped => new TranslatableString(getKey(@"rotation_format_snapped"), @"0.0° (snapped)");
|
||||
|
||||
private static string getKey(string key) => $@"{prefix}:{key}";
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Localisation;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using Key = osuTK.Input.Key;
|
||||
@ -56,7 +57,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
cumulativeRotation.BindValueChanged(_ => updateTooltipText(), true);
|
||||
}
|
||||
|
||||
protected override void UpdateHoverState()
|
||||
@ -130,7 +130,10 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
newRotation = (newRotation - 180) % 360 + 180;
|
||||
|
||||
cumulativeRotation.Value = newRotation;
|
||||
HandleRotate?.Invoke((float)cumulativeRotation.Value - oldRotation);
|
||||
|
||||
HandleRotate?.Invoke(newRotation - oldRotation);
|
||||
string tooltipFormat = shouldSnap ? EditorStrings.RotationFormatSnapped.ToString() : EditorStrings.RotationFormatUnsnapped.ToString();
|
||||
TooltipText = newRotation.ToLocalisableString(tooltipFormat);
|
||||
}
|
||||
|
||||
private float snap(float value, float step)
|
||||
@ -138,10 +141,5 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
float floor = MathF.Floor(value / step) * step;
|
||||
return value - floor < step / 2f ? floor : floor + step;
|
||||
}
|
||||
|
||||
private void updateTooltipText()
|
||||
{
|
||||
TooltipText = cumulativeRotation.Value?.ToLocalisableString("0.0°") ?? default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user