com.watabou.noosa.NinePatch Java Examples

The following examples show how to use com.watabou.noosa.NinePatch. 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: Chrome.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 6 votes vote down vote up
public static NinePatch get( Type type ) {
	switch (type) {
	case WINDOW:
		return new NinePatch( Assets.CHROME, 0, 0, 22, 22, 7 );
	case TOAST:
		return new NinePatch( Assets.CHROME, 22, 0, 18, 18, 5 );
	case TOAST_TR:
		return new NinePatch( Assets.CHROME, 40, 0, 18, 18, 5 );
	case BUTTON:
		return new NinePatch( Assets.CHROME, 58, 0, 4, 4, 1 );
       case TAG_RIGHT:
           return new NinePatch( Assets.CHROME, 22, 18, 16, 14, 3 );
       case TAG_LEFT:
           return new NinePatch( Assets.CHROME, 39, 18, 16, 14, 3 );
	case SCROLL:
		return new NinePatch( Assets.CHROME, 32, 32, 32, 32, 5, 11, 5, 11 );
	case TAB_SET:
		return new NinePatch( Assets.CHROME, 64, 0, 22, 22, 7, 7, 7, 7 );
	case TAB_SELECTED:
		return new NinePatch( Assets.CHROME, 64, 22, 10, 14, 4, 7, 4, 6 );
	case TAB_UNSELECTED:
		return new NinePatch( Assets.CHROME, 74, 22, 10, 14, 4, 7, 4, 6 );
	default:
		return null;
	}
}
 
Example #2
Source File: Chrome.java    From pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
public static NinePatch get( Type type ) {
	switch (type) {
	case WINDOW:
		return new NinePatch( Assets.CHROME, 0, 0, 22, 22, 7 );
	case TOAST:
		return new NinePatch( Assets.CHROME, 22, 0, 18, 18, 5 );
	case TOAST_TR:
		return new NinePatch( Assets.CHROME, 40, 0, 18, 18, 5 );
	case BUTTON:
		return new NinePatch( Assets.CHROME, 58, 0, 6, 6, 2 );
	case TAG:
		return new NinePatch( Assets.CHROME, 22, 18, 16, 14, 3 );
	case SCROLL:
		return new NinePatch( Assets.CHROME, 32, 32, 32, 32, 5, 11, 5, 11 );
	case TAB_SET:
		return new NinePatch( Assets.CHROME, 64, 0, 22, 22, 7, 7, 7, 7 );
	case TAB_SELECTED:
		return new NinePatch( Assets.CHROME, 64, 22, 10, 14, 4, 7, 4, 6 );
	case TAB_UNSELECTED:
		return new NinePatch( Assets.CHROME, 74, 22, 10, 14, 4, 7, 4, 6 );
	default:
		return null;
	}
}
 
Example #3
Source File: Chrome.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public static NinePatch get( Type type ) {
	String Asset = Assets.CHROME;
	switch (type) {
	case WINDOW:
		return new NinePatch( Asset, 0, 0, 20, 20, 6 );
	case TOAST:
		return new NinePatch( Asset, 22, 0, 18, 18, 5 );
	case TOAST_TR:
		return new NinePatch( Asset, 40, 0, 18, 18, 5 );
	case BUTTON:
		return new NinePatch( Asset, 58, 0, 4, 4, 1 );
	case TAG:
		return new NinePatch( Asset, 22, 18, 16, 14, 3 );
	case GEM:
		return new NinePatch( Asset, 0, 32, 32, 32, 13 );
	case SCROLL:
		return new NinePatch( Asset, 32, 32, 32, 32, 5, 11, 5, 11 );
	case TAB_SET:
		return new NinePatch( Asset, 64, 0, 20, 20, 6 );
	case TAB_SELECTED:
		return new NinePatch( Asset, 65, 22, 8, 13, 3, 7, 3, 5 );
	case TAB_UNSELECTED:
		return new NinePatch( Asset, 75, 22, 8, 13, 3, 7, 3, 5 );
	default:
		return null;
	}
}
 
