Java Code Examples for com.watabou.noosa.BitmapTextMultiline#height()
The following examples show how to use
com.watabou.noosa.BitmapTextMultiline#height() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WndClass.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 5 votes |
public HistoryTab() { super(); String[] items = cl.history(); float pos = MARGIN; for (int i=0; i < items.length; i++) { if (i > 0) { pos += GAP; } BitmapTextMultiline item = PixelScene.createMultiline( items[i], 6 ); item.x = MARGIN; item.y = pos; item.maxWidth = WIDTH - MARGIN * 2; item.measure(); add( item ); pos += item.height(); float w = item.width(); if (w > width) { width = w; } } width += MARGIN; height = pos + MARGIN; }
Example 2
Source File: GameLog.java From pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override protected void layout() { float pos = y; for (int i=length-1; i >= 0; i--) { BitmapTextMultiline entry = (BitmapTextMultiline)members.get( i ); entry.maxWidth = (int)width; entry.measure(); entry.x = x; entry.y = pos - entry.height(); pos -= entry.height(); } }
Example 3
Source File: WndOptions.java From pixel-dungeon with GNU General Public License v3.0 | 5 votes |
public WndOptions( String title, String message, String... options ) { super(); BitmapTextMultiline tfTitle = PixelScene.createMultiline( title, 9 ); tfTitle.hardlight( TITLE_COLOR ); tfTitle.x = tfTitle.y = MARGIN; tfTitle.maxWidth = WIDTH - MARGIN * 2; tfTitle.measure(); add( tfTitle ); BitmapTextMultiline tfMesage = PixelScene.createMultiline( message, 8 ); tfMesage.maxWidth = WIDTH - MARGIN * 2; tfMesage.measure(); tfMesage.x = MARGIN; tfMesage.y = tfTitle.y + tfTitle.height() + MARGIN; add( tfMesage ); float pos = tfMesage.y + tfMesage.height() + MARGIN; for (int i=0; i < options.length; i++) { final int index = i; RedButton btn = new RedButton( options[i] ) { @Override protected void onClick() { hide(); onSelect( index ); } }; btn.setRect( MARGIN, pos, WIDTH - MARGIN * 2, BUTTON_HEIGHT ); add( btn ); pos += BUTTON_HEIGHT + MARGIN; } resize( WIDTH, (int)pos ); }
Example 4
Source File: WndTradeItem.java From pixel-dungeon with GNU General Public License v3.0 | 5 votes |
private float createDescription( Item item, boolean forSale ) { IconTitle titlebar = new IconTitle(); titlebar.icon( new ItemSprite( item.image(), item.glowing() ) ); titlebar.label( forSale ? Utils.format( TXT_SALE, item.toString(), price( item ) ) : Utils.capitalize( item.toString() ) ); titlebar.setRect( 0, 0, WIDTH, 0 ); add( titlebar ); if (item.levelKnown) { if (item.level() < 0) { titlebar.color( ItemSlot.DEGRADED ); } else if (item.level() > 0) { titlebar.color( item.isBroken() ? ItemSlot.WARNING : ItemSlot.UPGRADED ); } } BitmapTextMultiline info = PixelScene.createMultiline( item.info(), 6 ); info.maxWidth = WIDTH; info.measure(); info.x = titlebar.left(); info.y = titlebar.bottom() + GAP; add( info ); return info.y + info.height(); }
Example 5
Source File: WndClass.java From pixel-dungeon with GNU General Public License v3.0 | 5 votes |
public PerksTab() { super(); float dotWidth = 0; String[] items = cl.perks(); float pos = MARGIN; 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 > width) { width = w; } } width += MARGIN + dotWidth; height = pos + MARGIN; }
Example 6
Source File: GameLog.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override protected void layout() { float pos = y; for (int i=length-1; i >= 0; i--) { BitmapTextMultiline entry = (BitmapTextMultiline)members.get( i ); entry.x = x; entry.y = pos - entry.height(); pos -= entry.height(); } }
Example 7
Source File: WndList.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
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) ); }
Example 8
Source File: WndOptions.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
public WndOptions( String title, String message, String... options ) { super(); BitmapTextMultiline tfTitle = PixelScene.createMultiline( title, 9 ); tfTitle.hardlight( TITLE_COLOR ); tfTitle.x = tfTitle.y = MARGIN; tfTitle.maxWidth = WIDTH - MARGIN * 2; tfTitle.measure(); add( tfTitle ); BitmapTextMultiline tfMesage = PixelScene.createMultiline( message, 8 ); tfMesage.maxWidth = WIDTH - MARGIN * 2; tfMesage.measure(); tfMesage.x = MARGIN; tfMesage.y = tfTitle.y + tfTitle.height() + MARGIN; add( tfMesage ); float pos = tfMesage.y + tfMesage.height() + MARGIN; for (int i=0; i < options.length; i++) { final int index = i; RedButton btn = new RedButton( options[i] ) { @Override protected void onClick() { hide(); onSelect( index ); } }; btn.setRect( MARGIN, pos, WIDTH - MARGIN * 2, BUTTON_HEIGHT ); add( btn ); pos += BUTTON_HEIGHT + MARGIN; } resize( WIDTH, (int)pos ); }
Example 9
Source File: WndTradeItem.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
private float createDescription( Item item, boolean forSale ) { // Title IconTitle titlebar = new IconTitle(); titlebar.icon( new ItemSprite( item ) ); titlebar.label( forSale ? Utils.format( TXT_SALE, item.toString(), price( item ) ) : Utils.capitalize( item.toString() ) ); titlebar.setRect( 0, 0, WIDTH, 0 ); add( titlebar ); // Upgraded / degraded if (item.levelKnown && item.level > 0) { titlebar.color( ItemSlot.UPGRADED ); } else if (item.levelKnown && item.level < 0) { titlebar.color( ItemSlot.DEGRADED ); } // Description BitmapTextMultiline info = PixelScene.createMultiline( item.info(), 6 ); info.maxWidth = WIDTH; info.measure(); info.x = titlebar.left(); info.y = titlebar.bottom() + GAP; add( info ); return info.y + info.height(); }
Example 10
Source File: WndClass.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
public PerksTab() { super(); float dotWidth = 0; String[] items = cl.perks(); float pos = MARGIN; 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 > width) { width = w; } } width += MARGIN + dotWidth; height = pos + MARGIN; }
Example 11
Source File: GameLog.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 5 votes |
@Override protected void layout() { float pos = y; for (int i=length-1; i >= 0; i--) { BitmapTextMultiline entry = (BitmapTextMultiline)members.get( i ); entry.x = x; entry.y = pos - entry.height(); pos -= entry.height(); } }
Example 12
Source File: WndClass.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 5 votes |
public DetailsTab() { super(); float dotWidth = 0; String[] items = cl.details(); float pos = MARGIN; 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 > width) { width = w; } } width += MARGIN + dotWidth; height = pos + MARGIN; }
Example 13
Source File: AmuletScene.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 4 votes |
@Override public void create() { super.create(); BitmapTextMultiline text = null; if (!noText) { text = createMultiline( TXT, 8 ); text.maxWidth = WIDTH; text.measure(); add( text ); } amulet = new Image( Assets.AMULET ); add( amulet ); RedButton btnExit = new RedButton( TXT_EXIT ) { @Override protected void onClick() { Dungeon.win( ResultDescriptions.WIN ); Dungeon.deleteGame( Dungeon.hero.heroClass, true ); Game.switchScene( noText ? TitleScene.class : RankingsScene.class ); } }; btnExit.setSize( WIDTH, BTN_HEIGHT ); add( btnExit ); RedButton btnStay = new RedButton( TXT_STAY ) { @Override protected void onClick() { onBackPressed(); } }; btnStay.setSize( WIDTH, BTN_HEIGHT ); add( btnStay ); float height; if (noText) { height = amulet.height + LARGE_GAP + btnExit.height() + SMALL_GAP + btnStay.height(); amulet.x = align( (Camera.main.width - amulet.width) / 2 ); amulet.y = align( (Camera.main.height - height) / 2 ); btnExit.setPos( (Camera.main.width - btnExit.width()) / 2, amulet.y + amulet.height + LARGE_GAP ); btnStay.setPos( btnExit.left(), btnExit.bottom() + SMALL_GAP ); } else { height = amulet.height + LARGE_GAP + text.height() + LARGE_GAP + btnExit.height() + SMALL_GAP + btnStay.height(); amulet.x = align( (Camera.main.width - amulet.width) / 2 ); amulet.y = align( (Camera.main.height - height) / 2 ); text.x = align( (Camera.main.width - text.width()) / 2 ); text.y = amulet.y + amulet.height + LARGE_GAP; btnExit.setPos( (Camera.main.width - btnExit.width()) / 2, text.y + text.height() + LARGE_GAP ); btnStay.setPos( btnExit.left(), btnExit.bottom() + SMALL_GAP ); } new Flare( 8, 48 ).color( 0xFFDDBB, true ).show( amulet, 0 ).angularSpeed = +30; fadeIn(); }
Example 14
Source File: Weightstone.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 4 votes |
public WndBalance( final Weapon weapon ) { super(); IconTitle titlebar = new IconTitle( weapon ); titlebar.setRect( 0, 0, WIDTH, 0 ); add( titlebar ); BitmapTextMultiline tfMesage = PixelScene.createMultiline( Utils.format( TXT_CHOICE, weapon.name() ), 8 ); tfMesage.maxWidth = WIDTH - MARGIN * 2; tfMesage.measure(); tfMesage.x = MARGIN; tfMesage.y = titlebar.bottom() + MARGIN; add( tfMesage ); float pos = tfMesage.y + tfMesage.height(); if (weapon.imbue != Weapon.Imbue.LIGHT) { RedButton btnSpeed = new RedButton( TXT_LIGHT ) { @Override protected void onClick() { hide(); Weightstone.this.apply( weapon, true ); } }; btnSpeed.setRect( MARGIN, pos + MARGIN, BUTTON_WIDTH, BUTTON_HEIGHT ); add( btnSpeed ); pos = btnSpeed.bottom(); } if (weapon.imbue != Weapon.Imbue.HEAVY) { RedButton btnAccuracy = new RedButton( TXT_HEAVY ) { @Override protected void onClick() { hide(); Weightstone.this.apply( weapon, false ); } }; btnAccuracy.setRect( MARGIN, pos + MARGIN, BUTTON_WIDTH, BUTTON_HEIGHT ); add( btnAccuracy ); pos = btnAccuracy.bottom(); } RedButton btnCancel = new RedButton( TXT_CANCEL ) { @Override protected void onClick() { hide(); } }; btnCancel.setRect( MARGIN, pos + MARGIN, BUTTON_WIDTH, BUTTON_HEIGHT ); add( btnCancel ); resize( WIDTH, (int)btnCancel.bottom() + MARGIN ); }
Example 15
Source File: AboutScene.java From pixel-dungeon with GNU General Public License v3.0 | 4 votes |
@Override public void create() { super.create(); BitmapTextMultiline text = createMultiline( TXT, 8 ); text.maxWidth = Math.min( Camera.main.width, 120 ); text.measure(); add( text ); text.x = align( (Camera.main.width - text.width()) / 2 ); text.y = align( (Camera.main.height - text.height()) / 2 ); BitmapTextMultiline link = createMultiline( LNK, 8 ); link.maxWidth = Math.min( Camera.main.width, 120 ); link.measure(); link.hardlight( Window.TITLE_COLOR ); add( link ); link.x = text.x; link.y = text.y + text.height(); TouchArea hotArea = new TouchArea( link ) { @Override protected void onClick( Touch touch ) { Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse( "http://" + LNK ) ); Game.instance.startActivity( intent ); } }; add( hotArea ); Image wata = Icons.WATA.get(); wata.x = align( (Camera.main.width - wata.width) / 2 ); wata.y = text.y - wata.height - 8; add( wata ); new Flare( 7, 64 ).color( 0x112233, true ).show( wata, 0 ).angularSpeed = +20; Archs archs = new Archs(); archs.setSize( Camera.main.width, Camera.main.height ); addToBack( archs ); ExitButton btnExit = new ExitButton(); btnExit.setPos( Camera.main.width - btnExit.width(), 0 ); add( btnExit ); fadeIn(); }
Example 16
Source File: AmuletScene.java From pixel-dungeon with GNU General Public License v3.0 | 4 votes |
@Override public void create() { super.create(); BitmapTextMultiline text = null; if (!noText) { text = createMultiline( TXT, 8 ); text.maxWidth = WIDTH; text.measure(); add( text ); } amulet = new Image( Assets.AMULET ); add( amulet ); RedButton btnExit = new RedButton( TXT_EXIT ) { @Override protected void onClick() { Dungeon.win( ResultDescriptions.WIN ); Dungeon.deleteGame( Dungeon.hero.heroClass, true ); Game.switchScene( noText ? TitleScene.class : RankingsScene.class ); } }; btnExit.setSize( WIDTH, BTN_HEIGHT ); add( btnExit ); RedButton btnStay = new RedButton( TXT_STAY ) { @Override protected void onClick() { onBackPressed(); } }; btnStay.setSize( WIDTH, BTN_HEIGHT ); add( btnStay ); float height; if (noText) { height = amulet.height + LARGE_GAP + btnExit.height() + SMALL_GAP + btnStay.height(); amulet.x = align( (Camera.main.width - amulet.width) / 2 ); amulet.y = align( (Camera.main.height - height) / 2 ); btnExit.setPos( (Camera.main.width - btnExit.width()) / 2, amulet.y + amulet.height + LARGE_GAP ); btnStay.setPos( btnExit.left(), btnExit.bottom() + SMALL_GAP ); } else { height = amulet.height + LARGE_GAP + text.height() + LARGE_GAP + btnExit.height() + SMALL_GAP + btnStay.height(); amulet.x = align( (Camera.main.width - amulet.width) / 2 ); amulet.y = align( (Camera.main.height - height) / 2 ); text.x = align( (Camera.main.width - text.width()) / 2 ); text.y = amulet.y + amulet.height + LARGE_GAP; btnExit.setPos( (Camera.main.width - btnExit.width()) / 2, text.y + text.height() + LARGE_GAP ); btnStay.setPos( btnExit.left(), btnExit.bottom() + SMALL_GAP ); } new Flare( 8, 48 ).color( 0xFFDDBB, true ).show( amulet, 0 ).angularSpeed = +30; fadeIn(); }
Example 17
Source File: WndOptions.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 4 votes |
public WndOptions( String title, String message, String... options ) { super(); this.disabled = disabled(); BitmapTextMultiline tfTitle = PixelScene.createMultiline( title, 9 ); tfTitle.hardlight( TITLE_COLOR ); tfTitle.x = tfTitle.y = MARGIN; tfTitle.maxWidth = WIDTH - MARGIN * 2; tfTitle.measure(); add( tfTitle ); BitmapTextMultiline tfMessage = PixelScene.createMultiline( message, 7 ); tfMessage.maxWidth = WIDTH - MARGIN * 2; tfMessage.measure(); tfMessage.x = MARGIN; tfMessage.y = tfTitle.y + tfTitle.height() + MARGIN; add( tfMessage ); float pos = tfMessage.y + tfMessage.height() + MARGIN; for (int i=0; i < options.length; i++) { final int index = i; RedButton btn = new RedButton( options[i] ) { @Override protected void onClick() { hide(); onSelect( index ); } }; if( disabled != null && disabled.contains( index ) ) { btn.textColor( DISABLED_COLOR ); } btn.setRect( MARGIN, pos, WIDTH - MARGIN * 2, BUTTON_HEIGHT ); add( btn ); pos += BUTTON_HEIGHT + MARGIN; } resize( WIDTH, (int)pos ); }
Example 18
Source File: AmuletScene.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 4 votes |
@Override public void create() { super.create(); BitmapTextMultiline text = null; text = createMultiline( !noText ? TXT : TXT_SHORT , 6 ); text.maxWidth = WIDTH; text.measure(); add( text ); amulet = new Image( Assets.AMULET ); add( amulet ); RedButton btnExit = new RedButton( TXT_EXIT ) { @Override protected void onClick() { Dungeon.win( ResultDescriptions.WIN ); Dungeon.deleteGame( Dungeon.hero.heroClass, true ); Game.switchScene( noText ? TitleScene.class : RankingsScene.class ); } }; btnExit.setSize( WIDTH, BTN_HEIGHT ); add( btnExit ); RedButton btnStay = new RedButton( TXT_STAY ) { @Override protected void onClick() { onBackPressed(); } }; btnStay.setSize( WIDTH, BTN_HEIGHT ); add( btnStay ); float height; // if (noText) { // height = amulet.height + LARGE_GAP + btnExit.height() + SMALL_GAP + btnStay.height(); // // amulet.x = align( (Camera.main.width - amulet.width) / 2 ); // amulet.y = align( (Camera.main.height - height) / 2 ); // // btnExit.setPos( (Camera.main.width - btnExit.width()) / 2, amulet.y + amulet.height + LARGE_GAP ); // btnStay.setPos( btnExit.left(), btnExit.bottom() + SMALL_GAP ); // } else { height = amulet.height + LARGE_GAP + text.height() + LARGE_GAP + btnExit.height() + SMALL_GAP + btnStay.height(); amulet.x = align( (Camera.main.width - amulet.width) / 2 ); amulet.y = align( (Camera.main.height - height) / 2 ); text.x = align( (Camera.main.width - text.width()) / 2 ); text.y = amulet.y + amulet.height + LARGE_GAP; btnExit.setPos( (Camera.main.width - btnExit.width()) / 2, text.y + text.height() + LARGE_GAP ); btnStay.setPos( btnExit.left(), btnExit.bottom() + SMALL_GAP ); // } new Flare( 8, 48 ).color( 0xFFDDBB, true ).show( amulet, 0 ).angularSpeed = +30; fadeIn(); }
Example 19
Source File: Weightstone.java From pixel-dungeon with GNU General Public License v3.0 | 4 votes |
public WndBalance( final Weapon weapon ) { super(); IconTitle titlebar = new IconTitle( weapon ); titlebar.setRect( 0, 0, WIDTH, 0 ); add( titlebar ); BitmapTextMultiline tfMesage = PixelScene.createMultiline( Utils.format( TXT_CHOICE, weapon.name() ), 8 ); tfMesage.maxWidth = WIDTH - MARGIN * 2; tfMesage.measure(); tfMesage.x = MARGIN; tfMesage.y = titlebar.bottom() + MARGIN; add( tfMesage ); float pos = tfMesage.y + tfMesage.height(); if (weapon.imbue != Weapon.Imbue.SPEED) { RedButton btnSpeed = new RedButton( TXT_SPEED ) { @Override protected void onClick() { hide(); Weightstone.this.apply( weapon, true ); } }; btnSpeed.setRect( MARGIN, pos + MARGIN, BUTTON_WIDTH, BUTTON_HEIGHT ); add( btnSpeed ); pos = btnSpeed.bottom(); } if (weapon.imbue != Weapon.Imbue.ACCURACY) { RedButton btnAccuracy = new RedButton( TXT_ACCURACY ) { @Override protected void onClick() { hide(); Weightstone.this.apply( weapon, false ); } }; btnAccuracy.setRect( MARGIN, pos + MARGIN, BUTTON_WIDTH, BUTTON_HEIGHT ); add( btnAccuracy ); pos = btnAccuracy.bottom(); } RedButton btnCancel = new RedButton( TXT_CANCEL ) { @Override protected void onClick() { hide(); } }; btnCancel.setRect( MARGIN, pos + MARGIN, BUTTON_WIDTH, BUTTON_HEIGHT ); add( btnCancel ); resize( WIDTH, (int)btnCancel.bottom() + MARGIN ); }