1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-18 09:32:53 +08:00
osu-lazer/osu.Game/Screens/Edit/Setup/SetupScreenHeaderBackground.cs

78 lines
2.4 KiB
C#
Raw Normal View History

2021-04-04 18:50:50 +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 osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
2023-01-15 06:49:19 +08:00
using osu.Game.Localisation;
2021-04-04 18:50:50 +08:00
namespace osu.Game.Screens.Edit.Setup
{
2022-11-24 13:32:20 +08:00
public partial class SetupScreenHeaderBackground : CompositeDrawable
2021-04-04 18:50:50 +08:00
{
[Resolved]
2023-01-14 07:24:28 +08:00
private OsuColour colours { get; set; } = null!;
2021-04-04 18:50:50 +08:00
[Resolved]
2023-01-14 07:24:28 +08:00
private IBindable<WorkingBeatmap> working { get; set; } = null!;
2021-04-04 18:50:50 +08:00
private readonly Container content;
public SetupScreenHeaderBackground()
{
InternalChild = content = new Container
{
RelativeSizeAxes = Axes.Both,
Masking = true
};
}
[BackgroundDependencyLoader]
private void load()
{
UpdateBackground();
}
public void UpdateBackground()
{
LoadComponentAsync(new BeatmapBackgroundSprite(working.Value)
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
FillMode = FillMode.Fill,
}, background =>
{
if (background.Texture != null)
content.Child = background;
else
{
content.Children = new Drawable[]
{
new Box
{
Colour = colours.GreySeaFoamDarker,
2021-04-04 18:50:50 +08:00
RelativeSizeAxes = Axes.Both,
},
new OsuTextFlowContainer(t => t.Font = OsuFont.Default.With(size: 24))
{
2023-01-15 06:49:19 +08:00
Text = EditorSetupStrings.DragToSetBackground,
2021-04-04 18:50:50 +08:00
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
AutoSizeAxes = Axes.Both
}
};
}
background.FadeInFromZero(500);
});
}
}
}