public void item(Item item) { if (item == null) { active = false; icon.visible = topLeft.visible = topRight.visible = bottomRight.visible = false; } else { active = true; icon.visible = topLeft.visible = topRight.visible = bottomRight.visible = true; icon.view(item.image(), item.glowing()); topLeft.text(item.status()); boolean isArmor = item instanceof Armor; boolean isWeapon = item instanceof Weapon; if (isArmor || isWeapon) { if (item.levelKnown || (isWeapon && !(item instanceof MeleeWeapon))) { int str = isArmor ? ((Armor) item).STR : ((Weapon) item).STR; topRight.text(Utils.format(TXT_STRENGTH, str)); if (str > Dungeon.hero.STR()) { topRight.hardlight(DEGRADED); } else { topRight.resetColor(); } } else { topRight.text( Utils.format( TXT_TYPICAL_STR, isArmor ? ((Armor) item).typicalSTR() : ((MeleeWeapon) item).typicalSTR())); topRight.hardlight(WARNING); } topRight.measure(); } else { topRight.text(null); } int level = item.visiblyUpgraded(); if (level != 0 || (item.cursed && item.cursedKnown)) { bottomRight.text(item.levelKnown ? Utils.format(TXT_LEVEL, level) : TXT_CURSED); bottomRight.measure(); bottomRight.hardlight(level > 0 ? UPGRADED : DEGRADED); } else { bottomRight.text(null); } layout(); } }
public void enable(boolean value) { active = value; float alpha = value ? ENABLED : DISABLED; icon.alpha(alpha); topLeft.alpha(alpha); topRight.alpha(alpha); bottomRight.alpha(alpha); }
@Override protected void layout() { super.layout(); icon.x = x + (width - icon.width) / 2; icon.y = y + (height - icon.height) / 2; if (topLeft != null) { topLeft.x = x; topLeft.y = y; } if (topRight != null) { topRight.x = x + (width - topRight.width()); topRight.y = y; } if (bottomRight != null) { bottomRight.x = x + (width - bottomRight.width()); bottomRight.y = y + (height - bottomRight.height()); } }