From 20226d29460daf6535f5d04eaa347bf454be77fb Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 12 Jul 2021 22:03:23 -0400 Subject: [PATCH] v0.9.4: fixed buff icons not being refreshable --- .../shatteredpixeldungeon/ui/BuffIcon.java | 16 ++++++++++++++-- .../shatteredpixeldungeon/ui/BuffIndicator.java | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/BuffIcon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/BuffIcon.java index ac2765ba9..975878976 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/BuffIcon.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/BuffIcon.java @@ -13,15 +13,27 @@ public class BuffIcon extends Image { private static TextureFilm largeFilm; private static final int LRG_SIZE = 16; + private final boolean large; + //TODO maybe roll fading behaviour into this too? public BuffIcon(Buff buff, boolean large){ - this(buff.icon(), large); - buff.tintIcon(this); + super( large ? Assets.Interfaces.BUFFS_LARGE : Assets.Interfaces.BUFFS_SMALL ); + this.large = large; + refresh(buff); } public BuffIcon(int icon, boolean large){ super( large ? Assets.Interfaces.BUFFS_LARGE : Assets.Interfaces.BUFFS_SMALL ); + this.large = large; + refresh(icon); + } + public void refresh(Buff buff){ + refresh(buff.icon()); + buff.tintIcon(this); + } + + public void refresh(int icon){ if (large){ if (largeFilm == null) largeFilm = new TextureFilm(texture, LRG_SIZE, LRG_SIZE); frame(largeFilm.get(icon)); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/BuffIndicator.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/BuffIndicator.java index 23746bab3..d5b799d09 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/BuffIndicator.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/BuffIndicator.java @@ -212,7 +212,7 @@ public class BuffIndicator extends Component { } public void updateIcon(){ - buff.tintIcon(icon); + ((BuffIcon)icon).refresh(buff); //round up to the nearest pixel if <50% faded, otherwise round down float fadeHeight = buff.iconFadePercent() * icon.height(); float zoom = (camera() != null) ? camera().zoom : 1;