List of usage examples for com.badlogic.gdx.scenes.scene2d.ui Label setAlignment
public void setAlignment(int labelAlign, int lineAlign)
From source file:com.exovum.test.animation.AnimatorMenuScreen.java
License:Creative Commons License
public AnimatorMenuScreen(final Game game) { this.batch = new SpriteBatch(); this.game = game; screen = this; menuBackground = new Texture(Gdx.files.internal("beach-ocean-sea-bg/transparent-png/full_background.png")); menuMusic = Gdx.audio.newMusic(Gdx.files.internal("Carpe Diem.mp3")); stage = new Stage(new FitViewport(800, 480)); Gdx.input.setInputProcessor(stage);/* w w w .ja va2 s. com*/ // Setup the UI skin. Pass the TextureAtlas too so it can find the default settings. TextureAtlas skinAtlas = new TextureAtlas(Gdx.files.internal("uiskin.atlas")); skin = new Skin(Gdx.files.internal("uiskin.json"), skinAtlas); mainTable = new Table(skin); //mainTable.defaults().expand().fill().padBottom(4f).padTop(4f); mainTable.setFillParent(true); // Add the title of the game at the top of the MenuScreen titleTable = new Table(skin); final Label titleLabel = new Label("Kordan Jirby", skin, "title"); titleLabel.setColor(Color.FIREBRICK); //titleLabel.setStyle(new Label.LabelStyle(titleFont, Color.FIREBRICK)); titleLabel.setAlignment(Align.center, Align.center); titleLabel.setPosition(stage.getWidth() / 2, stage.getHeight()); //titleLabel.setFontScale(2.0f); titleTable.defaults().expand().fill().padBottom(4f).padTop(4f); titleTable.add(titleLabel); titleTable.padBottom(10f); // Bottom/Base Table: left-child holds buttonTable for menu buttons, // right-child holds some text info ie instructions or credits baseTable = new Table(skin); baseTable.defaults().expand().fill().padBottom(10f).padTop(10f); // Add the buttons for the user to press: play, help, credits, exit TextButton playButton = new TextButton("Play Game", skin, "small-font"); TextButton helpButton = new TextButton("Instructions", skin, "small-font"); TextButton creditsButton = new TextButton("Credits", skin, "small-font"); TextButton exitButton = new TextButton("Exit", skin, "small-font"); Table buttonTable = new Table(skin); // Add the button table as the left-child to baseTable baseTable.add(buttonTable); //menuTable.setBackground("console2"); // Set the color of the BACKGROUND on the buttons Color buttonColor = Color.SKY; Gdx.app.log("AnimatorMenuScreen", "Color RGB SKY: " + Color.SKY.toString()); playButton.setColor(buttonColor); helpButton.setColor(buttonColor); creditsButton.setColor(buttonColor); exitButton.setColor(buttonColor); // Set the color of the TEXT on the buttons //buttonColor = new Color(0.845f, 0.845f, 0.845f, 1); buttonColor = new Color(0.91f, 0.91f, 0.91f, 1); playButton.getLabel().setColor(buttonColor); helpButton.getLabel().setColor(buttonColor); creditsButton.getLabel().setColor(buttonColor); exitButton.getLabel().setColor(buttonColor); buttonTable.defaults().expand().fill().padBottom(8f).padTop(2f); buttonTable.add(playButton).width(180f).height(60f).row(); buttonTable.add(helpButton).width(180f).height(60f).row(); buttonTable.add(creditsButton).width(180f).height(60f).row(); buttonTable.add(exitButton).width(180f).height(60f); buttonTable.padTop(30f).padBottom(30f); buttonTable.left(); /* Temporary removal of infoTable It was not easy for me to add hidden/new text and for the layouts to update correctly. Changing plan to create a new Screen for Credits (and instructions too). */ infoTable = new Table(skin); // = new Label("", skin, "small-font"); infoTable.setVisible(false); infoTable.defaults().expand().fill().padBottom(8f).padTop(2f); //baseTable.add(infoTable); // Add title table at the top of mainTable mainTable.add(titleTable).row(); // Add baseTable containing buttonTable to the next row of mainTable //mainTable.add(buttonTable); mainTable.add(baseTable); // Add mainTable to the stage stage.addActor(mainTable); // Event Listeners for the menu buttons playButton.addListener(new ChangeListener() { public void changed(ChangeEvent event, Actor actor) { Gdx.app.log("AnimatorMenuScreen", "Pressed playButton"); //game.setScreen(new AnimatorGameScreen(game, screen)); ((Game) Gdx.app.getApplicationListener()).setScreen(new AnimatorGameScreen(game, screen)); } }); helpButton.addListener(new ChangeListener() { public void changed(ChangeEvent event, Actor actor) { Gdx.app.log("AnimatorMenuScreen", "Pressed helpButton"); //game.setScreen(new InstructionsScreen(game, screen)); ((Game) Gdx.app.getApplicationListener()).setScreen(new InstructionsScreen(game, screen)); } }); creditsButton.addListener(new ChangeListener() { public void changed(ChangeEvent event, Actor actor) { Gdx.app.log("AnimatorMenuScreen", "Pressed creditsButton"); //game.setScreen(new CreditsScreen(game, screen)); ((Game) Gdx.app.getApplicationListener()).setScreen(new CreditsScreen(game, screen)); /* * Attempt at adding text next to the buttons. * Status: Unsuccessful. Updating the layout once adding the credits text * does not update as easily as I hoped. * Changing plan to use different Screens for Credits & Instructions. // If the table is visible and already showing credits, then 'minimize' infoTable if(infoTable.isVisible() && infoTable.getName() != null && infoTable.getName().equals("Credits")) { Gdx.app.log("AnimatorMenuScreen", "Hide the credits menu"); infoTable.setVisible(false); infoTable.clearChildren(); } else { Gdx.app.log("AnimatorMenuScreen", "Display the credits text"); // Otherwise, make the infoTable visible and set text to the credits infoTable.setVisible(true); infoTable.clearChildren(); //infoTable.center(); Label musicLabel = new Label("Music\n" + "Pixel Peeker Polka - slower Kevin MacLeod (incompetech.com)\n" + "Licensed under Creative Commons: By Attribution 3.0 License\n" + "http://creativecommons.org/licenses/by/3.0/", skin, "small-font"); musicLabel.setColor(Color.BLACK); //infoTable.addActor(musicLabel); infoTable.addActor(musicLabel); infoTable.padLeft(20f); //musicLabel.setPosition(stage.getWidth() / 2 + 50, stage.getHeight() / 2 + 100, Align.right); infoTable.defaults().expand().fill().padBottom(8f).padTop(2f); musicLabel.setWidth(200f); //musicLabel.setWrap(true); musicLabel.setAlignment(Align.center); //musicLabel.setFillParent(true); // "Invalidates this actor's layout, causing layout() to happen next time // validate() is called infoTable.invalidate(); baseTable.invalidate(); infoTable.center(); //infoTable.setFillParent(true); //titleTable.add(musicLabel); } infoTable.setName("Credits"); */ } }); exitButton.addListener(new ChangeListener() { public void changed(ChangeEvent event, Actor actor) { Gdx.app.log("AnimatorMenuScreen", "Pressed exitButton - exiting application"); Gdx.app.exit(); } }); }
From source file:de.longri.cachebox3.gui.help.GestureHelp.java
License:Open Source License
@Override public void pack() { super.pack(); if (this.hasChildren()) return; // table is created int colNum = 5, rowNum = 5; int cellCount = 0; for (int row = 0; row < rowNum; row++) { for (int col = 0; col < colNum; col++) { cellCount++;/*w ww. j a v a 2 s. c o m*/ switch (cellCount) { case 3: if (gestureUpIcon != null) table.add(new Image(gestureUpIcon)); else table.add(new Label("", VisUI.getSkin())); break; case 8: if (gestureUpIcon != null) { arrowUp = getArrowImageRotated(0); table.add(arrowUp); } else table.add(new Label("", VisUI.getSkin())); break; case 11: if (gestureLeftIcon != null) table.add(new Image(gestureLeftIcon)); else table.add(new Label("", VisUI.getSkin())); break; case 12: if (gestureLeftIcon != null) { arrowLeft = getArrowImageRotated(90); table.add(arrowLeft); } else table.add(new Label("", VisUI.getSkin())); break; case 13: table.add(new Image(buttonDrawable)); break; case 14: if (gestureRightIcon != null) { arrowRight = getArrowImageRotated(-90); table.add(arrowRight); } else table.add(new Label("", VisUI.getSkin())); break; case 15: if (gestureRightIcon != null) table.add(new Image(gestureRightIcon)); else table.add(new Label("", VisUI.getSkin())); break; case 18: if (gestureDownIcon != null) { arrowDown = getArrowImageRotated(180); table.add(arrowDown); } else table.add(new Label("", VisUI.getSkin())); break; case 23: if (gestureDownIcon != null) table.add(new Image(gestureDownIcon)); else table.add(new Label("", VisUI.getSkin())); break; default: table.add(new Label("", VisUI.getSkin())); } } table.row(); } table.pack(); table.setPosition((Gdx.graphics.getWidth() - table.getWidth()) / 2, (Gdx.graphics.getHeight() - table.getHeight()) / 2); this.addActor(table); // add label Label.LabelStyle labelStyle = new Label.LabelStyle(); labelStyle.font = this.style.font; labelStyle.fontColor = this.style.fontColor; Label label = new Label("", labelStyle); label.setWrap(true); label.setAlignment(Align.center, Align.center); float width = Gdx.graphics.getWidth() - CB.scaledSizes.MARGINx2; label.setWidth(width); GlyphLayout bounds = label.getStyle().font.newFontCache().setText(GESTURE_MSG, 0, 0, width, 0, true); label.setText(GESTURE_MSG); label.setPosition(CB.scaledSizes.MARGIN, Gdx.graphics.getHeight() - (bounds.height + CB.scaledSizes.MARGINx2)); this.addActor(label); TextButton.TextButtonStyle buttonStyle = new TextButton.TextButtonStyle(); buttonStyle.font = this.style.font; buttonStyle.fontColor = this.style.fontColor; buttonStyle.up = new ColorDrawable(this.style.backgroundColor); TextButton button = new TextButton(DONT_SHOW_AGAIN_MSG, buttonStyle); button.setPosition(CB.scaledSizes.MARGIN, this.ellipseRectangle.getMaxY() + CB.scaledSizes.MARGINx2); button.addListener(new ClickListener() { public void clicked(InputEvent event, float x, float y) { log.debug("click on don't show again"); Config.showGestureHelp.setValue(false); Config.AcceptChanges(); //close directly hide(); } }); this.addActor(button); }
From source file:it.alcacoop.backgammon.layers.DiceStatsScreen.java
License:Open Source License
public void initTable() { StatManager mgr = StatManager.getInstance(); table.clear();//from www .j av a2 s. co m float w1 = stage.getWidth() * 0.30f; float w2 = stage.getWidth() * 0.13f; table.setWidth(stage.getWidth() * 0.9f); table.setHeight(stage.getHeight() * 0.9f); table.setX((stage.getWidth() - table.getWidth()) / 2); table.setY((stage.getHeight() - table.getHeight()) / 2); table.add(new Label("DICE STATISTICS", GnuBackgammon.skin)); table.row(); table.add().fill().expand().height(stage.getHeight() / 40); Table controls = new Table(); if (GnuBackgammon.Instance.ss != 2) controls.setBackground(GnuBackgammon.skin.getDrawable("list")); controls.row(); controls.add(new Label("SELECT LEVEL:", GnuBackgammon.skin)).fill(); controls.add(sb).fill().padLeft(stage.getWidth() / 85); if (GnuBackgammon.Instance.ss != 2) { Label note = new Label("For less than 2000 rolls data have\n large variation from expected values", GnuBackgammon.skin); note.setAlignment(Align.right, Align.right); controls.add(note).expand().fill(); } table.row(); table.add(controls).left().fill().expand(); Table data_table = new Table(); data_table.row().width(w1 + 3 * w2); Table t0 = new Table(); t0.add().expand().width(w1); Label l = new Label("YOU", GnuBackgammon.skin); l.setAlignment(0, 1); t0.add(l).uniform().center().width(w2); t0.add(new Label("CPU", GnuBackgammon.skin)).uniform().center(); t0.add(new Label("EXPT", GnuBackgammon.skin)).uniform().center(); data_table.add(t0).fill(); data_table.row(); data_table.add(new Label("GENERAL", GnuBackgammon.skin, "even")).left().padBottom(stage.getHeight() / 50); Table t1 = new Table(); t1.setBackground(GnuBackgammon.skin.getDrawable("even")); for (int i = 0; i < 4; i++) { t1.row(); t1.add().expand().width(w1 * 0.15f); t1.add(new Label(dataStrings[i][0], GnuBackgammon.skin)).expand().width(w1 * 0.85f); Label l1 = new Label(mgr.getRollStat(i, statLevel, 0), GnuBackgammon.skin); l1.setAlignment(0, 1); t1.add(l1).uniform().center().width(w2); t1.add(new Label(mgr.getRollStat(i, statLevel, 1), GnuBackgammon.skin)).uniform().center(); t1.add(new Label(dataStrings[i][1], GnuBackgammon.skin)).uniform().center(); } data_table.row(); data_table.add(t1).colspan(4).fill(); data_table.row().padTop(stage.getHeight() / 20); data_table.add(new Label("DOUBLE IN A ROW", GnuBackgammon.skin, "even")).left() .padBottom(stage.getHeight() / 50); Table t2 = new Table(); t2.setBackground(GnuBackgammon.skin.getDrawable("even")); for (int i = 4; i < 8; i++) { t2.row(); t2.add().expand().width(w1 * 0.15f); t2.add(new Label(dataStrings[i][0], GnuBackgammon.skin)).expand().width(w1 * 0.85f); Label l1 = new Label(mgr.getRollStat(i, statLevel, 0), GnuBackgammon.skin); l1.setAlignment(0, 1); t2.add(l1).uniform().center().width(w2); t2.add(new Label(mgr.getRollStat(i, statLevel, 1), GnuBackgammon.skin)).uniform().center(); t2.add(new Label(dataStrings[i][1], GnuBackgammon.skin)).uniform().center(); } data_table.row(); data_table.add(t2).colspan(4).fill(); data_table.row().padTop(stage.getHeight() / 20); data_table.add(new Label("ENTER AGAINST", GnuBackgammon.skin, "even")).left() .padBottom(stage.getHeight() / 50); Table t3 = new Table(); t3.setBackground(GnuBackgammon.skin.getDrawable("even")); for (int i = 8; i < dataStrings.length; i++) { t3.row(); t3.add().expand().width(w1 * 0.15f); t3.add(new Label(dataStrings[i][0], GnuBackgammon.skin)).expand().width(w1 * 0.85f); Label l1 = new Label(mgr.getRollStat(i, statLevel, 0), GnuBackgammon.skin); l1.setAlignment(0, 1); t3.add(l1).uniform().center().width(w2); t3.add(new Label(mgr.getRollStat(i, statLevel, 1), GnuBackgammon.skin)).uniform().center(); t3.add(new Label(dataStrings[i][1], GnuBackgammon.skin)).uniform().center(); } data_table.row(); data_table.add(t3).colspan(4).fill(); ScrollPane sp = new ScrollPane(data_table, GnuBackgammon.skin); sp.setFadeScrollBars(false); Table wrapper = new Table(); wrapper.setBackground(GnuBackgammon.skin.getDrawable("list")); wrapper.add().expand().fill(); wrapper.add(sp).expand().fill(); wrapper.add().expand().fill(); wrapper.addActor(resetBtn); resetBtn.setPosition(table.getWidth() - 1.8f * resetBtn.getWidth(), resetBtn.getHeight() / 2); table.row(); table.add(wrapper).expand().fill(); table.row(); table.add().fill().expand().height(stage.getHeight() / 40); table.row(); table.add(backBtn).width(stage.getWidth() / 4).fill().expand().height(stage.getHeight() / 8); }
From source file:kyle.game.besiege.panels.PanelAttributes.java
License:Open Source License
public PanelAttributes(SidePanel panel) { this.panel = panel; this.player = panel.getPlayer(); this.addParentPanel(panel); this.character = player.getCharacter(); this.attributeNameLabels = new Array<Label>(); this.attributeValueLabels = new Array<Label>(); this.attributePlusButtons = new Array<Button>(); // Create text text = new Table(); text.padRight(PAD);// w w w . j a v a 2 s . c o m text.padLeft(PAD * 2); //text.debug(); text.defaults().padTop(NEG); lsBig = new LabelStyle(); lsBig.font = Assets.pixel30; lsSmall = new LabelStyle(); lsSmall.font = Assets.pixel16; ls = new LabelStyle(); ls.font = Assets.pixel20; bs = new ButtonStyle(); bs.up = new NinePatchDrawable(new NinePatch(Assets.atlas.findRegion(upTexture), r, r, r, r)); bs.down = new NinePatchDrawable(new NinePatch(Assets.atlas.findRegion(downTexture), r, r, r, r)); bs.pressedOffsetX = OFFSET; bs.pressedOffsetY = -OFFSET; Label availableC = new Label("Remaining:", ls); available = new Label("", ls); description = new Label("", lsSmall); description.setWrap(true); description.setWidth(SidePanel.WIDTH - PAD * 2); Label charC = new Label("Attributes", lsBig); charC.setAlignment(0, 0); text.add(charC).colspan(3).padBottom(PAD).width(SidePanel.WIDTH - PAD * 2).fillX().expandX() .padTop(NEG_TOP); text.row(); text.add(availableC).left().padBottom(PAD); text.add(available).colspan(2).left().padBottom(PAD).padRight(PAD * 2); addAttributes(); pointsAvailable = false; this.addTopTable(text); this.setButton(4, "Back"); }
From source file:kyle.game.besiege.panels.PanelCharacter.java
License:Open Source License
public PanelCharacter(SidePanel panel) { this.panel = panel; this.player = panel.getPlayer(); this.addParentPanel(panel); this.character = player.getCharacter(); // Create text text = new Table(); //text.debug(); text.defaults().padTop(NEG);//from w w w . jav a 2 s .co m LabelStyle ls30 = new LabelStyle(); ls30.font = Assets.pixel30; LabelStyle ls24 = new LabelStyle(); ls24.font = Assets.pixel24; Label charC = new Label("Character", ls30); charC.setAlignment(0, 0); Label nameC = new Label("Name:", ls24); Label levelC = new Label("Level:", ls24); Label expC = new Label("EXP:", ls24); Label nextLevelC = new Label("Next:", ls24); Label factionC = new Label("Faction:", ls24); Label titleC = new Label("Title:", ls24); Label fameC = new Label("Fame:", ls24); name = new Label("", ls24); level = new Label("", ls24); exp = new Label("", ls24); nextLevel = new Label("", ls24); faction = new Label("", ls24); title = new Label("", ls24); fame = new Label("", ls24); text.add(charC).colspan(2).padBottom(PAD).width(SidePanel.WIDTH - PAD * 2).fillX().expandX(); text.row(); text.add(nameC).left(); text.add(name).right(); text.row(); text.add(levelC).left(); text.add(level).right(); text.row(); text.add(expC).left(); text.add(exp).right(); text.row(); text.add(nextLevelC).left(); text.add(nextLevel).right(); text.row(); text.add(factionC).left(); text.add(faction).right(); text.row(); text.add(titleC).left(); text.add(title).right(); text.row(); text.add(fameC).left(); text.add(fame).right(); this.addTopTable(text); this.setButton(1, "Attributes"); this.setButton(2, "Holdings"); this.setButton(4, "Back"); }
From source file:kyle.game.besiege.panels.PanelHire.java
License:Open Source License
public void updateSoldierTable() { toHire = location.getToHire();/*ww w. j av a2 s. c o m*/ soldierTable.clear(); soldierTable.padLeft(MINI_PAD).padRight(MINI_PAD); soldierTable.add().colspan(2).width(SidePanel.WIDTH - PAD * 2).padTop(0); soldierTable.row(); for (Soldier s : toHire.getHealthy()) { SoldierLabel name = new SoldierLabel(s.name, ls, s); name.addListener(new ClickListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { select(((SoldierLabel) event.getTarget()).soldier); } }); soldierTable.add(name).left(); Label count = new Label(s.level + "", ls); // soldierTable.add(count).right(); soldierTable.add().right(); soldierTable.row(); } if (toHire.getHealthySize() == 0) { Label none = new Label("No troops available for hire", ls); none.setWrap(true); none.setAlignment(0, 0); soldierTable.add(none).colspan(2).width(SidePanel.WIDTH - PAD * 6).padTop(PAD * 4); soldierTable.row(); } }
From source file:kyle.game.besiege.panels.PanelParty.java
License:Open Source License
public void updateSoldierTable() { soldierTable.clear(); // clearing the table is a problem right now. it hides the scroll bar and prevents click-drag scrolling soldierTable.padLeft(MINI_PAD).padRight(MINI_PAD); soldierTable.row();/* ww w . j a v a 2 s .com*/ // This method is very leaky. Should only call when update to party occurs necessary. updateTableWithTypes(soldierTable, party.getConsolHealthy(), ls); updateTableWithTypes(soldierTable, party.getConsolWounded(), lsG); Label prisonersC; // LEAK IS ABOVE if (party.getPrisoners().size > 0) prisonersC = new Label("Captured", ls); else prisonersC = new Label("", ls); prisonersC.setAlignment(0, 0); soldierTable.add(prisonersC).colspan(2).width(SidePanel.WIDTH - PAD * 2).expandX().fillX().padTop(0); soldierTable.row(); updateTableWithTypes(soldierTable, party.getConsolPrisoners(), lsG); }
From source file:kyle.game.besiege.panels.PanelUpgrades.java
License:Open Source License
public PanelUpgrades(SidePanel panel, Army army) { this.panel = panel; this.army = army; this.party = army.getParty(); this.addParentPanel(panel); LabelStyle lsBig = new LabelStyle(); lsBig.font = Assets.pixel24;//from w w w. j a v a 2 s.c om LabelStyle lsMB = new LabelStyle(); lsMB.font = Assets.pixel22; LabelStyle lsMed = new LabelStyle(); lsMed.font = Assets.pixel18; LabelStyle lsSmall = new LabelStyle(); lsSmall.font = Assets.pixel14; LabelStyle lsMicro = new LabelStyle(); lsMicro.font = Assets.pixel14; ls = new LabelStyle(); ls.font = Assets.pixel16; Label sizeC = new Label("Size:", ls); Label moraleC = new Label("Morale:", ls); Label moneyC = new Label("Money:", ls); Label atkC = new Label("Atk:", ls); Label defC = new Label("Def:", ls); Label spdC = new Label("Spd:", ls); title = new Label("Upgrades", lsBig); title.setAlignment(0, 0); title.setWrap(true); title.setWidth(SidePanel.WIDTH - PAD * 2 - MINI_PAD * 2); faction = new Label("", lsMed); faction.setAlignment(0, 0); size = new Label("", ls); morale = new Label("", ls); money = new Label("", ls); atk = new Label("", ls); def = new Label("", ls); spd = new Label("", ls); // Create text text = new Table(); //text.debug(); text.defaults().padTop(NEG).left(); text.add(title).colspan(4).fillX().expandX().padBottom(MINI_PAD); text.row(); text.add().colspan(2).width((SidePanel.WIDTH - PAD * 2) / 2); text.add().colspan(2).width((SidePanel.WIDTH - PAD * 2) / 2); text.row(); text.add(faction).colspan(4).padBottom(MINI_PAD).fillX().expandX(); text.row(); text.add(sizeC).padLeft(MINI_PAD); text.add(size); text.add(atkC).padLeft(PAD); text.add(atk); text.row(); text.add(moraleC).padLeft(MINI_PAD); text.add(morale); text.add(defC).padLeft(PAD); text.add(def); text.row(); text.add(moneyC).padLeft(MINI_PAD); text.add(money); text.add(spdC).padLeft(PAD); text.add(spd); soldierTable = new Table(); //soldierTable.debug(); soldierTable.defaults().padTop(NEG); soldierTable.top(); soldierTable.setBackground( new NinePatchDrawable(new NinePatch(Assets.atlas.findRegion(tablePatch), r, r, r, r))); text.row(); text.add().colspan(4).padBottom(PAD); text.row(); soldierPane = new ScrollPane(soldierTable); soldierPane.setScrollbarsOnTop(true); soldierPane.setFadeScrollBars(false); text.add(soldierPane).colspan(4).top().padTop(0); text.row(); // Soldier's stats upgrades = new Table(); upgrades.setVisible(false); upgrades.padLeft(MINI_PAD); Label equippedSC = new Label("Equipped with:", lsMed); equippedSC.setAlignment(0, 0); Label upgradeSC = new Label("Upgrade with:", lsMed); upgradeSC.setAlignment(0, 0); nameS = new Label("", lsMB); nameS.setAlignment(0, 0); upgradeS = new Label("", ls); upgradeS.setAlignment(0, 0); naturalS = new Label("", ls); naturalS.setAlignment(0, 0); equippedS = new Label("", lsMed); equippedStatsS = new Label("", ls); upgrade1S = new Label("", lsMicro); upgrade2S = new Label("", lsMicro); upgrade3S = new Label("", lsMicro); upgrade1S.setTouchable(Touchable.disabled); upgrade2S.setTouchable(Touchable.disabled); upgrade3S.setTouchable(Touchable.disabled); upgrade1StatsS = new Label("", lsSmall); upgrade2StatsS = new Label("", lsSmall); upgrade3StatsS = new Label("", lsSmall); upgrade1StatsS.setWrap(true); upgrade2StatsS.setWrap(true); upgrade3StatsS.setWrap(true); // upgrade1StatsS.setAlignment(Align.right,Align.right); // upgrade2StatsS.setAlignment(Align.right,Align.right); // upgrade3StatsS.setAlignment(Align.right,Align.right); ButtonStyle bs = new ButtonStyle(); bs = new ButtonStyle(); bs.up = new NinePatchDrawable(new NinePatch(Assets.atlas.findRegion(upTexture), r, r, r, r)); bs.down = new NinePatchDrawable(new NinePatch(Assets.atlas.findRegion(downTexture), r, r, r, r)); bs.pressedOffsetX = OFFSET; bs.pressedOffsetY = -OFFSET; up1B = new WeaponButton(upgrade1S, bs, null); up1B.addListener(new ClickListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { upgradeCurrent(((WeaponButton) event.getTarget()).weapon); } }); up2B = new WeaponButton(upgrade2S, bs, null); up2B.addListener(new ClickListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { upgradeCurrent(((WeaponButton) event.getTarget()).weapon); } }); up3B = new WeaponButton(upgrade3S, bs, null); up3B.addListener(new ClickListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { upgradeCurrent(((WeaponButton) event.getTarget()).weapon); } }); up1B.setVisible(false); up2B.setVisible(false); up3B.setVisible(false); upgrades.defaults().left(); upgrades.add(nameS).colspan(2).width(SidePanel.WIDTH - PAD * 2).fillX().expandX(); // upgrades.row(); // upgrades.add(equippedSC).fillX().expandX(); // upgrades.row(); // upgrades.add(equippedS).left(); // upgrades.row(); // upgrades.add(equippedStatsS).padTop(NEG); upgrades.row(); upgrades.add(upgradeS).padBottom(NEG).expandX().fillX().colspan(2); upgrades.row(); upgrades.add(naturalS).padBottom(MINI_PAD).expandX().fillX().colspan(2); upgrades.row(); upgrades.add(upgradeSC).fillX().expandX().padBottom(MINI_PAD).colspan(2); upgrades.row(); upgrades.add(up1B).padRight(MINI_PAD).fillX().padBottom(MINI_PAD).padTop(MINI_PAD); upgrades.add(upgrade1StatsS).fillX().expandX(); upgrades.row(); upgrades.add(up2B).padRight(MINI_PAD).fillX().padTop(MINI_PAD).padBottom(MINI_PAD); upgrades.add(upgrade2StatsS).fillX().expandX(); upgrades.row(); upgrades.add(up3B).padRight(MINI_PAD).fillX().padTop(MINI_PAD).padTop(MINI_PAD); upgrades.add(upgrade3StatsS).fillX().expandX(); //upgrades.debug(); text.add(upgrades).colspan(4).padTop(PAD); this.addTopTable(text); // this.addButton(null); // this.addButton(null); // // this.addButton(null); this.setButton(4, "Back"); }
From source file:kyle.game.besiege.panels.PanelUpgrades.java
License:Open Source License
public void updateSoldierTable() { soldierTable.clear();/* ww w .j a va2 s. c o m*/ soldierTable.padLeft(MINI_PAD).padRight(MINI_PAD); // Label healthyC = new Label("Upgradable", ls); // healthyC.setAlignment(0,0); soldierTable.add().colspan(2).width(SidePanel.WIDTH - PAD * 2).padTop(0); soldierTable.row(); for (Soldier s : party.getUpgradable()) { SoldierLabel name = new SoldierLabel(s.name, ls, s); name.addListener(new ClickListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { select(((SoldierLabel) event.getTarget()).soldier); } }); soldierTable.add(name).left(); Label count = new Label(s.level + "", ls); soldierTable.add(count).right(); soldierTable.row(); } if (party.getUpgradable().size == 0) { Label none = new Label("No troops are ready to upgrade!", ls); // healthyC.setText(""); none.setWrap(true); none.setAlignment(0, 0); soldierTable.add(none).colspan(2).width(SidePanel.WIDTH - PAD * 6).padTop(PAD * 4); soldierTable.row(); } }
From source file:org.anism.lotw.LOTW.java
License:Open Source License
public void initEverything() { Color fullAnti = new Color(G.getAntiColor()); fullAnti.a = 1;// w ww .ja v a 2 s. com Texture upTexture = new Texture(Gdx.files.internal("images/grey_button_up.png")); Texture downTexture = new Texture(Gdx.files.internal("images/grey_button_down.png")); NinePatch buttonPatchUp = new NinePatch(upTexture, 11, 11, 11, 11); NinePatch buttonPatchDown = new NinePatch(downTexture, 11, 11, 11, 11); NinePatchDrawable npdUp = new NinePatchDrawable(buttonPatchUp); NinePatchDrawable npdDown = new NinePatchDrawable(buttonPatchDown); textButtonStyle = new TextButton.TextButtonStyle(npdUp, npdDown, npdUp, G.roboto16); textButtonStyle.fontColor = new Color(G.getAntiColor()); textButtonStyle.fontColor.a = 1; buttonStyle = new ButtonStyle(npdUp, npdDown, npdUp); labelStyle = new Label.LabelStyle(G.roboto24, G.getAntiColor()); labelStyleSmall = new Label.LabelStyle(G.roboto16, G.getAntiColor()); resumeButton = addIconButton(game, G.playIcon, new ClickListener() { @Override public void clicked(InputEvent e, float x, float y) { if (!G.pausing) { G.pause(); } } }, buttonWidth / dpi / 2 + 4 * dpi, -48, buttonWidth / dpi, 88); resumeButton.setColor(G.colors.green); exitButton = addIconButton(game, G.backIcon, new ClickListener() { @Override public void clicked(InputEvent e, float x, float y) { if (!G.pausing) { G.gameOver(); } } }, -buttonWidth / dpi / 2 - 4 * dpi, -48, buttonWidth / dpi, 88); exitButton.setColor(G.colors.red); togglePauseButtons(); //intro.addActor(logo); //putLogo(settings); putLogo(instructions); //putLogo(statistics); /* // intro screen: addButton(intro, game, "Start Game", 0, 0, 200f, 40f); addButton(intro, settings, "Settings", 0, -70, 100f, 40f); addButton(intro, instructions, "How to Play", 0, -120, 100f, 40f); */ // settings screen: ImageTextButton.ImageTextButtonStyle lbs = new ImageTextButton.ImageTextButtonStyle(textButtonStyle); TextureRegionDrawable gamepadDrawable = new TextureRegionDrawable(new TextureRegion(G.controllerIcon)); lbs.imageChecked = gamepadDrawable; lbs.imageCheckedOver = gamepadDrawable; lbs.imageDisabled = gamepadDrawable; lbs.imageDown = gamepadDrawable; lbs.imageOver = gamepadDrawable; lbs.imageUp = gamepadDrawable; logButton = new ImageTextButton("Sign In", lbs); if (actionResolver.getSignedInGPGS()) { logButton.setText("Sign Out"); } logButton.addListener(new ClickListener() { @Override public void clicked(InputEvent e, float x, float y) { if (actionResolver.getSignedInGPGS()) { actionResolver.logoutGPGS(); } else { actionResolver.loginGPGS(); } G.toggleAutologin(); } }); logButton.setWidth(184 * dpi); logButton.setHeight(88 * dpi); logButton.setColor(G.colors.grey); logButton.getImage().setColor(fullAnti); //settings.addActor(logButton); TextureRegionDrawable cbOn = new TextureRegionDrawable(new TextureRegion(G.dashIcon)); TextureRegionDrawable cbOff = new TextureRegionDrawable(new TextureRegion(G.circleIcon)); CheckBoxStyle cbs = new CheckBoxStyle(cbOff, cbOn, G.roboto16, fullAnti); cbs.checked = npdUp; cbs.checkedOver = npdUp; cbs.down = npdDown; cbs.over = npdUp; cbs.up = npdUp; // colorblind settings: CheckBox colorButton = new CheckBox("", cbs); colorButton.addListener(new ClickListener() { @Override public void clicked(InputEvent e, float x, float y) { G.toggleColorblind(); } }); colorButton.setWidth(88 * dpi); colorButton.setHeight(88 * dpi); /* colorButton.setPosition(G.width/2 - 188 * dpi, G.height/2 + 100*dpi); */ Table colorTable = makeSettingsTable("Display"); colorButton.setColor(Math.random() > 0.5 ? G.colors.green : G.colors.red); colorButton.getImage().setColor(fullAnti); colorButton.setChecked(G.settings.colorblind); ListStyle listStyle = new ListStyle(G.roboto16, G.getAntiColor(), G.getAntiColor(), npdDown); listStyle.background = npdUp; SelectBoxStyle sbs = new SelectBoxStyle(G.roboto16, new Color(0x00000000), npdUp, new ScrollPane.ScrollPaneStyle(), listStyle); final SelectBox<Season> seasonPicker = new SelectBox(sbs); seasonPicker.setItems((Season[]) G.settings.getUnlockedSeasons()); if (G.settings.unlock) { seasonPicker.setSelected(G.settings.unlockSeason); } else { seasonPicker.setSelected(G.settings.getSeason()); } seasonPicker.setColor(G.colors.grey); seasonPicker.getList().setColor(G.colors.grey); Stack seasonStack = new Stack(); final Container seasonImage = new Container(new Image(seasonPicker.getSelected().getIcon())); seasonImage.setSize(32, 32); seasonImage.setTouchable(Touchable.disabled); seasonImage.getActor().setColor(G.getAntiColor()); seasonStack.add(seasonPicker); seasonStack.add(seasonImage); seasonPicker.addListener(new ChangeListener() { @Override public void changed(ChangeEvent e, Actor a) { Season s = seasonPicker.getSelected(); if (s.getName().toUpperCase().equals("UNLOCK")) { G.glider.score = 0; G.settings.unlock = true; G.settings.setSeason(G.settings.getSeasons()[0]); G.updateBgColor(); G.lotw.resetEverything(); } else { G.settings.unlock = false; G.changeSeason(s); } } }); putSettingsButton(colorTable, seasonStack, "Season."); CheckBox ninjaButton = new CheckBox("", cbs); ninjaButton.addListener(new ClickListener() { @Override public void clicked(InputEvent e, float x, float y) { G.toggleNinja(); } }); ninjaButton.setColor(G.colors.grey); ninjaButton.getImage().setColor(fullAnti); ninjaButton.setChecked(G.settings.ninjaMode); putSettingsButton(colorTable, colorButton, "Add markings to distinguish red and green orbs."); putSettingsButton(colorTable, ninjaButton, "Ninja mode."); // advanced settings: CheckBox bottomButton = new CheckBox("", cbs); bottomButton.addListener(new ClickListener() { @Override public void clicked(InputEvent e, float x, float y) { G.toggleBottomOut(); } }); bottomButton.setChecked(G.settings.bottomOut); bottomButton.setColor(G.colors.grey); bottomButton.getImage().setColor(fullAnti); Table bottomTable = makeSettingsTable("Advanced"); putSettingsButton(bottomTable, bottomButton, "The glider respawns if it falls too far. Experienced players may wish to turn this off."); ImageButton statsButton = addIconButton(null, G.image("icons/stats.png"), new ClickListener() { @Override public void clicked(InputEvent e, float x, float y) { seeStats(); } }, 96, -48, 88, 88); statsButton.setColor(G.colors.grey); putSettingsButton(bottomTable, statsButton, "View aggregate and record statistics."); ImageButton aboutButton = addIconButton(null, G.infoIcon, new ClickListener() { @Override public void clicked(InputEvent e, float x, float y) { setStage(about); } }, 0, 0, 0, 0); aboutButton.setColor(G.colors.grey); putSettingsButton(bottomTable, aboutButton, "About."); // online settings: ImageButton leaderButton = addIconButton(null, G.leaderIcon, new ClickListener() { @Override public void clicked(InputEvent e, float x, float y) { actionResolver.getLeaderboardGPGS(G.constants.scoreBoard); } }, 48, -G.height / 2 / dpi + 48, 88, 88); leaderButton.setColor(G.colors.gold); ImageButton achieveButton = addIconButton(null, G.achieveIcon, new ClickListener() { @Override public void clicked(InputEvent e, float x, float y) { actionResolver.getAchievementsGPGS(); } }, -48, -G.height / 2 / dpi + 48, 88, 88); achieveButton.setColor(G.colors.blue); Table loginTable = makeSettingsTable("Online"); putSettingsButton(loginTable, achieveButton, "View achievements."); putSettingsButton(loginTable, leaderButton, "Access leaderboards."); loginTable.add(logButton).width(182 * dpi).pad(4 * dpi).colspan(2).center(); // control settings: Table controlTable = makeSettingsTable("Controls"); CheckBox twoTouchControls = new CheckBox("", cbs); twoTouchControls.setColor(G.colors.grey); twoTouchControls.getImage().setColor(fullAnti); twoTouchControls.setChecked(G.settings.twoTouch()); twoTouchControls.addListener(new ClickListener() { @Override public void clicked(InputEvent e, float x, float y) { G.settings.setControl("TWO_TOUCH"); } }); CheckBox tiltControls = new CheckBox("", cbs); tiltControls.setColor(G.colors.grey); tiltControls.getImage().setColor(fullAnti); tiltControls.setChecked(G.settings.tilt()); tiltControls.addListener(new ClickListener() { @Override public void clicked(InputEvent e, float x, float y) { G.settings.setControl("TILT"); } }); CheckBox dragControls = new CheckBox("", cbs); dragControls.setColor(G.colors.grey); dragControls.getImage().setColor(fullAnti); dragControls.setChecked(G.settings.oneTouch()); dragControls.addListener(new ClickListener() { @Override public void clicked(InputEvent e, float x, float y) { G.settings.setControl("ONE_TOUCH"); } }); ButtonGroup controlGroup = new ButtonGroup(twoTouchControls, tiltControls, dragControls); controlGroup.setMaxCheckCount(1); controlGroup.setMinCheckCount(1); controlGroup.setUncheckLast(true); putSettingsButton(controlTable, twoTouchControls, "Touch on the left or right."); putSettingsButton(controlTable, tiltControls, "Tilt your device."); putSettingsButton(controlTable, dragControls, "Touch and drag."); // mode settings: Table modeTable = makeSettingsTable("Mode"); CheckBox hellMode = new CheckBox("", cbs); hellMode.setColor(G.colors.red); hellMode.getImage().setColor(fullAnti); hellMode.setChecked(G.settings.hell()); hellMode.addListener(new ClickListener() { @Override public void clicked(InputEvent e, float x, float y) { G.settings.setMode(-1); } }); CheckBox normalMode = new CheckBox("", cbs); normalMode.setColor(G.colors.grey); normalMode.getImage().setColor(fullAnti); normalMode.setChecked(G.settings.normal()); normalMode.addListener(new ClickListener() { @Override public void clicked(InputEvent e, float x, float y) { G.settings.setMode(0); } }); ButtonGroup modeGroup = new ButtonGroup(hellMode, normalMode); modeGroup.setMaxCheckCount(1); modeGroup.setMinCheckCount(1); modeGroup.setUncheckLast(true); putSettingsButton(modeTable, normalMode, "Normal mode: catch orbs for points."); putSettingsButton(modeTable, hellMode, "Hell mode: dodge red orbs."); putActionBar(settings); putActionBar(colorSettings); putActionBar(controlSettings); putActionBar(modeSettings); putActionBar(loginSettings); putActionBar(bottomSettings); putSettingsMenu(settings); putSettingsMenu(colorSettings); colorSettings.addActor(colorTable); putSettingsMenu(controlSettings); controlSettings.addActor(controlTable); putSettingsMenu(loginSettings); loginSettings.addActor(loginTable); putSettingsMenu(modeSettings); modeSettings.addActor(modeTable); putSettingsMenu(bottomSettings); bottomSettings.addActor(bottomTable); Table aboutTable = new Table(); aboutTable.setSize(G.width, G.height - 88 * dpi); aboutTable.setPosition(0, 88 * dpi); aboutTable.add(new Label("About", labelStyle)); aboutTable.row(); Label aboutTextLabel = new Label( "Leaf on the Wind copyright 2014 Ethan Goldberg, all rights reserved.\n\nIcons made by Google and licensed under CC BY 4.0.\n\n\nThank you for playing!", labelStyleSmall); aboutTextLabel.setWrap(true); aboutTextLabel.setAlignment(Align.center, Align.center); aboutTable.add(aboutTextLabel).width(G.width / 2); ImageButton aboutBackButton = addIconButton(about, G.backIcon, new ClickListener() { @Override public void clicked(InputEvent e, float x, float y) { setStage(bottomSettings); } }, 0, -G.height / 2 / dpi + 48, buttonWidth / dpi, 88); aboutBackButton.setColor(G.colors.red); about.addActor(aboutTable); about.addActor(aboutBackButton); // instructions: //delay float d = 0f; addLabel(instructions, "This is your glider.", 0, G.height / 2 / dpi - 96, 8, tr) .addAction(Actions.delay(d, Actions.fadeIn(fadeDur))); // wait two seconds: d += 2.5; addLabel(instructions, "Touch the screen", 0, G.height / 2 / dpi - 136, 8, tr) .addAction(Actions.delay(d, Actions.fadeIn(fadeDur))); d += 1; addLabel(instructions, "on the left,", -G.width / 4 / dpi, G.height / 2 / dpi - 166, 8, tr) .addAction(Actions.delay(d, Actions.fadeIn(fadeDur))); d += 1.5; addLabel(instructions, "or the right.", G.width / 4 / dpi, G.height / 2 / dpi - 166, 8, tr) .addAction(Actions.delay(d, Actions.fadeIn(fadeDur))); d += 3; int pickUpOffset = G.size * 2; addLabel(instructions, "Catch these,", -G.width / 4 / dpi, -G.height / 6 / dpi, G.size * 2 / dpi, tr) .addAction(Actions.delay(d, Actions.fadeIn(fadeDur))); Goody i; d += 1.5; Color r = new Color(G.colors.goodyRed); r.a = 0; Color gr = new Color(G.colors.goodyGreen); gr.a = 0; Color go = new Color(G.colors.goodyGold); go.a = 0; Color b = new Color(G.colors.goodyBlue); b.a = 0; i = addDumbGoody(instructions, b, -G.width / 4 / dpi - (G.size * 2) / dpi, -G.height / 6 / dpi + pickUpOffset); i.addAction(Actions.delay(d, Actions.alpha(1))); //bounce(i, 0, 8, 0.33f, 8); bounce(i, 0, 8, 0.33f, 4); d += .5; i = addDumbGoody(instructions, gr, -G.width / 4 / dpi, -G.height / 6 / dpi + pickUpOffset); i.addAction(Actions.delay(d, Actions.alpha(1))); //bounce(i, 0.25f, 8, 0.33f, 8); bounce(i, 0.25f, 8, 0.33f, 4); d += .5; i = addDumbGoody(instructions, go, -G.width / 4 / dpi + (G.size * 2) / dpi, -G.height / 6 / dpi + pickUpOffset); i.addAction(Actions.delay(d, Actions.alpha(1))); //bounce(i, 0.5f, 8, 0.33f, 8); bounce(i, 0.5f, 8, 0.33f, 4); d += 1.5; addLabel(instructions, "not these.", G.width / 4 / dpi, -G.height / 6 / dpi, G.size * 2 / dpi, tr) .addAction(Actions.delay(d, Actions.fadeIn(fadeDur))); d += 2; i = addDumbBaddy(instructions, r, G.width / 4 / dpi, -G.height / 6 / dpi + pickUpOffset); i.addAction(Actions.delay(d, Actions.alpha(1))); //bounce(i, 0.75f, 8, 0.33f, 8); bounce(i, 0.75f, 8, 0.33f, 4); d += 2; addIconButton(instructions, G.playIcon, new ClickListener() { @Override public void clicked(InputEvent e, float x, float y) { setStage(game); } }, G.width / 2 / dpi - buttonWidth / dpi / 2 - 4, -G.height / 2 / dpi + 48, buttonWidth / dpi, 88) .setColor(G.colors.green); addIconButton(instructions, G.image("icons/settings.png"), new ClickListener() { @Override public void clicked(InputEvent e, float x, float y) { setStage(settings); } }, -G.width / 2 / dpi + buttonWidth / 2 / dpi + 4, -G.height / 2 / dpi + 48, buttonWidth / dpi, 88) .setColor(G.colors.grey); d += 2; Color c = new Color(G.getAntiColor()); c.a = 0; addImage(instructions, G.playWrite, c, G.width / 2 / dpi - 3 * buttonWidth / 2 / dpi - 8, -G.height / 2 / dpi + 48, buttonWidth / 2 / dpi, 48) .addAction(Actions.delay(d, Actions .forever(Actions.sequence(Actions.fadeOut(fadeDur), Actions.fadeIn(fadeDur))))); /* TextButton b1 = addButton(instructions, game, "Start", 0, -G.height/2/dpi + 88f, 192, 40f); TextButton b2 = addButton(instructions, settings, "Settings", 0, -G.height/2/dpi + 40f, 192, 40f); b1.addAction(Actions.alpha(.5f)); b2.addAction(Actions.alpha(.25f)); b1.addAction(Actions.delay(d, Actions.fadeIn(fadeDur))); b2.addAction(Actions.delay(d, Actions.fadeIn(fadeDur))); */ }