mirror of
https://github.com/osukey/osukey.git
synced 2025-06-05 12:57:39 +09:00
Merge branch 'master' into mod-overlay/test-coverage-parity
This commit is contained in:
commit
5f11ff564b
@ -59,11 +59,6 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
{
|
{
|
||||||
LayerBelowRuleset.AddRange(new Drawable[]
|
LayerBelowRuleset.AddRange(new Drawable[]
|
||||||
{
|
{
|
||||||
new PlayfieldBorder
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
PlayfieldBorderStyle = { Value = PlayfieldBorderStyle.Corners }
|
|
||||||
},
|
|
||||||
distanceSnapGridContainer = new Container
|
distanceSnapGridContainer = new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both
|
RelativeSizeAxes = Axes.Both
|
||||||
|
@ -79,6 +79,8 @@ namespace osu.Game.Input.Bindings
|
|||||||
new KeyBinding(new[] { InputKey.F5 }, GlobalAction.EditorTestGameplay),
|
new KeyBinding(new[] { InputKey.F5 }, GlobalAction.EditorTestGameplay),
|
||||||
new KeyBinding(new[] { InputKey.Control, InputKey.H }, GlobalAction.EditorFlipHorizontally),
|
new KeyBinding(new[] { InputKey.Control, InputKey.H }, GlobalAction.EditorFlipHorizontally),
|
||||||
new KeyBinding(new[] { InputKey.Control, InputKey.J }, GlobalAction.EditorFlipVertically),
|
new KeyBinding(new[] { InputKey.Control, InputKey.J }, GlobalAction.EditorFlipVertically),
|
||||||
|
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[]
|
public IEnumerable<KeyBinding> InGameKeyBindings => new[]
|
||||||
@ -301,5 +303,11 @@ namespace osu.Game.Input.Bindings
|
|||||||
|
|
||||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorFlipVertically))]
|
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorFlipVertically))]
|
||||||
EditorFlipVertically,
|
EditorFlipVertically,
|
||||||
|
|
||||||
|
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorIncreaseDistanceSpacing))]
|
||||||
|
EditorIncreaseDistanceSpacing,
|
||||||
|
|
||||||
|
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorDecreaseDistanceSpacing))]
|
||||||
|
EditorDecreaseDistanceSpacing,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -239,6 +239,16 @@ namespace osu.Game.Localisation
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static LocalisableString EditorFlipVertically => new TranslatableString(getKey(@"editor_flip_vertically"), @"Flip selection vertically");
|
public static LocalisableString EditorFlipVertically => new TranslatableString(getKey(@"editor_flip_vertically"), @"Flip selection vertically");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Increase distance spacing"
|
||||||
|
/// </summary>
|
||||||
|
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>
|
/// <summary>
|
||||||
/// "Toggle skin editor"
|
/// "Toggle skin editor"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -3,10 +3,18 @@
|
|||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Extensions;
|
||||||
|
using osu.Framework.Extensions.LocalisationExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
|
using osu.Framework.Localisation;
|
||||||
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Input.Bindings;
|
||||||
|
using osu.Game.Overlays;
|
||||||
|
using osu.Game.Overlays.OSD;
|
||||||
using osu.Game.Overlays.Settings.Sections;
|
using osu.Game.Overlays.Settings.Sections;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -18,7 +26,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TObject">The base type of supported objects.</typeparam>
|
/// <typeparam name="TObject">The base type of supported objects.</typeparam>
|
||||||
[Cached(typeof(IDistanceSnapProvider))]
|
[Cached(typeof(IDistanceSnapProvider))]
|
||||||
public abstract class DistancedHitObjectComposer<TObject> : HitObjectComposer<TObject>, IDistanceSnapProvider
|
public abstract class DistancedHitObjectComposer<TObject> : HitObjectComposer<TObject>, IDistanceSnapProvider, IScrollBindingHandler<GlobalAction>
|
||||||
where TObject : HitObject
|
where TObject : HitObject
|
||||||
{
|
{
|
||||||
protected Bindable<double> DistanceSpacingMultiplier { get; } = new BindableDouble(1.0)
|
protected Bindable<double> DistanceSpacingMultiplier { get; } = new BindableDouble(1.0)
|
||||||
@ -33,7 +41,9 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
protected ExpandingToolboxContainer RightSideToolboxContainer { get; private set; }
|
protected ExpandingToolboxContainer RightSideToolboxContainer { get; private set; }
|
||||||
|
|
||||||
private ExpandableSlider<double, SizeSlider<double>> distanceSpacingSlider;
|
private ExpandableSlider<double, SizeSlider<double>> distanceSpacingSlider;
|
||||||
private bool distanceSpacingScrollActive;
|
|
||||||
|
[Resolved(canBeNull: true)]
|
||||||
|
private OnScreenDisplay onScreenDisplay { get; set; }
|
||||||
|
|
||||||
protected DistancedHitObjectComposer(Ruleset ruleset)
|
protected DistancedHitObjectComposer(Ruleset ruleset)
|
||||||
: base(ruleset)
|
: base(ruleset)
|
||||||
@ -66,45 +76,58 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
if (!DistanceSpacingMultiplier.Disabled)
|
if (!DistanceSpacingMultiplier.Disabled)
|
||||||
{
|
{
|
||||||
DistanceSpacingMultiplier.Value = EditorBeatmap.BeatmapInfo.DistanceSpacing;
|
DistanceSpacingMultiplier.Value = EditorBeatmap.BeatmapInfo.DistanceSpacing;
|
||||||
DistanceSpacingMultiplier.BindValueChanged(v =>
|
DistanceSpacingMultiplier.BindValueChanged(multiplier =>
|
||||||
{
|
{
|
||||||
distanceSpacingSlider.ContractedLabelText = $"D. S. ({v.NewValue:0.##x})";
|
distanceSpacingSlider.ContractedLabelText = $"D. S. ({multiplier.NewValue:0.##x})";
|
||||||
distanceSpacingSlider.ExpandedLabelText = $"Distance Spacing ({v.NewValue:0.##x})";
|
distanceSpacingSlider.ExpandedLabelText = $"Distance Spacing ({multiplier.NewValue:0.##x})";
|
||||||
EditorBeatmap.BeatmapInfo.DistanceSpacing = v.NewValue;
|
|
||||||
|
if (multiplier.NewValue != multiplier.OldValue)
|
||||||
|
onScreenDisplay?.Display(new DistanceSpacingToast(multiplier.NewValue.ToLocalisableString(@"0.##x"), multiplier));
|
||||||
|
|
||||||
|
EditorBeatmap.BeatmapInfo.DistanceSpacing = multiplier.NewValue;
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnKeyDown(KeyDownEvent e)
|
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
|
||||||
{
|
{
|
||||||
if (!DistanceSpacingMultiplier.Disabled && e.ControlPressed && e.AltPressed && !e.Repeat)
|
switch (e.Action)
|
||||||
{
|
{
|
||||||
RightSideToolboxContainer.Expanded.Value = true;
|
case GlobalAction.EditorIncreaseDistanceSpacing:
|
||||||
distanceSpacingScrollActive = true;
|
case GlobalAction.EditorDecreaseDistanceSpacing:
|
||||||
return true;
|
return adjustDistanceSpacing(e.Action, 0.1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
return base.OnKeyDown(e);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnKeyUp(KeyUpEvent e)
|
public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
|
||||||
{
|
{
|
||||||
if (!DistanceSpacingMultiplier.Disabled && distanceSpacingScrollActive && (!e.AltPressed || !e.ControlPressed))
|
|
||||||
{
|
|
||||||
RightSideToolboxContainer.Expanded.Value = false;
|
|
||||||
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);
|
case GlobalAction.EditorIncreaseDistanceSpacing:
|
||||||
return true;
|
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)
|
public virtual float GetBeatSnapDistanceAt(HitObject referenceObject)
|
||||||
@ -158,5 +181,26 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
FillFlow.Spacing = new Vector2(10);
|
FillFlow.Spacing = new Vector2(10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class DistanceSpacingToast : Toast
|
||||||
|
{
|
||||||
|
private readonly ValueChangedEvent<double> change;
|
||||||
|
|
||||||
|
public DistanceSpacingToast(LocalisableString value, ValueChangedEvent<double> change)
|
||||||
|
: base(getAction(change).GetLocalisableDescription(), value, string.Empty)
|
||||||
|
{
|
||||||
|
this.change = change;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuConfigManager config)
|
||||||
|
{
|
||||||
|
ShortcutText.Text = config.LookupKeyBindings(getAction(change)).ToUpper();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static GlobalAction getAction(ValueChangedEvent<double> change) => change.NewValue - change.OldValue > 0
|
||||||
|
? GlobalAction.EditorIncreaseDistanceSpacing
|
||||||
|
: GlobalAction.EditorDecreaseDistanceSpacing;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,13 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Layout;
|
using osu.Framework.Layout;
|
||||||
|
using osu.Framework.Utils;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Compose.Components
|
namespace osu.Game.Screens.Edit.Compose.Components
|
||||||
@ -72,33 +75,47 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
int index = 0;
|
int index = 0;
|
||||||
float currentPosition = startPosition;
|
float currentPosition = startPosition;
|
||||||
|
|
||||||
while ((endPosition - currentPosition) * Math.Sign(step) > 0)
|
// Make lines the same width independent of display resolution.
|
||||||
|
float lineWidth = DrawWidth / ScreenSpaceDrawQuad.Width;
|
||||||
|
|
||||||
|
List<Box> generatedLines = new List<Box>();
|
||||||
|
|
||||||
|
while (Precision.AlmostBigger((endPosition - currentPosition) * Math.Sign(step), 0))
|
||||||
{
|
{
|
||||||
var gridLine = new Box
|
var gridLine = new Box
|
||||||
{
|
{
|
||||||
Colour = Colour4.White,
|
Colour = Colour4.White,
|
||||||
Alpha = index == 0 ? 0.3f : 0.1f,
|
Alpha = 0.1f,
|
||||||
EdgeSmoothness = new Vector2(0.2f)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (direction == Direction.Horizontal)
|
if (direction == Direction.Horizontal)
|
||||||
{
|
{
|
||||||
|
gridLine.Origin = Anchor.CentreLeft;
|
||||||
gridLine.RelativeSizeAxes = Axes.X;
|
gridLine.RelativeSizeAxes = Axes.X;
|
||||||
gridLine.Height = 1;
|
gridLine.Height = lineWidth;
|
||||||
gridLine.Y = currentPosition;
|
gridLine.Y = currentPosition;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
gridLine.Origin = Anchor.TopCentre;
|
||||||
gridLine.RelativeSizeAxes = Axes.Y;
|
gridLine.RelativeSizeAxes = Axes.Y;
|
||||||
gridLine.Width = 1;
|
gridLine.Width = lineWidth;
|
||||||
gridLine.X = currentPosition;
|
gridLine.X = currentPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
AddInternal(gridLine);
|
generatedLines.Add(gridLine);
|
||||||
|
|
||||||
index += 1;
|
index += 1;
|
||||||
currentPosition = startPosition + index * step;
|
currentPosition = startPosition + index * step;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (generatedLines.Count == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
generatedLines.First().Alpha = 0.3f;
|
||||||
|
generatedLines.Last().Alpha = 0.3f;
|
||||||
|
|
||||||
|
AddRangeInternal(generatedLines);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector2 GetSnappedPosition(Vector2 original)
|
public Vector2 GetSnappedPosition(Vector2 original)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user