v1.4.2: fixed screen size changes cancelling scroll of enchantment
This commit is contained in:
+83
-35
@@ -123,27 +123,70 @@ public class ScrollOfEnchantment extends ExoticScroll {
|
|||||||
enchants[1] = Weapon.Enchantment.randomUncommon( existing );
|
enchants[1] = Weapon.Enchantment.randomUncommon( existing );
|
||||||
enchants[2] = Weapon.Enchantment.random( existing, enchants[0].getClass(), enchants[1].getClass());
|
enchants[2] = Weapon.Enchantment.random( existing, enchants[0].getClass(), enchants[1].getClass());
|
||||||
|
|
||||||
GameScene.show(new WndOptions(new ItemSprite(ScrollOfEnchantment.this),
|
GameScene.show(new WndEnchantSelect((Weapon) item, enchants[0], enchants[1], enchants[2]));
|
||||||
Messages.titleCase(ScrollOfEnchantment.this.name()),
|
|
||||||
Messages.get(ScrollOfEnchantment.class, "weapon") +
|
} else if (item instanceof Armor) {
|
||||||
|
|
||||||
|
final Armor.Glyph glyphs[] = new Armor.Glyph[3];
|
||||||
|
|
||||||
|
Class<? extends Armor.Glyph> existing = ((Armor) item).glyph != null ? ((Armor) item).glyph.getClass() : null;
|
||||||
|
glyphs[0] = Armor.Glyph.randomCommon( existing );
|
||||||
|
glyphs[1] = Armor.Glyph.randomUncommon( existing );
|
||||||
|
glyphs[2] = Armor.Glyph.random( existing, glyphs[0].getClass(), glyphs[1].getClass());
|
||||||
|
|
||||||
|
GameScene.show(new WndGlyphSelect((Armor) item, glyphs[0], glyphs[1], glyphs[2]));
|
||||||
|
} else {
|
||||||
|
if (!identifiedByUse){
|
||||||
|
curItem.collect();
|
||||||
|
} else {
|
||||||
|
((ScrollOfEnchantment)curItem).confirmCancelation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public static class WndEnchantSelect extends WndOptions {
|
||||||
|
|
||||||
|
private static Weapon wep;
|
||||||
|
private static Weapon.Enchantment[] enchantments;
|
||||||
|
|
||||||
|
//used in PixelScene.restoreWindows
|
||||||
|
public WndEnchantSelect(){
|
||||||
|
this(wep, enchantments[0], enchantments[1], enchantments[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public WndEnchantSelect(Weapon wep, Weapon.Enchantment ench1,
|
||||||
|
Weapon.Enchantment ench2, Weapon.Enchantment ench3){
|
||||||
|
super(new ItemSprite(new ScrollOfEnchantment()),
|
||||||
|
Messages.titleCase(new ScrollOfEnchantment().name()),
|
||||||
|
Messages.get(ScrollOfEnchantment.class, "armor") +
|
||||||
"\n\n" +
|
"\n\n" +
|
||||||
Messages.get(ScrollOfEnchantment.class, "cancel_warn"),
|
Messages.get(ScrollOfEnchantment.class, "cancel_warn"),
|
||||||
enchants[0].name(),
|
ench1.name(),
|
||||||
enchants[1].name(),
|
ench2.name(),
|
||||||
enchants[2].name(),
|
ench3.name(),
|
||||||
Messages.get(ScrollOfEnchantment.class, "cancel")){
|
Messages.get(ScrollOfEnchantment.class, "cancel"));
|
||||||
|
this.wep = wep;
|
||||||
|
enchantments = new Weapon.Enchantment[3];
|
||||||
|
enchantments[0] = ench1;
|
||||||
|
enchantments[1] = ench2;
|
||||||
|
enchantments[2] = ench3;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSelect(int index) {
|
protected void onSelect(int index) {
|
||||||
if (index < 3) {
|
if (index < 3) {
|
||||||
((Weapon) item).enchant(enchants[index]);
|
wep.enchant(enchantments[index]);
|
||||||
GLog.p(Messages.get(StoneOfEnchantment.class, "weapon"));
|
GLog.p(Messages.get(StoneOfEnchantment.class, "weapon"));
|
||||||
((ScrollOfEnchantment)curItem).readAnimation();
|
((ScrollOfEnchantment)curItem).readAnimation();
|
||||||
|
|
||||||
Sample.INSTANCE.play( Assets.Sounds.READ );
|
Sample.INSTANCE.play( Assets.Sounds.READ );
|
||||||
Enchanting.show(curUser, item);
|
Enchanting.show(curUser, wep);
|
||||||
Talent.onUpgradeScrollUsed( Dungeon.hero );
|
Talent.onUpgradeScrollUsed( Dungeon.hero );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wep = null;
|
||||||
|
enchantments = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -155,46 +198,59 @@ public class ScrollOfEnchantment extends ExoticScroll {
|
|||||||
protected void onInfo( int index ) {
|
protected void onInfo( int index ) {
|
||||||
GameScene.show(new WndTitledMessage(
|
GameScene.show(new WndTitledMessage(
|
||||||
Icons.get(Icons.INFO),
|
Icons.get(Icons.INFO),
|
||||||
Messages.titleCase(enchants[index].name()),
|
Messages.titleCase(enchantments[index].name()),
|
||||||
enchants[index].desc()));
|
enchantments[index].desc()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
//do nothing, reader has to cancel
|
//do nothing, reader has to cancel
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
} else if (item instanceof Armor) {
|
}
|
||||||
|
|
||||||
final Armor.Glyph glyphs[] = new Armor.Glyph[3];
|
public static class WndGlyphSelect extends WndOptions {
|
||||||
|
|
||||||
Class<? extends Armor.Glyph> existing = ((Armor) item).glyph != null ? ((Armor) item).glyph.getClass() : null;
|
private static Armor arm;
|
||||||
glyphs[0] = Armor.Glyph.randomCommon( existing );
|
private static Armor.Glyph[] glyphs;
|
||||||
glyphs[1] = Armor.Glyph.randomUncommon( existing );
|
|
||||||
glyphs[2] = Armor.Glyph.random( existing, glyphs[0].getClass(), glyphs[1].getClass());
|
|
||||||
|
|
||||||
GameScene.show(new WndOptions( new ItemSprite(ScrollOfEnchantment.this),
|
//used in PixelScene.restoreWindows
|
||||||
Messages.titleCase(ScrollOfEnchantment.this.name()),
|
public WndGlyphSelect(){
|
||||||
|
this(arm, glyphs[0], glyphs[1], glyphs[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public WndGlyphSelect(Armor arm, Armor.Glyph glyph1,
|
||||||
|
Armor.Glyph glyph2, Armor.Glyph glyph3){
|
||||||
|
super(new ItemSprite(new ScrollOfEnchantment()),
|
||||||
|
Messages.titleCase(new ScrollOfEnchantment().name()),
|
||||||
Messages.get(ScrollOfEnchantment.class, "armor") +
|
Messages.get(ScrollOfEnchantment.class, "armor") +
|
||||||
"\n\n" +
|
"\n\n" +
|
||||||
Messages.get(ScrollOfEnchantment.class, "cancel_warn"),
|
Messages.get(ScrollOfEnchantment.class, "cancel_warn"),
|
||||||
glyphs[0].name(),
|
glyph1.name(),
|
||||||
glyphs[1].name(),
|
glyph2.name(),
|
||||||
glyphs[2].name(),
|
glyph3.name(),
|
||||||
Messages.get(ScrollOfEnchantment.class, "cancel")){
|
Messages.get(ScrollOfEnchantment.class, "cancel"));
|
||||||
|
this.arm = arm;
|
||||||
|
glyphs = new Armor.Glyph[3];
|
||||||
|
glyphs[0] = glyph1;
|
||||||
|
glyphs[1] = glyph2;
|
||||||
|
glyphs[2] = glyph3;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSelect(int index) {
|
protected void onSelect(int index) {
|
||||||
if (index < 3) {
|
if (index < 3) {
|
||||||
((Armor) item).inscribe(glyphs[index]);
|
arm.inscribe(glyphs[index]);
|
||||||
GLog.p(Messages.get(StoneOfEnchantment.class, "armor"));
|
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, item);
|
Enchanting.show(curUser, arm);
|
||||||
Talent.onUpgradeScrollUsed( Dungeon.hero );
|
Talent.onUpgradeScrollUsed( Dungeon.hero );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
arm = null;
|
||||||
|
glyphs = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -214,14 +270,6 @@ public class ScrollOfEnchantment extends ExoticScroll {
|
|||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
//do nothing, reader has to cancel
|
//do nothing, reader has to cancel
|
||||||
}
|
}
|
||||||
});
|
|
||||||
} else {
|
|
||||||
if (!identifiedByUse){
|
|
||||||
curItem.collect();
|
|
||||||
} else {
|
|
||||||
((ScrollOfEnchantment)curItem).confirmCancelation();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user