1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 12:17:26 +08:00

stop component transform when skineditor is hidden

This commit is contained in:
Gabe Livengood 2022-06-17 11:28:58 -04:00
parent 4bc26dbb48
commit 48ffd6aeb5
No known key found for this signature in database
GPG Key ID: 70321B78DAECE683

View File

@ -11,6 +11,7 @@ using osu.Framework.Extensions.EnumExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Graphics.Containers;
using osu.Framework.Utils;
using osu.Game.Extensions;
using osu.Game.Graphics.UserInterface;
@ -25,8 +26,17 @@ namespace osu.Game.Skinning.Editor
[Resolved]
private SkinEditor skinEditor { get; set; }
/// <summary>
/// Whether the <see cref="SkinEditor"/>'s state allows selected blueprints to undergo transformations.
/// Used to prevent operations from being performed on unloaded blueprints.
/// </summary>
private bool allowHandling => skinEditor.State.Value == Visibility.Visible;
public override bool HandleRotation(float angle)
{
if (!allowHandling)
return false;
if (SelectedBlueprints.Count == 1)
{
// for single items, rotate around the origin rather than the selection centre.
@ -53,6 +63,9 @@ namespace osu.Game.Skinning.Editor
public override bool HandleScale(Vector2 scale, Anchor anchor)
{
if (!allowHandling)
return false;
// convert scale to screen space
scale = ToScreenSpace(scale) - ToScreenSpace(Vector2.Zero);
@ -130,6 +143,9 @@ namespace osu.Game.Skinning.Editor
public override bool HandleFlip(Direction direction, bool flipOverOrigin)
{
if (!allowHandling)
return false;
var selectionQuad = getSelectionQuad();
Vector2 scaleFactor = direction == Direction.Horizontal ? new Vector2(-1, 1) : new Vector2(1, -1);
@ -150,6 +166,9 @@ namespace osu.Game.Skinning.Editor
public override bool HandleMovement(MoveSelectionEvent<ISkinnableDrawable> moveEvent)
{
if (!allowHandling)
return false;
foreach (var c in SelectedBlueprints)
{
var item = c.Item;