2022-03-15 06:34:04 +00:00
|
|
|
// 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.
|
|
|
|
|
2022-04-23 20:16:32 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
2022-03-15 06:34:04 +00:00
|
|
|
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;
|
2022-03-29 07:45:21 +00:00
|
|
|
using osu.Game.Rulesets.Mods;
|
2022-04-18 08:49:28 +00:00
|
|
|
using osu.Game.Screens;
|
2022-03-15 06:34:04 +00:00
|
|
|
using osu.Game.Screens.Play;
|
|
|
|
using osu.Game.Screens.Select;
|
2022-04-23 20:16:32 +00:00
|
|
|
using osu.Game.Utils;
|
2022-03-15 06:34:04 +00:00
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Skinning.Editor
|
|
|
|
{
|
|
|
|
public class SkinEditorSceneLibrary : CompositeDrawable
|
|
|
|
{
|
2022-06-06 09:02:42 +00:00
|
|
|
public const float HEIGHT = BUTTON_HEIGHT + padding * 2;
|
|
|
|
|
2022-03-15 06:34:04 +00:00
|
|
|
public const float BUTTON_HEIGHT = 40;
|
|
|
|
|
|
|
|
private const float padding = 10;
|
|
|
|
|
|
|
|
[Resolved(canBeNull: true)]
|
2022-04-18 08:49:28 +00:00
|
|
|
private IPerformFromScreenRunner performer { get; set; }
|
2022-03-15 06:34:04 +00:00
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
private IBindable<RulesetInfo> ruleset { get; set; }
|
|
|
|
|
2022-04-23 20:16:32 +00:00
|
|
|
[Resolved]
|
|
|
|
private Bindable<IReadOnlyList<Mod>> mods { get; set; }
|
|
|
|
|
2022-03-15 06:34:04 +00:00
|
|
|
public SkinEditorSceneLibrary()
|
|
|
|
{
|
2022-06-06 09:02:42 +00:00
|
|
|
Height = HEIGHT;
|
2022-03-15 06:34:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[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,
|
2022-04-18 08:49:28 +00:00
|
|
|
Action = () => performer?.PerformFromScreen(screen =>
|
2022-03-15 06:34:04 +00:00
|
|
|
{
|
|
|
|
if (screen is SongSelect)
|
|
|
|
return;
|
|
|
|
|
|
|
|
screen.Push(new PlaySongSelect());
|
|
|
|
}, new[] { typeof(SongSelect) })
|
|
|
|
},
|
|
|
|
new SceneButton
|
|
|
|
{
|
|
|
|
Text = "Gameplay",
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
2022-04-18 08:49:28 +00:00
|
|
|
Action = () => performer?.PerformFromScreen(screen =>
|
2022-03-15 06:34:04 +00:00
|
|
|
{
|
|
|
|
if (screen is Player)
|
|
|
|
return;
|
|
|
|
|
|
|
|
var replayGeneratingMod = ruleset.Value.CreateInstance().GetAutoplayMod();
|
2022-04-23 20:16:32 +00:00
|
|
|
|
|
|
|
if (!ModUtils.CheckCompatibleSet(mods.Value.Append(replayGeneratingMod), out var invalid))
|
|
|
|
mods.Value = mods.Value.Except(invalid).ToArray();
|
|
|
|
|
2022-03-15 06:34:04 +00:00
|
|
|
if (replayGeneratingMod != null)
|
2022-03-29 07:45:21 +00:00
|
|
|
screen.Push(new PlayerLoader(() => new ReplayPlayer((beatmap, mods) => replayGeneratingMod.CreateScoreFromReplayData(beatmap, mods))));
|
2022-03-15 06:34:04 +00:00
|
|
|
}, new[] { typeof(Player), typeof(SongSelect) })
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-03-21 08:01:46 +00:00
|
|
|
public class SceneButton : OsuButton
|
2022-03-15 06:34:04 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|