2020-10-06 14:17:15 +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.
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
2021-04-04 01:02:33 +08:00
|
|
|
using osu.Framework.Localisation;
|
2020-10-06 14:17:15 +08:00
|
|
|
using osu.Game.Graphics.UserInterfaceV2;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Edit.Setup
|
|
|
|
{
|
|
|
|
internal class MetadataSection : SetupSection
|
|
|
|
{
|
|
|
|
private LabelledTextBox artistTextBox;
|
|
|
|
private LabelledTextBox titleTextBox;
|
|
|
|
private LabelledTextBox creatorTextBox;
|
|
|
|
private LabelledTextBox difficultyTextBox;
|
|
|
|
|
2021-04-04 01:02:33 +08:00
|
|
|
public override LocalisableString Title => "Metadata";
|
|
|
|
|
2020-10-06 14:17:15 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
2020-10-06 18:26:57 +08:00
|
|
|
Children = new Drawable[]
|
2020-10-06 14:17:15 +08:00
|
|
|
{
|
2021-06-10 19:55:34 +08:00
|
|
|
artistTextBox = createTextBox("Artist", Beatmap.Metadata.Artist),
|
|
|
|
titleTextBox = createTextBox("Title", Beatmap.Metadata.Title),
|
|
|
|
creatorTextBox = createTextBox("Creator", Beatmap.Metadata.AuthorString),
|
|
|
|
difficultyTextBox = createTextBox("Difficulty Name", Beatmap.BeatmapInfo.Version)
|
2020-10-06 14:17:15 +08:00
|
|
|
};
|
|
|
|
|
2020-10-06 18:26:57 +08:00
|
|
|
foreach (var item in Children.OfType<LabelledTextBox>())
|
2020-10-06 14:17:15 +08:00
|
|
|
item.OnCommit += onCommit;
|
|
|
|
}
|
|
|
|
|
2021-06-10 19:55:34 +08:00
|
|
|
private LabelledTextBox createTextBox(string label, string initialValue) => new LabelledTextBox
|
|
|
|
{
|
|
|
|
Label = label,
|
|
|
|
FixedLabelWidth = LABEL_WIDTH,
|
|
|
|
Current = { Value = initialValue },
|
|
|
|
TabbableContentContainer = this
|
|
|
|
};
|
|
|
|
|
2021-03-17 15:57:14 +08:00
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(artistTextBox.Current.Value))
|
|
|
|
GetContainingInputManager().ChangeFocus(artistTextBox);
|
|
|
|
}
|
|
|
|
|
2020-10-06 14:17:15 +08:00
|
|
|
private void onCommit(TextBox sender, bool newText)
|
|
|
|
{
|
|
|
|
if (!newText) return;
|
|
|
|
|
|
|
|
// for now, update these on commit rather than making BeatmapMetadata bindables.
|
|
|
|
// after switching database engines we can reconsider if switching to bindables is a good direction.
|
2021-01-04 15:47:08 +08:00
|
|
|
Beatmap.Metadata.Artist = artistTextBox.Current.Value;
|
|
|
|
Beatmap.Metadata.Title = titleTextBox.Current.Value;
|
|
|
|
Beatmap.Metadata.AuthorString = creatorTextBox.Current.Value;
|
|
|
|
Beatmap.BeatmapInfo.Version = difficultyTextBox.Current.Value;
|
2020-10-06 14:17:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|