1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 08:32:57 +08:00

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).
This commit is contained in:
Dean Herbert 2017-12-31 06:40:28 +09:00
parent 398d90ee52
commit f2d302f8dc
6 changed files with 39 additions and 7 deletions

View File

@ -19,6 +19,7 @@ using osu.Game.Beatmaps.Formats;
using osu.Game.Beatmaps.IO; using osu.Game.Beatmaps.IO;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Textures;
using osu.Game.IO; using osu.Game.IO;
using osu.Game.IPC; using osu.Game.IPC;
using osu.Game.Online.API; using osu.Game.Online.API;
@ -651,7 +652,7 @@ namespace osu.Game.Beatmaps
try try
{ {
return new TextureStore(new RawTextureLoaderStore(store), false).Get(getPathForFile(Metadata.BackgroundFile)); return new LargeTextureStore(new RawTextureLoaderStore(store)).Get(getPathForFile(Metadata.BackgroundFile));
} }
catch catch
{ {

View File

@ -5,8 +5,8 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Game.Graphics.Textures;
namespace osu.Game.Graphics.Backgrounds namespace osu.Game.Graphics.Backgrounds
{ {
@ -22,7 +22,6 @@ namespace osu.Game.Graphics.Backgrounds
this.textureName = textureName; this.textureName = textureName;
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
Depth = float.MaxValue;
Add(Sprite = new Sprite Add(Sprite = new Sprite
{ {
@ -35,7 +34,7 @@ namespace osu.Game.Graphics.Backgrounds
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(TextureStore textures) private void load(LargeTextureStore textures)
{ {
if (!string.IsNullOrEmpty(textureName)) if (!string.IsNullOrEmpty(textureName))
Sprite.Texture = textures.Get(textureName); Sprite.Texture = textures.Get(textureName);

View File

@ -0,0 +1,18 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// 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
{
/// <summary>
/// A texture store that bypasses atlasing.
/// </summary>
public class LargeTextureStore : TextureStore
{
public LargeTextureStore(IResourceStore<RawTexture> store = null) : base(store, false)
{
}
}
}

View File

@ -18,8 +18,10 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Cursor; using osu.Game.Graphics.Cursor;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Framework.Graphics.Performance; using osu.Framework.Graphics.Performance;
using osu.Framework.Graphics.Textures;
using osu.Framework.Logging; using osu.Framework.Logging;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Graphics.Textures;
using osu.Game.Input; using osu.Game.Input;
using osu.Game.Input.Bindings; using osu.Game.Input.Bindings;
using osu.Game.IO; using osu.Game.IO;
@ -84,11 +86,15 @@ namespace osu.Game
private DatabaseContextFactory contextFactory; private DatabaseContextFactory contextFactory;
private LargeTextureStore largeTextureStore;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
dependencies.Cache(contextFactory = new DatabaseContextFactory(Host)); dependencies.Cache(contextFactory = new DatabaseContextFactory(Host));
dependencies.Cache(largeTextureStore = new LargeTextureStore(new RawTextureLoaderStore(new NamespacedResourceStore<byte[]>(Resources, @"Textures"))));
dependencies.Cache(this); dependencies.Cache(this);
dependencies.Cache(LocalConfig); dependencies.Cache(LocalConfig);

View File

@ -3,6 +3,7 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Threading;
using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Backgrounds;
namespace osu.Game.Screens.Backgrounds namespace osu.Game.Screens.Backgrounds
@ -24,16 +25,22 @@ namespace osu.Game.Screens.Backgrounds
private void display(Background newBackground) private void display(Background newBackground)
{ {
current?.FadeOut(800, Easing.OutQuint); current?.FadeOut(800, Easing.InOutSine);
current?.Expire(); current?.Expire();
Add(current = newBackground); Add(current = newBackground);
currentDisplay++;
} }
private ScheduledDelegate nextTask;
public void Next() public void Next()
{ {
currentDisplay++; nextTask?.Cancel();
LoadComponentAsync(new Background(backgroundName) { Depth = currentDisplay }, display); nextTask = Scheduler.AddDelayed(() =>
{
LoadComponentAsync(new Background(backgroundName) { Depth = currentDisplay }, display);
}, 100);
} }
} }
} }

View File

@ -267,6 +267,7 @@
<Compile Include="Beatmaps\Formats\LegacyStoryboardDecoder.cs" /> <Compile Include="Beatmaps\Formats\LegacyStoryboardDecoder.cs" />
<Compile Include="Database\DatabaseContextFactory.cs" /> <Compile Include="Database\DatabaseContextFactory.cs" />
<Compile Include="Database\IHasPrimaryKey.cs" /> <Compile Include="Database\IHasPrimaryKey.cs" />
<Compile Include="Graphics\Textures\LargeTextureStore.cs" />
<Compile Include="Overlays\Profile\SupporterIcon.cs" /> <Compile Include="Overlays\Profile\SupporterIcon.cs" />
<Compile Include="Overlays\Settings\DangerousSettingsButton.cs" /> <Compile Include="Overlays\Settings\DangerousSettingsButton.cs" />
<Compile Include="Graphics\UserInterface\HoverClickSounds.cs" /> <Compile Include="Graphics\UserInterface\HoverClickSounds.cs" />