mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 17:23:22 +08:00
Fix deleting skin elements not saving out to skin
Closes https://github.com/ppy/osu/issues/12786.
This commit is contained in:
parent
1d4bcbaa6e
commit
d09da02673
@ -2,6 +2,7 @@
|
|||||||
// 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 System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -193,14 +194,16 @@ namespace osu.Game.Skinning.Editor
|
|||||||
SelectedComponents.Add(component);
|
SelectedComponents.Add(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IEnumerable<ISkinnableTarget> availableTargets => targetScreen.ChildrenOfType<ISkinnableTarget>();
|
||||||
|
|
||||||
private ISkinnableTarget getTarget(SkinnableTarget target)
|
private ISkinnableTarget getTarget(SkinnableTarget target)
|
||||||
{
|
{
|
||||||
return targetScreen.ChildrenOfType<ISkinnableTarget>().FirstOrDefault(c => c.Target == target);
|
return availableTargets.FirstOrDefault(c => c.Target == target);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void revert()
|
private void revert()
|
||||||
{
|
{
|
||||||
SkinnableTargetContainer[] targetContainers = targetScreen.ChildrenOfType<SkinnableTargetContainer>().ToArray();
|
ISkinnableTarget[] targetContainers = availableTargets.ToArray();
|
||||||
|
|
||||||
foreach (var t in targetContainers)
|
foreach (var t in targetContainers)
|
||||||
{
|
{
|
||||||
@ -216,7 +219,7 @@ namespace osu.Game.Skinning.Editor
|
|||||||
if (!hasBegunMutating)
|
if (!hasBegunMutating)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SkinnableTargetContainer[] targetContainers = targetScreen.ChildrenOfType<SkinnableTargetContainer>().ToArray();
|
ISkinnableTarget[] targetContainers = availableTargets.ToArray();
|
||||||
|
|
||||||
foreach (var t in targetContainers)
|
foreach (var t in targetContainers)
|
||||||
currentSkin.Value.UpdateDrawableTarget(t);
|
currentSkin.Value.UpdateDrawableTarget(t);
|
||||||
@ -237,5 +240,11 @@ namespace osu.Game.Skinning.Editor
|
|||||||
{
|
{
|
||||||
this.FadeOut(TRANSITION_DURATION, Easing.OutQuint);
|
this.FadeOut(TRANSITION_DURATION, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DeleteItems(ISkinnableDrawable[] items)
|
||||||
|
{
|
||||||
|
foreach (var item in items.ToArray())
|
||||||
|
availableTargets.FirstOrDefault(t => t.Components.Contains(item))?.Remove(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.Allocation;
|
||||||
using osu.Framework.Extensions.EnumExtensions;
|
using osu.Framework.Extensions.EnumExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
@ -17,6 +18,9 @@ namespace osu.Game.Skinning.Editor
|
|||||||
{
|
{
|
||||||
public class SkinSelectionHandler : SelectionHandler<ISkinnableDrawable>
|
public class SkinSelectionHandler : SelectionHandler<ISkinnableDrawable>
|
||||||
{
|
{
|
||||||
|
[Resolved]
|
||||||
|
private SkinEditor skinEditor { get; set; }
|
||||||
|
|
||||||
public override bool HandleRotation(float angle)
|
public override bool HandleRotation(float angle)
|
||||||
{
|
{
|
||||||
// TODO: this doesn't correctly account for origin/anchor specs being different in a multi-selection.
|
// TODO: this doesn't correctly account for origin/anchor specs being different in a multi-selection.
|
||||||
@ -72,14 +76,8 @@ namespace osu.Game.Skinning.Editor
|
|||||||
SelectionBox.CanReverse = false;
|
SelectionBox.CanReverse = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void DeleteItems(IEnumerable<ISkinnableDrawable> items)
|
protected override void DeleteItems(IEnumerable<ISkinnableDrawable> items) =>
|
||||||
{
|
skinEditor.DeleteItems(items.ToArray());
|
||||||
foreach (var i in items)
|
|
||||||
{
|
|
||||||
((Drawable)i).Expire();
|
|
||||||
SelectedItems.Remove(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override IEnumerable<MenuItem> GetContextMenuItemsForSelection(IEnumerable<SelectionBlueprint<ISkinnableDrawable>> selection)
|
protected override IEnumerable<MenuItem> GetContextMenuItemsForSelection(IEnumerable<SelectionBlueprint<ISkinnableDrawable>> selection)
|
||||||
{
|
{
|
||||||
|
@ -37,8 +37,15 @@ namespace osu.Game.Skinning
|
|||||||
void Reload();
|
void Reload();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add the provided item to this target.
|
/// Add a new skinnable component to this target.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="drawable">The component to add.</param>
|
||||||
void Add(ISkinnableDrawable drawable);
|
void Add(ISkinnableDrawable drawable);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove an existing skinnable component to this target.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="component">The component to add.</param>
|
||||||
|
public void Remove(ISkinnableDrawable component);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,10 +43,7 @@ namespace osu.Game.Skinning
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc cref="ISkinnableTarget"/>
|
||||||
/// Add a new skinnable component to this target.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="component">The component to add.</param>
|
|
||||||
/// <exception cref="NotSupportedException">Thrown when attempting to add an element to a target which is not supported by the current skin.</exception>
|
/// <exception cref="NotSupportedException">Thrown when attempting to add an element to a target which is not supported by the current skin.</exception>
|
||||||
/// <exception cref="ArgumentException">Thrown if the provided instance is not a <see cref="Drawable"/>.</exception>
|
/// <exception cref="ArgumentException">Thrown if the provided instance is not a <see cref="Drawable"/>.</exception>
|
||||||
public void Add(ISkinnableDrawable component)
|
public void Add(ISkinnableDrawable component)
|
||||||
@ -61,6 +58,21 @@ namespace osu.Game.Skinning
|
|||||||
components.Add(component);
|
components.Add(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="ISkinnableTarget"/>
|
||||||
|
/// <exception cref="NotSupportedException">Thrown when attempting to add an element to a target which is not supported by the current skin.</exception>
|
||||||
|
/// <exception cref="ArgumentException">Thrown if the provided instance is not a <see cref="Drawable"/>.</exception>
|
||||||
|
public void Remove(ISkinnableDrawable component)
|
||||||
|
{
|
||||||
|
if (content == null)
|
||||||
|
throw new NotSupportedException("Attempting to add a new component to a target container which is not supported by the current skin.");
|
||||||
|
|
||||||
|
if (!(component is Drawable drawable))
|
||||||
|
throw new ArgumentException($"Provided argument must be of type {nameof(Drawable)}.", nameof(drawable));
|
||||||
|
|
||||||
|
content.Remove(drawable);
|
||||||
|
components.Remove(component);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
||||||
{
|
{
|
||||||
base.SkinChanged(skin, allowFallback);
|
base.SkinChanged(skin, allowFallback);
|
||||||
|
Loading…
Reference in New Issue
Block a user