List of usage examples for com.badlogic.gdx.scenes.scene2d.ui Table getCell
public <T extends Actor> Cell<T> getCell(T actor)
From source file:com.kotcrab.vis.ui.widget.VisWindow.java
License:Apache License
/** * Adds close button to window, next to window title. After pressing that button, {@link #close()} is called. If nothing * else was added to title table, and current title alignment is center then the title will be automatically centered. *///ww w.ja v a2 s .c o m public void addCloseButton() { Label titleLabel = getTitleLabel(); Table titleTable = getTitleTable(); VisImageButton closeButton = new VisImageButton("close-window"); titleTable.add(closeButton).padRight(-getPadRight() + 0.7f); closeButton.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { close(); } }); closeButton.addListener(new ClickListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { event.cancel(); return true; } }); if (titleLabel.getLabelAlign() == Align.center && titleTable.getChildren().size == 2) titleTable.getCell(titleLabel).padLeft(closeButton.getWidth() * 2); }
From source file:de.fgerbig.spacepeng.screens.MenuScreen.java
License:Apache License
public MenuScreen(final SpacePeng game) { super(game);/*from ww w . j av a2 s . c om*/ // retrieve the default table actor Table table = super.getTable(); table.setSkin(game.getSkin()); Label label = new Label("SPACE PENG!", game.getSkin()); label.setStyle(labelStyle_Heading); table.add(label).spaceBottom(25); table.row(); profile = SpacePeng.profileManager.retrieveProfile(); if (profile.getLastPlayedLevel() > 1) { // register the button "start game" continueGameButton = new TextButton("Level " + profile.getLastPlayedLevel(), game.getSkin()); continueGameButton.setStyle(textButtonStyle_Default); continueGameButton.addListener(new DefaultInputListener() { @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { super.touchUp(event, x, y, pointer, button); SpacePeng.soundManager.play(SoundKey.CLICK); game.setScreen(new GameScreen(game)); } }); table.add(continueGameButton).size(BUTTON_WIDTH, BUTTON_HEIGHT).uniform() .spaceBottom(BUTTON_HEIGHT / 3); table.row(); } // register the button "start game" String title = (profile.getLastPlayedLevel() > 1) ? "RESTART" : "START"; startGameButton = new TextButton(title, game.getSkin()); startGameButton.setStyle(textButtonStyle_Default); startGameButton.addListener(new DefaultInputListener() { @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { super.touchUp(event, x, y, pointer, button); SpacePeng.soundManager.play(SoundKey.CLICK); profile.setLastPlayedLevel(1); game.setScreen(new GameScreen(game)); } }); table.add(startGameButton).size(BUTTON_WIDTH, BUTTON_HEIGHT).uniform().spaceBottom(BUTTON_SPACING); table.row(); // register the button "Credits" creditsButton = new TextButton("Credits", game.getSkin()); creditsButton.setStyle(textButtonStyle_Default); creditsButton.addListener(new DefaultInputListener() { @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { super.touchUp(event, x, y, pointer, button); SpacePeng.soundManager.play(SoundKey.CLICK); game.setScreen(new CreditsScreen(game)); } }); table.add(creditsButton).size(BUTTON_WIDTH, BUTTON_HEIGHT).uniform().fill().spaceBottom(BUTTON_SPACING); table.row(); // register the button "options" optionsButton = new TextButton("Options", game.getSkin()); optionsButton.setStyle(textButtonStyle_Default); optionsButton.addListener(new DefaultInputListener() { @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { super.touchUp(event, x, y, pointer, button); SpacePeng.soundManager.play(SoundKey.CLICK); game.setScreen(new OptionsScreen(game)); } }); table.add(optionsButton).size(BUTTON_WIDTH, BUTTON_HEIGHT).uniform().fill().spaceBottom(BUTTON_HEIGHT / 3); table.row(); // register the button "quit" quitButton = new TextButton("QUIT", game.getSkin()); quitButton.setStyle(textButtonStyle_Default); quitButton.addListener(new DefaultInputListener() { @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { super.touchUp(event, x, y, pointer, button); SpacePeng.soundManager.play(SoundKey.CLICK); game.pause(); game.dispose(); } }); table.add(quitButton).size(BUTTON_WIDTH, BUTTON_HEIGHT); Cell cell; if (profile.getLastPlayedLevel() > 1) { cell = table.getCell(continueGameButton); continueGameButton_w = cell.getMaxWidth(); continueGameButton_h = cell.getMaxHeight(); cell.maxSize(BUTTON_START_WIDTH, BUTTON_START_HEIGHT); } cell = table.getCell(startGameButton); startGameButton_w = cell.getMaxWidth(); startGameButton_h = cell.getMaxHeight(); cell.maxSize(BUTTON_START_WIDTH, BUTTON_START_HEIGHT); cell = table.getCell(creditsButton); creditsButton_w = cell.getMaxWidth(); creditsButton_h = cell.getMaxHeight(); cell.maxSize(BUTTON_START_WIDTH, BUTTON_START_HEIGHT); cell = table.getCell(optionsButton); optionsButton_w = cell.getMaxWidth(); optionsButton_h = cell.getMaxHeight(); cell.maxSize(BUTTON_START_WIDTH, BUTTON_START_HEIGHT); cell = table.getCell(quitButton); quitButton_w = cell.getMaxWidth(); quitButton_h = cell.getMaxHeight(); cell.maxSize(BUTTON_START_WIDTH, BUTTON_START_HEIGHT); getTable().invalidate(); }