Search in sources :

Example 61 with Table

use of com.badlogic.gdx.scenes.scene2d.ui.Table in project AmazingMaze by TheVirtualMachine.

the class MazeScreen method setupHUD.

/** Create the game HUD. */
private void setupHUD() {
    hud = new Stage(new ScreenViewport(), game.batch);
    Table table = new Table();
    table.setFillParent(true);
    table.top().left();
    hud.addActor(table);
    Label level = new Label("Level " + game.save.getLevel(), game.assets.skin, Assets.HUD_STYLE);
    table.add(level).colspan(2);
    table.row();
    Image lifeIcon = new Image(game.assets.manager.get(Assets.LIFE_HUD_IMAGE, Texture.class));
    table.add(lifeIcon).pad(Gdx.graphics.getWidth() / 128).left();
    livesLeft = new Label("", game.assets.skin, Assets.HUD_STYLE);
    table.add(livesLeft);
    updateLives(-2);
}
Also used : Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) Stage(com.badlogic.gdx.scenes.scene2d.Stage) ScreenViewport(com.badlogic.gdx.utils.viewport.ScreenViewport) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) Texture(com.badlogic.gdx.graphics.Texture)

Example 62 with Table

use of com.badlogic.gdx.scenes.scene2d.ui.Table in project AmazingMaze by TheVirtualMachine.

the class FishMiniGame method setupPauseMenu.

/** Create the pause menu. */
private void setupPauseMenu() {
    pauseMenu = new Stage(new ScreenViewport(), game.batch);
    Table table = new Table();
    table.setFillParent(true);
    table.center();
    pauseMenu.addActor(table);
    TextButton resumeButton = new TextButton("Resume", game.assets.skin);
    resumeButton.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            paused = false;
        }
    });
    table.add(resumeButton).pad(10).width(Gdx.graphics.getWidth() / 4).height(Gdx.graphics.getHeight() / 8);
    table.row();
    TextButton settingsButton = new TextButton("Settings", game.assets.skin);
    final Screen sourceScreen = this;
    settingsButton.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            game.settingsScreen.setSourceScreen(sourceScreen);
            game.setScreen(game.settingsScreen);
        }
    });
    table.add(settingsButton).pad(10).width(Gdx.graphics.getWidth() / 4).height(Gdx.graphics.getHeight() / 8);
    table.row();
    TextButton quitButton = new TextButton("Quit", game.assets.skin);
    quitButton.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            game.save.setLevel(game.save.getLevel() - 1);
            game.setScreen(game.menuScreen);
        }
    });
    table.add(quitButton).pad(10).width(Gdx.graphics.getWidth() / 4).height(Gdx.graphics.getHeight() / 8);
}
Also used : TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Screen(com.badlogic.gdx.Screen) Actor(com.badlogic.gdx.scenes.scene2d.Actor) Stage(com.badlogic.gdx.scenes.scene2d.Stage) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) ScreenViewport(com.badlogic.gdx.utils.viewport.ScreenViewport)

Example 63 with Table

use of com.badlogic.gdx.scenes.scene2d.ui.Table in project AmazingMaze by TheVirtualMachine.

the class HighScoresScreen method show.

@Override
public void show() {
    Gdx.input.setInputProcessor(stage);
    game.music.setSong(Song.MENU);
    stage.clear();
    table = new Table();
    table.setFillParent(true);
    table.top();
    stage.addActor(table);
    Label header = new Label("High Scores", game.assets.skin, Assets.SANS_HEADER_STYLE);
    table.add(header).pad(Gdx.graphics.getHeight() / 20).colspan(3);
    table.row();
    HighScore[] scores = game.save.getHighScores();
    for (int i = 0; i < scores.length; i++) {
        Label position = new Label(Integer.toString(i + 1) + ". ", game.assets.skin);
        Label name = new Label(scores[i].getName(), game.assets.skin);
        Label score = new Label(Integer.toString(scores[i].getScore()), game.assets.skin);
        if (scores[i].getScore() < 0) {
            score.setText("");
        }
        table.add(position).padBottom(Gdx.graphics.getHeight() / 50);
        table.add(name).left().padBottom(Gdx.graphics.getHeight() / 50).padRight(Gdx.graphics.getWidth() / 32);
        table.add(score).padBottom(Gdx.graphics.getHeight() / 50).right();
        table.row();
    }
    final TextButton resetButton = new TextButton("Reset High Scores", game.assets.skin);
    resetButton.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if (resetButton.isPressed()) {
                game.save.resetScores();
                game.setScreen(game.highScoresScreen);
            }
        }
    });
    table.add(resetButton).colspan(3);
    table.row();
    final TextButton menuButton = new TextButton("Main Menu", game.assets.skin);
    menuButton.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if (menuButton.isPressed()) {
                game.setScreen(game.menuScreen);
            }
        }
    });
    table.add(menuButton).colspan(3).pad(10);
}
Also used : TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Actor(com.badlogic.gdx.scenes.scene2d.Actor) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)

