com.watabou.noosa.BitmapTextMultiline Java Examples

The following examples show how to use com.watabou.noosa.BitmapTextMultiline. 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: WndInfoPlant.java    From pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
public WndInfoPlant( Plant plant ) {
	
	super();
	
	IconTitle titlebar = new IconTitle();
	titlebar.icon( new PlantSprite( plant.image ) );
	titlebar.label( plant.plantName );
	titlebar.setRect( 0, 0, WIDTH, 0 );
	add( titlebar );
	
	BitmapTextMultiline info = PixelScene.createMultiline( 6 );
	add( info );
	
	info.text( plant.desc() );
	info.maxWidth = WIDTH;
	info.measure();
	info.x = titlebar.left();
	info.y = titlebar.bottom() + GAP;
	
	resize( WIDTH, (int)(info.y + info.height()) );
}
 
Example #2
Source File: WndInfoBuff.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
public WndInfoBuff(Buff buff){
	super();

	IconTitle titlebar = new IconTitle();

	icons = TextureCache.get( Assets.BUFFS_LARGE );
	film = new TextureFilm( icons, 16, 16 );

	Image buffIcon = new Image( icons );
	buffIcon.frame( film.get(buff.icon()) );

	titlebar.icon( buffIcon );
	titlebar.label( Utils.capitalize(buff.toString()), Window.TITLE_COLOR );
	titlebar.setRect( 0, 0, WIDTH, 0 );
	add( titlebar );

	BitmapTextMultiline txtInfo = PixelScene.createMultiline(buff.desc(), 6);
	txtInfo.maxWidth = WIDTH;
	txtInfo.measure();
	txtInfo.x = titlebar.left();
	txtInfo.y = titlebar.bottom() + GAP;
	add( txtInfo );

	resize( WIDTH, (int)(txtInfo.y + txtInfo.height()) );
}
 
Example #3
Source File: WndInfoItem.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
private void fillFields( int image, ItemSprite.Glowing glowing, int titleColor, String title, String info ) {
	
	IconTitle titlebar = new IconTitle();
	titlebar.icon( new ItemSprite( image, glowing ) );
	titlebar.label( Utils.capitalize( title ), titleColor );
	titlebar.setRect( 0, 0, WIDTH, 0 );
	add( titlebar );
	
	BitmapTextMultiline txtInfo = PixelScene.createMultiline( info, 6 );
	txtInfo.maxWidth = WIDTH;
	txtInfo.measure();
	txtInfo.x = titlebar.left();
	txtInfo.y = titlebar.bottom() + GAP;
	add( txtInfo );
	
	resize( WIDTH, (int)(txtInfo.y + txtInfo.height()) );
}
 
Example #4
Source File: WndInfoItem.java    From pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
private void fillFields( int image, ItemSprite.Glowing glowing, int titleColor, String title, String info ) {
	
	IconTitle titlebar = new IconTitle();
	titlebar.icon( new ItemSprite( image, glowing ) );
	titlebar.label( Utils.capitalize( title ), titleColor );
	titlebar.setRect( 0, 0, WIDTH, 0 );
	add( titlebar );
	
	BitmapTextMultiline txtInfo = PixelScene.createMultiline( info, 6 );
	txtInfo.maxWidth = WIDTH;
	txtInfo.measure();
	txtInfo.x = titlebar.left();
	txtInfo.y = titlebar.bottom() + GAP;
	add( txtInfo );
	
	resize( WIDTH, (int)(txtInfo.y + txtInfo.height()) );
}
 
Example #5
Source File: WndClass.java    From pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
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: WndList.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
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 #7
Source File: GameLog.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@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 #8
Source File: WndBadge.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public WndBadge( Badges.Badge badge ) {
	
	super();
	
	Image icon = BadgeBanner.image( badge.image );
	icon.scale.set( 2 );
	add( icon );
	
	BitmapTextMultiline info = PixelScene.createMultiline( badge.description, 8 );
	info.maxWidth = WIDTH - MARGIN * 2;
	info.measure();
	
	float w = Math.max( icon.width(), info.width() ) + MARGIN * 2;
	
	icon.x = (w - icon.width()) / 2;
	icon.y = MARGIN;
	
	float pos = icon.y + icon.height() + MARGIN;
	for (BitmapText line : info.new LineSplitter().split()) {
		line.measure();
		line.x = PixelScene.align( (w - line.width()) / 2 );
		line.y = PixelScene.align( pos );
		add( line );
		
		pos += line.height();
	}

	resize( (int)w, (int)(pos + MARGIN) );
	
	BadgeBanner.highlight( icon, badge.image );
}
 
Example #9
Source File: WndOptions.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
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 #10
Source File: WndTradeItem.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
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 #11
Source File: WndMessage.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public WndMessage( String text ) {
	
	super();
	
	BitmapTextMultiline info = PixelScene.createMultiline( text, 6 );
	info.maxWidth = (ShatteredPixelDungeon.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 );
}
 
