From fea40ccc1a0543d80bd7bfdf57053bc3b1e98dbe Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 13 Jul 2017 01:17:47 -0300 Subject: [PATCH] Share BeatmapSet cover sprite code. --- .../Beatmaps/Drawables/BeatmapSetCover.cs | 28 +++++++++++++++++++ osu.Game/Overlays/Direct/DirectPanel.cs | 22 +-------------- osu.Game/Screens/Multiplayer/DrawableRoom.cs | 24 +--------------- osu.Game/osu.Game.csproj | 1 + 4 files changed, 31 insertions(+), 44 deletions(-) create mode 100644 osu.Game/Beatmaps/Drawables/BeatmapSetCover.cs diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetCover.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetCover.cs new file mode 100644 index 0000000000..502ac59d46 --- /dev/null +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetCover.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2007-2017 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; +using osu.Framework.Graphics.Textures; +using osu.Game.Database; + +namespace osu.Game +{ + public class BeatmapSetCover : Sprite + { + private readonly BeatmapSetInfo set; + public BeatmapSetCover(BeatmapSetInfo set) + { + this.set = set; + } + + [BackgroundDependencyLoader] + private void load(TextureStore textures) + { + string resource = set.OnlineInfo.Covers.Cover; + + if (resource != null) + Texture = textures.Get(resource); + } + } +} diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index 02b6e32192..4fc9a922a8 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -3,11 +3,9 @@ using System.Collections.Generic; using OpenTK; -using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Textures; using osu.Game.Beatmaps.Drawables; using osu.Game.Database; using osu.Game.Graphics; @@ -34,7 +32,7 @@ namespace osu.Game.Overlays.Direct return icons; } - protected Drawable CreateBackground() => new DelayedLoadWrapper(new BeatmapSetBackgroundSprite(SetInfo) + protected Drawable CreateBackground() => new DelayedLoadWrapper(new BeatmapSetCover(SetInfo) { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -89,23 +87,5 @@ namespace osu.Game.Overlays.Direct Value = value; } } - - private class BeatmapSetBackgroundSprite : Sprite - { - private readonly BeatmapSetInfo set; - public BeatmapSetBackgroundSprite(BeatmapSetInfo set) - { - this.set = set; - } - - [BackgroundDependencyLoader] - private void load(TextureStore textures) - { - string resource = set.OnlineInfo.Covers.Card; - - if (resource != null) - Texture = textures.Get(resource); - } - } } } diff --git a/osu.Game/Screens/Multiplayer/DrawableRoom.cs b/osu.Game/Screens/Multiplayer/DrawableRoom.cs index 8e17adc490..f8c1844615 100644 --- a/osu.Game/Screens/Multiplayer/DrawableRoom.cs +++ b/osu.Game/Screens/Multiplayer/DrawableRoom.cs @@ -9,10 +9,8 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Framework.Localisation; -using osu.Game.Beatmaps.Drawables; using osu.Game.Database; using osu.Game.Graphics; using osu.Game.Graphics.Containers; @@ -45,7 +43,6 @@ namespace osu.Game.Screens.Multiplayer private readonly Bindable participantsBind = new Bindable(); private OsuColour colours; - private TextureStore textures; private LocalisationEngine localisation; public readonly Room Room; @@ -188,7 +185,6 @@ namespace osu.Game.Screens.Multiplayer private void load(OsuColour colours, TextureStore textures, LocalisationEngine localisation) { this.localisation = localisation; - this.textures = textures; this.colours = colours; beatmapInfoFlow.Colour = colours.Gray9; @@ -234,7 +230,7 @@ namespace osu.Game.Screens.Multiplayer coverContainer.FadeIn(transition_duration); coverContainer.Children = new[] { - new AsyncLoadWrapper(new BeatmapSetBackgroundSprite(value.BeatmapSet) + new AsyncLoadWrapper(new BeatmapSetCover(value.BeatmapSet) { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -263,23 +259,5 @@ namespace osu.Game.Screens.Multiplayer { participantInfo.Participants = value; } - - private class BeatmapSetBackgroundSprite : Sprite - { - private readonly BeatmapSetInfo set; - public BeatmapSetBackgroundSprite(BeatmapSetInfo set) - { - this.set = set; - } - - [BackgroundDependencyLoader] - private void load(TextureStore textures) - { - string resource = set.OnlineInfo.Covers.Cover; - - if (resource != null) - Texture = textures.Get(resource); - } - } } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index fc21cbafc0..da3f8fa2eb 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -494,6 +494,7 @@ +