Use GetAsync on all textures

This commit is contained in:
smoogipoo
2018-08-27 17:26:44 +09:00
parent 21d5322899
commit 1b279d383f
28 changed files with 92 additions and 67 deletions

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -24,14 +25,14 @@ namespace osu.Game.Users
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
private async Task load(TextureStore textures)
{
if (textures == null)
throw new ArgumentNullException(nameof(textures));
Texture texture = null;
if (user != null && user.Id > 1) texture = textures.Get($@"https://a.ppy.sh/{user.Id}");
if (texture == null) texture = textures.Get(@"Online/avatar-guest");
if (user != null && user.Id > 1) texture = await textures.GetAsync($@"https://a.ppy.sh/{user.Id}");
if (texture == null) texture = await textures.GetAsync(@"Online/avatar-guest");
Add(new Sprite
{

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Threading.Tasks;
using Newtonsoft.Json;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
@ -44,7 +45,7 @@ namespace osu.Game.Users
country = value;
if (LoadState >= LoadState.Ready)
sprite.Texture = getFlagTexture();
sprite.Texture = getFlagTexture().Result;
}
}
@ -64,15 +65,15 @@ namespace osu.Game.Users
}
[BackgroundDependencyLoader]
private void load(TextureStore ts)
private async Task load(TextureStore ts)
{
if (ts == null)
throw new ArgumentNullException(nameof(ts));
textures = ts;
sprite.Texture = getFlagTexture();
sprite.Texture = await getFlagTexture();
}
private Texture getFlagTexture() => textures.Get($@"Flags/{country?.FlagName ?? @"__"}");
private async Task<Texture> getFlagTexture() => await textures.GetAsync($@"Flags/{country?.FlagName ?? @"__"}");
}
}

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
@ -18,13 +19,13 @@ namespace osu.Game.Users
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
private async Task load(TextureStore textures)
{
if (textures == null)
throw new ArgumentNullException(nameof(textures));
if (!string.IsNullOrEmpty(user.CoverUrl))
Texture = textures.Get(user.CoverUrl);
Texture = await textures.GetAsync(user.CoverUrl);
}
}
}