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 );
|
||||||
|
|||||||
+20
-8
@@ -83,10 +83,11 @@ 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();
|
||||||
|
|
||||||
if (!visible && action != null){
|
synchronized (ActionIndicator.class) {
|
||||||
|
if (!visible && action != null) {
|
||||||
visible = true;
|
visible = true;
|
||||||
needsRefresh = true;
|
needsRefresh = true;
|
||||||
flash();
|
flash();
|
||||||
@@ -94,13 +95,13 @@ public class ActionIndicator extends Tag {
|
|||||||
visible = action != null;
|
visible = action != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needsRefresh){
|
if (needsRefresh) {
|
||||||
if (primaryVis != null) {
|
if (primaryVis != null) {
|
||||||
primaryVis.destroy();
|
primaryVis.destroy();
|
||||||
primaryVis.killAndErase();
|
primaryVis.killAndErase();
|
||||||
primaryVis = null;
|
primaryVis = null;
|
||||||
}
|
}
|
||||||
if (secondVis != null){
|
if (secondVis != null) {
|
||||||
secondVis.destroy();
|
secondVis.destroy();
|
||||||
secondVis.killAndErase();
|
secondVis.killAndErase();
|
||||||
secondVis = null;
|
secondVis = null;
|
||||||
@@ -110,7 +111,7 @@ public class ActionIndicator extends Tag {
|
|||||||
add(primaryVis);
|
add(primaryVis);
|
||||||
|
|
||||||
secondVis = action.secondaryVisual();
|
secondVis = action.secondaryVisual();
|
||||||
if (secondVis != null){
|
if (secondVis != null) {
|
||||||
add(secondVis);
|
add(secondVis);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,13 +122,14 @@ public class ActionIndicator extends Tag {
|
|||||||
needsRefresh = false;
|
needsRefresh = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Dungeon.hero.ready){
|
if (!Dungeon.hero.ready) {
|
||||||
if (primaryVis != null) primaryVis.alpha(0.5f);
|
if (primaryVis != null) primaryVis.alpha(0.5f);
|
||||||
if (secondVis != null) secondVis.alpha(0.5f);
|
if (secondVis != null) secondVis.alpha(0.5f);
|
||||||
} else {
|
} else {
|
||||||
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(){
|
||||||
if (instance != null){
|
synchronized (ActionIndicator.class) {
|
||||||
|
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