public WndJournal() { super(); resize(WIDTH, ShatteredPixelDungeon.landscape() ? HEIGHT_L : HEIGHT_P); txtTitle = PixelScene.createText(TXT_TITLE, 9); txtTitle.hardlight(Window.TITLE_COLOR); txtTitle.measure(); txtTitle.x = PixelScene.align(PixelScene.uiCamera, (WIDTH - txtTitle.width()) / 2); add(txtTitle); Component content = new Component(); Collections.sort(Journal.records); float pos = 0; for (Journal.Record rec : Journal.records) { ListItem item = new ListItem(rec.feature, rec.depth); item.setRect(0, pos, WIDTH, ITEM_HEIGHT); content.add(item); pos += item.height(); } content.setSize(WIDTH, pos); list = new ScrollPane(content); add(list); list.setRect(0, txtTitle.height(), WIDTH, height - txtTitle.height()); }
@Override protected void createChildren() { super.createChildren(); bg = Chrome.get(Chrome.Type.BUTTON); add(bg); slot = new ItemSlot() { @Override protected void onTouchDown() { bg.brightness(1.2f); Sample.INSTANCE.play(Assets.SND_CLICK); }; @Override protected void onTouchUp() { bg.resetColor(); } @Override protected void onClick() { ItemButton.this.onClick(); } }; add(slot); }
@Override public void destroy() { super.destroy(); if (this == heroInstance) { heroInstance = null; } }
@Override protected void layout() { super.layout(); bg.x = x; bg.y = y; bg.size(width, height); slot.setRect(x + 2, y + 2, width - 4, height - 4); };
@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)); } }
@Override public void update() { super.update(); float shift = Game.elapsed * SCROLL_SPEED; if (reversed) { shift = -shift; } arcsBg.offset(0, shift); arcsFg.offset(0, shift * 2); offsB = arcsBg.offsetY(); offsF = arcsFg.offsetY(); }
@Override public void update() { super.update(); if (target != null && target.isAlive() && target.sprite.visible) { CharSprite sprite = target.sprite; bg.scale.x = sprite.width; level.scale.x = sprite.width * target.HP / target.HT; bg.x = level.x = sprite.x; bg.y = level.y = sprite.y - HEIGHT - 1; visible = true; } else { visible = false; } }
@Override public void destroy() { GLog.update.remove(this); super.destroy(); }