mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 01:02:55 +08:00
Handle component changes via ISkinnableTarget.Components
rather than inside SkinEditor
directly
Seems saner? Maybe?
This commit is contained in:
parent
e162fd56da
commit
0320ba770f
@ -329,8 +329,6 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
|
|
||||||
SelectedComponents.Clear();
|
SelectedComponents.Clear();
|
||||||
SelectedComponents.Add(component);
|
SelectedComponents.Add(component);
|
||||||
|
|
||||||
changeHandler?.SaveState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateSettings()
|
private void populateSettings()
|
||||||
@ -406,8 +404,6 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
{
|
{
|
||||||
foreach (var item in items)
|
foreach (var item in items)
|
||||||
availableTargets.FirstOrDefault(t => t.Components.Contains(item))?.Remove(item);
|
availableTargets.FirstOrDefault(t => t.Components.Contains(item))?.Remove(item);
|
||||||
|
|
||||||
changeHandler?.SaveState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Drag & drop import handling
|
#region Drag & drop import handling
|
||||||
|
@ -6,6 +6,7 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Extensions;
|
using osu.Game.Extensions;
|
||||||
@ -17,9 +18,10 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
{
|
{
|
||||||
public partial class SkinEditorChangeHandler : EditorChangeHandler
|
public partial class SkinEditorChangeHandler : EditorChangeHandler
|
||||||
{
|
{
|
||||||
private readonly Drawable targetScreen;
|
private readonly ISkinnableTarget? firstTarget;
|
||||||
|
|
||||||
private ISkinnableTarget? firstTarget => targetScreen.ChildrenOfType<ISkinnableTarget>().FirstOrDefault();
|
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable
|
||||||
|
private readonly BindableList<ISkinnableDrawable>? components;
|
||||||
|
|
||||||
public SkinEditorChangeHandler(Drawable targetScreen)
|
public SkinEditorChangeHandler(Drawable targetScreen)
|
||||||
{
|
{
|
||||||
@ -27,10 +29,13 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
// In the future we'll want this to cover all changes, even to skin's `InstantiationInfo`.
|
// In the future we'll want this to cover all changes, even to skin's `InstantiationInfo`.
|
||||||
// We'll also need to consider cases where multiple targets are on screen at the same time.
|
// We'll also need to consider cases where multiple targets are on screen at the same time.
|
||||||
|
|
||||||
this.targetScreen = targetScreen;
|
firstTarget = targetScreen?.ChildrenOfType<ISkinnableTarget>().FirstOrDefault();
|
||||||
|
|
||||||
// Save initial state.
|
if (firstTarget == null)
|
||||||
SaveState();
|
return;
|
||||||
|
|
||||||
|
components = new BindableList<ISkinnableDrawable> { BindTarget = firstTarget.Components };
|
||||||
|
components.BindCollectionChanged((_, _) => SaveState());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void WriteCurrentStateToStream(MemoryStream stream)
|
protected override void WriteCurrentStateToStream(MemoryStream stream)
|
||||||
|
Loading…
Reference in New Issue
Block a user