mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 10:22:56 +08:00
Fix SkinEditor
's initial target not being a Screen
This commit is contained in:
parent
7e8aa77b2b
commit
99e3161cf0
@ -3,7 +3,6 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
@ -49,16 +48,20 @@ namespace osu.Game.Skinning.Editor
|
||||
|
||||
private EditorToolboxGroup settingsToolbox;
|
||||
|
||||
public SkinEditor()
|
||||
{
|
||||
}
|
||||
|
||||
public SkinEditor(Drawable targetScreen)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
UpdateTargetScreen(targetScreen);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
InternalChild = new OsuContextMenuContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
@ -155,7 +158,7 @@ namespace osu.Game.Skinning.Editor
|
||||
Scheduler.AddOnce(skinChanged);
|
||||
}, true);
|
||||
|
||||
SelectedComponents.BindCollectionChanged(selectionChanged);
|
||||
SelectedComponents.BindCollectionChanged((_, __) => Scheduler.AddOnce(populateSettings), true);
|
||||
}
|
||||
|
||||
public void UpdateTargetScreen(Drawable targetScreen)
|
||||
@ -163,6 +166,7 @@ namespace osu.Game.Skinning.Editor
|
||||
this.targetScreen = targetScreen;
|
||||
|
||||
SelectedComponents.Clear();
|
||||
|
||||
Scheduler.AddOnce(loadBlueprintContainer);
|
||||
|
||||
void loadBlueprintContainer()
|
||||
@ -224,7 +228,7 @@ namespace osu.Game.Skinning.Editor
|
||||
SelectedComponents.Add(component);
|
||||
}
|
||||
|
||||
private void selectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
private void populateSettings()
|
||||
{
|
||||
settingsToolbox.Clear();
|
||||
|
||||
|
@ -21,16 +21,18 @@ namespace osu.Game.Skinning.Editor
|
||||
/// </summary>
|
||||
public class SkinEditorOverlay : CompositeDrawable, IKeyBindingHandler<GlobalAction>
|
||||
{
|
||||
private readonly ScalingContainer target;
|
||||
private readonly ScalingContainer scalingContainer;
|
||||
|
||||
[CanBeNull]
|
||||
private SkinEditor skinEditor;
|
||||
|
||||
public const float VISIBLE_TARGET_SCALE = 0.8f;
|
||||
|
||||
public SkinEditorOverlay(ScalingContainer target)
|
||||
private Screen lastTargetScreen;
|
||||
|
||||
public SkinEditorOverlay(ScalingContainer scalingContainer)
|
||||
{
|
||||
this.target = target;
|
||||
this.scalingContainer = scalingContainer;
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
@ -77,7 +79,7 @@ namespace osu.Game.Skinning.Editor
|
||||
return;
|
||||
}
|
||||
|
||||
var editor = new SkinEditor(target);
|
||||
var editor = new SkinEditor();
|
||||
editor.State.BindValueChanged(editorVisibilityChanged);
|
||||
|
||||
skinEditor = editor;
|
||||
@ -95,6 +97,8 @@ namespace osu.Game.Skinning.Editor
|
||||
return;
|
||||
|
||||
AddInternal(editor);
|
||||
|
||||
SetTarget(lastTargetScreen);
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -105,11 +109,11 @@ namespace osu.Game.Skinning.Editor
|
||||
|
||||
if (visibility.NewValue == Visibility.Visible)
|
||||
{
|
||||
target.SetCustomRect(new RectangleF(toolbar_padding_requirement, 0.1f, 0.8f - toolbar_padding_requirement, 0.7f), true);
|
||||
scalingContainer.SetCustomRect(new RectangleF(toolbar_padding_requirement, 0.1f, 0.8f - toolbar_padding_requirement, 0.7f), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
target.SetCustomRect(null);
|
||||
scalingContainer.SetCustomRect(null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,6 +126,8 @@ namespace osu.Game.Skinning.Editor
|
||||
/// </summary>
|
||||
public void SetTarget(Screen screen)
|
||||
{
|
||||
lastTargetScreen = screen;
|
||||
|
||||
if (skinEditor == null) return;
|
||||
|
||||
skinEditor.Save();
|
||||
|
Loading…
Reference in New Issue
Block a user