v2.1.3: added some sync and safety checks to action indicator
This commit is contained in:
+2
-2
@@ -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 );
|
||||
|
||||
+14
-2
@@ -83,9 +83,10 @@ public class ActionIndicator extends Tag {
|
||||
private boolean needsRefresh = false;
|
||||
|
||||
@Override
|
||||
public synchronized void update() {
|
||||
public void update() {
|
||||
super.update();
|
||||
|
||||
synchronized (ActionIndicator.class) {
|
||||
if (!visible && action != null) {
|
||||
visible = true;
|
||||
needsRefresh = true;
|
||||
@@ -128,6 +129,7 @@ public class ActionIndicator extends Tag {
|
||||
if (primaryVis != null) primaryVis.alpha(1f);
|
||||
if (secondVis != null) secondVis.alpha(1f);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -149,21 +151,31 @@ public class ActionIndicator extends Tag {
|
||||
}
|
||||
|
||||
public static void setAction(Action action){
|
||||
synchronized (ActionIndicator.class) {
|
||||
ActionIndicator.action = action;
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearAction(){
|
||||
clearAction(null);
|
||||
}
|
||||
|
||||
public static void clearAction(Action action){
|
||||
if (ActionIndicator.action == action) {
|
||||
synchronized (ActionIndicator.class) {
|
||||
if (action == null || ActionIndicator.action == action) {
|
||||
ActionIndicator.action = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void refresh(){
|
||||
synchronized (ActionIndicator.class) {
|
||||
if (instance != null) {
|
||||
instance.needsRefresh = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface Action {
|
||||
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user