From 8630dafd9985738cde4ef2c568be5a29bb659c14 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sat, 24 Feb 2024 14:07:32 -0500 Subject: [PATCH] v2.4.0: added a missing item warning to WndResurrect --- .../messages/windows/windows.properties | 4 ++ .../windows/WndResurrect.java | 48 +++++++++++++------ 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/core/src/main/assets/messages/windows/windows.properties b/core/src/main/assets/messages/windows/windows.properties index a1fad6ed0..5cff719f5 100644 --- a/core/src/main/assets/messages/windows/windows.properties +++ b/core/src/main/assets/messages/windows/windows.properties @@ -217,6 +217,10 @@ windows.wndresurrect.title=Resurrection windows.wndresurrect.message=As you perish you can feel your ankh guiding your spirit back toward this world. It's giving you another chance to conquer the dungeon!\n\nYou can bring two of your items with you, but the rest will be left where you perished. Which items will you choose? windows.wndresurrect.prompt=Select an item windows.wndresurrect.confirm=Preserve these items +windows.wndresurrect.warn_title=Missing Items +windows.wndresurrect.warn_body=You haven't selected two items. Are you sure you want to resurrect without two items? +windows.wndresurrect.warn_yes=Yes, I'm sure +windows.wndresurrect.warn_no=No, let me reconsider windows.wndsadghost.rat_title=DEFEATED FETID RAT windows.wndsadghost.gnoll_title=DEFEATED GNOLL TRICKSTER diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndResurrect.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndResurrect.java index e78632184..a87a8a3e1 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndResurrect.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndResurrect.java @@ -31,6 +31,7 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.InterlevelScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; +import com.shatteredpixel.shatteredpixeldungeon.ui.Icons; import com.shatteredpixel.shatteredpixeldungeon.ui.ItemButton; import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock; @@ -96,21 +97,22 @@ public class WndResurrect extends Window { btnContinue = new RedButton( Messages.get(this, "confirm") ) { @Override protected void onClick() { - hide(); - - Statistics.ankhsUsed++; - - ankh.detach(Dungeon.hero.belongings.backpack); - - if (btnItem1.item() != null){ - btnItem1.item().keptThoughLostInvent = true; + if (btnItem1.item() == null || btnItem2.item() == null){ + GameScene.show(new WndOptions(Icons.WARNING.get(), + Messages.get(WndResurrect.class, "warn_title"), + Messages.get(WndResurrect.class, "warn_body"), + Messages.get(WndResurrect.class, "warn_yes"), + Messages.get(WndResurrect.class, "warn_no")){ + @Override + protected void onSelect(int index) { + if (index == 0){ + resurrect(ankh); + } + } + }); + } else { + resurrect( ankh ); } - if (btnItem2.item() != null){ - btnItem2.item().keptThoughLostInvent = true; - } - - InterlevelScene.mode = InterlevelScene.Mode.RESURRECT; - Game.switchScene( InterlevelScene.class ); } }; btnContinue.setRect( 0, btnItem1.bottom() + BTN_GAP, WIDTH, BTN_HEIGHT ); @@ -119,6 +121,24 @@ public class WndResurrect extends Window { resize( WIDTH, (int)btnContinue.bottom() ); } + private void resurrect( final Ankh ankh ){ + hide(); + + Statistics.ankhsUsed++; + + ankh.detach(Dungeon.hero.belongings.backpack); + + if (btnItem1.item() != null){ + btnItem1.item().keptThoughLostInvent = true; + } + if (btnItem2.item() != null){ + btnItem2.item().keptThoughLostInvent = true; + } + + InterlevelScene.mode = InterlevelScene.Mode.RESURRECT; + Game.switchScene( InterlevelScene.class ); + } + protected WndBag.ItemSelector itemSelector = new WndBag.ItemSelector() { @Override