1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 22:22:54 +08:00

Merge branch 'master' into distance-spacing-osd

This commit is contained in:
Salman Ahmed 2022-05-04 11:41:12 +03:00
commit 3d2072498e
3 changed files with 38 additions and 17 deletions

View File

@ -79,7 +79,8 @@ namespace osu.Game.Input.Bindings
new KeyBinding(new[] { InputKey.F5 }, GlobalAction.EditorTestGameplay),
new KeyBinding(new[] { InputKey.Control, InputKey.H }, GlobalAction.EditorFlipHorizontally),
new KeyBinding(new[] { InputKey.Control, InputKey.J }, GlobalAction.EditorFlipVertically),
new KeyBinding(new[] { InputKey.Control, InputKey.Alt }, GlobalAction.EditorDistanceSpacing),
new KeyBinding(new[] { InputKey.Control, InputKey.Alt, InputKey.MouseWheelDown }, GlobalAction.EditorDecreaseDistanceSpacing),
new KeyBinding(new[] { InputKey.Control, InputKey.Alt, InputKey.MouseWheelUp }, GlobalAction.EditorIncreaseDistanceSpacing),
};
public IEnumerable<KeyBinding> InGameKeyBindings => new[]
@ -303,7 +304,10 @@ namespace osu.Game.Input.Bindings
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorFlipVertically))]
EditorFlipVertically,
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorDistanceSpacing))]
EditorDistanceSpacing,
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorIncreaseDistanceSpacing))]
EditorIncreaseDistanceSpacing,
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorDecreaseDistanceSpacing))]
EditorDecreaseDistanceSpacing,
}
}

View File

@ -240,9 +240,14 @@ namespace osu.Game.Localisation
public static LocalisableString EditorFlipVertically => new TranslatableString(getKey(@"editor_flip_vertically"), @"Flip selection vertically");
/// <summary>
/// "Distance grid spacing (hold)"
/// "Increase distance spacing"
/// </summary>
public static LocalisableString EditorDistanceSpacing => new TranslatableString(getKey(@"editor_distance_spacing"), @"Distance grid spacing (hold)");
public static LocalisableString EditorIncreaseDistanceSpacing => new TranslatableString(getKey(@"editor_increase_distance_spacing"), @"Increase distance spacing");
/// <summary>
/// "Decrease distance spacing"
/// </summary>
public static LocalisableString EditorDecreaseDistanceSpacing => new TranslatableString(getKey(@"editor_decrease_distance_spacing"), @"Decrease distance spacing");
/// <summary>
/// "Toggle skin editor"

View File

@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Edit
/// </summary>
/// <typeparam name="TObject">The base type of supported objects.</typeparam>
[Cached(typeof(IDistanceSnapProvider))]
public abstract class DistancedHitObjectComposer<TObject> : HitObjectComposer<TObject>, IDistanceSnapProvider, IKeyBindingHandler<GlobalAction>
public abstract class DistancedHitObjectComposer<TObject> : HitObjectComposer<TObject>, IDistanceSnapProvider, IScrollBindingHandler<GlobalAction>
where TObject : HitObject
{
protected Bindable<double> DistanceSpacingMultiplier { get; } = new BindableDouble(1.0)
@ -39,7 +39,6 @@ namespace osu.Game.Rulesets.Edit
protected ExpandingToolboxContainer RightSideToolboxContainer { get; private set; }
private ExpandableSlider<double, SizeSlider<double>> distanceSpacingSlider;
private bool distanceSpacingScrollActive;
[Resolved(canBeNull: true)]
private OnScreenDisplay onScreenDisplay { get; set; }
@ -90,10 +89,11 @@ namespace osu.Game.Rulesets.Edit
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
if (!DistanceSpacingMultiplier.Disabled && e.Action == GlobalAction.EditorDistanceSpacing)
switch (e.Action)
{
distanceSpacingScrollActive = true;
return true;
case GlobalAction.EditorIncreaseDistanceSpacing:
case GlobalAction.EditorDecreaseDistanceSpacing:
return adjustDistanceSpacing(e.Action, 0.1f);
}
return false;
@ -101,19 +101,31 @@ namespace osu.Game.Rulesets.Edit
public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
{
if (!DistanceSpacingMultiplier.Disabled && e.Action == GlobalAction.EditorDistanceSpacing)
distanceSpacingScrollActive = false;
}
protected override bool OnScroll(ScrollEvent e)
public bool OnScroll(KeyBindingScrollEvent<GlobalAction> e)
{
if (distanceSpacingScrollActive)
switch (e.Action)
{
DistanceSpacingMultiplier.Value += e.ScrollDelta.Y * (e.IsPrecise ? 0.01f : 0.1f);
return true;
case GlobalAction.EditorIncreaseDistanceSpacing:
case GlobalAction.EditorDecreaseDistanceSpacing:
return adjustDistanceSpacing(e.Action, e.ScrollAmount * (e.IsPrecise ? 0.01f : 0.1f));
}
return base.OnScroll(e);
return false;
}
private bool adjustDistanceSpacing(GlobalAction action, float amount)
{
if (DistanceSpacingMultiplier.Disabled)
return false;
if (action == GlobalAction.EditorIncreaseDistanceSpacing)
DistanceSpacingMultiplier.Value += amount;
else if (action == GlobalAction.EditorDecreaseDistanceSpacing)
DistanceSpacingMultiplier.Value -= amount;
return true;
}
public virtual float GetBeatSnapDistanceAt(HitObject referenceObject)