v2.0.1: added some safety checks for windows rendering on actor thread

This commit is contained in:
Evan Debenham
2023-03-20 16:27:35 -04:00
parent b57db0739a
commit 1685809d9f
2 changed files with 46 additions and 33 deletions
@@ -23,6 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.potions.exotic;
import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob; import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob;
@@ -90,26 +91,31 @@ public class PotionOfDragonsBreath extends ExoticPotion {
if (cell == null && identifiedByUse){ if (cell == null && identifiedByUse){
showingWindow = true; showingWindow = true;
GameScene.show( new WndOptions(new ItemSprite(PotionOfDragonsBreath.this), ShatteredPixelDungeon.runOnRenderThread(new Callback() {
Messages.titleCase(name()),
Messages.get(ExoticPotion.class, "warning"),
Messages.get(ExoticPotion.class, "yes"),
Messages.get(ExoticPotion.class, "no") ) {
@Override @Override
protected void onSelect( int index ) { public void call() {
showingWindow = false; GameScene.show( new WndOptions(new ItemSprite(PotionOfDragonsBreath.this),
switch (index) { Messages.titleCase(name()),
case 0: Messages.get(ExoticPotion.class, "warning"),
curUser.spendAndNext(1f); Messages.get(ExoticPotion.class, "yes"),
identifiedByUse = false; Messages.get(ExoticPotion.class, "no") ) {
break; @Override
case 1: protected void onSelect( int index ) {
GameScene.selectCell( targeter ); showingWindow = false;
break; switch (index) {
} case 0:
curUser.spendAndNext(1f);
identifiedByUse = false;
break;
case 1:
GameScene.selectCell( targeter );
break;
}
}
public void onBackPressed() {}
} );
} }
public void onBackPressed() {} });
} );
} else if (cell == null && !anonymous){ } else if (cell == null && !anonymous){
curItem.collect( curUser.belongings.backpack ); curItem.collect( curUser.belongings.backpack );
} else if (cell != null) { } else if (cell != null) {
@@ -382,22 +382,29 @@ public class CursedWand {
//Don't bother doing this joke to none-english speakers, I doubt it would translate. //Don't bother doing this joke to none-english speakers, I doubt it would translate.
return cursedEffect(origin, user, targetPos); return cursedEffect(origin, user, targetPos);
} else { } else {
GameScene.show( ShatteredPixelDungeon.runOnRenderThread(
new WndOptions(Icons.get(Icons.WARNING), new Callback() {
"CURSED WAND ERROR",
"this application will now self-destruct",
"abort",
"retry",
"fail") {
@Override @Override
protected void onSelect(int index) { public void call() {
Game.instance.finish(); GameScene.show(
} new WndOptions(Icons.get(Icons.WARNING),
"CURSED WAND ERROR",
@Override "this application will now self-destruct",
public void onBackPressed() { "abort",
//do nothing "retry",
"fail") {
@Override
protected void onSelect(int index) {
Game.instance.finish();
}
@Override
public void onBackPressed() {
//do nothing
}
}
);
} }
} }
); );