Java Code Examples for com.watabou.noosa.ui.Component#setSize()

The following examples show how to use com.watabou.noosa.ui.Component#setSize() . 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: WndJournal.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public WndJournal() {
	
	super();
	resize( WIDTH, ShatteredPixelDungeon.landscape() ? HEIGHT_L : HEIGHT_P );

	txtTitle = PixelScene.createText( TXT_TITLE, 9 );
	txtTitle.hardlight( Window.TITLE_COLOR );
	txtTitle.measure();
	txtTitle.x = PixelScene.align( PixelScene.uiCamera, (WIDTH - txtTitle.width()) / 2 );
	add( txtTitle );
	
	Component content = new Component();
	
	Collections.sort( Journal.records );
	
	float pos = 0;
	for (Journal.Record rec : Journal.records) {
		ListItem item = new ListItem( rec.feature, rec.depth );
		item.setRect( 0, pos, WIDTH, ITEM_HEIGHT );
		content.add( item );
		
		pos += item.height();
	}
	
	content.setSize( WIDTH, pos );
	
	list = new ScrollPane( content );
	add( list );

	list.setRect( 0, txtTitle.height(), WIDTH, height - txtTitle.height() );
}
 
Example 2
Source File: WndJournal.java    From pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public WndJournal() {
	
	super();
	resize( WIDTH, PixelDungeon.landscape() ? HEIGHT_L : HEIGHT_P );
	
	txtTitle = PixelScene.createText( TXT_TITLE, 9 );
	txtTitle.hardlight( Window.TITLE_COLOR );
	txtTitle.measure();
	txtTitle.x = PixelScene.align( PixelScene.uiCamera, (WIDTH - txtTitle.width()) / 2 );
	add( txtTitle );
	
	Component content = new Component();
	
	Collections.sort( Journal.records );
	
	float pos = 0;
	for (Journal.Record rec : Journal.records) {
		ListItem item = new ListItem( rec.feature, rec.depth );
		item.setRect( 0, pos, WIDTH, ITEM_HEIGHT );
		content.add( item );
		
		pos += item.height();
	}
	
	content.setSize( WIDTH, pos );
	
	list = new ScrollPane( content );
	add( list );
	
	list.setRect( 0, txtTitle.height(), WIDTH, height - txtTitle.height() );
}
 
Example 3
Source File: WndHero.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
private void setupList() {
	Component content = buffList.content();
	for (Buff buff : Dungeon.hero.buffs()) {
		if (buff.icon() != BuffIndicator.NONE) {
			BuffSlot slot = new BuffSlot(buff);
			slot.setRect(0, pos, WIDTH, slot.icon.height());
			content.add(slot);
			slots.add(slot);
			pos += GAP + slot.height();
		}
	}
	content.setSize(buffList.width(), pos);
	buffList.setSize(buffList.width(), buffList.height());
}
 
Example 4
Source File: WndJournal.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
private void updateList(){
	Component content = list.content();
	
	float pos = 0;
	
	ColorBlock line = new ColorBlock( width(), 1, 0xFF222222);
	line.y = pos;
	content.add(line);
	
	RenderedTextBlock title = PixelScene.renderTextBlock(Document.ADVENTURERS_GUIDE.title(), 9);
	title.hardlight(TITLE_COLOR);
	title.maxWidth( (int)width() - 2 );
	title.setPos( (width() - title.width())/2f, pos + 1 + ((ITEM_HEIGHT) - title.height())/2f);
	PixelScene.align(title);
	content.add(title);
	
	pos += Math.max(ITEM_HEIGHT, title.height());
	
	for (String page : Document.ADVENTURERS_GUIDE.pages()){
		GuideItem item = new GuideItem( page );
		
		item.setRect( 0, pos, width(), ITEM_HEIGHT );
		content.add( item );
		
		pos += item.height();
		pages.add(item);
	}
	
	content.setSize( width(), pos );
	list.setSize( list.width(), list.height() );
}
 
Example 5
Source File: GenericInfo.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
static public void makeInfo(Window parent, Image icon, String title, int titleColor, String desc){
	
	IconTitle titlebar = new IconTitle();
	titlebar.icon( icon );
	titlebar.label( Utils.capitalize( title ), titleColor );
	titlebar.setRect( 0, 0, WIDTH, 0 );
	parent.add( titlebar );
	
	Text txtInfo = PixelScene.createMultiline( desc, GuiProperties.regularFontSize() );
	txtInfo.maxWidth(WIDTH);
	txtInfo.setPos(0, 0);
	
	int wndHeight = (int) Math.min((titlebar.bottom() + txtInfo.height() + 3 * GAP),MAX_HEIGHT);
	parent.resize( WIDTH, wndHeight);
	
	int scroolZoneHeight = (int) (wndHeight - titlebar.bottom() - GAP * 2);

	ScrollPane list = new ScrollPane(new Component());
	parent.add(list);
	
	list.setRect(0, titlebar.height() + GAP, WIDTH, scroolZoneHeight);
	
	Component content = list.content();
	content.clear();

	content.add(txtInfo);
	content.setSize(txtInfo.width(), txtInfo.height());
}
 
