Java Code Examples for com.watabou.noosa.BitmapTextMultiline#measure()

The following examples show how to use com.watabou.noosa.BitmapTextMultiline#measure() . 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: 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 2
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 3
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 4
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 5
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 6
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 7
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 8
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 9
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 10
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 11
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 12
Source File: WndImp.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 4 votes vote down vote up
public WndImp( final AmbitiousImp 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 );

       String story = TXT_MESSAGE;

       switch( Dungeon.hero.heroClass ) {
           case WARRIOR:
               story = Utils.format( story, "paladin" );
               break;
           case SCHOLAR:
               story = Utils.format( story, "sorcerer" );
               break;
           case BRIGAND:
               story = Utils.format( story, "assassin" );
               break;
           case ACOLYTE:
               story = Utils.format( story, "ranger" );
               break;
       }


	BitmapTextMultiline message = PixelScene.createMultiline( story, 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, AmbitiousImp.Quest.reward );
		}
	};
	btnReward.setRect( 0, message.y + message.height() + GAP, WIDTH, BTN_HEIGHT );
	add( btnReward );
	
	resize( WIDTH, (int)btnReward.bottom() );
}
 
Example 13
Source File: WndOptions.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 4 votes vote down vote up
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 14
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 15
Source File: WndBlacksmith.java    From YetAnotherPixelDungeon 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() );
}
 
