diff --git a/osu.Game/Beatmaps/Drawables/BeatmapBackgroundSprite.cs b/osu.Game/Beatmaps/Drawables/BeatmapBackgroundSprite.cs new file mode 100644 index 0000000000..e90829873f --- /dev/null +++ b/osu.Game/Beatmaps/Drawables/BeatmapBackgroundSprite.cs @@ -0,0 +1,24 @@ +//Copyright (c) 2007-2016 ppy Pty Ltd . +//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Framework.Graphics.Sprites; + +namespace osu.Game.Beatmaps.Drawables +{ + class BeatmapBackgroundSprite : Sprite + { + private readonly WorkingBeatmap working; + + public BeatmapBackgroundSprite(WorkingBeatmap working) + { + this.working = working; + } + + [BackgroundDependencyLoader] + private void load(OsuGameBase game) + { + Texture = working.Background; + } + } +} diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs index 709885d132..9ab9aaf9f5 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs @@ -156,38 +156,17 @@ namespace osu.Game.Beatmaps.Drawables [BackgroundDependencyLoader] private void load(OsuGameBase game) { - new BeatmapBackground(working) + new BeatmapBackgroundSprite(working) { Anchor = Anchor.Centre, Origin = Anchor.Centre, + FillMode = FillMode.Fill, }.Preload(game, (bg) => { Add(bg); ForceRedraw(); }); } - - class BeatmapBackground : Sprite - { - private readonly WorkingBeatmap working; - - public BeatmapBackground(WorkingBeatmap working) - { - this.working = working; - } - - [BackgroundDependencyLoader] - private void load(OsuGameBase game) - { - Texture = working.Background; - } - - protected override void LoadComplete() - { - base.LoadComplete(); - Scale = new Vector2(1366 / (Texture?.Width ?? 1) * 0.6f); - } - } } } } \ No newline at end of file diff --git a/osu.Game/Screens/Select/BeatmapInfoWedge.cs b/osu.Game/Screens/Select/BeatmapInfoWedge.cs index 1e12f03749..c6ed202326 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedge.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedge.cs @@ -1,4 +1,6 @@ using System; +using osu.Framework; +using osu.Framework.Allocation; using OpenTK; using OpenTK.Graphics; using osu.Framework.Graphics; @@ -8,31 +10,37 @@ using osu.Framework.Graphics.Sprites; using osu.Game.Beatmaps; using osu.Game.Database; using osu.Framework.Graphics.Colour; +using osu.Game.Beatmaps.Drawables; namespace osu.Game.Screens.Select { - class BeatmapInfoOverlay : Container + class BeatmapInfoWedge : Container { private Container beatmapInfoContainer; + private BaseGame game; + + [BackgroundDependencyLoader] + private void load(BaseGame game) + { + this.game = game; + } + public void UpdateBeatmap(WorkingBeatmap beatmap) { if (beatmap == null) return; - float newDepth = 0; - if (beatmapInfoContainer != null) - { - newDepth = beatmapInfoContainer.Depth - 1; - beatmapInfoContainer.FadeOut(250); - beatmapInfoContainer.Expire(); - } + var lastContainer = beatmapInfoContainer; + + float newDepth = lastContainer?.Depth - 1 ?? 0; FadeIn(250); BeatmapSetInfo beatmapSetInfo = beatmap.BeatmapSetInfo; BeatmapInfo beatmapInfo = beatmap.BeatmapInfo; - Add(beatmapInfoContainer = new BufferedContainer + + (beatmapInfoContainer = new BufferedContainer { Depth = newDepth, PixelSnapping = true, @@ -51,18 +59,17 @@ namespace osu.Game.Screens.Select }, // 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. - beatmap.Background == null ? new Container() : new Container + new Container { RelativeSizeAxes = Axes.Both, ColourInfo = ColourInfo.GradientVertical(Color4.White, new Color4(1f, 1f, 1f, 0.3f)), Children = new [] { // Zoomed-in and cropped beatmap background - new Sprite + new BeatmapBackgroundSprite(beatmap) { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Texture = beatmap.Background, FillMode = FillMode.Fill, }, }, @@ -117,6 +124,12 @@ namespace osu.Game.Screens.Select } } } + }).Preload(game, delegate(Drawable d) + { + lastContainer?.FadeOut(250); + lastContainer?.Expire(); + + Add(d); }); } } diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index ba06b797ef..76ecdcb64e 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -40,7 +40,7 @@ namespace osu.Game.Screens.Select private static readonly Vector2 wedged_container_size = new Vector2(0.5f, 225); private static readonly Vector2 wedged_container_shear = new Vector2(0.15f, 0); private static readonly Vector2 wedged_container_start_position = new Vector2(0, 50); - private BeatmapInfoWedge wedgedBeatmapInfoWedge; + private BeatmapInfoWedge beatmapInfoWedge; private static readonly Vector2 BACKGROUND_BLUR = new Vector2(20); private CancellationTokenSource initialAddSetsTask; @@ -102,7 +102,7 @@ namespace osu.Game.Screens.Select Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, }, - wedgedBeatmapInfoWedge = new BeatmapInfoWedge + beatmapInfoWedge = new BeatmapInfoWedge { Alpha = 0, Position = wedged_container_start_position, @@ -239,7 +239,7 @@ namespace osu.Game.Screens.Select (Background as BackgroundModeBeatmap)?.BlurTo(BACKGROUND_BLUR, 1000); } - wedgedBeatmapInfoWedge.UpdateBeatmap(beatmap); + beatmapInfoWedge.UpdateBeatmap(beatmap); } /// diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 9cb1535981..9c2bbf086a 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -63,6 +63,7 @@ + @@ -159,7 +160,7 @@ - +