Example #4
Source File: Chrome.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 5 votes vote down vote up
public static NinePatch get( Type type ) {
	String Asset = Assets.CHROME;
	switch (type) {
	case WINDOW:
		return new NinePatch( Asset, 0, 0, 20, 20, 6 );
	case TOAST:
		return new NinePatch( Asset, 22, 0, 18, 18, 5 );
	case TOAST_TR:
		return new NinePatch( Asset, 40, 0, 18, 18, 5 );
	case RED_BUTTON:
		return new NinePatch( Asset, 58, 0, 6, 6, 2 );
	case GREY_BUTTON:
		return new NinePatch( Asset, 58, 6, 6, 6, 2 );
	case TAG:
		return new NinePatch( Asset, 22, 18, 16, 14, 3 );
	case GEM:
		return new NinePatch( Asset, 0, 32, 32, 32, 13 );
	case GREY_BUTTON_TR:
		return new NinePatch( Asset, 53, 20, 9, 9, 5 );
	case SCROLL:
		return new NinePatch( Asset, 32, 32, 32, 32, 5, 11, 5, 11 );
	case TAB_SET:
		return new NinePatch( Asset, 64, 0, 20, 20, 6 );
	case TAB_SELECTED:
		return new NinePatch( Asset, 65, 22, 8, 13, 3, 7, 3, 5 );
	case TAB_UNSELECTED:
		return new NinePatch( Asset, 75, 22, 8, 13, 3, 7, 3, 5 );
	default:
		return null;
	}
}
 
Example #5
Source File: Chrome.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public static NinePatch get( Type type ) {
	String Asset = Assets.Interfaces.CHROME;
	switch (type) {
	case WINDOW:
		return new NinePatch( Asset, 0, 0, 20, 20, 6 );
	case WINDOW_SILVER:
		return new NinePatch( Asset, 86, 0, 22, 22, 7 );
	case TOAST:
		return new NinePatch( Asset, 22, 0, 18, 18, 5 );
	case TOAST_TR:
		return new NinePatch( Asset, 40, 0, 18, 18, 5 );
	case RED_BUTTON:
		return new NinePatch( Asset, 58, 0, 6, 6, 2 );
	case GREY_BUTTON:
		return new NinePatch( Asset, 58, 6, 6, 6, 2 );
	case TAG:
		return new NinePatch( Asset, 22, 18, 16, 14, 3 );
	case GEM:
		return new NinePatch( Asset, 0, 32, 32, 32, 13 );
	case GREY_BUTTON_TR:
		return new NinePatch( Asset, 53, 20, 9, 9, 5 );
	case SCROLL:
		return new NinePatch( Asset, 32, 32, 32, 32, 5, 11, 5, 11 );
	case TAB_SET:
		return new NinePatch( Asset, 64, 0, 20, 20, 6 );
	case TAB_SELECTED:
		return new NinePatch( Asset, 65, 22, 8, 13, 3, 7, 3, 5 );
	case TAB_UNSELECTED:
		return new NinePatch( Asset, 75, 22, 8, 13, 3, 7, 3, 5 );
	default:
		return null;
	}
}
 
Example #6
Source File: Chrome.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public static NinePatch get( Type type ) {
	switch (type) {
	case WINDOW:
		return new NinePatch( Assets.getChrome(), 0, 0, 22, 22, 7 );
	case TOAST:
		return new NinePatch( Assets.getChrome(), 22, 0, 18, 18, 5 );
	case TOAST_TR:
		return new NinePatch( Assets.getChrome(), 40, 0, 18, 18, 5 );
	case BUTTON:
		return new NinePatch( Assets.getChrome(), 58, 0, 4, 4, 1 );
	case TAG:
		return new NinePatch( Assets.getChrome(), 22, 18, 16, 14, 3 );
	case GEM:
		return new NinePatch( Assets.getChrome(), 0, 32, 32, 32, 13 );
	case SCROLL:
		return new NinePatch( Assets.getChrome(), 32, 32, 32, 32, 5, 11, 5, 11 );
	case TAB_SET:
		return new NinePatch( Assets.getChrome(), 64, 0, 22, 22, 7, 7, 7, 7 );
	case TAB_SELECTED:
		return new NinePatch( Assets.getChrome(), 64, 22, 10, 14, 4, 7, 4, 6 );
	case TAB_UNSELECTED:
		return new NinePatch( Assets.getChrome(), 74, 22, 10, 14, 4, 7, 4, 6 );
	case QUICKSLOT:
		return new NinePatch( Assets.getChrome(), 107, 44, 20, 20, 3 );
	case ACTION_BUTTON:
		return new NinePatch( Assets.getChrome(), 65, 49, 14, 14, 2 );
	}
	throw new TrackedRuntimeException("wrong chrome type");
}
 