Example 16
Source File: WndResurrect.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 4 votes vote down vote up
public WndResurrect( final Ankh ankh, Object killedBy, Element killedWith ) {
	
	super();
	
	instance = this;
	WndResurrect.killedBy = killedBy;
	WndResurrect.killedWith = killedWith;

	IconTitle titlebar = new IconTitle();
	titlebar.icon( new ItemSprite( ankh.image(), null ) );
	titlebar.label( ankh.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 btnYes = new RedButton( TXT_YES ) {
		@Override
		protected void onClick() {
			hide();
			
			Statistics.ankhsUsed++;

			InterlevelScene.mode = InterlevelScene.Mode.RESURRECT ;

               ankh.detach( Dungeon.hero.belongings.backpack );

			Game.switchScene( InterlevelScene.class );
		}
	};
	btnYes.setRect( 0, message.y + message.height() + GAP, WIDTH, BTN_HEIGHT );
	add( btnYes );
	
	RedButton btnNo = new RedButton( TXT_NO ) {
		@Override
		protected void onClick() {
			hide();
			
			Rankings.INSTANCE.submit( false );
			Hero.reallyDie( WndResurrect.killedBy, WndResurrect.killedWith );
		}
	};
	btnNo.setRect( 0, btnYes.bottom() + GAP, WIDTH, BTN_HEIGHT );
	add( btnNo );
	
	resize( WIDTH, (int)btnNo.bottom() );
}
 
Example 17
Source File: WelcomeScene.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void create() {
	super.create();

	final int gameversion = ShatteredPixelDungeon.version();

	BitmapTextMultiline title;
	BitmapTextMultiline text;

	if (gameversion == 0) {

		text = createMultiline(TXT_Welcome, 8);
		title = createMultiline(TTL_Welcome, 16);

	} else if (gameversion <= Game.versionCode) {

		text = createMultiline(TXT_Update, 6 );
		title = createMultiline(TTL_Update, 9 );

	} else {

		text = createMultiline( TXT_Future, 8 );
		title = createMultiline( TTL_Future, 16 );

	}

	int w = Camera.main.width;
	int h = Camera.main.height;

	int pw = w - 10;
	int ph = h - 50;

	title.maxWidth = pw;
	title.measure();
	title.hardlight(Window.SHPX_COLOR);

	title.x = align( (w - title.width()) / 2 );
	title.y = align( 8 );
	add( title );

	NinePatch panel = Chrome.get(Chrome.Type.WINDOW);
	panel.size( pw, ph );
	panel.x = (w - pw) / 2;
	panel.y = (h - ph) / 2;
	add( panel );

	ScrollPane list = new ScrollPane( new Component() );
	add( list );
	list.setRect(
			panel.x + panel.marginLeft(),
			panel.y + panel.marginTop(),
			panel.innerWidth(),
			panel.innerHeight());
	list.scrollTo( 0, 0 );

	Component content = list.content();
	content.clear();

	text.maxWidth = (int) panel.innerWidth();
	text.measure();

	content.add(text);

	content.setSize( panel.innerWidth(), text.height() );

	RedButton okay = new RedButton("Okay!") {
		@Override
		protected void onClick() {
			ShatteredPixelDungeon.version(Game.versionCode);
			Game.switchScene(TitleScene.class);
		}
	};

	/*
	okay.setRect(text.x, text.y + text.height() + 5, 55, 18);
	add(okay);

	RedButton changes = new RedButton("Changes") {
		@Override
		protected void onClick() {
			parent.add(new WndChanges());
		}
	};

	changes.setRect(text.x + 65, text.y + text.height() + 5, 55, 18);
	add(changes);*/

	okay.setRect((w - pw) / 2, h - 22, pw, 18);
	add(okay);

	Archs archs = new Archs();
	archs.setSize( Camera.main.width, Camera.main.height );
	addToBack( archs );

	fadeIn();
}
 
Example 18
Source File: WndChooseWay.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
public WndChooseWay( final TomeOfMastery tome, final HeroSubClass way1, final HeroSubClass way2 ) {
	
	super();
	
	IconTitle titlebar = new IconTitle();
	titlebar.icon( new ItemSprite( tome.image(), null ) );
	titlebar.label( tome.name() );
	titlebar.setRect( 0, 0, WIDTH, 0 );
	add( titlebar );
	
	Highlighter hl = new Highlighter( way1.desc() + "\n\n" + way2.desc() + "\n\n" + TXT_MESSAGE );
	
	BitmapTextMultiline normal = PixelScene.createMultiline( hl.text, 6 );
	normal.maxWidth = WIDTH;
	normal.measure();
	normal.x = titlebar.left();
	normal.y = titlebar.bottom() + GAP;
	add( normal );
	
	if (hl.isHighlighted()) {
		normal.mask = hl.inverted();
		
		BitmapTextMultiline highlighted = PixelScene.createMultiline( hl.text, 6 );
		highlighted.maxWidth = normal.maxWidth;
		highlighted.measure();
		highlighted.x = normal.x;
		highlighted.y = normal.y;
		add( highlighted );

		highlighted.mask = hl.mask;
		highlighted.hardlight( TITLE_COLOR );
	}
	
	RedButton btnWay1 = new RedButton( Utils.capitalize( way1.title() ) ) {
		@Override
		protected void onClick() {
			hide();
			tome.choose( way1 );
		}
	};
	btnWay1.setRect( 0, normal.y + normal.height() + GAP, (WIDTH - GAP) / 2, BTN_HEIGHT );
	add( btnWay1 );
	
	RedButton btnWay2 = new RedButton( Utils.capitalize( way2.title() ) ) {
		@Override
		protected void onClick() {
			hide();
			tome.choose( way2 );
		}
	};
	btnWay2.setRect( btnWay1.right() + GAP, btnWay1.top(), btnWay1.width(), BTN_HEIGHT );
	add( btnWay2 );
	
	RedButton btnCancel = new RedButton( TXT_CANCEL ) {
		@Override
		protected void onClick() {
			hide();
		}
	};
	btnCancel.setRect( 0, btnWay2.bottom() + GAP, WIDTH, BTN_HEIGHT );
	add( btnCancel );
	
	resize( WIDTH, (int)btnCancel.bottom() );
}
 
Example 19
Source File: WndSadGhost.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
public WndSadGhost( final Ghost ghost, final int type ) {
	
	super();
	
	IconTitle titlebar = new IconTitle();
	BitmapTextMultiline message;
	switch (type){
		case 1:default:
			titlebar.icon( new FetidRatSprite() );
			titlebar.label( "DEFEATED FETID RAT" );
			message = PixelScene.createMultiline( TXT_RAT+TXT_GIVEITEM, 6 );
			break;
		case 2:
			titlebar.icon( new GnollTricksterSprite() );
			titlebar.label( "DEFEATED GNOLL TRICKSTER" );
			message = PixelScene.createMultiline( TXT_GNOLL+TXT_GIVEITEM, 6 );
			break;
		case 3:
			titlebar.icon( new GreatCrabSprite());
			titlebar.label( "DEFEATED GREAT CRAB" );
			message = PixelScene.createMultiline( TXT_CRAB+TXT_GIVEITEM, 6 );
			break;

	}


	titlebar.setRect( 0, 0, WIDTH, 0 );
	add( titlebar );

	message.maxWidth = WIDTH;
	message.measure();
	message.y = titlebar.bottom() + GAP;
	add( message );
	
	RedButton btnWeapon = new RedButton( TXT_WEAPON ) {
		@Override
		protected void onClick() {
			selectReward( ghost, Ghost.Quest.weapon );
		}
	};
	btnWeapon.setRect( 0, message.y + message.height() + GAP, WIDTH, BTN_HEIGHT );
	add( btnWeapon );

	if (!Dungeon.isChallenged( Challenges.NO_ARMOR )) {
		RedButton btnArmor = new RedButton(TXT_ARMOR) {
			@Override
			protected void onClick() {
				selectReward(ghost, Ghost.Quest.armor);
			}
		};
		btnArmor.setRect(0, btnWeapon.bottom() + GAP, WIDTH, BTN_HEIGHT);
		add(btnArmor);

		resize(WIDTH, (int) btnArmor.bottom());
	} else {
		resize(WIDTH, (int) btnWeapon.bottom());
	}
}
 
Example 20
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();
}