From f2d302f8dcb77f23021286738c2c2d0dd5176d70 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 31 Dec 2017 06:40:28 +0900 Subject: [PATCH 1/2] Create a LargeTextureStore for cached (but not atlased) global textures Also - Fixes first transition depth being incorrect. - Improves smoothness of transitions (and adds a slight delay to offset from screen switches). --- osu.Game/Beatmaps/BeatmapManager.cs | 3 ++- osu.Game/Graphics/Backgrounds/Background.cs | 5 ++--- .../Graphics/Textures/LargeTextureStore.cs | 18 ++++++++++++++++++ osu.Game/OsuGameBase.cs | 6 ++++++ .../Backgrounds/BackgroundScreenDefault.cs | 13 ++++++++++--- osu.Game/osu.Game.csproj | 1 + 6 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 osu.Game/Graphics/Textures/LargeTextureStore.cs diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index c86860f7b0..ceeac516e1 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -19,6 +19,7 @@ using osu.Game.Beatmaps.Formats; using osu.Game.Beatmaps.IO; using osu.Game.Database; using osu.Game.Graphics; +using osu.Game.Graphics.Textures; using osu.Game.IO; using osu.Game.IPC; using osu.Game.Online.API; @@ -651,7 +652,7 @@ namespace osu.Game.Beatmaps try { - return new TextureStore(new RawTextureLoaderStore(store), false).Get(getPathForFile(Metadata.BackgroundFile)); + return new LargeTextureStore(new RawTextureLoaderStore(store)).Get(getPathForFile(Metadata.BackgroundFile)); } catch { diff --git a/osu.Game/Graphics/Backgrounds/Background.cs b/osu.Game/Graphics/Backgrounds/Background.cs index 8eb2ddc0ab..4fb08a41f3 100644 --- a/osu.Game/Graphics/Backgrounds/Background.cs +++ b/osu.Game/Graphics/Backgrounds/Background.cs @@ -5,8 +5,8 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Textures; using OpenTK.Graphics; +using osu.Game.Graphics.Textures; namespace osu.Game.Graphics.Backgrounds { @@ -22,7 +22,6 @@ namespace osu.Game.Graphics.Backgrounds this.textureName = textureName; RelativeSizeAxes = Axes.Both; - Depth = float.MaxValue; Add(Sprite = new Sprite { @@ -35,7 +34,7 @@ namespace osu.Game.Graphics.Backgrounds } [BackgroundDependencyLoader] - private void load(TextureStore textures) + private void load(LargeTextureStore textures) { if (!string.IsNullOrEmpty(textureName)) Sprite.Texture = textures.Get(textureName); diff --git a/osu.Game/Graphics/Textures/LargeTextureStore.cs b/osu.Game/Graphics/Textures/LargeTextureStore.cs new file mode 100644 index 0000000000..166364c8dd --- /dev/null +++ b/osu.Game/Graphics/Textures/LargeTextureStore.cs @@ -0,0 +1,18 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics.Textures; +using osu.Framework.IO.Stores; + +namespace osu.Game.Graphics.Textures +{ + /// + /// A texture store that bypasses atlasing. + /// + public class LargeTextureStore : TextureStore + { + public LargeTextureStore(IResourceStore store = null) : base(store, false) + { + } + } +} diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index ea0bf22112..bba09f3257 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -18,8 +18,10 @@ using osu.Game.Graphics; using osu.Game.Graphics.Cursor; using osu.Game.Online.API; using osu.Framework.Graphics.Performance; +using osu.Framework.Graphics.Textures; using osu.Framework.Logging; using osu.Game.Database; +using osu.Game.Graphics.Textures; using osu.Game.Input; using osu.Game.Input.Bindings; using osu.Game.IO; @@ -84,11 +86,15 @@ namespace osu.Game private DatabaseContextFactory contextFactory; + private LargeTextureStore largeTextureStore; + [BackgroundDependencyLoader] private void load() { dependencies.Cache(contextFactory = new DatabaseContextFactory(Host)); + dependencies.Cache(largeTextureStore = new LargeTextureStore(new RawTextureLoaderStore(new NamespacedResourceStore(Resources, @"Textures")))); + dependencies.Cache(this); dependencies.Cache(LocalConfig); diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs index de84e90baf..36867a84d5 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs @@ -3,6 +3,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; +using osu.Framework.Threading; using osu.Game.Graphics.Backgrounds; namespace osu.Game.Screens.Backgrounds @@ -24,16 +25,22 @@ namespace osu.Game.Screens.Backgrounds private void display(Background newBackground) { - current?.FadeOut(800, Easing.OutQuint); + current?.FadeOut(800, Easing.InOutSine); current?.Expire(); Add(current = newBackground); + currentDisplay++; } + private ScheduledDelegate nextTask; + public void Next() { - currentDisplay++; - LoadComponentAsync(new Background(backgroundName) { Depth = currentDisplay }, display); + nextTask?.Cancel(); + nextTask = Scheduler.AddDelayed(() => + { + LoadComponentAsync(new Background(backgroundName) { Depth = currentDisplay }, display); + }, 100); } } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 82b9f41567..bbdc8b8b76 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -267,6 +267,7 @@ + From 94b761e63e9b935914f94d1c18b0f438d30e3567 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 31 Dec 2017 12:22:17 +0900 Subject: [PATCH 2/2] Remove local storage for now --- osu.Game/OsuGameBase.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index bba09f3257..e311aea8e4 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -86,14 +86,12 @@ namespace osu.Game private DatabaseContextFactory contextFactory; - private LargeTextureStore largeTextureStore; - [BackgroundDependencyLoader] private void load() { dependencies.Cache(contextFactory = new DatabaseContextFactory(Host)); - dependencies.Cache(largeTextureStore = new LargeTextureStore(new RawTextureLoaderStore(new NamespacedResourceStore(Resources, @"Textures")))); + dependencies.Cache(new LargeTextureStore(new RawTextureLoaderStore(new NamespacedResourceStore(Resources, @"Textures")))); dependencies.Cache(this); dependencies.Cache(LocalConfig);