mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 07:47:25 +08:00
Merge pull request #1581 from peppy/fix-sprite-icon
Fix SpriteIcon potentially not updating texture during a load race condition
This commit is contained in:
commit
d6ba5685cf
@ -57,19 +57,31 @@ namespace osu.Game.Graphics
|
||||
private void load(FontStore store)
|
||||
{
|
||||
this.store = store;
|
||||
|
||||
updateTexture();
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
updateTexture();
|
||||
}
|
||||
|
||||
private FontAwesome loadedIcon;
|
||||
private void updateTexture()
|
||||
{
|
||||
var texture = store?.Get(((char)icon).ToString());
|
||||
var loadableIcon = icon;
|
||||
|
||||
if (loadableIcon == loadedIcon) return;
|
||||
|
||||
var texture = store?.Get(((char)loadableIcon).ToString());
|
||||
|
||||
spriteMain.Texture = texture;
|
||||
spriteShadow.Texture = texture;
|
||||
|
||||
if (Size == Vector2.Zero)
|
||||
Size = new Vector2(texture?.DisplayWidth ?? 0, texture?.DisplayHeight ?? 0);
|
||||
|
||||
loadedIcon = loadableIcon;
|
||||
}
|
||||
|
||||
public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true)
|
||||
|
Loading…
Reference in New Issue
Block a user