public Record(int pos, boolean latest, Rankings.Record rec) { super(); this.rec = rec; if (latest) { flare = new Flare(6, 24); flare.angularSpeed = 90; flare.color(rec.win ? FLARE_WIN : FLARE_LOSE); addToBack(flare); } if (pos != Rankings.TABLE_SIZE - 1) { position.text(Integer.toString(pos + 1)); } else position.text(" "); position.measure(); desc.text(rec.info); desc.measure(); int odd = pos % 2; if (rec.win) { shield.view(ItemSpriteSheet.AMULET, null); position.hardlight(TEXT_WIN[odd]); desc.hardlight(TEXT_WIN[odd]); depth.hardlight(TEXT_WIN[odd]); level.hardlight(TEXT_WIN[odd]); } else { position.hardlight(TEXT_LOSE[odd]); desc.hardlight(TEXT_LOSE[odd]); depth.hardlight(TEXT_LOSE[odd]); level.hardlight(TEXT_LOSE[odd]); if (rec.depth != 0) { depth.text(Integer.toString(rec.depth)); depth.measure(); steps.copy(Icons.DEPTH_LG.get()); add(steps); add(depth); } } if (rec.herolevel != 0) { level.text(Integer.toString(rec.herolevel)); level.measure(); add(level); } classIcon.copy(Icons.get(rec.heroClass)); }
@Override public void update() { super.update(); float health = (float) Dungeon.hero.HP / Dungeon.hero.HT; if (health == 0) { avatar.tint(0x000000, 0.6f); blood.on = false; } else if (health < 0.25f) { avatar.tint(0xcc0000, 0.4f); blood.on = true; } else { avatar.resetColor(); blood.on = false; } hp.scale.x = health; exp.scale.x = (width / exp.width) * Dungeon.hero.exp / Dungeon.hero.maxExp(); if (Dungeon.hero.lvl != lastLvl) { if (lastLvl != -1) { Emitter emitter = (Emitter) recycle(Emitter.class); emitter.revive(); emitter.pos(27, 27); emitter.burst(Speck.factory(Speck.STAR), 12); } lastLvl = Dungeon.hero.lvl; level.text(Integer.toString(lastLvl)); level.measure(); level.x = PixelScene.align(27.0f - level.width() / 2); level.y = PixelScene.align(27.5f - level.baseLine() / 2); } int k = IronKey.curDepthQuantity; if (k != lastKeys) { lastKeys = k; keys.text(Integer.toString(lastKeys)); keys.measure(); keys.x = width - 8 - keys.width() - 18; } int tier = Dungeon.hero.tier(); if (tier != lastTier) { lastTier = tier; avatar.copy(HeroSprite.avatar(Dungeon.hero.heroClass, tier)); } }
public ListItem(Journal.Feature f, int d) { super(); feature.text(f.desc); feature.measure(); depth.text(Integer.toString(d)); depth.measure(); if (d == Dungeon.depth) { feature.hardlight(TITLE_COLOR); depth.hardlight(TITLE_COLOR); } }
@Override protected void layout() { bg.x = x; bg.y = y; slot.setRect(x, y, HEIGHT, HEIGHT); name.x = slot.right() + 2; name.y = y + (height - name.baseLine()) / 2; String str = Utils.capitalize(item.name()); name.text(str); name.measure(); if (name.width() > width - name.x) { do { str = str.substring(0, str.length() - 1); name.text(str + "..."); name.measure(); } while (name.width() > width - name.x); } super.layout(); }
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(); } }