1
0
mirror of https://github.com/ppy/osu.git synced 2026-06-13 16:04:43 +08:00
Files
osu-lazer/osu.Game/Screens/Edit/Setup/SetupScreenBackgroundPreview.cs
T
Bartłomiej Dach f5c70679f5 Add ability to add videos in editor (#37857)
https://github.com/user-attachments/assets/bc329cca-dfa1-4149-9760-121626cf1cb4

---

- Closes https://github.com/ppy/osu/issues/36326

Currently lacks the ability to specify custom video offset that isn't
manual .osu editing (defaults to 0) but I'm starting here and listening
to requirements.

---------

Co-authored-by: Dean Herbert <pe@ppy.sh>
2026-05-22 17:21:06 +09:00

79 lines
2.4 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 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;
using osu.Game.Localisation;
namespace osu.Game.Screens.Edit.Setup
{
public partial class SetupScreenBackgroundPreview : CompositeDrawable
{
[Resolved]
private OsuColour colours { get; set; } = null!;
[Resolved]
private IBindable<WorkingBeatmap> working { get; set; } = null!;
private readonly Container content;
public SetupScreenBackgroundPreview()
{
InternalChild = content = new Container
{
RelativeSizeAxes = Axes.Both,
Masking = true,
CornerRadius = 3.5f,
};
}
[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,
RelativeSizeAxes = Axes.Both,
},
new OsuTextFlowContainer(t => t.Font = OsuFont.Default.With(size: 24))
{
Text = EditorSetupStrings.DragToSetBackground,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
AutoSizeAxes = Axes.Both
}
};
}
background.FadeInFromZero(500);
});
}
}
}