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.hero = null;
|
||||||
Dungeon.daily = Dungeon.dailyReplay = false;
|
Dungeon.daily = Dungeon.dailyReplay = false;
|
||||||
ActionIndicator.action = null;
|
ActionIndicator.clearAction();
|
||||||
InterlevelScene.mode = InterlevelScene.Mode.DESCEND;
|
InterlevelScene.mode = InterlevelScene.Mode.DESCEND;
|
||||||
|
|
||||||
Game.switchScene( InterlevelScene.class );
|
Game.switchScene( InterlevelScene.class );
|
||||||
@@ -662,7 +662,7 @@ public class HeroSelectScene extends PixelScene {
|
|||||||
|
|
||||||
Dungeon.hero = null;
|
Dungeon.hero = null;
|
||||||
Dungeon.daily = true;
|
Dungeon.daily = true;
|
||||||
ActionIndicator.action = null;
|
ActionIndicator.clearAction();
|
||||||
InterlevelScene.mode = InterlevelScene.Mode.DESCEND;
|
InterlevelScene.mode = InterlevelScene.Mode.DESCEND;
|
||||||
|
|
||||||
Game.switchScene( InterlevelScene.class );
|
Game.switchScene( InterlevelScene.class );
|
||||||
|
|||||||
+14
-2
@@ -83,9 +83,10 @@ public class ActionIndicator extends Tag {
|
|||||||
private boolean needsRefresh = false;
|
private boolean needsRefresh = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void update() {
|
public void update() {
|
||||||
super.update();
|
super.update();
|
||||||
|
|
||||||
|
synchronized (ActionIndicator.class) {
|
||||||
if (!visible && action != null) {
|
if (!visible && action != null) {
|
||||||
visible = true;
|
visible = true;
|
||||||
needsRefresh = true;
|
needsRefresh = true;
|
||||||
@@ -128,6 +129,7 @@ public class ActionIndicator extends Tag {
|
|||||||
if (primaryVis != null) primaryVis.alpha(1f);
|
if (primaryVis != null) primaryVis.alpha(1f);
|
||||||
if (secondVis != null) secondVis.alpha(1f);
|
if (secondVis != null) secondVis.alpha(1f);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,21 +151,31 @@ public class ActionIndicator extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setAction(Action action){
|
public static void setAction(Action action){
|
||||||
|
synchronized (ActionIndicator.class) {
|
||||||
ActionIndicator.action = action;
|
ActionIndicator.action = action;
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void clearAction(){
|
||||||
|
clearAction(null);
|
||||||
|
}
|
||||||
|
|
||||||
public static void clearAction(Action action){
|
public static void clearAction(Action action){
|
||||||
if (ActionIndicator.action == action) {
|
synchronized (ActionIndicator.class) {
|
||||||
|
if (action == null || ActionIndicator.action == action) {
|
||||||
ActionIndicator.action = null;
|
ActionIndicator.action = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void refresh(){
|
public static void refresh(){
|
||||||
|
synchronized (ActionIndicator.class) {
|
||||||
if (instance != null) {
|
if (instance != null) {
|
||||||
instance.needsRefresh = true;
|
instance.needsRefresh = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public interface Action {
|
public interface Action {
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -122,7 +122,7 @@ public class WndGameInProgress extends Window {
|
|||||||
|
|
||||||
Dungeon.hero = null;
|
Dungeon.hero = null;
|
||||||
Dungeon.daily = Dungeon.dailyReplay = false;
|
Dungeon.daily = Dungeon.dailyReplay = false;
|
||||||
ActionIndicator.action = null;
|
ActionIndicator.clearAction();
|
||||||
InterlevelScene.mode = InterlevelScene.Mode.CONTINUE;
|
InterlevelScene.mode = InterlevelScene.Mode.CONTINUE;
|
||||||
ShatteredPixelDungeon.switchScene(InterlevelScene.class);
|
ShatteredPixelDungeon.switchScene(InterlevelScene.class);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user