Example 64 with Table

use of com.badlogic.gdx.scenes.scene2d.ui.Table in project skin-composer by raeleus.

the class DialogColors method showColorPicker.

private void showColorPicker() {
    main.getDialogFactory().showDialogColorPicker(new DialogColorPicker.ColorListener() {

        @Override
        public void selected(Color color) {
            if (color != null) {
                final TextField field = new TextField("RGBA_" + (int) (color.r * 255) + "_" + (int) (color.g * 255) + "_" + (int) (color.b * 255) + "_" + (int) (color.a * 255), getSkin());
                final Dialog dialog = new Dialog("Color name...", getSkin(), "bg") {

                    @Override
                    protected void result(Object object) {
                        if ((Boolean) object == true) {
                            newColor(field.getText(), color);
                        }
                    }
                };
                dialog.getTitleTable().padLeft(5.0f);
                dialog.button("Ok", true).button("Cancel", false).key(Keys.ESCAPE, false);
                final TextButton button = (TextButton) dialog.getButtonTable().getCells().first().getActor();
                button.addListener(main.getHandListener());
                dialog.getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener());
                dialog.getButtonTable().pad(15.0f);
                field.setTextFieldListener(new TextField.TextFieldListener() {

                    @Override
                    public void keyTyped(TextField textField, char c) {
                        if (c == '\n') {
                            if (!button.isDisabled()) {
                                String name = field.getText();
                                if (newColor(name, color)) {
                                    dialog.hide();
                                }
                            }
                            main.getStage().setKeyboardFocus(textField);
                        }
                    }
                });
                field.addListener(main.getIbeamListener());
                dialog.getContentTable().padLeft(10.0f).padRight(10.0f).padTop(5.0f);
                dialog.text("Please enter a name for the new color: ");
                dialog.getContentTable().row();
                dialog.getContentTable().add(field).growX();
                dialog.getContentTable().row();
                dialog.text("Preview:");
                dialog.getContentTable().row();
                Table table = new Table(getSkin());
                table.setBackground("white");
                table.setColor(color);
                dialog.getContentTable().add(table).minSize(50.0f);
                button.setDisabled(!ColorData.validate(field.getText()));
                field.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        boolean disable = !ColorData.validate(field.getText());
                        if (!disable) {
                            for (ColorData data : main.getJsonData().getColors()) {
                                if (data.getName().equals(field.getText())) {
                                    disable = true;
                                    break;
                                }
                            }
                        }
                        button.setDisabled(disable);
                    }
                });
                dialog.show(getStage());
                getStage().setKeyboardFocus(field);
                field.selectAll();
                field.setFocusTraversal(false);
            }
        }
    });
}
Also used : TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Color(com.badlogic.gdx.graphics.Color) ColorData(com.ray3k.skincomposer.data.ColorData) Dialog(com.badlogic.gdx.scenes.scene2d.ui.Dialog) Actor(com.badlogic.gdx.scenes.scene2d.Actor) TextField(com.badlogic.gdx.scenes.scene2d.ui.TextField) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)

Example 65 with Table

use of com.badlogic.gdx.scenes.scene2d.ui.Table in project skin-composer by raeleus.

the class DialogDrawables method populate.

