mirror of
https://github.com/ppy/osu.git
synced 2025-01-19 02:52:54 +08:00
6a6db5a22b
- Closes https://github.com/ppy/osu/issues/21189 - Supersedes / closes https://github.com/ppy/osu-framework/pull/5627 - Supersedes / closes https://github.com/ppy/osu/pull/22235 The reason why I opted for a complete rewrite rather than a revival of that aforementioned pull series is that it always felt quite gross to me to be pulling framework's audio subsystem into the task of reading ID3 tags, and I also partially don't believe that BASS is *good* at reading ID3 tags. Meanwhile, we already have another library pulled in that is *explicitly* intended for reading multimedia metadata, and using it does not require framework changes. (And it was pulled in explicitly for use in the editor verify tab as well.) The hard and dumb part of this diff is hacking the gibson such that the metadata section on setup screen actually *updates itself* after the resources section is done doing its thing. After significant gnashing of teeth I just did the bare minimum to make work by caching a common parent and exposing an `Action?` on it. If anyone has better ideas, I'm all ears.
97 lines
3.1 KiB
C#
97 lines
3.1 KiB
C#
// 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;
|
|
using System.Linq;
|
|
using osu.Framework.Allocation;
|
|
using osu.Framework.Graphics;
|
|
using osu.Framework.Graphics.Containers;
|
|
using osu.Framework.Graphics.Shapes;
|
|
using osu.Framework.Screens;
|
|
using osu.Game.Graphics.Containers;
|
|
using osu.Game.Overlays;
|
|
using osuTK;
|
|
|
|
namespace osu.Game.Screens.Edit.Setup
|
|
{
|
|
[Cached]
|
|
public partial class SetupScreen : EditorScreen
|
|
{
|
|
public const float COLUMN_WIDTH = 450;
|
|
public const float SPACING = 28;
|
|
public const float MAX_WIDTH = 2 * COLUMN_WIDTH + SPACING;
|
|
|
|
public Action? MetadataChanged { get; set; }
|
|
|
|
public SetupScreen()
|
|
: base(EditorScreenMode.SongSetup)
|
|
{
|
|
}
|
|
|
|
private OsuScrollContainer scroll = null!;
|
|
private FillFlowContainer flow = null!;
|
|
|
|
[BackgroundDependencyLoader]
|
|
private void load(EditorBeatmap beatmap, OverlayColourProvider colourProvider)
|
|
{
|
|
var ruleset = beatmap.BeatmapInfo.Ruleset.CreateInstance();
|
|
|
|
Children = new Drawable[]
|
|
{
|
|
new Box
|
|
{
|
|
RelativeSizeAxes = Axes.Both,
|
|
Colour = colourProvider.Background3,
|
|
},
|
|
scroll = new OsuScrollContainer
|
|
{
|
|
RelativeSizeAxes = Axes.Both,
|
|
Padding = new MarginPadding(15),
|
|
Child = flow = new FillFlowContainer
|
|
{
|
|
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 =>
|
|
{
|
|
s.Width = 450;
|
|
s.Anchor = Anchor.TopCentre;
|
|
s.Origin = Anchor.TopCentre;
|
|
})),
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
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).
|
|
GetContainingFocusManager()?.TriggerFocusContention(this);
|
|
}
|
|
}
|
|
}
|