1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-16 02:11:05 +08:00
osu-lazer/osu.Game/Screens/Edit/Setup/SetupScreen.cs

80 lines
2.8 KiB
C#
Raw Normal View History

// 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 System.Collections.Generic;
2020-09-07 18:21:35 +08:00
using osu.Framework.Allocation;
using osu.Framework.Graphics;
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;
using osu.Game.Overlays;
2020-09-07 18:21:35 +08:00
namespace osu.Game.Screens.Edit.Setup
{
2022-11-24 13:32:20 +08:00
public partial class SetupScreen : EditorScreen
{
2021-04-04 02:02:26 +08:00
[Cached]
private SectionsContainer<SetupSection> sections { get; } = new SetupScreenSectionsContainer();
2021-04-04 02:02:26 +08:00
2021-04-04 18:50:50 +08:00
[Cached]
private SetupScreenHeader header = new SetupScreenHeader();
public SetupScreen()
: base(EditorScreenMode.SongSetup)
{
}
2020-09-07 18:21:35 +08:00
[BackgroundDependencyLoader]
private void load(EditorBeatmap beatmap, OverlayColourProvider colourProvider)
{
var ruleset = beatmap.BeatmapInfo.Ruleset.CreateInstance();
// ReSharper disable once UseObjectOrCollectionInitializer
var sectionsEnumerable = new List<SetupSection>();
sectionsEnumerable.Add(new ResourcesSection());
sectionsEnumerable.Add(new MetadataSection());
sectionsEnumerable.AddRange(ruleset.CreateEditorSetupSections());
sectionsEnumerable.Add(new DesignSection());
Add(new Box
{
Colour = colourProvider.Background3,
RelativeSizeAxes = Axes.Both,
});
Add(sections.With(s =>
2020-09-07 18:21:35 +08:00
{
s.RelativeSizeAxes = Axes.Both;
s.ChildrenEnumerable = sectionsEnumerable;
s.FixedHeader = header;
}));
}
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
}
2022-11-24 13:32:20 +08:00
private partial class SetupScreenSectionsContainer : SectionsContainer<SetupSection>
{
protected override UserTrackingScrollContainer CreateScrollContainer()
{
var scrollContainer = base.CreateScrollContainer();
// Workaround for masking issues (see https://github.com/ppy/osu-framework/issues/1675#issuecomment-910023157)
// Note that this actually causes the full scroll range to be reduced by 2px at the bottom, but it's not really noticeable.
scrollContainer.Margin = new MarginPadding { Top = 2 };
return scrollContainer;
}
}
}
}