Example #12
Source File: WndImp.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public WndImp( final Imp imp, final DwarfToken tokens ) {
	
	super();
	
	IconTitle titlebar = new IconTitle();
	titlebar.icon( new ItemSprite( tokens.image(), null ) );
	titlebar.label( Utils.capitalize( tokens.name() ) );
	titlebar.setRect( 0, 0, WIDTH, 0 );
	add( titlebar );
	
	BitmapTextMultiline message = PixelScene.createMultiline( TXT_MESSAGE, 6 );
	message.maxWidth = WIDTH;
	message.measure();
	message.y = titlebar.bottom() + GAP;
	add( message );
	
	RedButton btnReward = new RedButton( TXT_REWARD ) {
		@Override
		protected void onClick() {
			takeReward( imp, tokens, Imp.Quest.reward );
		}
	};
	btnReward.setRect( 0, message.y + message.height() + GAP, WIDTH, BTN_HEIGHT );
	add( btnReward );
	
	resize( WIDTH, (int)btnReward.bottom() );
}
 
Example #13
Source File: WndClass.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
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 #14
Source File: WndImp.java    From pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public WndImp( final Imp imp, final DwarfToken tokens ) {
	
	super();
	
	IconTitle titlebar = new IconTitle();
	titlebar.icon( new ItemSprite( tokens.image(), null ) );
	titlebar.label( Utils.capitalize( tokens.name() ) );
	titlebar.setRect( 0, 0, WIDTH, 0 );
	add( titlebar );
	
	BitmapTextMultiline message = PixelScene.createMultiline( TXT_MESSAGE, 6 );
	message.maxWidth = WIDTH;
	message.measure();
	message.y = titlebar.bottom() + GAP;
	add( message );
	
	RedButton btnReward = new RedButton( TXT_REWARD ) {
		@Override
		protected void onClick() {
			takeReward( imp, tokens, Imp.Quest.reward );
		}
	};
	btnReward.setRect( 0, message.y + message.height() + GAP, WIDTH, BTN_HEIGHT );
	add( btnReward );
	
	resize( WIDTH, (int)btnReward.bottom() );
}
 
Example #15
Source File: GameLog.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
@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 #16
Source File: WndTradeItem.java    From pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
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 #17
Source File: GameLog.java    From pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@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 #18
Source File: WndWandmaker.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
public WndWandmaker( final Wandmaker wandmaker, final Item item ) {
	
	super();
	
	IconTitle titlebar = new IconTitle();
	titlebar.icon( new ItemSprite( item.image(), null ) );
	titlebar.label( Utils.capitalize( item.name() ) );
	titlebar.setRect( 0, 0, WIDTH, 0 );
	add( titlebar );
	
	BitmapTextMultiline message = PixelScene.createMultiline( TXT_MESSAGE, 6 );
	message.maxWidth = WIDTH;
	message.measure();
	message.y = titlebar.bottom() + GAP;
	add( message );
	
	RedButton btnBattle = new RedButton( Wandmaker.Quest.wand1.name() ) {
		@Override
		protected void onClick() {
			selectReward( wandmaker, item, Wandmaker.Quest.wand1 );
		}
	};
	btnBattle.setRect( 0, message.y + message.height() + GAP, WIDTH, BTN_HEIGHT );
	add( btnBattle );
	
	RedButton btnNonBattle = new RedButton( Wandmaker.Quest.wand2.name() ) {
		@Override
		protected void onClick() {
			selectReward( wandmaker, item, Wandmaker.Quest.wand2 );
		}
	};
	btnNonBattle.setRect( 0, btnBattle.bottom() + GAP, WIDTH, BTN_HEIGHT );
	add( btnNonBattle );
	
	resize( WIDTH, (int)btnNonBattle.bottom() );
}
 
Example #19
Source File: WndSadGhost.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
public WndSadGhost( final Ghost ghost, final Item item ) {
	
	super();
	
	IconTitle titlebar = new IconTitle();
	titlebar.icon( new ItemSprite( item.image(), null ) );
	titlebar.label( Utils.capitalize( item.name() ) );
	titlebar.setRect( 0, 0, WIDTH, 0 );
	add( titlebar );
	
	BitmapTextMultiline message = PixelScene.createMultiline( item instanceof DriedRose ? TXT_ROSE : TXT_RAT, 6 );
	message.maxWidth = WIDTH;
	message.measure();
	message.y = titlebar.bottom() + GAP;
	add( message );
	
	RedButton btnWeapon = new RedButton( Ghost.Quest.weapon.toString() ) {
		@Override
		protected void onClick() {
			selectReward( ghost, item, Ghost.Quest.weapon );
		}
	};
	btnWeapon.setRect( 0, message.y + message.height() + GAP, WIDTH, BTN_HEIGHT );
	add( btnWeapon );
	
	RedButton btnArmor = new RedButton( Ghost.Quest.armor.toString() ) {
		@Override
		protected void onClick() {
			selectReward( ghost, item, Ghost.Quest.armor );
		}
	};
	btnArmor.setRect( 0, btnWeapon.bottom() + GAP, WIDTH, BTN_HEIGHT );
	add( btnArmor );
	
	resize( WIDTH, (int)btnArmor.bottom() );
}
 
