Merge pull request #13948 from peppy/skin-editor-button-access

Add the ability to enter and exit the skin editor via on-screen buttons
This commit is contained in:
Bartłomiej Dach 2021-07-22 23:49:51 +02:00 committed by GitHub
commit b650d0d17c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 17 deletions

View File

@ -757,7 +757,7 @@ namespace osu.Game
loadComponentSingleFile(userProfile = new UserProfileOverlay(), overlayContent.Add, true); loadComponentSingleFile(userProfile = new UserProfileOverlay(), overlayContent.Add, true);
loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay(), overlayContent.Add, true); loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay(), overlayContent.Add, true);
loadComponentSingleFile(wikiOverlay = new WikiOverlay(), 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 loadComponentSingleFile(new LoginOverlay
{ {

View File

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

View File

@ -14,6 +14,7 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Cursor; using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Resources.Localisation.Web;
using osuTK; using osuTK;
namespace osu.Game.Skinning.Editor namespace osu.Game.Skinning.Editor
@ -88,6 +89,13 @@ namespace osu.Game.Skinning.Editor
Children = new Drawable[] Children = new Drawable[]
{ {
new SkinBlueprintContainer(targetScreen), new SkinBlueprintContainer(targetScreen),
new TriangleButton
{
Margin = new MarginPadding(10),
Text = CommonStrings.ButtonsClose,
Width = 100,
Action = Hide,
},
new FillFlowContainer new FillFlowContainer
{ {
Direction = FillDirection.Horizontal, Direction = FillDirection.Horizontal,

View File

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