public static BitmapTextMultiline createMultiline( String text, float size ) { chooseFont( size ); BitmapTextMultiline result = new BitmapTextMultiline( text, font ); result.scale.set( scale ); return result; }
public WndMessage( String text ) { super(); BitmapTextMultiline info = PixelScene.createMultiline( text, 6 ); info.maxWidth = (YetAnotherPixelDungeon.landscape() ? WIDTH_L : WIDTH_P) - MARGIN * 2; info.measure(); info.x = info.y = MARGIN; add( info ); resize( (int)info.width() + MARGIN * 2, (int)info.height() + MARGIN * 2 ); } }
public void text( String value, int maxWidth ) { Highlighter hl = new Highlighter( value ); normal.text( hl.text ); normal.maxWidth = maxWidth; normal.measure(); if (hl.isHighlighted()) { normal.mask = hl.inverted(); highlighted.text( hl.text ); highlighted.maxWidth = maxWidth; highlighted.measure(); highlighted.mask = hl.mask; highlighted.visible = true; } else { highlighted.visible = false; } width = normal.width(); height = normal.height(); }
tfTitle.hardlight( TITLE_COLOR ); tfTitle.x = tfTitle.y = MARGIN; tfTitle.maxWidth = WIDTH - MARGIN * 2; tfTitle.measure(); add( tfTitle ); tfMessage.measure(); tfMessage.x = MARGIN; tfMessage.y = tfTitle.y + tfTitle.height() + MARGIN; add( tfMessage ); float pos = tfMessage.y + tfMessage.height() + MARGIN;
text1.measure(); text1.x = align(landscape ? (Camera.main.width / 2 - text1.width()) / 2 : (Camera.main.width - text1.width()) / 2); text1.y = align( landscape ? (Camera.main.height - text1.height()) / 2 : (Camera.main.height / 2 - text1.height()) / 2 ) + 8; add(text1); title1.hardlight(Window.TITLE_COLOR); title1.measure(); title1.x = align(landscape ? (Camera.main.width / 2 - title1.width()) / 2 : (Camera.main.width - title1.width()) / 2); title1.y = text1.y - title1.height; add(title1); text2.measure(); text2.x = align( landscape ? (Camera.main.width / 2 - text2.width()) / 2 + Camera.main.width / 2 : (Camera.main.width - text2.width()) / 2); text2.y = align( landscape ? (Camera.main.height - text2.height()) / 2 : (Camera.main.height / 2 - text2.height()) / 2 + Camera.main.height / 2 ) + 8; add(text2); title2.hardlight(Window.TITLE_COLOR); title2.measure(); title2.x = align( landscape ? (Camera.main.width / 2 - title2.width()) / 2 + Camera.main.width / 2 : (Camera.main.width - title2.width()) / 2); title2.y = text2.y - title2.height; link1.measure(); link1.hardlight(Window.TITLE_COLOR); add( link1 ); link1.y = text1.y + text1.height() + 8; link2.measure(); link2.hardlight(Window.TITLE_COLOR);
@Override protected void layout() { health.visible = !Float.isNaN( healthLvl ); imIcon.x = x; imIcon.y = y; tfLabel.x = PixelScene.align( PixelScene.uiCamera, imIcon.x + imIcon.width() + GAP ); tfLabel.maxWidth = (int)(width - tfLabel.x); tfLabel.measure(); tfLabel.y = PixelScene.align( PixelScene.uiCamera, imIcon.height > tfLabel.height() ? imIcon.y + (imIcon.height() - tfLabel.baseLine()) / 2 : imIcon.y ); if (health.visible) { health.setRect( tfLabel.x, Math.max( tfLabel.y + tfLabel.height(), imIcon.y + imIcon.height() - health.height() ), tfLabel.maxWidth, 0 ); height = health.bottom(); } else { height = Math.max( imIcon.y + imIcon.height(), tfLabel.y + tfLabel.height() ); } }
getWordMetrics( word, metrics ); writer.addSymbol( metrics.x, metrics.y ); writer.addSpace( spaceSize );
public void label( String label ) { tfLabel.text( label ); }
@Override protected void layout() { super.layout(); shield.x = x; shield.y = y + (height - shield.height) / 2; position.x = align( shield.x + (shield.width - position.width()) / 2 ); position.y = align( shield.y + (shield.height - position.height()) / 2 + 1 ); if (flare != null) { flare.point( shield.center() ); } floorIcon.x = align( x + width - floorIcon.width * 2 ); floorIcon.y = shield.y; flNumber.x = align( floorIcon.x + (floorIcon.width - flNumber.width()) / 2 ); flNumber.y = align( floorIcon.y + (floorIcon.height - flNumber.height()) / 2 + 1 ); classIcon.x = align( x + width - classIcon.width ); classIcon.y = shield.y; chLevel.x = align( classIcon.x + (classIcon.width - chLevel.width()) / 2 ); chLevel.y = align( classIcon.y + (classIcon.height - chLevel.height()) / 2 + 1 ); desc.x = shield.x + shield.width + GAP; desc.maxWidth = (int)(floorIcon.x - desc.x); desc.measure(); desc.y = position.y + position.baseLine() - desc.baseLine(); }
); showDifficulty.hardlight( 0xAAAAAA ); showDifficulty.maxWidth = WIDTH - GAP * 2; showDifficulty.measure(); showDifficulty.x = ( WIDTH - showDifficulty.width() ) / 2 + GAP; showDifficulty.y = pos + ( BTN_HEIGHT / 2 - showDifficulty.height() ) / 2 + GAP * 2; add(showDifficulty); ); showVersion.hardlight( 0xAAAAAA ); showVersion.maxWidth = WIDTH - GAP * 2; showVersion.measure(); showVersion.x = ( WIDTH - showVersion.width() ) / 2 + GAP; showVersion.y = pos + ( BTN_HEIGHT - showVersion.height() / 2 ) / 2 + GAP * 2; add(showVersion);
public void text( String value, int maxWidth ) { Highlighter hl = new Highlighter( value ); normal.text( hl.text ); normal.maxWidth = maxWidth; normal.measure(); if (hl.isHighlighted()) { normal.mask = hl.inverted(); highlighted.text( hl.text ); highlighted.maxWidth = maxWidth; highlighted.measure(); highlighted.mask = hl.mask; highlighted.visible = true; } else { highlighted.visible = false; } width = normal.width(); height = normal.height(); }