Example 6
Source File: WndStory.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public WndStory( String text ) {
	super( 0, 0, Chrome.get( Chrome.Type.SCROLL ) );

	Text tf = PixelScene.createMultiline(StringsManager.maybeId(text), GuiProperties.regularFontSize());
	tf.maxWidth(WIDTH - MARGIN * 2);
	tf.ra = bgR;
	tf.ga = bgG;
	tf.ba = bgB;
	tf.rm = -bgR;
	tf.gm = -bgG;
	tf.bm = -bgB;
	tf.x = MARGIN;
	
	int h = (int) Math.min(HEIGHT - MARGIN, tf.height());
	int w = (int)(tf.width() + MARGIN * 2);
	
	resize( w, h );
	
	Component content = new Component();
	
	content.add(tf);
	
	content.setSize(tf.width(), tf.height());
	
	ScrollPane list = new ScrollPane(content);
	add(list);

	list.setRect(0, 0, w, h);
}
 
Example 7
Source File: WndHero.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 5 votes vote down vote up
private void setupList() {
	Component content = buffList.content();
	for (Buff buff : Dungeon.hero.buffs()) {
		if (buff.icon() != BuffIndicator.NONE) {
			BuffSlot slot = new BuffSlot(buff);
			slot.setRect(0, pos, WIDTH, slot.icon.height());
			content.add(slot);
			slots.add(slot);
			pos += GAP + slot.height();
		}
	}
	content.setSize(buffList.width(), pos);
	buffList.setSize(buffList.width(), buffList.height());
}
 
Example 8
Source File: WndJournal.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 5 votes vote down vote up
private void updateList(){
	Component content = list.content();
	
	float pos = 0;
	
	ColorBlock line = new ColorBlock( width(), 1, 0xFF222222);
	line.y = pos;
	content.add(line);
	
	RenderedTextBlock title = PixelScene.renderTextBlock(Document.ADVENTURERS_GUIDE.title(), 9);
	title.hardlight(TITLE_COLOR);
	title.maxWidth( (int)width() - 2 );
	title.setPos( (width() - title.width())/2f, pos + 1 + ((ITEM_HEIGHT) - title.height())/2f);
	PixelScene.align(title);
	content.add(title);
	
	pos += Math.max(ITEM_HEIGHT, title.height());
	
	for (String page : Document.ADVENTURERS_GUIDE.pages()){
		GuideItem item = new GuideItem( page );
		
		item.setRect( 0, pos, width(), ITEM_HEIGHT );
		content.add( item );
		
		pos += item.height();
		pages.add(item);
	}
	
	content.setSize( width(), pos );
	list.setSize( list.width(), list.height() );
}
 
Example 9
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 10
Source File: WndDocument.java    From shattered-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
public WndDocument( Document doc ){
	
	int w = PixelScene.landscape() ? WIDTH_L : WIDTH_P;
	int h = PixelScene.landscape() ? HEIGHT_L : HEIGHT_P;
	
	resize(w, h);
	
	list = new ScrollPane( new Component() ){
		@Override
		public void onClick( float x, float y ) {
			int size = pages.size();
			for (int i=0; i < size; i++) {
				if (pages.get( i ).onClick( x, y )) {
					break;
				}
			}
		}
	};
	add( list );
	
	list.setRect( 0, 0, w, h);
	
	Component content = list.content();
	
	float pos = 0;
	
	ColorBlock line = new ColorBlock( w, 1, 0xFF222222);
	line.y = pos;
	content.add(line);
	
	RenderedTextBlock title = PixelScene.renderTextBlock(doc.title(), 9);
	title.hardlight(TITLE_COLOR);
	title.maxWidth( w - 2 );
	title.setPos( (w - title.width())/2f, pos + 1 + ((ITEM_HEIGHT) - title.height())/2f);
	PixelScene.align(title);
	content.add(title);
	
	pos += Math.max(ITEM_HEIGHT, title.height());
	
	for (String page : doc.pages()){
		docPage item = new docPage( doc, page );
		
		item.setRect( 0, pos, w, ITEM_HEIGHT );
		content.add( item );
		
		pos += item.height();
		pages.add(item);
	}
	
	content.setSize( w, pos );
	list.setSize( list.width(), list.height() );
	
}
 
