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 layout() { icon.x = width - icon.width; depth.x = icon.x - 1 - depth.width(); depth.y = PixelScene.align(y + (height - depth.height()) / 2); icon.y = depth.y - 1; feature.y = PixelScene.align(depth.y + depth.baseLine() - feature.baseLine()); }
@Override protected void createChildren() { feature = PixelScene.createText(9); add(feature); depth = new BitmapText(PixelScene.font1x); add(depth); icon = Icons.get(Icons.DEPTH); add(icon); }
public WndList(String[] items) { super(); float pos = MARGIN; float dotWidth = 0; float maxWidth = 0; for (int i = 0; i < items.length; i++) { if (i > 0) { pos += GAP; } BitmapText dot = PixelScene.createText(DOT, 6); dot.x = MARGIN; dot.y = pos; if (dotWidth == 0) { dot.measure(); dotWidth = dot.width(); } add(dot); BitmapTextMultiline item = PixelScene.createMultiline(items[i], 6); item.x = dot.x + dotWidth; item.y = pos; item.maxWidth = (int) (WIDTH - MARGIN * 2 - dotWidth); item.measure(); add(item); pos += item.height(); float w = item.width(); if (w > maxWidth) { maxWidth = w; } } resize((int) (maxWidth + dotWidth + MARGIN * 2), (int) (pos + MARGIN)); }