From 3e749325d02cb14a34780dd349b9ef19ee7c16c1 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 7 Aug 2024 13:49:10 -0400 Subject: [PATCH] v2.5.0: added a cancel confirmation window to scrolls of enchantment --- .../assets/messages/items/items.properties | 4 +- .../scrolls/exotic/ScrollOfEnchantment.java | 61 +++++++++++++------ 2 files changed, 47 insertions(+), 18 deletions(-) diff --git a/core/src/main/assets/messages/items/items.properties b/core/src/main/assets/messages/items/items.properties index 747431cf5..ddde55438 100644 --- a/core/src/main/assets/messages/items/items.properties +++ b/core/src/main/assets/messages/items/items.properties @@ -1149,8 +1149,10 @@ items.scrolls.exotic.scrollofenchantment.name=scroll of enchantment items.scrolls.exotic.scrollofenchantment.inv_title=Enchant an item items.scrolls.exotic.scrollofenchantment.weapon=Select an enchantment to apply to your weapon. items.scrolls.exotic.scrollofenchantment.armor=Select a glyph to apply to your armor. -items.scrolls.exotic.scrollofenchantment.cancel_warn=Cancelling will still consume the scroll. items.scrolls.exotic.scrollofenchantment.cancel=cancel +items.scrolls.exotic.scrollofenchantment.cancel_warn=Cancelling with still consume your scroll of enchantment, are you sure? +items.scrolls.exotic.scrollofenchantment.cancel_warn_yes=Yes, I'm sure +items.scrolls.exotic.scrollofenchantment.cancel_warn_no=No, I changed my mind items.scrolls.exotic.scrollofenchantment.desc=This scroll will infuse a weapon or armor with powerful magical energy. The reader even has some degree of control over which magic is imbued. items.scrolls.exotic.scrollofforesight.name=scroll of foresight diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/exotic/ScrollOfEnchantment.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/exotic/ScrollOfEnchantment.java index 2c9f3c69d..f501cbfdc 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/exotic/ScrollOfEnchantment.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/exotic/ScrollOfEnchantment.java @@ -162,9 +162,7 @@ public class ScrollOfEnchantment extends ExoticScroll { Weapon.Enchantment ench2, Weapon.Enchantment ench3){ super(new ItemSprite(new ScrollOfEnchantment()), Messages.titleCase(new ScrollOfEnchantment().name()), - Messages.get(ScrollOfEnchantment.class, "weapon") + - "\n\n" + - Messages.get(ScrollOfEnchantment.class, "cancel_warn"), + Messages.get(ScrollOfEnchantment.class, "weapon"), ench1.name(), ench2.name(), ench3.name(), @@ -185,10 +183,9 @@ public class ScrollOfEnchantment extends ExoticScroll { Sample.INSTANCE.play( Assets.Sounds.READ ); Enchanting.show(curUser, wep); + } else { + GameScene.show(new WndConfirmCancel()); } - - wep = null; - enchantments = null; } @Override @@ -217,17 +214,15 @@ public class ScrollOfEnchantment extends ExoticScroll { private static Armor.Glyph[] glyphs; //used in PixelScene.restoreWindows - public WndGlyphSelect(){ + public WndGlyphSelect() { this(arm, glyphs[0], glyphs[1], glyphs[2]); } public WndGlyphSelect(Armor arm, Armor.Glyph glyph1, - Armor.Glyph glyph2, Armor.Glyph glyph3){ + Armor.Glyph glyph2, Armor.Glyph glyph3) { super(new ItemSprite(new ScrollOfEnchantment()), Messages.titleCase(new ScrollOfEnchantment().name()), - Messages.get(ScrollOfEnchantment.class, "armor") + - "\n\n" + - Messages.get(ScrollOfEnchantment.class, "cancel_warn"), + Messages.get(ScrollOfEnchantment.class, "armor"), glyph1.name(), glyph2.name(), glyph3.name(), @@ -244,14 +239,13 @@ public class ScrollOfEnchantment extends ExoticScroll { if (index < 3) { arm.inscribe(glyphs[index]); GLog.p(Messages.get(StoneOfEnchantment.class, "armor")); - ((ScrollOfEnchantment)curItem).readAnimation(); + ((ScrollOfEnchantment) curItem).readAnimation(); - Sample.INSTANCE.play( Assets.Sounds.READ ); + Sample.INSTANCE.play(Assets.Sounds.READ); Enchanting.show(curUser, arm); + } else { + GameScene.show(new WndConfirmCancel()); } - - arm = null; - glyphs = null; } @Override @@ -260,7 +254,7 @@ public class ScrollOfEnchantment extends ExoticScroll { } @Override - protected void onInfo( int index ) { + protected void onInfo(int index) { GameScene.show(new WndTitledMessage( Icons.get(Icons.INFO), Messages.titleCase(glyphs[index].name()), @@ -273,4 +267,37 @@ public class ScrollOfEnchantment extends ExoticScroll { } } + + public static class WndConfirmCancel extends WndOptions{ + + public WndConfirmCancel(){ + super(new ItemSprite(new ScrollOfEnchantment()), + Messages.titleCase(new ScrollOfEnchantment().name()), + Messages.get(ScrollOfEnchantment.class, "cancel_warn"), + Messages.get(ScrollOfEnchantment.class, "cancel_warn_yes"), + Messages.get(ScrollOfEnchantment.class, "cancel_warn_no")); + } + + @Override + protected void onSelect(int index) { + super.onSelect(index); + if (index == 1){ + if (WndEnchantSelect.wep != null) { + GameScene.show(new WndEnchantSelect()); + } else { + GameScene.show(new WndGlyphSelect()); + } + } else { + WndEnchantSelect.wep = null; + WndEnchantSelect.enchantments = null; + WndGlyphSelect.arm = null; + WndGlyphSelect.glyphs = null; + } + } + + @Override + public void onBackPressed() { + //do nothing + } + } }