mirror of
https://github.com/osukey/osukey.git
synced 2025-05-29 17:37:23 +09:00
Merge branch 'master' into editor-waveform-opacity
This commit is contained in:
commit
3bb86ce127
@ -62,6 +62,8 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
|||||||
|
|
||||||
public abstract class DrawableCatchHitObject : DrawableHitObject<CatchHitObject>
|
public abstract class DrawableCatchHitObject : DrawableHitObject<CatchHitObject>
|
||||||
{
|
{
|
||||||
|
protected override double InitialLifetimeOffset => HitObject.TimePreempt;
|
||||||
|
|
||||||
public virtual bool StaysOnPlate => HitObject.CanBePlated;
|
public virtual bool StaysOnPlate => HitObject.CanBePlated;
|
||||||
|
|
||||||
public float DisplayRadius => DrawSize.X / 2 * Scale.X * HitObject.Scale;
|
public float DisplayRadius => DrawSize.X / 2 * Scale.X * HitObject.Scale;
|
||||||
|
@ -41,7 +41,7 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
AddToggleStep("toggle y", state => selectionBox.CanScaleY = state);
|
AddToggleStep("toggle y", state => selectionBox.CanScaleY = state);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleScale(Vector2 amount, Anchor reference)
|
private bool handleScale(Vector2 amount, Anchor reference)
|
||||||
{
|
{
|
||||||
if ((reference & Anchor.y1) == 0)
|
if ((reference & Anchor.y1) == 0)
|
||||||
{
|
{
|
||||||
@ -58,12 +58,15 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
selectionArea.X += amount.X;
|
selectionArea.X += amount.X;
|
||||||
selectionArea.Width += directionX * amount.X;
|
selectionArea.Width += directionX * amount.X;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleRotation(float angle)
|
private bool handleRotation(float angle)
|
||||||
{
|
{
|
||||||
// kinda silly and wrong, but just showing that the drag handles work.
|
// kinda silly and wrong, but just showing that the drag handles work.
|
||||||
selectionArea.Rotation += angle;
|
selectionArea.Rotation += angle;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,13 +7,14 @@ using osu.Framework.Graphics.Colour;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Primitives;
|
using osu.Framework.Graphics.Primitives;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Utils;
|
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Cursor;
|
using osu.Game.Graphics.Cursor;
|
||||||
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Editing
|
namespace osu.Game.Tests.Visual.Editing
|
||||||
{
|
{
|
||||||
@ -88,6 +89,7 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
|
|
||||||
// Scroll in at 0.25
|
// Scroll in at 0.25
|
||||||
AddStep("Move mouse to 0.25x", () => InputManager.MoveMouseTo(new Vector2(scrollQuad.TopLeft.X + 0.25f * scrollQuad.Size.X, scrollQuad.Centre.Y)));
|
AddStep("Move mouse to 0.25x", () => InputManager.MoveMouseTo(new Vector2(scrollQuad.TopLeft.X + 0.25f * scrollQuad.Size.X, scrollQuad.Centre.Y)));
|
||||||
|
AddStep("Press alt down", () => InputManager.PressKey(Key.AltLeft));
|
||||||
AddStep("Scroll by 3", () => InputManager.ScrollBy(new Vector2(0, 3)));
|
AddStep("Scroll by 3", () => InputManager.ScrollBy(new Vector2(0, 3)));
|
||||||
AddAssert("Box not at 0", () => !Precision.AlmostEquals(boxQuad.TopLeft, scrollQuad.TopLeft));
|
AddAssert("Box not at 0", () => !Precision.AlmostEquals(boxQuad.TopLeft, scrollQuad.TopLeft));
|
||||||
AddAssert("Box 1/4 at 1/4", () => Precision.AlmostEquals(boxQuad.TopLeft.X + 0.25f * boxQuad.Size.X, scrollQuad.TopLeft.X + 0.25f * scrollQuad.Size.X));
|
AddAssert("Box 1/4 at 1/4", () => Precision.AlmostEquals(boxQuad.TopLeft.X + 0.25f * boxQuad.Size.X, scrollQuad.TopLeft.X + 0.25f * scrollQuad.Size.X));
|
||||||
@ -96,6 +98,25 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
AddStep("Scroll by -3", () => InputManager.ScrollBy(new Vector2(0, -3)));
|
AddStep("Scroll by -3", () => InputManager.ScrollBy(new Vector2(0, -3)));
|
||||||
AddAssert("Box at 0", () => Precision.AlmostEquals(boxQuad.TopLeft, scrollQuad.TopLeft));
|
AddAssert("Box at 0", () => Precision.AlmostEquals(boxQuad.TopLeft, scrollQuad.TopLeft));
|
||||||
AddAssert("Box 1/4 at 1/4", () => Precision.AlmostEquals(boxQuad.TopLeft.X + 0.25f * boxQuad.Size.X, scrollQuad.TopLeft.X + 0.25f * scrollQuad.Size.X));
|
AddAssert("Box 1/4 at 1/4", () => Precision.AlmostEquals(boxQuad.TopLeft.X + 0.25f * boxQuad.Size.X, scrollQuad.TopLeft.X + 0.25f * scrollQuad.Size.X));
|
||||||
|
AddStep("Release alt", () => InputManager.ReleaseKey(Key.AltLeft));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMouseZoomInThenScroll()
|
||||||
|
{
|
||||||
|
reset();
|
||||||
|
|
||||||
|
// Scroll in at 0.25
|
||||||
|
AddStep("Move mouse to 0.25x", () => InputManager.MoveMouseTo(new Vector2(scrollQuad.TopLeft.X + 0.25f * scrollQuad.Size.X, scrollQuad.Centre.Y)));
|
||||||
|
AddStep("Press alt down", () => InputManager.PressKey(Key.AltLeft));
|
||||||
|
AddStep("Zoom by 3", () => InputManager.ScrollBy(new Vector2(0, 3)));
|
||||||
|
AddStep("Release alt", () => InputManager.ReleaseKey(Key.AltLeft));
|
||||||
|
|
||||||
|
AddStep("Scroll far left", () => InputManager.ScrollBy(new Vector2(0, 30)));
|
||||||
|
AddUntilStep("Scroll is at start", () => Precision.AlmostEquals(scrollQuad.TopLeft.X, boxQuad.TopLeft.X, 1));
|
||||||
|
|
||||||
|
AddStep("Scroll far right", () => InputManager.ScrollBy(new Vector2(0, -300)));
|
||||||
|
AddUntilStep("Scroll is at end", () => Precision.AlmostEquals(scrollQuad.TopRight.X, boxQuad.TopRight.X, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -103,6 +124,8 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
|
AddStep("Press alt down", () => InputManager.PressKey(Key.AltLeft));
|
||||||
|
|
||||||
// Scroll in at 0.25
|
// Scroll in at 0.25
|
||||||
AddStep("Move mouse to 0.25x", () => InputManager.MoveMouseTo(new Vector2(scrollQuad.TopLeft.X + 0.25f * scrollQuad.Size.X, scrollQuad.Centre.Y)));
|
AddStep("Move mouse to 0.25x", () => InputManager.MoveMouseTo(new Vector2(scrollQuad.TopLeft.X + 0.25f * scrollQuad.Size.X, scrollQuad.Centre.Y)));
|
||||||
AddStep("Scroll by 1", () => InputManager.ScrollBy(new Vector2(0, 1)));
|
AddStep("Scroll by 1", () => InputManager.ScrollBy(new Vector2(0, 1)));
|
||||||
@ -124,6 +147,8 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
AddStep("Move mouse to 0.25x", () => InputManager.MoveMouseTo(new Vector2(scrollQuad.TopLeft.X + 0.25f * scrollQuad.Size.X, scrollQuad.Centre.Y)));
|
AddStep("Move mouse to 0.25x", () => InputManager.MoveMouseTo(new Vector2(scrollQuad.TopLeft.X + 0.25f * scrollQuad.Size.X, scrollQuad.Centre.Y)));
|
||||||
AddStep("Scroll by -1", () => InputManager.ScrollBy(new Vector2(0, -1)));
|
AddStep("Scroll by -1", () => InputManager.ScrollBy(new Vector2(0, -1)));
|
||||||
AddAssert("Box at 0", () => Precision.AlmostEquals(boxQuad.TopLeft, scrollQuad.TopLeft));
|
AddAssert("Box at 0", () => Precision.AlmostEquals(boxQuad.TopLeft, scrollQuad.TopLeft));
|
||||||
|
|
||||||
|
AddStep("Release alt", () => InputManager.ReleaseKey(Key.AltLeft));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reset()
|
private void reset()
|
||||||
|
@ -7,17 +7,19 @@ 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.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Compose.Components
|
namespace osu.Game.Screens.Edit.Compose.Components
|
||||||
{
|
{
|
||||||
public class SelectionBox : CompositeDrawable
|
public class SelectionBox : CompositeDrawable
|
||||||
{
|
{
|
||||||
public Action<float> OnRotation;
|
public Func<float, bool> OnRotation;
|
||||||
public Action<Vector2, Anchor> OnScale;
|
public Func<Vector2, Anchor, bool> OnScale;
|
||||||
public Action<Direction> OnFlip;
|
public Func<Direction, bool> OnFlip;
|
||||||
public Action OnReverse;
|
public Func<bool> OnReverse;
|
||||||
|
|
||||||
public Action OperationStarted;
|
public Action OperationStarted;
|
||||||
public Action OperationEnded;
|
public Action OperationEnded;
|
||||||
@ -105,6 +107,26 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
recreate();
|
recreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool OnKeyDown(KeyDownEvent e)
|
||||||
|
{
|
||||||
|
if (e.Repeat || !e.ControlPressed)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
switch (e.Key)
|
||||||
|
{
|
||||||
|
case Key.G:
|
||||||
|
return CanReverse && OnReverse?.Invoke() == true;
|
||||||
|
|
||||||
|
case Key.H:
|
||||||
|
return CanScaleX && OnFlip?.Invoke(Direction.Horizontal) == true;
|
||||||
|
|
||||||
|
case Key.J:
|
||||||
|
return CanScaleY && OnFlip?.Invoke(Direction.Vertical) == true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.OnKeyDown(e);
|
||||||
|
}
|
||||||
|
|
||||||
private void recreate()
|
private void recreate()
|
||||||
{
|
{
|
||||||
if (LoadState < LoadState.Loading)
|
if (LoadState < LoadState.Loading)
|
||||||
@ -143,7 +165,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
if (CanScaleX && CanScaleY) addFullScaleComponents();
|
if (CanScaleX && CanScaleY) addFullScaleComponents();
|
||||||
if (CanScaleY) addYScaleComponents();
|
if (CanScaleY) addYScaleComponents();
|
||||||
if (CanRotate) addRotationComponents();
|
if (CanRotate) addRotationComponents();
|
||||||
if (CanReverse) addButton(FontAwesome.Solid.Backward, "Reverse pattern", () => OnReverse?.Invoke());
|
if (CanReverse) addButton(FontAwesome.Solid.Backward, "Reverse pattern (Ctrl-G)", () => OnReverse?.Invoke());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addRotationComponents()
|
private void addRotationComponents()
|
||||||
@ -178,7 +200,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
|
|
||||||
private void addYScaleComponents()
|
private void addYScaleComponents()
|
||||||
{
|
{
|
||||||
addButton(FontAwesome.Solid.ArrowsAltV, "Flip vertically", () => OnFlip?.Invoke(Direction.Vertical));
|
addButton(FontAwesome.Solid.ArrowsAltV, "Flip vertically (Ctrl-J)", () => OnFlip?.Invoke(Direction.Vertical));
|
||||||
|
|
||||||
addDragHandle(Anchor.TopCentre);
|
addDragHandle(Anchor.TopCentre);
|
||||||
addDragHandle(Anchor.BottomCentre);
|
addDragHandle(Anchor.BottomCentre);
|
||||||
@ -194,7 +216,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
|
|
||||||
private void addXScaleComponents()
|
private void addXScaleComponents()
|
||||||
{
|
{
|
||||||
addButton(FontAwesome.Solid.ArrowsAltH, "Flip horizontally", () => OnFlip?.Invoke(Direction.Horizontal));
|
addButton(FontAwesome.Solid.ArrowsAltH, "Flip horizontally (Ctrl-H)", () => OnFlip?.Invoke(Direction.Horizontal));
|
||||||
|
|
||||||
addDragHandle(Anchor.CentreLeft);
|
addDragHandle(Anchor.CentreLeft);
|
||||||
addDragHandle(Anchor.CentreRight);
|
addDragHandle(Anchor.CentreRight);
|
||||||
|
@ -99,10 +99,10 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
OperationStarted = OnOperationBegan,
|
OperationStarted = OnOperationBegan,
|
||||||
OperationEnded = OnOperationEnded,
|
OperationEnded = OnOperationEnded,
|
||||||
|
|
||||||
OnRotation = angle => HandleRotation(angle),
|
OnRotation = HandleRotation,
|
||||||
OnScale = (amount, anchor) => HandleScale(amount, anchor),
|
OnScale = HandleScale,
|
||||||
OnFlip = direction => HandleFlip(direction),
|
OnFlip = HandleFlip,
|
||||||
OnReverse = () => HandleReverse(),
|
OnReverse = HandleReverse,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -113,19 +113,19 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
|
|
||||||
protected override bool OnScroll(ScrollEvent e)
|
protected override bool OnScroll(ScrollEvent e)
|
||||||
{
|
{
|
||||||
if (e.IsPrecise)
|
if (e.AltPressed)
|
||||||
{
|
{
|
||||||
// can't handle scroll correctly while playing.
|
// zoom when holding alt.
|
||||||
// the editor will handle this case for us.
|
setZoomTarget(zoomTarget + e.ScrollDelta.Y, zoomedContent.ToLocalSpace(e.ScreenSpaceMousePosition).X);
|
||||||
if (editorClock?.IsRunning == true)
|
return true;
|
||||||
return false;
|
|
||||||
|
|
||||||
// for now, we don't support zoom when using a precision scroll device. this needs gesture support.
|
|
||||||
return base.OnScroll(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setZoomTarget(zoomTarget + e.ScrollDelta.Y, zoomedContent.ToLocalSpace(e.ScreenSpaceMousePosition).X);
|
// can't handle scroll correctly while playing.
|
||||||
return true;
|
// the editor will handle this case for us.
|
||||||
|
if (editorClock?.IsRunning == true)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return base.OnScroll(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateZoomedContentWidth() => zoomedContent.Width = DrawWidth * currentZoom;
|
private void updateZoomedContentWidth() => zoomedContent.Width = DrawWidth * currentZoom;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user