Search in sources :

Example 31 with TextButton

use of com.badlogic.gdx.scenes.scene2d.ui.TextButton 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 32 with TextButton

use of com.badlogic.gdx.scenes.scene2d.ui.TextButton 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 33 with TextButton

use of com.badlogic.gdx.scenes.scene2d.ui.TextButton in project gdx-skineditor by cobolfoo.

the class ColorPickerDialog method updateTable.

/**
	 * Refresh table content with colors from the skin
	 */
public void updateTable() {
    tableColors.clear();
    tableColors.add(new Label("Color Name", game.skin, "title")).left().width(170);
    tableColors.add(new Label("Value", game.skin, "title")).colspan(2).left().width(60).padRight(50);
    tableColors.row();
    Iterator<String> it = colors.keys().iterator();
    while (it.hasNext()) {
        final String key = it.next();
        final Color color = colors.get(key);
        tableColors.add(key).left();
        // Create drawable on the fly
        Pixmap pixmap = new Pixmap(18, 18, Pixmap.Format.RGBA8888);
        pixmap.setColor(color);
        pixmap.fill();
        pixmap.setColor(Color.BLACK);
        pixmap.drawRectangle(0, 0, 18, 18);
        Texture texture = new Texture(pixmap);
        pixmap.dispose();
        tableColors.add(new Image(texture));
        tableColors.add(color.toString()).left();
        TextButton buttonSelect = new TextButton("Select", game.skin);
        buttonSelect.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                try {
                    field.set(game.screenMain.paneOptions.currentStyle, color);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                hide();
                game.screenMain.panePreview.refresh();
                game.screenMain.paneOptions.updateSelectedTableFields();
                game.screenMain.saveToSkin();
            }
        });
        TextButton buttonRemove = new TextButton("Remove", game.skin);
        buttonRemove.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                Dialog dlg = new Dialog("Delete Style", game.skin) {

                    @Override
                    protected void result(Object object) {
                        if ((Boolean) object == false) {
                            return;
                        }
                        if (isColorInUse(color) == true) {
                            game.showNotice("Error", "Color already in use!", game.screenMain.stage);
                        } else {
                            colors.remove(key);
                            // update table
                            updateTable();
                            game.screenMain.saveToSkin();
                        }
                    }
                };
                dlg.pad(20);
                dlg.getContentTable().add("You are sure you want to delete this color?");
                dlg.button("OK", true);
                dlg.button("Cancel", false);
                dlg.key(com.badlogic.gdx.Input.Keys.ENTER, true);
                dlg.key(com.badlogic.gdx.Input.Keys.ESCAPE, false);
                dlg.show(game.screenMain.stage);
            }
        });
        if (field != null) {
            tableColors.add(buttonSelect).padRight(5);
        }
        tableColors.add(buttonRemove);
        tableColors.row();
    }
}
Also used : TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) Color(com.badlogic.gdx.graphics.Color) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) Texture(com.badlogic.gdx.graphics.Texture) ChangeEvent(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent) Dialog(com.badlogic.gdx.scenes.scene2d.ui.Dialog) Actor(com.badlogic.gdx.scenes.scene2d.Actor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) Pixmap(com.badlogic.gdx.graphics.Pixmap)

Example 34 with TextButton

use of com.badlogic.gdx.scenes.scene2d.ui.TextButton in project gdx-skineditor by cobolfoo.

the class FontPickerDialog method updateTable.

/**
	 * 
	 */
