1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +08:00

Add the ability to enter and exit the skin editor via on-screen buttons

This commit is contained in:
Dean Herbert 2021-07-20 19:36:12 +09:00
parent 6cc81c24b4
commit 9c4fbf45e9
4 changed files with 46 additions and 17 deletions

View File

@ -757,7 +757,7 @@ namespace osu.Game
loadComponentSingleFile(userProfile = new UserProfileOverlay(), overlayContent.Add, true);
loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay(), overlayContent.Add, true);
loadComponentSingleFile(wikiOverlay = new WikiOverlay(), overlayContent.Add, true);
loadComponentSingleFile(skinEditor = new SkinEditorOverlay(screenContainer), overlayContent.Add);
loadComponentSingleFile(skinEditor = new SkinEditorOverlay(screenContainer), overlayContent.Add, true);
loadComponentSingleFile(new LoginOverlay
{

View File

@ -13,6 +13,7 @@ using osu.Framework.Logging;
using osu.Game.Configuration;
using osu.Game.Graphics.UserInterface;
using osu.Game.Skinning;
using osu.Game.Skinning.Editor;
using osuTK;
namespace osu.Game.Overlays.Settings.Sections
@ -57,14 +58,19 @@ namespace osu.Game.Overlays.Settings.Sections
private IBindable<WeakReference<SkinInfo>> managerUpdated;
private IBindable<WeakReference<SkinInfo>> managerRemoved;
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
[BackgroundDependencyLoader(permitNulls: true)]
private void load(OsuConfigManager config, SkinEditorOverlay skinEditor)
{
FlowContent.Spacing = new Vector2(0, 5);
Children = new Drawable[]
{
skinDropdown = new SkinSettingsDropdown(),
new SettingsButton
{
Text = "Skin layout editor",
Action = () => skinEditor?.Toggle(),
},
new ExportSkinButton(),
new SettingsSlider<float, SizeSlider>
{

View File

@ -56,6 +56,13 @@ namespace osu.Game.Skinning.Editor
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
new TriangleButton
{
Margin = new MarginPadding(10),
Text = "Close",
Width = 100,
Action = Hide,
},
headerText = new OsuTextFlowContainer
{
TextAnchor = Anchor.TopCentre,

View File

@ -38,28 +38,44 @@ namespace osu.Game.Skinning.Editor
{
case GlobalAction.Back:
if (skinEditor?.State.Value == Visibility.Visible)
{
skinEditor.ToggleVisibility();
return true;
}
break;
Hide();
return true;
case GlobalAction.ToggleSkinEditor:
if (skinEditor == null)
{
LoadComponentAsync(skinEditor = new SkinEditor(target), AddInternal);
skinEditor.State.BindValueChanged(editorVisibilityChanged);
}
else
skinEditor.ToggleVisibility();
Toggle();
return true;
}
return false;
}
public void Toggle()
{
if (skinEditor == null)
Show();
else
skinEditor.ToggleVisibility();
}
public override void Hide()
{
base.Hide();
skinEditor.Hide();
}
public override void Show()
{
base.Show();
if (skinEditor == null)
{
LoadComponentAsync(skinEditor = new SkinEditor(target), AddInternal);
skinEditor.State.BindValueChanged(editorVisibilityChanged);
}
else
skinEditor.Show();
}
private void editorVisibilityChanged(ValueChangedEvent<Visibility> visibility)
{
if (visibility.NewValue == Visibility.Visible)