com.watabou.noosa.ui.Button Java Examples

The following examples show how to use com.watabou.noosa.ui.Button. 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: StatusPane.java    From shattered-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void createChildren() {

	bg = new NinePatch( Assets.Interfaces.STATUS, 0, 0, 128, 36, 85, 0, 45, 0 );
	add( bg );

	add( new Button(){
		@Override
		protected void onClick () {
			Camera.main.panTo( Dungeon.hero.sprite.center(), 5f );
			GameScene.show( new WndHero() );
		}
		
		@Override
		public GameAction keyAction() {
			return SPDAction.HERO_INFO;
		}
	}.setRect( 0, 1, 30, 30 ));

	btnJournal = new JournalButton();
	add( btnJournal );

	btnMenu = new MenuButton();
	add( btnMenu );

	avatar = HeroSprite.avatar( Dungeon.hero.heroClass, lastTier );
	add( avatar );

	compass = new Compass( Statistics.amuletObtained ? Dungeon.level.entrance : Dungeon.level.exit );
	add( compass );

	rawShielding = new Image( Assets.Interfaces.SHLD_BAR );
	rawShielding.alpha(0.5f);
	add(rawShielding);

	shieldedHP = new Image( Assets.Interfaces.SHLD_BAR );
	add(shieldedHP);

	hp = new Image( Assets.Interfaces.HP_BAR );
	add( hp );

	exp = new Image( Assets.Interfaces.XP_BAR );
	add( exp );

	bossHP = new BossHealthBar();
	add( bossHP );

	level = new BitmapText( PixelScene.pixelFont);
	level.hardlight( 0xFFEBA4 );
	add( level );

	depth = new BitmapText( Integer.toString( Dungeon.depth ), PixelScene.pixelFont);
	depth.hardlight( 0xCACFC2 );
	depth.measure();
	add( depth );

	danger = new DangerIndicator();
	add( danger );

	buffs = new BuffIndicator( Dungeon.hero );
	add( buffs );

	add( pickedUp = new Toolbar.PickedUpItem());
	
	version = new BitmapText( "v" + Game.version, PixelScene.pixelFont);
	version.alpha( 0.5f );
	add(version);
}
 
Example #2
Source File: Toolbar.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void layout() {

	int[] visible = new int[4];
	int slots = SPDSettings.quickSlots();

	for(int i = 0; i <= 3; i++)
		visible[i] = (int)((slots > i) ? y+2 : y+25);

	for(int i = 0; i <= 3; i++) {
		btnQuick[i].visible = btnQuick[i].active = slots > i;
		//decides on quickslot layout, depending on available screen size.
		if (slots == 4 && width < 152){
			if (width < 138){
				if ((SPDSettings.flipToolbar() && i == 3) ||
						(!SPDSettings.flipToolbar() && i == 0)) {
					btnQuick[i].border(0, 0);
					btnQuick[i].frame(88, 0, 17, 24);
				} else {
					btnQuick[i].border(0, 1);
					btnQuick[i].frame(88, 0, 18, 24);
				}
			} else {
				if (i == 0 && !SPDSettings.flipToolbar() ||
						i == 3 && SPDSettings.flipToolbar()){
					btnQuick[i].border(0, 2);
					btnQuick[i].frame(106, 0, 19, 24);
				} else if (i == 0 && SPDSettings.flipToolbar() ||
						i == 3 && !SPDSettings.flipToolbar()){
					btnQuick[i].border(2, 1);
					btnQuick[i].frame(86, 0, 20, 24);
				} else {
					btnQuick[i].border(0, 1);
					btnQuick[i].frame(88, 0, 18, 24);
				}
			}
		} else {
			btnQuick[i].border(2, 2);
			btnQuick[i].frame(64, 0, 22, 24);
		}

	}

	float right = width;
	switch(Mode.valueOf(SPDSettings.toolbarMode())){
		case SPLIT:
			btnWait.setPos(x, y);
			btnSearch.setPos(btnWait.right(), y);

			btnInventory.setPos(right - btnInventory.width(), y);

			btnQuick[0].setPos(btnInventory.left() - btnQuick[0].width(), visible[0]);
			btnQuick[1].setPos(btnQuick[0].left() - btnQuick[1].width(), visible[1]);
			btnQuick[2].setPos(btnQuick[1].left() - btnQuick[2].width(), visible[2]);
			btnQuick[3].setPos(btnQuick[2].left() - btnQuick[3].width(), visible[3]);
			break;

		//center = group but.. well.. centered, so all we need to do is pre-emptively set the right side further in.
		case CENTER:
			float toolbarWidth = btnWait.width() + btnSearch.width() + btnInventory.width();
			for(Button slot : btnQuick){
				if (slot.visible) toolbarWidth += slot.width();
			}
			right = (width + toolbarWidth)/2;

		case GROUP:
			btnWait.setPos(right - btnWait.width(), y);
			btnSearch.setPos(btnWait.left() - btnSearch.width(), y);
			btnInventory.setPos(btnSearch.left() - btnInventory.width(), y);

			btnQuick[0].setPos(btnInventory.left() - btnQuick[0].width(), visible[0]);
			btnQuick[1].setPos(btnQuick[0].left() - btnQuick[1].width(), visible[1]);
			btnQuick[2].setPos(btnQuick[1].left() - btnQuick[2].width(), visible[2]);
			btnQuick[3].setPos(btnQuick[2].left() - btnQuick[3].width(), visible[3]);
			break;
	}
	right = width;

	if (SPDSettings.flipToolbar()) {

		btnWait.setPos( (right - btnWait.right()), y);
		btnSearch.setPos( (right - btnSearch.right()), y);
		btnInventory.setPos( (right - btnInventory.right()), y);

		for(int i = 0; i <= 3; i++) {
			btnQuick[i].setPos( right - btnQuick[i].right(), visible[i]);
		}

	}

}