From 1685809d9f6a7799d305bb599c2de9101894bc8c Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 20 Mar 2023 16:27:35 -0400 Subject: [PATCH] v2.0.1: added some safety checks for windows rendering on actor thread --- .../potions/exotic/PotionOfDragonsBreath.java | 42 +++++++++++-------- .../items/wands/CursedWand.java | 37 +++++++++------- 2 files changed, 46 insertions(+), 33 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/exotic/PotionOfDragonsBreath.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/exotic/PotionOfDragonsBreath.java index 6ceb74b16..ccdb833fe 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/exotic/PotionOfDragonsBreath.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/exotic/PotionOfDragonsBreath.java @@ -23,6 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.potions.exotic; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; +import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob; @@ -90,26 +91,31 @@ public class PotionOfDragonsBreath extends ExoticPotion { if (cell == null && identifiedByUse){ showingWindow = true; - GameScene.show( new WndOptions(new ItemSprite(PotionOfDragonsBreath.this), - Messages.titleCase(name()), - Messages.get(ExoticPotion.class, "warning"), - Messages.get(ExoticPotion.class, "yes"), - Messages.get(ExoticPotion.class, "no") ) { + ShatteredPixelDungeon.runOnRenderThread(new Callback() { @Override - protected void onSelect( int index ) { - showingWindow = false; - switch (index) { - case 0: - curUser.spendAndNext(1f); - identifiedByUse = false; - break; - case 1: - GameScene.selectCell( targeter ); - break; - } + public void call() { + GameScene.show( new WndOptions(new ItemSprite(PotionOfDragonsBreath.this), + Messages.titleCase(name()), + Messages.get(ExoticPotion.class, "warning"), + Messages.get(ExoticPotion.class, "yes"), + Messages.get(ExoticPotion.class, "no") ) { + @Override + protected void onSelect( int index ) { + showingWindow = false; + 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){ curItem.collect( curUser.belongings.backpack ); } else if (cell != null) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/CursedWand.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/CursedWand.java index bd1ec3587..8b5dc2d2b 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/CursedWand.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/CursedWand.java @@ -382,22 +382,29 @@ public class CursedWand { //Don't bother doing this joke to none-english speakers, I doubt it would translate. return cursedEffect(origin, user, targetPos); } else { - GameScene.show( - new WndOptions(Icons.get(Icons.WARNING), - "CURSED WAND ERROR", - "this application will now self-destruct", - "abort", - "retry", - "fail") { - + ShatteredPixelDungeon.runOnRenderThread( + new Callback() { @Override - protected void onSelect(int index) { - Game.instance.finish(); - } - - @Override - public void onBackPressed() { - //do nothing + public void call() { + GameScene.show( + new WndOptions(Icons.get(Icons.WARNING), + "CURSED WAND ERROR", + "this application will now self-destruct", + "abort", + "retry", + "fail") { + + @Override + protected void onSelect(int index) { + Game.instance.finish(); + } + + @Override + public void onBackPressed() { + //do nothing + } + } + ); } } );