v2.5.0: added a cancel confirmation window to scrolls of enchantment

This commit is contained in:
Evan Debenham
2024-08-07 13:49:10 -04:00
parent fa66229e96
commit 3e749325d0
2 changed files with 47 additions and 18 deletions

View File

@@ -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

View File

@@ -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
}
}
}