com.watabou.noosa.ui.Component Java Examples
The following examples show how to use
com.watabou.noosa.ui.Component.
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: WndHardNotification.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 6 votes |
public WndHardNotification(Component titlebar, String message, String btnMessage, int time) { super(titlebar, message); timeLeft = time; this.btnMessage = btnMessage; btnOkay = new RedButton(btnMessage + " (" + time +")"){ @Override protected void onClick() { hide(); } }; btnOkay.setRect(0, height + GAP, width, 16); btnOkay.enable(false); add(btnOkay); resize(width, (int) btnOkay.bottom()); }
Example #2
Source File: WndHardNotification.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
public WndHardNotification(Component titlebar, String message, String btnMessage, int time) { super(titlebar, message); timeLeft = time; this.btnMessage = btnMessage; btnOkay = new RedButton(btnMessage + " (" + time +")"){ @Override protected void onClick() { hide(); } }; btnOkay.setRect(0, height + GAP, width, 16); btnOkay.enable(false); add(btnOkay); resize(width, (int) btnOkay.bottom()); }
Example #3
Source File: WndTitledMessage.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
public WndTitledMessage( Component titlebar, String message ) { super(); resizeLimited(STD_WIDTH); titlebar.setRect( 0, 0, width, 0 ); add( titlebar ); Highlighter hl = new Highlighter( message ); Text normal = PixelScene.createMultiline(hl.text, GuiProperties.regularFontSize()); if (hl.isHighlighted()) { normal.mask = hl.inverted(); } normal.maxWidth(width); normal.x = titlebar.left(); normal.y = titlebar.bottom() + 2*GAP; add(normal); if (hl.isHighlighted()) { Text highlighted = PixelScene.createMultiline(hl.text, GuiProperties.regularFontSize()); highlighted.mask = hl.mask; highlighted.maxWidth(normal.getMaxWidth()); highlighted.x = normal.x; highlighted.y = normal.y; add(highlighted); highlighted.hardlight(TITLE_COLOR); } resize( width, (int)(normal.y + normal.height()) ); }
Example #4
Source File: BadgesList.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
public BadgesList( boolean global ) { super( new Component() ); for (Badges.Badge badge : Badges.filtered( global )) { if (badge.image == -1) { continue; } ListItem item = new ListItem( badge ); content.add( item ); items.add( item ); } }
Example #5
Source File: ScrollPane.java From pixel-dungeon with GNU General Public License v3.0 | 5 votes |
public ScrollPane( Component content ) { super(); this.content = content; addToBack( content ); width = content.width(); height = content.height(); content.camera = new Camera( 0, 0, 1, 1, PixelScene.defaultZoom ); Camera.add( content.camera ); }
Example #6
Source File: BadgesList.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
public BadgesList( boolean global ) { super( new Component() ); for (Badges.Badge badge : Badges.filtered( global )) { if (badge.image == -1) { continue; } ListItem item = new ListItem( badge ); content.add( item ); items.add( item ); } }
Example #7
Source File: WndSurvey.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
public WndSurvey(final JSONObject survey) { super(); String lang = RemixedDungeon.uiLanguage(); if (!survey.has(lang)) { lang = "en"; } try { String surveyId = survey.getString("survey_id"); if (Preferences.INSTANCE.getString(SURVEY_TAKEN, Utils.EMPTY_STRING).equals(surveyId)) { Game.addToScene(new WndMessage(Game.getVar(R.string.SociologistNPC_AlreadyTaken))); super.hide(); return; } Preferences.INSTANCE.put(SURVEY_TAKEN, surveyId); this.survey = survey.getJSONArray(lang); } catch (JSONException e) { this.survey = new JSONArray(); } question = 0; //Title text questionText = PixelScene.createMultiline(Utils.EMPTY_STRING, GuiProperties.mediumTitleFontSize()); questionText.hardlight(TITLE_COLOR); questionText.maxWidth(WIDTH - GAP); questionText.x = GAP; questionText.y = GAP; add(questionText); answers = new Component(); add(answers); resize(WIDTH, (int) (questionText.bottom() + GAP)); NextQuestion(); }
Example #8
Source File: HBox.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
private float yAlign(Component c) { switch (vAlign) { case Top: return top(); case Bottom: return bottom() - c.height(); case Center: return top() + (height() - c.height())/2; } return y; }
Example #9
Source File: HBox.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
private void alignLeft() { float pos = x; for(Gizmo g :members) { if (g instanceof Component) { ((Component) g).setPos(pos, yAlign((Component) g)); pos += ((Component) g).width() + gap; } } }
Example #10
Source File: HBox.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
private void alignCenter() { float pos = x + (maxWidth - childsWidth()) / 2; for(Gizmo g :members) { if (g instanceof Component) { ((Component) g).setPos(pos, yAlign((Component) g)); pos += ((Component) g).width() + gap; } } }
Example #11
Source File: HBox.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
@Override protected void _measure() { width = 0; height = 0; for(Gizmo g :members) { if (g instanceof Component) { width += ((Component) g).width() + gap; height = Math.max(height,((Component) g).height()); } } }
Example #12
Source File: BasicBox.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public Gizmo add(Gizmo g) { dirty = true; if(g instanceof Component) { ((Component)g).measure(); } return super.add(g); }
Example #13
Source File: BasicBox.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public void remove(Gizmo g) { dirty = true; super.remove(g); if(g instanceof Component) { ((Component)g).measure(); } }
Example #14
Source File: GenericInfo.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
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 #15
Source File: WndStory.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
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 #16
Source File: WndRanking.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
public ItemsTab() { super(); setSize(WIDTH,HEIGHT); camera = WndRanking.this.camera; list = new ScrollableList(new Component()); add(list); Belongings stuff = Dungeon.hero.getBelongings(); addItem( stuff.weapon ); addItem( stuff.leftHand ); addItem( stuff.armor ); addItem( stuff.ring1 ); addItem( stuff.ring2 ); for(int i = 0;i<25;++i) { Item qsItem = QuickSlot.getEarlyLoadItem(i); if(stuff.backpack.contains(qsItem) || (qsItem instanceof Spell.SpellItem)){ addItem(qsItem); } } list.content().setRect(0,0,width, posY); list.setSize(WIDTH,HEIGHT); list.scrollTo(0,0); }
Example #17
Source File: HBox.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
private void alignRight() { float pos = x + maxWidth; for(Gizmo g :members) { if (g instanceof Component) { ((Component) g).setPos(pos - ((Component) g).width() - gap, yAlign((Component) g)); pos -= ((Component) g).width() + gap; } } }
Example #18
Source File: WndJournal.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
public WndJournal() { super(); resize(WndHelper.getLimitedWidth(120), WndHelper.getFullscreenHeight() - tabHeight() - MARGIN); Text txtTitle = PixelScene.createText(Game.getVar(R.string.WndJournal_Title), GuiProperties.titleFontSize()); txtTitle.hardlight(Window.TITLE_COLOR); txtTitle.x = PixelScene.align(PixelScene.uiCamera, (width - txtTitle.width()) / 2); add(txtTitle); list = new ScrollPane(new Component()); add(list); list.setRect(0, txtTitle.height(), width, height - txtTitle.height()); Tab[] tabs = { // Create two tabs that will be in the bottom of the window new JournalTab(), new LogbookTab() }; for (Tab tab : tabs) { // Add the tab buttons to the window tab.setSize(width / tabs.length, tabHeight()); add(tab); } select(0); // Select the first tab and update the list }
Example #19
Source File: ScrollPane.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
public ScrollPane( Component content ) { super(); this.content = content; addToBack( content ); width = content.width(); height = content.height(); content.camera = new Camera( 0, 0, 1, 1, PixelScene.defaultZoom ); Camera.add( content.camera ); }
Example #20
Source File: BadgesList.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
public BadgesList( boolean global ) { super( new Component() ); for (Badges.Badge badge : Badges.filtered( global )) { if (badge.image == -1) { continue; } ListItem item = new ListItem( badge ); content.add( item ); items.add( item ); } }
Example #21
Source File: WndHero.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
public BuffsTab() { buffList = new ScrollPane( new Component() ){ @Override public void onClick( float x, float y ) { int size = slots.size(); for (int i=0; i < size; i++) { if (slots.get( i ).onClick( x, y )) { break; } } } }; add(buffList); }
Example #22
Source File: WndHero.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
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 #23
Source File: WndKeymap.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
public WndKeymap() { int ww = Math.min( 160, PixelScene.uiCamera.width - 16 ); int wh = PixelScene.uiCamera.height - 24; resize( ww, wh ); RedButton btnReset = new RedButton( "Reset To Defaults" ) { @Override protected void onClick() { resetToDefaults(); populateList(); } }; btnReset.setRect( 0, height - BTN_HEIGHT, width, BTN_HEIGHT ); add( btnReset ); listContent = new Component(); final ScrollPane list = new ScrollPane(listContent) { @Override public void onClick( float x, float y ) { for (ListItem item : items.values()) { if (item.onClick( x, y )) { break; } } } }; populateList(); add(list); list.setRect(0, 0, width, btnReset.top() ); }
Example #24
Source File: WndKeymap.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
private void addKey(Component content, int maxWidth, Map.Entry<GameAction, KeyPair> entry) { final GameAction action = entry.getKey(); final ListItem keyItem = new ListItem(action, entry.getValue()); keyItem.setRect(0, tempPos, maxWidth, ITEM_HEIGHT); tempPos += ITEM_HEIGHT; content.add(keyItem); items.put(action, keyItem); }
Example #25
Source File: WndJournal.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
@Override protected void createChildren() { 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 ); }
Example #26
Source File: WndJournal.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
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 #27
Source File: WndJournal.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
@Override protected void createChildren() { pageButtons = new RedButton[NUM_BUTTONS]; for (int i = 0; i < NUM_BUTTONS; i++){ final int idx = i; pageButtons[i] = new RedButton( "" ){ @Override protected void onClick() { currentPageIdx = idx; updateList(); } }; if (Document.ALCHEMY_GUIDE.hasPage(i)) { pageButtons[i].icon(new ItemSprite(ItemSpriteSheet.SOMETHING + spriteIndexes[i], null)); } else { pageButtons[i].icon(new ItemSprite(ItemSpriteSheet.SOMETHING, null)); pageButtons[i].enable(false); } add( pageButtons[i] ); } title = new IconTitle(); title.icon( new ItemSprite(ItemSpriteSheet.ALCH_PAGE)); title.visible = false; body = PixelScene.renderTextBlock(6); list = new ScrollPane(new Component()); add(list); }
Example #28
Source File: WndJournal.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
@Override protected void createChildren() { itemButtons = new RedButton[NUM_BUTTONS]; for (int i = 0; i < NUM_BUTTONS; i++){ final int idx = i; itemButtons[i] = new RedButton( "" ){ @Override protected void onClick() { currentItemIdx = idx; updateList(); } }; itemButtons[i].icon(new ItemSprite(ItemSpriteSheet.SOMETHING + spriteIndexes[i], null)); add( itemButtons[i] ); } list = new ScrollPane( new Component() ) { @Override public void onClick( float x, float y ) { int size = items.size(); for (int i=0; i < size; i++) { if (items.get( i ).onClick( x, y )) { break; } } } }; add( list ); }
Example #29
Source File: ScrollPane.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
public ScrollPane( Component content ) { super(); this.content = content; addToBack( content ); width = content.width(); height = content.height(); content.camera = new Camera( 0, 0, 1, 1, PixelScene.defaultZoom ); Camera.add( content.camera ); }
Example #30
Source File: BadgesList.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
public BadgesList( boolean global ) { super( new Component() ); for (Badges.Badge badge : Badges.filtered( global )) { if (badge.image == -1) { continue; } ListItem item = new ListItem( badge ); content.add( item ); items.add( item ); } }