Java Code Examples for com.watabou.noosa.NinePatch#size()

The following examples show how to use com.watabou.noosa.NinePatch#size() . 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: 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 2
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 3
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 4
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 5
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 6
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();
}