Merge pull request #17273 from peppy/skin-editor-scene-library

Add a basic scene library to skin editor
This commit is contained in:
Dan Balasescu 2022-03-16 21:12:05 +09:00 committed by GitHub
commit 36c97e5a8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 158 additions and 6 deletions

View File

@ -24,7 +24,7 @@ namespace osu.Game.Tests.Visual.Gameplay
AddStep("reload skin editor", () =>
{
skinEditor?.Expire();
Player.ScaleTo(SkinEditorOverlay.VISIBLE_TARGET_SCALE);
Player.ScaleTo(0.8f);
LoadComponentAsync(skinEditor = new SkinEditor(Player), Add);
});
}

View File

@ -37,6 +37,7 @@ using osu.Game.Graphics.UserInterface;
using System.Diagnostics;
using osu.Game.Screens.Play;
using osu.Game.Database;
using osu.Game.Skinning;
namespace osu.Game.Screens.Select
{
@ -235,6 +236,10 @@ namespace osu.Game.Screens.Select
}
}
},
new SkinnableTargetContainer(SkinnableTarget.SongSelect)
{
RelativeSizeAxes = Axes.Both,
},
});
if (ShowFooter)

View File

@ -70,6 +70,14 @@ namespace osu.Game.Skinning
case SkinnableTargetComponent target:
switch (target.Target)
{
case SkinnableTarget.SongSelect:
var songSelectComponents = new SkinnableTargetComponentsContainer(container =>
{
// do stuff when we need to.
});
return songSelectComponents;
case SkinnableTarget.MainHUDComponents:
var skinnableTargetWrapper = new SkinnableTargetComponentsContainer(container =>
{

View File

@ -16,6 +16,7 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays;
using osu.Game.Rulesets.Edit;
using osu.Game.Screens.Edit.Components.Menus;
@ -42,6 +43,9 @@ namespace osu.Game.Skinning.Editor
[Resolved]
private OsuColour colours { get; set; }
[Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
private bool hasBegunMutating;
private Container content;
@ -62,6 +66,8 @@ namespace osu.Game.Skinning.Editor
{
RelativeSizeAxes = Axes.Both;
const float menu_height = 40;
InternalChild = new OsuContextMenuContainer
{
RelativeSizeAxes = Axes.Both,
@ -69,10 +75,10 @@ namespace osu.Game.Skinning.Editor
{
new Container
{
Name = "Top bar",
Name = "Menu container",
RelativeSizeAxes = Axes.X,
Depth = float.MinValue,
Height = 40,
Height = menu_height,
Children = new Drawable[]
{
new EditorMenuBar
@ -105,6 +111,12 @@ namespace osu.Game.Skinning.Editor
},
},
},
new SkinEditorSceneLibrary
{
RelativeSizeAxes = Axes.X,
Y = menu_height,
},
new GridContainer
{
RelativeSizeAxes = Axes.Both,
@ -173,7 +185,10 @@ namespace osu.Game.Skinning.Editor
{
content.Children = new Drawable[]
{
new SkinBlueprintContainer(targetScreen),
new SkinBlueprintContainer(targetScreen)
{
Margin = new MarginPadding { Top = 100 },
}
};
}
}

View File

@ -114,7 +114,7 @@ namespace osu.Game.Skinning.Editor
if (skinEditor.State.Value == Visibility.Visible)
{
scalingContainer.SetCustomRect(new RectangleF(toolbar_padding_requirement, 0.1f, 0.8f - toolbar_padding_requirement, 0.7f), true);
scalingContainer.SetCustomRect(new RectangleF(toolbar_padding_requirement, 0.2f, 0.8f - toolbar_padding_requirement, 0.7f), true);
game?.Toolbar.Hide();
game?.CloseAllOverlays();

View File

@ -0,0 +1,123 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Screens;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays;
using osu.Game.Rulesets;
using osu.Game.Screens.Play;
using osu.Game.Screens.Select;
using osuTK;
namespace osu.Game.Skinning.Editor
{
public class SkinEditorSceneLibrary : CompositeDrawable
{
public const float BUTTON_HEIGHT = 40;
private const float padding = 10;
[Resolved(canBeNull: true)]
private OsuGame game { get; set; }
[Resolved]
private IBindable<RulesetInfo> ruleset { get; set; }
public SkinEditorSceneLibrary()
{
Height = BUTTON_HEIGHT + padding * 2;
}
[BackgroundDependencyLoader]
private void load(OverlayColourProvider overlayColourProvider)
{
InternalChildren = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = overlayColourProvider.Background6,
},
new OsuScrollContainer(Direction.Horizontal)
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
new FillFlowContainer
{
Name = "Scene library",
AutoSizeAxes = Axes.X,
RelativeSizeAxes = Axes.Y,
Spacing = new Vector2(padding),
Padding = new MarginPadding(padding),
Direction = FillDirection.Horizontal,
Children = new Drawable[]
{
new OsuSpriteText
{
Text = "Scene library",
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Margin = new MarginPadding(10),
},
new SceneButton
{
Text = "Song Select",
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Action = () => game?.PerformFromScreen(screen =>
{
if (screen is SongSelect)
return;
screen.Push(new PlaySongSelect());
}, new[] { typeof(SongSelect) })
},
new SceneButton
{
Text = "Gameplay",
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Action = () => game?.PerformFromScreen(screen =>
{
if (screen is Player)
return;
var replayGeneratingMod = ruleset.Value.CreateInstance().GetAutoplayMod();
if (replayGeneratingMod != null)
screen.Push(new ReplayPlayer((beatmap, mods) => replayGeneratingMod.CreateReplayScore(beatmap, mods)));
}, new[] { typeof(Player), typeof(SongSelect) })
},
}
},
}
}
};
}
private class SceneButton : OsuButton
{
public SceneButton()
{
Width = 100;
Height = BUTTON_HEIGHT;
}
[BackgroundDependencyLoader(true)]
private void load([CanBeNull] OverlayColourProvider overlayColourProvider, OsuColour colours)
{
BackgroundColour = overlayColourProvider?.Background3 ?? colours.Blue3;
Content.CornerRadius = 5;
}
}
}
}

View File

@ -5,6 +5,7 @@ namespace osu.Game.Skinning
{
public enum SkinnableTarget
{
MainHUDComponents
MainHUDComponents,
SongSelect
}
}