mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 18:12:56 +08:00
Add aspect ratio locking and flip support to skin editor
This commit is contained in:
parent
7bac81f394
commit
1cda55393e
@ -4,6 +4,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using osu.Framework.Extensions.EnumExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Game.Extensions;
|
using osu.Game.Extensions;
|
||||||
@ -36,6 +37,20 @@ namespace osu.Game.Skinning.Editor
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool HandleFlip(Direction direction)
|
||||||
|
{
|
||||||
|
// TODO: this is temporary as well.
|
||||||
|
foreach (var c in SelectedBlueprints)
|
||||||
|
{
|
||||||
|
((Drawable)c.Item).Scale *= new Vector2(
|
||||||
|
direction == Direction.Horizontal ? -1 : 1,
|
||||||
|
direction == Direction.Vertical ? -1 : 1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public override bool HandleMovement(MoveSelectionEvent<ISkinnableComponent> moveEvent)
|
public override bool HandleMovement(MoveSelectionEvent<ISkinnableComponent> moveEvent)
|
||||||
{
|
{
|
||||||
foreach (var c in SelectedBlueprints)
|
foreach (var c in SelectedBlueprints)
|
||||||
@ -116,6 +131,15 @@ namespace osu.Game.Skinning.Editor
|
|||||||
// reverse the scale direction if dragging from top or left.
|
// reverse the scale direction if dragging from top or left.
|
||||||
if ((reference & Anchor.x0) > 0) scale.X = -scale.X;
|
if ((reference & Anchor.x0) > 0) scale.X = -scale.X;
|
||||||
if ((reference & Anchor.y0) > 0) scale.Y = -scale.Y;
|
if ((reference & Anchor.y0) > 0) scale.Y = -scale.Y;
|
||||||
|
|
||||||
|
// for now aspect lock scale adjustments that occur at corners.
|
||||||
|
if (!reference.HasFlagFast(Anchor.x1) && !reference.HasFlagFast(Anchor.y1))
|
||||||
|
{
|
||||||
|
if (reference.HasFlagFast(Anchor.x0) || reference.HasFlagFast(Anchor.x2))
|
||||||
|
scale.Y = scale.X;
|
||||||
|
else
|
||||||
|
scale.X = scale.Y;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AnchorMenuItem : TernaryStateMenuItem
|
public class AnchorMenuItem : TernaryStateMenuItem
|
||||||
|
Loading…
Reference in New Issue
Block a user