public void updateTable() {
    fonts = game.skinProject.getAll(BitmapFont.class);
    tableFonts.clear();
    tableFonts.add(new Label("Font Name", game.skin, "title")).left().width(170);
    tableFonts.add(new Label("Value", game.skin, "title")).colspan(3).left().width(60).padRight(50).expandX().fillX();
    tableFonts.row();
    Iterator<String> it = fonts.keys().iterator();
    while (it.hasNext()) {
        final String key = it.next();
        final BitmapFont font = fonts.get(key);
        tableFonts.add(key).left();
        Label.LabelStyle labelStyle = new Label.LabelStyle();
        labelStyle.font = font;
        labelStyle.fontColor = Color.WHITE;
        tableFonts.add(new Label("Sample Text", labelStyle)).left();
        TextButton buttonSelect = new TextButton("Select", game.skin);
        buttonSelect.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                try {
                    // Since we have reloaded everything we have to get
                    // field back
                    game.screenMain.paneOptions.refreshSelection();
                    field.set(game.screenMain.paneOptions.currentStyle, font);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                hide();
                game.screenMain.panePreview.refresh();
                game.screenMain.paneOptions.updateSelectedTableFields();
                game.screenMain.saveToSkin();
            }
        });
        TextButton buttonRemove = new TextButton("Remove", game.skin);
        buttonRemove.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                Dialog dlg = new Dialog("Delete Font", game.skin) {

                    @Override
                    protected void result(Object object) {
                        if ((Boolean) object == false) {
                            return;
                        }
                        if (isFontInUse(font) == true) {
                            game.showNotice("Error", "Bitmap font already in use!", getStage());
                        } else {
                            // Remove files from disk (fnt and png)
                            FileHandle targetFont = new FileHandle("projects/" + game.screenMain.getcurrentProject() + "/" + key + ".fnt");
                            FileHandle targetImage = new FileHandle("projects/" + game.screenMain.getcurrentProject() + "/assets/" + key + ".png");
                            targetFont.delete();
                            targetImage.delete();
                            fonts.remove(key);
                            // update table
                            updateTable();
                            game.screenMain.saveToSkin();
                        }
                    }
                };
                dlg.pad(20);
                dlg.getContentTable().add("You are sure you want to delete this bitmap font?");
                dlg.button("OK", true);
                dlg.button("Cancel", false);
                dlg.key(com.badlogic.gdx.Input.Keys.ENTER, true);
                dlg.key(com.badlogic.gdx.Input.Keys.ESCAPE, false);
                dlg.show(getStage());
            }
        });
        if (field != null) {
            tableFonts.add(buttonSelect).left();
        }
        tableFonts.add(buttonRemove).left().expandX();
        tableFonts.row();
    }
}
Also used : TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) FileHandle(com.badlogic.gdx.files.FileHandle) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) Dialog(com.badlogic.gdx.scenes.scene2d.ui.Dialog) Actor(com.badlogic.gdx.scenes.scene2d.Actor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont)

Example 35 with TextButton

use of com.badlogic.gdx.scenes.scene2d.ui.TextButton in project gdx-skineditor by cobolfoo.

the class WelcomeScreen method show.

@Override
public void show() {
    Table table = new Table(game.skin);
    table.setFillParent(true);
    table.setBackground(game.skin.getDrawable("dialogDim"));
    stage.addActor(table);
    Table tableContent = new Table(game.skin);
    tableContent.left();
    tableContent.add(new Label("Project List", game.skin, "title")).left().row();
    listProjects = new List<String>(game.skin);
    ScrollPane scrollPane = new ScrollPane(listProjects, game.skin);
    tableContent.add(scrollPane).width(320).height(200).row();
    Table tableButtons = new Table(game.skin);
    TextButton buttonNewProject = new TextButton("New Project", game.skin);
    final TextButton buttonOpen = new TextButton("Open", game.skin);
    final TextButton buttonDelete = new TextButton("Delete", game.skin);
    buttonOpen.setDisabled(true);
    buttonDelete.setDisabled(true);
    tableButtons.add(buttonNewProject).pad(5).expandX().fillX();
    tableButtons.add(buttonOpen).pad(5).width(92);
    tableButtons.add(buttonDelete).pad(5).width(92);
    tableContent.add(tableButtons).expandX().fillX();
    table.add(tableContent);
    Gdx.input.setInputProcessor(stage);
    listProjects.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if (listProjects.getSelected() != null) {
                buttonOpen.setDisabled(false);
                buttonDelete.setDisabled(false);
            } else {
                buttonOpen.setDisabled(true);
                buttonDelete.setDisabled(true);
            }
        }
    });
    buttonNewProject.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            showNewProjectDialog();
        }
    });
    buttonOpen.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            game.screenMain.setCurrentProject((String) listProjects.getSelected());
            game.setScreen(game.screenMain);
        }
    });
    buttonDelete.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            showDeleteDialog();
        }
    });
    refreshProjects();
//		NinePatchEditorDialog dlg = new NinePatchEditorDialog(game);
//		dlg.show(stage);
}
Also used : TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) 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)

Aggregations

TextButton (com.badlogic.gdx.scenes.scene2d.ui.TextButton)35 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)23 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)23 Stage (com.badlogic.gdx.scenes.scene2d.Stage)20 Actor (com.badlogic.gdx.scenes.scene2d.Actor)18 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)17 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)17 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)16 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)12 ScrollPane (com.badlogic.gdx.scenes.scene2d.ui.ScrollPane)9 Texture (com.badlogic.gdx.graphics.Texture)6 CheckBox (com.badlogic.gdx.scenes.scene2d.ui.CheckBox)6 Dialog (com.badlogic.gdx.scenes.scene2d.ui.Dialog)6 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)5 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)5 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)5 Slider (com.badlogic.gdx.scenes.scene2d.ui.Slider)5 TextButtonStyle (com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle)5 TextField (com.badlogic.gdx.scenes.scene2d.ui.TextField)5 Window (com.badlogic.gdx.scenes.scene2d.ui.Window)5