Example #20
Source File: WndClass.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
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 #21
Source File: WndClass.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
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 #22
Source File: WndBadge.java    From pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public WndBadge( Badges.Badge badge ) {
	
	super();
	
	Image icon = BadgeBanner.image( badge.image );
	icon.scale.set( 2 );
	add( icon );
	
	BitmapTextMultiline info = PixelScene.createMultiline( badge.description, 8 );
	info.maxWidth = WIDTH - MARGIN * 2;
	info.measure();
	
	float w = Math.max( icon.width(), info.width() ) + MARGIN * 2;
	
	icon.x = (w - icon.width()) / 2;
	icon.y = MARGIN;
	
	float pos = icon.y + icon.height() + MARGIN;
	for (BitmapText line : info.new LineSplitter().split()) {
		line.measure();
		line.x = PixelScene.align( (w - line.width()) / 2 );
		line.y = PixelScene.align( pos );
		add( line );
		
		pos += line.height(); 
	}

	resize( (int)w, (int)(pos + MARGIN) );
	
	BadgeBanner.highlight( icon, badge.image );
}
 
Example #23
Source File: WndMessage.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
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 );
}
 
Example #24
Source File: WndOptions.java    From pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
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 #25
Source File: WndBadge.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
public WndBadge( Badges.Badge badge ) {
	
	super();
	
	Image icon = BadgeBanner.image( badge.image );
	icon.scale.set( 2 );
	add( icon );
	
	BitmapTextMultiline info = PixelScene.createMultiline( badge.description, 8 );
	info.maxWidth = WIDTH - MARGIN * 2;
	info.measure();
	
	float w = Math.max( icon.width(), info.width() ) + MARGIN * 2;
	
	icon.x = (w - icon.width()) / 2;
	icon.y = MARGIN;
	
	float pos = icon.y + icon.height() + MARGIN;
	for (BitmapText line : info.new LineSplitter().split()) {
		line.measure();
		line.x = PixelScene.align( (w - line.width()) / 2 );
		line.y = PixelScene.align( pos );
		add( line );
		
		pos += line.height(); 
	}

	resize( (int)w, (int)(pos + MARGIN) );
	
	BadgeBanner.highlight( icon, badge.image );
}
 
Example #26
Source File: WndMessage.java    From pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public WndMessage( String text ) {
	
	super();
	
	BitmapTextMultiline info = PixelScene.createMultiline( text, 6 );
	info.maxWidth = (PixelDungeon.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 );
}
 
Example #27
Source File: PixelScene.java    From pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
public static BitmapTextMultiline createMultiline( float size ) {
	return createMultiline( null, size );
}
 
Example #28
Source File: AboutScene.java    From pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@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 #29
Source File: AmuletScene.java    From pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@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 #30
Source File: WndBlacksmith.java    From pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
public WndBlacksmith( Blacksmith troll, Hero hero ) {
	
	super();
	
	IconTitle titlebar = new IconTitle();
	titlebar.icon( troll.sprite() );
	titlebar.label( Utils.capitalize( troll.name ) );
	titlebar.setRect( 0, 0, WIDTH, 0 );
	add( titlebar );
	
	BitmapTextMultiline message = PixelScene.createMultiline( TXT_PROMPT, 6 );
	message.maxWidth = WIDTH;
	message.measure();
	message.y = titlebar.bottom() + GAP;
	add( message );
	
	btnItem1 = new ItemButton() {
		@Override
		protected void onClick() {
			btnPressed = btnItem1;
			GameScene.selectItem( itemSelector, WndBag.Mode.UPGRADEABLE, TXT_SELECT );
		}
	};
	btnItem1.setRect( (WIDTH - BTN_GAP) / 2 - BTN_SIZE, message.y + message.height() + BTN_GAP, BTN_SIZE, BTN_SIZE );
	add( btnItem1 );
	
	btnItem2 = new ItemButton() {
		@Override
		protected void onClick() {
			btnPressed = btnItem2;
			GameScene.selectItem( itemSelector, WndBag.Mode.UPGRADEABLE, TXT_SELECT );
		}
	};
	btnItem2.setRect( btnItem1.right() + BTN_GAP, btnItem1.top(), BTN_SIZE, BTN_SIZE );
	add( btnItem2 );
	
	btnReforge = new RedButton( TXT_REFORGE ) {
		@Override
		protected void onClick() {
			Blacksmith.upgrade( btnItem1.item, btnItem2.item );
			hide();
		}
	};
	btnReforge.enable( false );
	btnReforge.setRect( 0, btnItem1.bottom() + BTN_GAP, WIDTH, 20 );
	add( btnReforge );
	
	
	resize( WIDTH, (int)btnReforge.bottom() );
}