mirror of
https://github.com/ppy/osu.git
synced 2025-01-19 17:03:02 +08:00
Update SpriteIcon
This commit is contained in:
parent
919e78a89a
commit
73c764d983
@ -2,6 +2,7 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
@ -24,7 +25,7 @@ namespace osu.Game.Graphics
|
|||||||
private FontStore store;
|
private FontStore store;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(FontStore store)
|
private async Task load(FontStore store)
|
||||||
{
|
{
|
||||||
this.store = store;
|
this.store = store;
|
||||||
|
|
||||||
@ -55,23 +56,23 @@ namespace osu.Game.Graphics
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
updateTexture();
|
await updateTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
updateTexture();
|
updateTexture().Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
private FontAwesome loadedIcon;
|
private FontAwesome loadedIcon;
|
||||||
private void updateTexture()
|
private async Task updateTexture()
|
||||||
{
|
{
|
||||||
var loadableIcon = icon;
|
var loadableIcon = icon;
|
||||||
|
|
||||||
if (loadableIcon == loadedIcon) return;
|
if (loadableIcon == loadedIcon) return;
|
||||||
|
|
||||||
var texture = store?.Get(((char)loadableIcon).ToString());
|
var texture = await store.GetAsync(((char)loadableIcon).ToString());
|
||||||
|
|
||||||
spriteMain.Texture = texture;
|
spriteMain.Texture = texture;
|
||||||
spriteShadow.Texture = texture;
|
spriteShadow.Texture = texture;
|
||||||
@ -129,8 +130,8 @@ namespace osu.Game.Graphics
|
|||||||
if (icon == value) return;
|
if (icon == value) return;
|
||||||
|
|
||||||
icon = value;
|
icon = value;
|
||||||
if (IsLoaded)
|
if (LoadState == LoadState.Loaded)
|
||||||
updateTexture();
|
updateTexture().Wait();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user