Example #7
Source File: StatusPane.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void createChildren() {

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

	add( new TouchArea<GameAction>( 0, 1, 31, 31 ) {
		@Override
		protected void onClick( NoosaInputProcessor.Touch touch ) {
			Image sprite = Dungeon.hero.sprite;
			Camera.main.panTo( sprite.center(), 5f );
			GameScene.show( new WndHero() );
		}

		@Override
		public boolean onKeyUp(NoosaInputProcessor.Key<GameAction> key) {
			boolean handled = true;
			switch (key.action) {
			case HERO_INFO:
				onClick( null );
				break;
			case JOURNAL:
				GameScene.show( new WndJournal() );
				break;
			default:
				handled = false;
				break;
			}
			return handled;
		}
	} );

	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.SHLD_BAR );
	rawShielding.alpha(0.5f);
	add(rawShielding);

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

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

	exp = new Image( Assets.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 #8
Source File: BadgesScene.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
	public void create() {
		
		super.create();
		
		Music.INSTANCE.play( Assets.TRACK_MAIN_THEME, true );
		Music.INSTANCE.volume( 1f );
		
		uiCamera.visible = false;
		
		int w = Camera.main.width;
		int h = Camera.main.height;
		
		Archs archs = new Archs();
		archs.setSize( w, h );
		add( archs );
		
		int pw = Math.min( MAX_PANE_WIDTH, w - 6 );
		int ph = h - 30;
		
		NinePatch panel = Chrome.get( Chrome.Type.WINDOW );
		panel.size( pw, ph );
		panel.x = (w - pw) / 2;
		panel.y = (h - ph) / 2;
		add( panel );
		
		BitmapText title = PixelScene.createText( TXT_TITLE, 9 );
		title.hardlight( Window.TITLE_COLOR );
		title.measure();
		title.x = align( (w - title.width()) / 2 );
		title.y = align( (panel.y - title.baseLine()) / 2 );
		add( title );

		ScrollPane list = new BadgesList( true );
		add( list );

		list.setRect( 
			panel.x + panel.marginLeft(), 
			panel.y + panel.marginTop(), 
			panel.innerWidth(), 
			panel.innerHeight() );
		
		ExitButton btnExit = new ExitButton();
		btnExit.setPos( Camera.main.width - btnExit.width(), 0 );
		add( btnExit );
		
		fadeIn();
		
//		Badges.loadingListener = new Callback() {
//			@Override
//			public void call() {
//				if (Game.scene() == BadgesScene.this) {
//					YetAnotherPixelDungeon.switchNoFade(BadgesScene.class);
//				}
//			}
//		};
	}
 
Example #9
Source File: Window.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 4 votes vote down vote up
public Window( int width, int height, NinePatch chrome ) {
	this(width, height, 0, chrome);
}
 
Example #10
Source File: StatusPane.java    From remixed-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void createChildren() {

    shield = new NinePatch(Assets.getStatus(), 80, 0, 30 + 18, 0);
    add(shield);

    add(new TouchArea(0, 1, 30, 30) {
        @Override
        protected void onClick(Touch touch) {
            Image sprite = hero.getSprite();
            if (!sprite.isVisible()) {
                Camera.main.focusOn(sprite);
            }
            GameScene.show(new WndHero());
        }
    });

    avatar = hero.getSprite().avatar();
    add(avatar);

    blood = new Emitter();
    blood.pos(avatar);
    blood.pour(BloodParticle.FACTORY, 0.3f);
    blood.autoKill = false;
    blood.on = false;
    add(blood);

    int compassTarget = currentLevel.entrance;

    if (currentLevel.hasCompassTarget()) {
        compassTarget = currentLevel.getCompassTarget();    // Set to compass target if exists
    } else if ( currentLevel.hasExit(0)
                && hero.getBelongings().getItem(Amulet.class) == null) {
        compassTarget = currentLevel.getExit(0);    // Set to first exit if exists
    }

    compass = new Compass(compassTarget, currentLevel);
    add(compass);


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

    sp = new Image(Assets.SP_BAR);
    add(sp);

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

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

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

    hero.getBelongings().countIronKeys();
    keys = new BitmapText(PixelScene.font1x);
    keys.hardlight(0xCACFC2);
    add(keys);

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

    loot = new LootIndicator();
    add(loot);

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

    btnMenu = new MenuButton(new Image(Assets.getStatus(), 114, 3, 12, 11), WndGame.class);
    add(btnMenu);

    btnHats = new MenuButton(new Image(Assets.getStatus(), 114, 18, 12, 11), WndHats.class);

    if (!Flavours.haveHats()) {
        btnHats.enable(false);
    }

    add(btnHats);
}
 
Example #11
Source File: AllowStatisticsCollectionScene.java    From remixed-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void create() {
	super.create();

	Text title = createMultiline( Game.getVar(R.string.AllowStatisticsCollectionScene_Title), GuiProperties.bigTitleFontSize());

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

	int pw = w - 10;

	title.maxWidth(pw);

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

	NinePatch panel = Chrome.get(Chrome.Type.WINDOW);

	panel.x = (w - pw) / 2;
	panel.y = title.y + title.height() + GAP * 2;
	int ph = (int) (h - panel.y - 22);

	panel.size(pw, ph);

	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();

	float yPos = 0;
	Text text = createMultiline(Game.getVar(R.string.AllowStatisticsCollectionScene_Request), GuiProperties.regularFontSize());
	text.maxWidth((int) panel.innerWidth());

	content.add(text);
	yPos += text.height() + GAP;

	content.setSize(panel.innerWidth(), yPos);

	RedButton allow = new RedButton(Game.getVar(R.string.AllowStatisticsCollectionScene_Allow)) {
		@Override
		protected void onClick() {
			Preferences.INSTANCE.put(Preferences.KEY_COLLECT_STATS, 100);
			Game.switchScene(TitleScene.class);
		}
	};

	RedButton deny = new RedButton(Game.getVar(R.string.AllowStatisticsCollectionScene_Deny)) {
		@Override
		protected void onClick() {
			Preferences.INSTANCE.put(Preferences.KEY_COLLECT_STATS, -100);
			Game.switchScene(TitleScene.class);
		}
	};

	allow.setRect((w - pw) / 2, h - 22, pw/2 - GAP, 18);
	deny.setRect((w - pw) / 2 + pw/2 , h - 22, pw/2-GAP, 18);
	add(allow);
	add(deny);

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

	fadeIn();
}
 
Example #12
Source File: BadgesScene.java    From remixed-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void create() {
	super.create();
	
	Music.INSTANCE.play( Assets.THEME, true );
	Music.INSTANCE.volume( 1f );
	
	uiCamera.setVisible(false);
	
	int w = Camera.main.width;
	int h = Camera.main.height;
	
	Archs archs = new Archs();
	archs.setSize( w, h );
	add( archs );
	
	int pw = Math.min( 160, w - 6 );
	int ph = h - 30;
	
	NinePatch panel = Chrome.get( Chrome.Type.WINDOW );
	panel.size( pw, ph );
	panel.x = (w - pw) / 2;
	panel.y = (h - ph) / 2;
	add( panel );
	
	Text title = PixelScene.createText( Game.getVar(R.string.BadgesScene_Title), GuiProperties.titleFontSize());
	title.hardlight( Window.TITLE_COLOR );
	title.x = align( (w - title.width()) / 2 );
	title.y = align( (panel.y - title.baseLine()) / 2 );
	add( title );
	
	Badges.loadGlobal();
	
	ScrollPane list = new BadgesList( true );
	add( list );
	
	list.setRect( 
		panel.x + panel.marginLeft(), 
		panel.y + panel.marginTop(), 
		panel.innerWidth(), 
		panel.innerHeight() );
	
	ExitButton btnExit = new ExitButton();
	btnExit.setPos( Camera.main.width - btnExit.width(), 0 );
	add( btnExit );
	
	fadeIn();
}
 
Example #13
Source File: WelcomeScene.java    From remixed-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void create() {
	super.create();

	String[] upds = {
			Game.getVar(R.string.Welcome_Text_29_1),
			Game.getVar(R.string.Welcome_Text_29_2),
			Game.getVar(R.string.Welcome_Text_29_3),
			Game.getVar(R.string.Welcome_Text_29_4),
			Game.getVar(R.string.Welcome_Text_29_5)
	};

	int displayUpdates = Math.min(upds.length, 5);

	Text[] updTexts = new Text[displayUpdates];

	for (int i = 0; i < displayUpdates; i++) {
		updTexts[i] = createMultiline(GuiProperties.regularFontSize());
	}

	Text title = createMultiline(Game.getVar(R.string.Welcome_Title), GuiProperties.bigTitleFontSize());

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

	int pw = w - 10;

	title.maxWidth(pw);

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

	NinePatch panel = Chrome.get(Chrome.Type.WINDOW);

	panel.x = (w - pw) / 2;
	panel.y = title.y + title.height() + GAP * 2;
	int ph = (int) (h - panel.y - 22);

	panel.size(pw, ph);

	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();

	float yPos = 0;
	for (int i = 0; i < displayUpdates; i++) {
		updTexts[i].maxWidth((int) panel.innerWidth());
		updTexts[i].text(upds[upds.length - i - 1]);

		updTexts[i].setPos(0, yPos);
		yPos += updTexts[i].height() + GAP;
		content.add(updTexts[i]);
	}

	content.setSize(panel.innerWidth(), yPos);

	RedButton okay = new RedButton(Game.getVar(R.string.Welcome_Ok)) {
		@Override
		protected void onClick() {
			RemixedDungeon.version(Game.versionCode);
			RemixedDungeon.versionString(Game.version);

			if (Preferences.INSTANCE.getInt(Preferences.KEY_COLLECT_STATS, 1) == 0) {
				Game.switchScene(AllowStatisticsCollectionScene.class);
			} else {
				Game.switchScene(TitleScene.class);
			}
		}
	};

	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 #14
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 #15
Source File: Window.java    From shattered-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
public Window( int width, int height, NinePatch chrome ) {
	this(width, height, 0, chrome);
}
 
Example #16
Source File: StatusPane.java    From pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void createChildren() {
	
	shield = new NinePatch( Assets.STATUS, 80, 0, 30   + 18, 0 );
	add( shield );
	
	add( new TouchArea( 0, 1, 30, 30 ) {
		@Override
		protected void onClick( Touch touch ) {
			Image sprite = Dungeon.hero.sprite;
			if (!sprite.isVisible()) {
				Camera.main.focusOn( sprite );
			}
			GameScene.show( new WndHero() );
		};			
	} );
	
	btnMenu = new MenuButton();
	add( btnMenu );
	
	avatar = HeroSprite.avatar( Dungeon.hero.heroClass, lastTier );
	add( avatar );
	
	blood = new BitmaskEmitter( avatar );
	blood.pour( BloodParticle.FACTORY, 0.3f );
	blood.autoKill = false;
	blood.on = false;
	add( blood );
	
	compass = new Compass( Dungeon.level.exit );
	add( compass );
	
	hp = new Image( Assets.HP_BAR );	
	add( hp );
	
	exp = new Image( Assets.XP_BAR );
	add( exp );
	
	level = new BitmapText( PixelScene.font1x );
	level.hardlight( 0xFFEBA4 );
	add( level );
	
	depth = new BitmapText( Integer.toString( Dungeon.depth ), PixelScene.font1x );
	depth.hardlight( 0xCACFC2 );
	depth.measure();
	add( depth );
	
	Dungeon.hero.belongings.countIronKeys();
	keys = new BitmapText( PixelScene.font1x );
	keys.hardlight( 0xCACFC2 );
	add( keys );
	
	danger = new DangerIndicator();
	add( danger );
	
	loot = new LootIndicator();
	add( loot );
	
	resume = new ResumeButton();
	add( resume );
	
	buffs = new BuffIndicator( Dungeon.hero );
	add( buffs );
}
 
Example #17
Source File: StatusPane.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void createChildren() {

	shield = new NinePatch( Assets.STATUS, 80, 0, 30   + 18, 0 );
	add( shield );

	add( new TouchArea( 0, 1, 31, 31 ) {
		@Override
		protected void onClick( Touch touch ) {
			Image sprite = Dungeon.hero.sprite;
			if (!sprite.isVisible()) {
				Camera.main.focusOn( sprite );
			}
			GameScene.show( new WndHero() );
		}
	} );

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

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

	blood = new Emitter();
	blood.pos( avatar );
	blood.pour( BloodParticle.FACTORY, 0.3f );
	blood.autoKill = false;
	blood.on = false;
	add( blood );

	compass = new Compass( Dungeon.level.exit );
	add( compass );

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

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

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

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

	Dungeon.hero.belongings.countIronKeys();
	keys = new BitmapText( PixelScene.font1x );
	keys.hardlight( 0xCACFC2 );
	add( keys );

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

	buffs = new BuffIndicator( Dungeon.hero );
	add( buffs );
}
 
Example #18
Source File: BadgesScene.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void create() {

	super.create();

	Music.INSTANCE.play( Assets.THEME, true );
	Music.INSTANCE.volume( 1f );

	uiCamera.visible = false;

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

	Archs archs = new Archs();
	archs.setSize( w, h );
	add( archs );

	int pw = Math.min( MAX_PANE_WIDTH, w - 6 );
	int ph = h - 30;

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

	BitmapText title = PixelScene.createText( TXT_TITLE, 9 );
	title.hardlight( Window.TITLE_COLOR );
	title.measure();
	title.x = align( (w - title.width()) / 2 );
	title.y = align( (panel.y - title.baseLine()) / 2 );
	add( title );

	Badges.loadGlobal();

	ScrollPane list = new BadgesList( true );
	add( list );

	list.setRect(
			panel.x + panel.marginLeft(),
			panel.y + panel.marginTop(),
			panel.innerWidth(),
			panel.innerHeight() );

	ExitButton btnExit = new ExitButton();
	btnExit.setPos( Camera.main.width - btnExit.width(), 0 );
	add( btnExit );

	fadeIn();

	Badges.loadingListener = new Callback() {
		@Override
		public void call() {
			if (Game.scene() == BadgesScene.this) {
				ShatteredPixelDungeon.switchNoFade( BadgesScene.class );
			}
		}
	};
}
 
Example #19
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 #20
Source File: StatusPane.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
	protected void createChildren() {
		
		shield = new NinePatch( Assets.STATUS, 80, 0, 48, 0 );
		add( shield );
		
		add( new TouchArea( 0, 1, 30, 30 ) {
			@Override
			protected void onClick( Touch touch ) {
				Image sprite = Dungeon.hero.sprite;
				if (!sprite.isVisible()) {
					Camera.main.focusOn( sprite );
				}
				GameScene.show( new WndHero() );
			};			
		} );
		
		btnMenu = new MenuButton();
		add( btnMenu );

        difficulty = new IconDifficulty();
        add(difficulty);

        avatar = HeroSprite.avatar( Dungeon.hero.heroClass, lastTier );
        add(avatar);
		
//		blood = new Emitter();
//		blood.pos(avatar);
//		blood.pour(BloodParticle.FACTORY, 0.3f);
//		blood.autoKill = false;
//		blood.on = false;
//		addFromDamage(blood);
		
		compass = new Compass( Dungeon.level.exit );
		add( compass );
		
		hp = new Image( Assets.HP_BAR );	
		add( hp );
		
		exp = new Image( Assets.XP_BAR );
		add(exp);

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

        health = new BitmapText( PixelScene.font1x );
        health.hardlight(0xCACFC2);
        add(health);
		
		depth = new BitmapText( Integer.toString( Dungeon.depth ), PixelScene.font1x );
		depth.hardlight(0xCACFC2);
		depth.measure();
		add( depth );
		
		Dungeon.hero.belongings.countIronKeys();
		keys = new BitmapText( PixelScene.font1x );
		keys.hardlight(0xCACFC2);
		add(keys);
		
		danger = new TagDanger();
		add(danger);

        attack = new TagAttack();
        add( attack );

        pickup = new TagPickup();
        add(pickup);
		
		resume = new TagResume();
		add( resume );



        btnWaterskin = new TagWaterskin();
        add(btnWaterskin);

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

	}