From 3e5c69b25e4911a6b5c1c3474957c1f63dafc2c4 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sat, 30 Sep 2017 22:04:27 -0400 Subject: [PATCH] v0.6.2: adjusted action indicator to be more crash resistant --- .../shatteredpixeldungeon/ui/ActionIndicator.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ActionIndicator.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ActionIndicator.java index 7adbd09f9..7b81cb4e9 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ActionIndicator.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ActionIndicator.java @@ -46,11 +46,11 @@ public class ActionIndicator extends Tag { super.destroy(); instance = null; } - + @Override protected void layout() { super.layout(); - + if (icon != null){ icon.x = x + (width - icon.width()) / 2; icon.y = y + (height - icon.height()) / 2; @@ -59,7 +59,9 @@ public class ActionIndicator extends Tag { add(icon); } } - + + private boolean needsLayout = false; + @Override public void update() { super.update(); @@ -77,6 +79,11 @@ public class ActionIndicator extends Tag { } else { visible = action != null; } + + if (needsLayout){ + layout(); + needsLayout = false; + } } @Override @@ -103,7 +110,7 @@ public class ActionIndicator extends Tag { } if (action != null){ instance.icon = action.getIcon(); - instance.layout(); + instance.needsLayout = true; } } }