v0.4.1: bugfixes to item slots and item sprites
This commit is contained in:
parent
093635c454
commit
3de8225f9b
|
@ -174,7 +174,6 @@ public class ItemSprite extends MovieClip {
|
||||||
|
|
||||||
public ItemSprite view(Item item){
|
public ItemSprite view(Item item){
|
||||||
view(item.image(), item.glowing());
|
view(item.image(), item.glowing());
|
||||||
if (this.emitter != null) this.emitter.killAndErase();
|
|
||||||
Emitter emitter = item.emitter();
|
Emitter emitter = item.emitter();
|
||||||
if (emitter != null && parent != null) {
|
if (emitter != null && parent != null) {
|
||||||
emitter.pos( this );
|
emitter.pos( this );
|
||||||
|
@ -185,7 +184,7 @@ public class ItemSprite extends MovieClip {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemSprite view( int image, Glowing glowing ) {
|
public ItemSprite view( int image, Glowing glowing ) {
|
||||||
if (this.emitter != null) this.emitter.on = false;
|
if (this.emitter != null) this.emitter.killAndErase();
|
||||||
emitter = null;
|
emitter = null;
|
||||||
frame( film.get( image ) );
|
frame( film.get( image ) );
|
||||||
if ((this.glowing = glowing) == null) {
|
if ((this.glowing = glowing) == null) {
|
||||||
|
|
|
@ -49,6 +49,7 @@ public class ItemSlot extends Button {
|
||||||
private static final float DISABLED = 0.3f;
|
private static final float DISABLED = 0.3f;
|
||||||
|
|
||||||
protected ItemSprite icon;
|
protected ItemSprite icon;
|
||||||
|
protected Item item;
|
||||||
protected BitmapText topLeft;
|
protected BitmapText topLeft;
|
||||||
protected BitmapText topRight;
|
protected BitmapText topRight;
|
||||||
protected BitmapText bottomRight;
|
protected BitmapText bottomRight;
|
||||||
|
@ -84,6 +85,8 @@ public class ItemSlot extends Button {
|
||||||
|
|
||||||
public ItemSlot() {
|
public ItemSlot() {
|
||||||
super();
|
super();
|
||||||
|
icon.visible(false);
|
||||||
|
enable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemSlot( Item item ) {
|
public ItemSlot( Item item ) {
|
||||||
|
@ -138,89 +141,107 @@ public class ItemSlot extends Button {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void item( Item item ) {
|
public void item( Item item ) {
|
||||||
|
if (this.item == item) {
|
||||||
|
updateText();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.item = item;
|
||||||
|
|
||||||
|
if (item == null) {
|
||||||
|
|
||||||
|
active = false;
|
||||||
|
icon.visible(false);
|
||||||
|
|
||||||
|
updateText();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
active = true;
|
||||||
|
icon.visible(true);
|
||||||
|
|
||||||
|
icon.view( item );
|
||||||
|
updateText();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateText(){
|
||||||
|
|
||||||
if (bottomRightIcon != null){
|
if (bottomRightIcon != null){
|
||||||
remove(bottomRightIcon);
|
remove(bottomRightIcon);
|
||||||
bottomRightIcon = null;
|
bottomRightIcon = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item == null) {
|
if (item == null){
|
||||||
|
|
||||||
active = false;
|
|
||||||
topLeft.visible = topRight.visible = bottomRight.visible = false;
|
topLeft.visible = topRight.visible = bottomRight.visible = false;
|
||||||
icon.visible(false);
|
return;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
active = true;
|
|
||||||
topLeft.visible = topRight.visible = bottomRight.visible = true;
|
topLeft.visible = topRight.visible = bottomRight.visible = true;
|
||||||
icon.visible(true);
|
}
|
||||||
|
|
||||||
icon.view( item );
|
topLeft.text( item.status() );
|
||||||
|
|
||||||
topLeft.text( item.status() );
|
boolean isArmor = item instanceof Armor;
|
||||||
|
boolean isWeapon = item instanceof Weapon;
|
||||||
boolean isArmor = item instanceof Armor;
|
if (isArmor || isWeapon) {
|
||||||
boolean isWeapon = item instanceof Weapon;
|
|
||||||
if (isArmor || isWeapon) {
|
if (item.levelKnown || (isWeapon && !(item instanceof MeleeWeapon))) {
|
||||||
|
|
||||||
if (item.levelKnown || (isWeapon && !(item instanceof MeleeWeapon))) {
|
int str = isArmor ? ((Armor)item).STRReq() : ((Weapon)item).STRReq();
|
||||||
|
topRight.text( Messages.format( TXT_STRENGTH, str ) );
|
||||||
int str = isArmor ? ((Armor)item).STRReq() : ((Weapon)item).STRReq();
|
if (str > Dungeon.hero.STR()) {
|
||||||
topRight.text( Messages.format( TXT_STRENGTH, str ) );
|
topRight.hardlight( DEGRADED );
|
||||||
if (str > Dungeon.hero.STR()) {
|
|
||||||
topRight.hardlight( DEGRADED );
|
|
||||||
} else {
|
|
||||||
topRight.resetColor();
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
topRight.resetColor();
|
||||||
topRight.text( Messages.format( TXT_TYPICAL_STR, isArmor ?
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
topRight.text( Messages.format( TXT_TYPICAL_STR, isArmor ?
|
||||||
((Armor)item).STRReq(0) :
|
((Armor)item).STRReq(0) :
|
||||||
((Weapon)item).STRReq(0) ) );
|
((Weapon)item).STRReq(0) ) );
|
||||||
topRight.hardlight( WARNING );
|
topRight.hardlight( WARNING );
|
||||||
|
|
||||||
}
|
|
||||||
topRight.measure();
|
|
||||||
|
|
||||||
} else if (item instanceof Key && !(item instanceof SkeletonKey)) {
|
|
||||||
topRight.text(Messages.format(TXT_KEY_DEPTH, ((Key) item).depth));
|
|
||||||
topRight.measure();
|
|
||||||
} else {
|
|
||||||
|
|
||||||
topRight.text( null );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
topRight.measure();
|
||||||
int level = item.visiblyUpgraded();
|
|
||||||
|
|
||||||
if (level != 0) {
|
} else if (item instanceof Key && !(item instanceof SkeletonKey)) {
|
||||||
bottomRight.text( item.levelKnown ? Messages.format( TXT_LEVEL, level ) : TXT_CURSED );
|
topRight.text(Messages.format(TXT_KEY_DEPTH, ((Key) item).depth));
|
||||||
bottomRight.measure();
|
topRight.measure();
|
||||||
bottomRight.hardlight( level > 0 ? UPGRADED : DEGRADED );
|
} else {
|
||||||
} else if (item instanceof Scroll || item instanceof Potion) {
|
|
||||||
bottomRight.text( null );
|
|
||||||
|
|
||||||
Integer iconInt;
|
topRight.text( null );
|
||||||
if (item instanceof Scroll){
|
|
||||||
iconInt = ((Scroll) item).initials();
|
|
||||||
} else {
|
|
||||||
iconInt = ((Potion) item).initials();
|
|
||||||
}
|
|
||||||
if (iconInt != null && iconVisible) {
|
|
||||||
bottomRightIcon = new Image(Assets.CONS_ICONS);
|
|
||||||
int left = iconInt*7;
|
|
||||||
int top = item instanceof Potion ? 0 : 8;
|
|
||||||
bottomRightIcon.frame(left, top, 7, 8);
|
|
||||||
add(bottomRightIcon);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
bottomRight.text( null );
|
|
||||||
}
|
|
||||||
|
|
||||||
layout();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int level = item.visiblyUpgraded();
|
||||||
|
|
||||||
|
if (level != 0) {
|
||||||
|
bottomRight.text( item.levelKnown ? Messages.format( TXT_LEVEL, level ) : TXT_CURSED );
|
||||||
|
bottomRight.measure();
|
||||||
|
bottomRight.hardlight( level > 0 ? UPGRADED : DEGRADED );
|
||||||
|
} else if (item instanceof Scroll || item instanceof Potion) {
|
||||||
|
bottomRight.text( null );
|
||||||
|
|
||||||
|
Integer iconInt;
|
||||||
|
if (item instanceof Scroll){
|
||||||
|
iconInt = ((Scroll) item).initials();
|
||||||
|
} else {
|
||||||
|
iconInt = ((Potion) item).initials();
|
||||||
|
}
|
||||||
|
if (iconInt != null && iconVisible) {
|
||||||
|
bottomRightIcon = new Image(Assets.CONS_ICONS);
|
||||||
|
int left = iconInt*7;
|
||||||
|
int top = item instanceof Potion ? 0 : 8;
|
||||||
|
bottomRightIcon.frame(left, top, 7, 8);
|
||||||
|
add(bottomRightIcon);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
bottomRight.text( null );
|
||||||
|
}
|
||||||
|
|
||||||
|
layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enable( boolean value ) {
|
public void enable( boolean value ) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user