1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 12:33:01 +08:00

Refactored background of BeatmapInfoWedge

This commit is contained in:
Denrage 2021-04-21 14:16:16 +02:00
parent d6928e91fd
commit 0dfd0bb59d
3 changed files with 68 additions and 57 deletions

View File

@ -193,8 +193,6 @@ namespace osu.Game.Tests.Visual.SongSelect
private class TestBeatmapInfoWedge : BeatmapInfoWedge
{
public new BufferedWedgeBackground Background => base.Background;
public new WedgeInfoText Info => base.Info;
public new BeatmapInfoWedgeContainer Container => base.Container;

View File

@ -11,7 +11,6 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
@ -43,7 +42,6 @@ namespace osu.Game.Screens.Select
protected BeatmapInfoWedgeContainer Container;
protected WedgeInfoText Info => Container.Info;
protected BufferedWedgeBackground Background => Container.Background;
public BeatmapInfoWedge()
{
@ -123,6 +121,7 @@ namespace osu.Game.Screens.Select
LoadComponentAsync(loadingInfo = new BeatmapInfoWedgeContainer(beatmap, ruleset.Value)
{
Shear = -Shear,
Depth = Container?.Depth + 1 ?? 0,
}, loaded =>
{
// ensure we are the most recent loaded wedge.
@ -139,7 +138,6 @@ namespace osu.Game.Screens.Select
private readonly WorkingBeatmap beatmap;
private readonly RulesetInfo ruleset;
internal BufferedWedgeBackground Background;
internal WedgeInfoText Info;
public BeatmapInfoWedgeContainer(WorkingBeatmap beatmap, RulesetInfo ruleset)
@ -155,10 +153,7 @@ namespace osu.Game.Screens.Select
Children = new Drawable[]
{
Background = new BufferedWedgeBackground(beatmap)
{
Depth = Background?.Depth + 1 ?? 0,
},
new BeatmapInfoWedgeBackground(beatmap),
Info = new WedgeInfoText(beatmap, ruleset),
};
}
@ -572,53 +567,5 @@ namespace osu.Game.Screens.Select
settingChangeTracker?.Dispose();
}
}
public class BufferedWedgeBackground : BufferedContainer
{
private readonly WorkingBeatmap beatmap;
public BufferedWedgeBackground(WorkingBeatmap beatmap)
: base(pixelSnapping: true)
{
this.beatmap = beatmap;
}
[BackgroundDependencyLoader]
private void load(LocalisationManager localisation)
{
CacheDrawnFrameBuffer = true;
RelativeSizeAxes = Axes.Both;
Children = new Drawable[]
{
// We will create the white-to-black gradient by modulating transparency and having
// a black backdrop. This results in an sRGB-space gradient and not linear space,
// transitioning from white to black more perceptually uniformly.
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
},
// We use a container, such that we can set the colour gradient to go across the
// vertices of the masked container instead of the vertices of the (larger) sprite.
new Container
{
RelativeSizeAxes = Axes.Both,
Colour = ColourInfo.GradientVertical(Color4.White, Color4.White.Opacity(0.3f)),
Children = new[]
{
// Zoomed-in and cropped beatmap background
new BeatmapBackgroundSprite(beatmap)
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
FillMode = FillMode.Fill,
},
},
},
};
}
}
}
}

View File

@ -0,0 +1,66 @@
// 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 osuTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables;
using osu.Framework.Graphics.Shapes;
namespace osu.Game.Screens.Select
{
internal class BeatmapInfoWedgeBackground : CompositeDrawable
{
private readonly WorkingBeatmap beatmap;
public BeatmapInfoWedgeBackground(WorkingBeatmap beatmap)
{
this.beatmap = beatmap;
}
[BackgroundDependencyLoader]
private void load()
{
RelativeSizeAxes = Axes.Both;
InternalChild = new BufferedContainer(pixelSnapping: true)
{
CacheDrawnFrameBuffer = true,
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
// We will create the white-to-black gradient by modulating transparency and having
// a black backdrop. This results in an sRGB-space gradient and not linear space,
// transitioning from white to black more perceptually uniformly.
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
},
// We use a container, such that we can set the colour gradient to go across the
// vertices of the masked container instead of the vertices of the (larger) sprite.
new Container
{
RelativeSizeAxes = Axes.Both,
Colour = ColourInfo.GradientVertical(Color4.White, Color4.White.Opacity(0.3f)),
Children = new[]
{
// Zoomed-in and cropped beatmap background
new BeatmapBackgroundSprite(beatmap)
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
FillMode = FillMode.Fill,
},
},
},
}
};
}
}
}