Example 11
Source File: WndLibraryCatalogue.java    From remixed-dungeon with GNU General Public License v3.0 4 votes vote down vote up
public WndLibraryCatalogue(String category, String catalogueName) {
	super();

	int yPos = 0;

	//Title
	Text listTitle = PixelScene.createMultiline(catalogueName, GuiProperties.mediumTitleFontSize());
	listTitle.hardlight(TITLE_COLOR);
	listTitle.maxWidth(WIDTH - GAP * 2);
	listTitle.x = (WIDTH - listTitle.width()) / 2;
	listTitle.y = 0;

	add(listTitle);

	Component content = new Component();

	Map<String, Integer> knownMap = Library.getKnowledgeMap(category);

	var sortedKeys = knownMap.keySet().toArray(new String[0]);

	Arrays.sort(sortedKeys,
			(o1, o2) -> {
				var e1 = Library.infoHeader(category, o1);
				var e2 = Library.infoHeader(category, o2);
				return Collator.getInstance().compare(e1.header, e2.header);
			});

	//List
	for (final String entry : sortedKeys) {

		//Button
		Library.EntryHeader entryHeader = Library.infoHeader(category, entry);

		if(!entryHeader.header.isEmpty()) {
			LibraryListItem rb = new LibraryListItem(category, entry, entryHeader);

			rb.setRect(0, yPos, WIDTH, BTN_HEIGHT);
			content.add(rb);

			yPos = (int) rb.bottom() + 1;
		}
	}

	int HEIGHT = WndHelper.getFullscreenHeight() - BTN_HEIGHT * 2;
	int h = Math.min(HEIGHT - GAP, yPos);

	resize(WIDTH, h + BTN_WIDTH);

	content.setSize(WIDTH, yPos);

	ScrollPane list = new ScrollableList(content);

	add(list);

	float topGap = listTitle.height() + GAP;
	float BottomGap = listTitle.bottom() - BTN_HEIGHT / 2;

	list.setRect(0, topGap, WIDTH, HEIGHT - BottomGap);

	//Back Button
	TextButton back = new RedButton(Game.getVar(R.string.Wnd_Button_Back)) {
		@Override
		protected void onClick() {
			super.onClick();
			hide();
			GameScene.show(new WndLibrary());
		}
	};

	back.setRect((WIDTH / 2) - (BTN_WIDTH / 2), (int) list.bottom() + GAP, BTN_WIDTH + GAP, BTN_HEIGHT);

	add(back);
}
 
Example 12
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 13
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 14
Source File: WndDocument.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 4 votes vote down vote up
public WndDocument( Document doc ){
	
	int w = SPDSettings.landscape() ? WIDTH_L : WIDTH_P;
	int h = SPDSettings.landscape() ? HEIGHT_L : HEIGHT_P;
	
	resize(w, h);
	
	list = new ScrollPane( new Component() ){
		@Override
		public void onClick( float x, float y ) {
			int size = pages.size();
			for (int i=0; i < size; i++) {
				if (pages.get( i ).onClick( x, y )) {
					break;
				}
			}
		}
	};
	add( list );
	
	list.setRect( 0, 0, w, h);
	
	Component content = list.content();
	
	float pos = 0;
	
	ColorBlock line = new ColorBlock( w, 1, 0xFF222222);
	line.y = pos;
	content.add(line);
	
	RenderedTextBlock title = PixelScene.renderTextBlock(doc.title(), 9);
	title.hardlight(TITLE_COLOR);
	title.maxWidth( w - 2 );
	title.setPos( (w - title.width())/2f, pos + 1 + ((ITEM_HEIGHT) - title.height())/2f);
	PixelScene.align(title);
	content.add(title);
	
	pos += Math.max(ITEM_HEIGHT, title.height());
	
	for (String page : doc.pages()){
		docPage item = new docPage( doc, page );
		
		item.setRect( 0, pos, w, ITEM_HEIGHT );
		content.add( item );
		
		pos += item.height();
		pages.add(item);
	}
	
	content.setSize( w, pos );
	list.setSize( list.width(), list.height() );
	
}
 
Example 15
Source File: WndHero.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 3 votes vote down vote up
public BuffsTab( Component content ) {

            super( content );

            pos = GAP_Y;

            for (Buff buff : Dungeon.hero.buffs()) {
                buffSlot( buff );
            }

            content.setSize( WIDTH, pos );
            content.setPos( 0, 0 );

        }