osu/osu.Game/Screens/Edit/Setup/SetupScreen.cs

108 lines
4.3 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.
2020-09-08 10:28:20 +00:00
using System.Linq;
2020-09-07 10:21:35 +00:00
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
2020-09-08 10:28:20 +00:00
using osu.Framework.Graphics.UserInterface;
2020-09-07 10:21:35 +00:00
using osu.Game.Beatmaps.Drawables;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterfaceV2;
using osuTK;
namespace osu.Game.Screens.Edit.Setup
{
public class SetupScreen : EditorScreen
{
2020-09-08 10:28:20 +00:00
private FillFlowContainer flow;
private LabelledTextBox artistTextBox;
private LabelledTextBox titleTextBox;
private LabelledTextBox creatorTextBox;
private LabelledTextBox difficultyTextBox;
2020-09-07 10:21:35 +00:00
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
2020-09-07 10:21:35 +00:00
Children = new Drawable[]
{
new Box
{
Colour = colours.Gray0,
2020-09-08 10:28:20 +00:00
Alpha = 0.4f,
2020-09-07 10:21:35 +00:00
RelativeSizeAxes = Axes.Both,
},
new OsuScrollContainer
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding(50),
2020-09-08 10:28:20 +00:00
Child = flow = new FillFlowContainer
2020-09-07 10:21:35 +00:00
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Spacing = new Vector2(20),
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
new Container
{
RelativeSizeAxes = Axes.X,
Height = 250,
Masking = true,
CornerRadius = 50,
Child = new BeatmapBackgroundSprite(Beatmap.Value)
{
RelativeSizeAxes = Axes.Both,
FillMode = FillMode.Fill,
},
},
new OsuSpriteText
{
Text = "Beatmap metadata"
},
2020-09-08 10:28:20 +00:00
artistTextBox = new LabelledTextBox
2020-09-07 10:21:35 +00:00
{
Label = "Artist",
Current = { Value = Beatmap.Value.Metadata.Artist }
},
2020-09-08 10:28:20 +00:00
titleTextBox = new LabelledTextBox
2020-09-07 10:21:35 +00:00
{
Label = "Title",
Current = { Value = Beatmap.Value.Metadata.Title }
},
2020-09-08 10:28:20 +00:00
creatorTextBox = new LabelledTextBox
2020-09-07 10:21:35 +00:00
{
Label = "Creator",
Current = { Value = Beatmap.Value.Metadata.AuthorString }
},
2020-09-08 10:28:20 +00:00
difficultyTextBox = new LabelledTextBox
2020-09-07 10:21:35 +00:00
{
Label = "Difficulty Name",
Current = { Value = Beatmap.Value.BeatmapInfo.Version }
},
}
},
},
};
2020-09-08 10:28:20 +00:00
foreach (var item in flow.OfType<LabelledTextBox>())
item.OnCommit += onCommit;
}
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.
Beatmap.Value.Metadata.Artist = artistTextBox.Current.Value;
Beatmap.Value.Metadata.Title = titleTextBox.Current.Value;
Beatmap.Value.Metadata.AuthorString = creatorTextBox.Current.Value;
Beatmap.Value.BeatmapInfo.Version = difficultyTextBox.Current.Value;
}
}
}