2019-10-08 13:23:13 +08: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.
|
|
|
|
|
|
2024-08-28 18:17:39 +08:00
|
|
|
|
using System.Linq;
|
2020-09-07 18:21:35 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
2024-08-28 18:17:39 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2022-05-24 16:13:44 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2024-05-24 16:24:50 +08:00
|
|
|
|
using osu.Framework.Screens;
|
2020-09-07 18:21:35 +08:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2022-05-24 16:13:44 +08:00
|
|
|
|
using osu.Game.Overlays;
|
2024-08-28 18:17:39 +08:00
|
|
|
|
using osuTK;
|
2020-09-07 18:21:35 +08:00
|
|
|
|
|
2019-10-08 13:23:13 +08:00
|
|
|
|
namespace osu.Game.Screens.Edit.Setup
|
|
|
|
|
{
|
2022-05-24 16:13:44 +08:00
|
|
|
|
public partial class SetupScreen : EditorScreen
|
2019-10-08 13:23:13 +08:00
|
|
|
|
{
|
2024-10-03 21:01:23 +08:00
|
|
|
|
public const float COLUMN_WIDTH = 450;
|
|
|
|
|
public const float SPACING = 28;
|
|
|
|
|
public const float MAX_WIDTH = 2 * COLUMN_WIDTH + SPACING;
|
|
|
|
|
|
2020-09-24 16:03:54 +08:00
|
|
|
|
public SetupScreen()
|
|
|
|
|
: base(EditorScreenMode.SongSetup)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-03 21:01:23 +08:00
|
|
|
|
private OsuScrollContainer scroll = null!;
|
|
|
|
|
private FillFlowContainer flow = null!;
|
|
|
|
|
|
2020-09-07 18:21:35 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
2022-05-24 16:13:44 +08:00
|
|
|
|
private void load(EditorBeatmap beatmap, OverlayColourProvider colourProvider)
|
2019-10-08 13:23:13 +08:00
|
|
|
|
{
|
2023-07-21 17:52:19 +08:00
|
|
|
|
var ruleset = beatmap.BeatmapInfo.Ruleset.CreateInstance();
|
|
|
|
|
|
2024-08-28 18:17:39 +08:00
|
|
|
|
Children = new Drawable[]
|
2022-05-24 16:13:44 +08:00
|
|
|
|
{
|
2024-08-28 18:17:39 +08:00
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = colourProvider.Background3,
|
|
|
|
|
},
|
2024-10-04 17:09:14 +08:00
|
|
|
|
scroll = new OsuScrollContainer
|
2024-08-28 18:17:39 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2024-10-04 17:09:14 +08:00
|
|
|
|
Padding = new MarginPadding(15),
|
|
|
|
|
Child = flow = new FillFlowContainer
|
2024-08-28 18:17:39 +08:00
|
|
|
|
{
|
2024-10-04 17:09:14 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Direction = FillDirection.Full,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Spacing = new Vector2(25),
|
|
|
|
|
ChildrenEnumerable = ruleset.CreateEditorSetupSections().Select(section => section.With(s =>
|
2024-08-28 18:17:39 +08:00
|
|
|
|
{
|
2024-10-04 17:09:14 +08:00
|
|
|
|
s.Width = 450;
|
|
|
|
|
s.Anchor = Anchor.TopCentre;
|
|
|
|
|
s.Origin = Anchor.TopCentre;
|
|
|
|
|
})),
|
2024-08-28 18:17:39 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2020-10-02 15:31:11 +08:00
|
|
|
|
}
|
2021-09-01 15:46:19 +08:00
|
|
|
|
|
2024-10-03 21:01:23 +08:00
|
|
|
|
protected override void UpdateAfterChildren()
|
|
|
|
|
{
|
|
|
|
|
base.UpdateAfterChildren();
|
|
|
|
|
|
|
|
|
|
if (scroll.DrawWidth > MAX_WIDTH)
|
|
|
|
|
{
|
|
|
|
|
flow.RelativeSizeAxes = Axes.None;
|
|
|
|
|
flow.Width = MAX_WIDTH;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
flow.RelativeSizeAxes = Axes.X;
|
|
|
|
|
flow.Width = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-24 16:24:50 +08:00
|
|
|
|
public override void OnExiting(ScreenExitEvent e)
|
|
|
|
|
{
|
|
|
|
|
base.OnExiting(e);
|
|
|
|
|
|
|
|
|
|
// Before exiting, trigger a focus loss.
|
|
|
|
|
//
|
|
|
|
|
// This is important to ensure that if the user is still editing a textbox, it will commit
|
|
|
|
|
// (and potentially block the exit procedure for save).
|
2024-05-24 17:25:29 +08:00
|
|
|
|
GetContainingFocusManager()?.TriggerFocusContention(this);
|
2024-05-24 16:24:50 +08:00
|
|
|
|
}
|
2019-10-08 13:23:13 +08:00
|
|
|
|
}
|
|
|
|
|
}
|