public void populate() {
    getContentTable().clear();
    getButtonTable().padBottom(15.0f);
    if (property == null && customProperty == null) {
        getContentTable().add(new Label("Drawables", getSkin(), "title"));
    } else {
        getContentTable().add(new Label("Select a Drawable", getSkin(), "title"));
    }
    getContentTable().row();
    Table table = new Table(getSkin());
    table.defaults().pad(10.0f);
    getContentTable().add(table).growX();
    table.add("Sort by:");
    sortSelectBox = new SelectBox(getSkin());
    sortSelectBox.setItems("A-Z", "Z-A", "Oldest", "Newest");
    sortSelectBox.setSelectedIndex(sortSelection);
    sortSelectBox.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            sortSelection = sortSelectBox.getSelectedIndex();
            sortBySelectedMode();
        }
    });
    sortSelectBox.addListener(main.getHandListener());
    sortSelectBox.getList().addListener(main.getHandListener());
    table.add(sortSelectBox);
    TextButton textButton = new TextButton("Add Drawable", getSkin(), "new");
    textButton.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            Gdx.graphics.setSystemCursor(Cursor.SystemCursor.Arrow);
            newDrawableDialog();
        }
    });
    textButton.addListener(main.getHandListener());
    table.add(textButton);
    textButton = new TextButton("Custom Drawable", getSkin(), "new");
    textButton.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            Gdx.graphics.setSystemCursor(Cursor.SystemCursor.Arrow);
            customDrawableDialog();
        }
    });
    textButton.addListener(main.getHandListener());
    table.add(textButton);
    table.add(new Label("Zoom:", getSkin())).right().expandX();
    zoomSlider = new Slider(0, 3, 1, false, getSkin());
    zoomSlider.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            refreshDrawableDisplay();
        }
    });
    zoomSlider.addListener(main.getHandListener());
    table.add(zoomSlider);
    getContentTable().row();
    contentGroup = new HorizontalGroup();
    contentGroup.center().wrap(true).space(5.0f).wrapSpace(5.0f).rowAlign(Align.left);
    scrollPane = new ScrollPane(contentGroup, getSkin());
    scrollPane.setFadeScrollBars(false);
    scrollPane.setFlickScroll(false);
    getContentTable().add(scrollPane).grow();
    sortBySelectedMode();
    getContentTable().row();
    if (property != null || customProperty != null) {
        button("Clear Drawable", true);
        button("Cancel", false);
        getButtonTable().getCells().first().getActor().addListener(main.getHandListener());
        getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener());
    } else {
        button("Close", false);
        getButtonTable().getCells().first().getActor().addListener(main.getHandListener());
    }
}
Also used : TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Slider(com.badlogic.gdx.scenes.scene2d.ui.Slider) SelectBox(com.badlogic.gdx.scenes.scene2d.ui.SelectBox) ScrollPane(com.badlogic.gdx.scenes.scene2d.ui.ScrollPane) Actor(com.badlogic.gdx.scenes.scene2d.Actor) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) HorizontalGroup(com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup)

Aggregations

Table (com.badlogic.gdx.scenes.scene2d.ui.Table)85 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)51 Stage (com.badlogic.gdx.scenes.scene2d.Stage)48 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)36 TextButton (com.badlogic.gdx.scenes.scene2d.ui.TextButton)35 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)31 Actor (com.badlogic.gdx.scenes.scene2d.Actor)30 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)25 ScrollPane (com.badlogic.gdx.scenes.scene2d.ui.ScrollPane)21 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)18 Texture (com.badlogic.gdx.graphics.Texture)17 ScreenViewport (com.badlogic.gdx.utils.viewport.ScreenViewport)16 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)15 TextField (com.badlogic.gdx.scenes.scene2d.ui.TextField)14 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)13 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)12 ImageButton (com.badlogic.gdx.scenes.scene2d.ui.ImageButton)11 ImageTextButton (com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton)11 CheckBox (com.badlogic.gdx.scenes.scene2d.ui.CheckBox)9 Dialog (com.badlogic.gdx.scenes.scene2d.ui.Dialog)8