mirror of
https://github.com/ppy/osu.git
synced 2026-05-19 15:40:14 +08:00
Merge pull request #34958 from smoogipoo/fix-skin-editor-initial-state
Fix mangled initial undo state on fresh skins
This commit is contained in:
@@ -391,10 +391,10 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
return;
|
||||
}
|
||||
|
||||
if (skinComponentsContainer.IsLoaded)
|
||||
if (skinComponentsContainer.ComponentsLoaded)
|
||||
bindChangeHandler(skinComponentsContainer);
|
||||
else
|
||||
skinComponentsContainer.OnLoadComplete += d => Schedule(() => bindChangeHandler((SkinnableContainer)d));
|
||||
skinComponentsContainer.OnComponentsLoaded += onComponentsLoaded;
|
||||
|
||||
content.Child = new SkinBlueprintContainer(skinComponentsContainer);
|
||||
|
||||
@@ -428,6 +428,13 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
RequestPlacement = requestPlacement
|
||||
});
|
||||
|
||||
void onComponentsLoaded(Drawable d)
|
||||
{
|
||||
SkinnableContainer container = (SkinnableContainer)d;
|
||||
container.OnComponentsLoaded -= onComponentsLoaded;
|
||||
Schedule(() => bindChangeHandler(container));
|
||||
}
|
||||
|
||||
void requestPlacement(Type type)
|
||||
{
|
||||
if (!(Activator.CreateInstance(type) is ISerialisableDrawable component))
|
||||
|
||||
@@ -21,6 +21,11 @@ namespace osu.Game.Skinning
|
||||
/// </remarks>
|
||||
public partial class SkinnableContainer : SkinReloadableDrawable, ISerialisableDrawableContainer
|
||||
{
|
||||
/// <summary>
|
||||
/// Invoked when the skinnable components of this container finish loading.
|
||||
/// </summary>
|
||||
public event Action<Drawable>? OnComponentsLoaded;
|
||||
|
||||
private Container? content;
|
||||
|
||||
/// <summary>
|
||||
@@ -67,6 +72,7 @@ namespace osu.Game.Skinning
|
||||
AddInternal(wrapper);
|
||||
components.AddRange(wrapper.Children.OfType<ISerialisableDrawable>());
|
||||
ComponentsLoaded = true;
|
||||
OnComponentsLoaded?.Invoke(this);
|
||||
}, (cancellationSource = new CancellationTokenSource()).Token);
|
||||
}
|
||||
|
||||
@@ -106,5 +112,12 @@ namespace osu.Game.Skinning
|
||||
|
||||
Reload();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
OnComponentsLoaded = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user