diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/HeroSelectScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/HeroSelectScene.java index e04e5a67d..7bf84c8d9 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/HeroSelectScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/HeroSelectScene.java @@ -136,7 +136,7 @@ public class HeroSelectScene extends PixelScene { Dungeon.hero = null; Dungeon.daily = Dungeon.dailyReplay = false; - ActionIndicator.action = null; + ActionIndicator.clearAction(); InterlevelScene.mode = InterlevelScene.Mode.DESCEND; Game.switchScene( InterlevelScene.class ); @@ -662,7 +662,7 @@ public class HeroSelectScene extends PixelScene { Dungeon.hero = null; Dungeon.daily = true; - ActionIndicator.action = null; + ActionIndicator.clearAction(); InterlevelScene.mode = InterlevelScene.Mode.DESCEND; Game.switchScene( InterlevelScene.class ); 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 fd605a058..79a73e17f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ActionIndicator.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ActionIndicator.java @@ -83,50 +83,52 @@ public class ActionIndicator extends Tag { private boolean needsRefresh = false; @Override - public synchronized void update() { + public void update() { super.update(); - if (!visible && action != null){ - visible = true; - needsRefresh = true; - flash(); - } else { - visible = action != null; - } - - if (needsRefresh){ - if (primaryVis != null) { - primaryVis.destroy(); - primaryVis.killAndErase(); - primaryVis = null; + synchronized (ActionIndicator.class) { + if (!visible && action != null) { + visible = true; + needsRefresh = true; + flash(); + } else { + visible = action != null; } - if (secondVis != null){ - secondVis.destroy(); - secondVis.killAndErase(); - secondVis = null; - } - if (action != null) { - primaryVis = action.primaryVisual(); - add(primaryVis); - secondVis = action.secondaryVisual(); - if (secondVis != null){ - add(secondVis); + if (needsRefresh) { + if (primaryVis != null) { + primaryVis.destroy(); + primaryVis.killAndErase(); + primaryVis = null; + } + if (secondVis != null) { + secondVis.destroy(); + secondVis.killAndErase(); + secondVis = null; + } + if (action != null) { + primaryVis = action.primaryVisual(); + add(primaryVis); + + secondVis = action.secondaryVisual(); + if (secondVis != null) { + add(secondVis); + } + + setColor(action.indicatorColor()); } - setColor(action.indicatorColor()); + layout(); + needsRefresh = false; } - layout(); - needsRefresh = false; - } - - if (!Dungeon.hero.ready){ - if (primaryVis != null) primaryVis.alpha(0.5f); - if (secondVis != null) secondVis.alpha(0.5f); - } else { - if (primaryVis != null) primaryVis.alpha(1f); - if (secondVis != null) secondVis.alpha(1f); + if (!Dungeon.hero.ready) { + if (primaryVis != null) primaryVis.alpha(0.5f); + if (secondVis != null) secondVis.alpha(0.5f); + } else { + if (primaryVis != null) primaryVis.alpha(1f); + if (secondVis != null) secondVis.alpha(1f); + } } } @@ -149,19 +151,29 @@ public class ActionIndicator extends Tag { } public static void setAction(Action action){ - ActionIndicator.action = action; - refresh(); + synchronized (ActionIndicator.class) { + ActionIndicator.action = action; + refresh(); + } + } + + public static void clearAction(){ + clearAction(null); } public static void clearAction(Action action){ - if (ActionIndicator.action == action) { - ActionIndicator.action = null; + synchronized (ActionIndicator.class) { + if (action == null || ActionIndicator.action == action) { + ActionIndicator.action = null; + } } } public static void refresh(){ - if (instance != null){ - instance.needsRefresh = true; + synchronized (ActionIndicator.class) { + if (instance != null) { + instance.needsRefresh = true; + } } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndGameInProgress.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndGameInProgress.java index 913aee43e..9cd96e29f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndGameInProgress.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndGameInProgress.java @@ -122,7 +122,7 @@ public class WndGameInProgress extends Window { Dungeon.hero = null; Dungeon.daily = Dungeon.dailyReplay = false; - ActionIndicator.action = null; + ActionIndicator.clearAction(); InterlevelScene.mode = InterlevelScene.Mode.CONTINUE; ShatteredPixelDungeon.switchScene(InterlevelScene.class); }