v2.5.0: improved logic for cancelling new upgrade window

This commit is contained in:
Evan Debenham
2024-06-22 13:40:06 -04:00
committed by Evan Debenham
parent 5381809f55
commit e4085fe445
4 changed files with 12 additions and 8 deletions

View File

@@ -1206,7 +1206,7 @@ items.spells.spell.no_magic=You can't cast spells while magic immune.
items.spells.magicalinfusion.name=magical infusion
items.spells.magicalinfusion.inv_title=Infuse an item
items.spells.magicalinfusion.infuse=Your item is infused with arcane energy!
items.spells.magicalinfusion.desc=This spell possesses the same magical power as a scroll of upgrade, but in a more stable form.\n\nIn addition to upgrading an item as normal it will never erase an enchantment on a weapon or a glyph on armor, including curses.
items.spells.magicalinfusion.desc=This spell possesses the same magical power as a scroll of upgrade, but in a more stable form.\n\nIn addition to upgrading an item as normal it will never erase an enchantment, glyph, or curse.
items.spells.magicalporter.name=magical porter
items.spells.magicalporter.inv_title=Port an item

View File

@@ -111,12 +111,13 @@ public abstract class InventoryScroll extends Scroll {
if (item != null) {
if (!identifiedByUse) {
//SoU opens a separate window that can be cancelled
//so we don't do a lot of logic here
if (!identifiedByUse && !(curItem instanceof ScrollOfUpgrade)) {
curItem = detach(curUser.belongings.backpack);
}
((InventoryScroll)curItem).onItemSelected( item );
//SoU still does these things, but after the upgrade window
if (!(curItem instanceof ScrollOfUpgrade)) {
((InventoryScroll) curItem).readAnimation();
Sample.INSTANCE.play(Assets.Sounds.READ);

View File

@@ -81,10 +81,13 @@ public abstract class InventorySpell extends Spell {
if (item != null) {
curItem = detach(curUser.belongings.backpack);
//Infusion opens a separate window that can be cancelled
//so we don't do a lot of logic here
if (!(curItem instanceof MagicalInfusion)) {
curItem = detach(curUser.belongings.backpack);
}
((InventorySpell)curItem).onItemSelected( item );
//Magical Infusion still does these things, but after the upgrade window
if (!(curItem instanceof MagicalInfusion)) {
curUser.spend(1f);
curUser.busy();

View File

@@ -254,6 +254,7 @@ public class WndUpgrade extends Window {
}
//Various ring stats (varies by ring)
//TODO cursed ring stats?
if (toUpgrade instanceof Ring){
if (((Ring) toUpgrade).upgradeStat1(levelFrom) != null){
bottom = fillFields(Messages.get(toUpgrade, "upgrade_stat_name_1"),
@@ -369,6 +370,7 @@ public class WndUpgrade extends Window {
upgraded = ((MagicalInfusion) upgrader).upgradeItem(toUpgrade);
}
if (!force) upgrader.detach(Dungeon.hero.belongings.backpack);
Item moreUpgradeItem = Dungeon.hero.belongings.getItem(upgrader.getClass());
hide();
@@ -429,9 +431,7 @@ public class WndUpgrade extends Window {
@Override
public void onBackPressed() {
//don't let this window be closed if
//TODO currently never closes, as the Sou/magic infusion is consumed as it is shown
//we might want to only have it be pre-consumed when force = true
//as atm quitting the game with the window open will eat the scroll/infuse when force=false
if (!force) super.onBackPressed();
}
private float fillFields(String title, String msg1, String msg2, float bottom){