Search in sources :

Example 1 with TextArea

use of com.badlogic.gdx.scenes.scene2d.ui.TextArea in project libgdx by libgdx.

the class TextAreaScrollTest method create.

@Override
public void create() {
    stage = new Stage(new ScreenViewport());
    skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    Gdx.input.setInputProcessor(stage);
    Table container = new Table();
    stage.addActor(container);
    container.setFillParent(true);
    container.pad(10).defaults().expandX().fillX().space(4);
    textArea = new TextArea(">>> FIRST LINE <<<\n" + "Scrolling to the bottom of the area you should see the last line.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + "Scrolling to the top of the area you should see the first line.\n" + ">>> LAST LINE <<<", skin) {

        public float getPrefHeight() {
            return getLines() * getStyle().font.getLineHeight();
        }
    };
    scrollPane = new ScrollPane(textArea, skin);
    scrollPane.setFadeScrollBars(false);
    scrollPane.setFlickScroll(false);
    container.row().height(350);
    container.add(scrollPane);
    container.debugAll();
}
Also used : Table(com.badlogic.gdx.scenes.scene2d.ui.Table) TextArea(com.badlogic.gdx.scenes.scene2d.ui.TextArea) ScrollPane(com.badlogic.gdx.scenes.scene2d.ui.ScrollPane) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) ScreenViewport(com.badlogic.gdx.utils.viewport.ScreenViewport)

Example 2 with TextArea

use of com.badlogic.gdx.scenes.scene2d.ui.TextArea in project libgdx by libgdx.

the class TextAreaTest method create.

@Override
public void create() {
    stage = new Stage();
    Gdx.input.setInputProcessor(stage);
    skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    TextArea textArea = new TextArea("Text Area\nEssentially, a text field\nwith\nmultiple\nlines.\n" + "It can even handle very loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong lines.", skin);
    textArea.setX(10);
    textArea.setY(10);
    textArea.setWidth(200);
    textArea.setHeight(200);
    TextField textField = new TextField("Text field", skin);
    textField.setX(10);
    textField.setY(220);
    textField.setWidth(200);
    textField.setHeight(30);
    stage.addActor(textArea);
    stage.addActor(textField);
}
Also used : TextArea(com.badlogic.gdx.scenes.scene2d.ui.TextArea) Stage(com.badlogic.gdx.scenes.scene2d.Stage) TextField(com.badlogic.gdx.scenes.scene2d.ui.TextField) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin)

Example 3 with TextArea

use of com.badlogic.gdx.scenes.scene2d.ui.TextArea in project libgdx by libgdx.

the class TextAreaTest2 method create.

@Override
public void create() {
    stage = new Stage();
    Gdx.input.setInputProcessor(stage);
    skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    //Create a string that perfectly fills the float array used in the textarea float array
    FloatArray dummyArray = new FloatArray();
    String limit = "";
    // Minus one, because TextField adds a magic char
    for (int i = 0; i < dummyArray.items.length - 1; i++) {
        limit += "a";
    }
    TextArea textArea = new TextArea(limit, skin);
    textArea.setX(10);
    textArea.setY(10);
    textArea.setWidth(200);
    textArea.setHeight(200);
    stage.addActor(textArea);
}
Also used : FloatArray(com.badlogic.gdx.utils.FloatArray) TextArea(com.badlogic.gdx.scenes.scene2d.ui.TextArea) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin)

Example 4 with TextArea

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

the class RootTable method refreshPreviewProperties.

public void refreshPreviewProperties() {
    if (previewPropertiesTable != null) {
        previewPropertiesTable.clear();
        previewProperties.clear();
        Table t = new Table();
        previewPropertiesTable.add(t).grow();
        t.defaults().pad(3.0f);
        if (previewBgColor == null) {
            previewBgColor.set(Color.WHITE);
        }
        previewProperties.put("bgcolor", previewBgColor);
        if (classSelectBox.getSelectedIndex() >= 0 && classSelectBox.getSelectedIndex() < Main.BASIC_CLASSES.length) {
            t.add(new Label("Stage Color: ", getSkin())).right();
            BrowseField browseField = new BrowseField(null, null, getSkin(), "color");
            browseField.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                    main.getDialogFactory().showDialogColorPicker((Color) previewProperties.get("bgcolor"), new DialogColorPicker.ColorListener() {

                        @Override
                        public void selected(Color color) {
                            if (color != null) {
                                browseField.getTextButton().setText((int) (color.r * 255) + "," + (int) (color.g * 255) + "," + (int) (color.b * 255) + "," + (int) (color.a * 255));
                                previewProperties.put("bgcolor", color);
                                previewBgColor.set(color);
                                refreshPreview();
                            }
                        }
                    });
                }
            });
            browseField.addListener(main.getHandListener());
            t.add(browseField).growX();
            browseField.getTextButton().setText((int) (previewBgColor.r * 255) + "," + (int) (previewBgColor.g * 255) + "," + (int) (previewBgColor.b * 255) + "," + (int) (previewBgColor.a * 255));
            t.row();
            t.add(new Label("Size: ", getSkin())).right();
            previewSizeSelectBox = new SelectBox<>(getSkin());
            previewSizeSelectBox.setItems(DEFAULT_SIZES);
            previewSizeSelectBox.setSelectedIndex(1);
            previewSizeSelectBox.addListener(main.getHandListener());
            previewSizeSelectBox.getList().addListener(main.getHandListener());
            t.add(previewSizeSelectBox).growX().minWidth(200.0f);
            Class clazz = Main.BASIC_CLASSES[classSelectBox.getSelectedIndex()];
            if (clazz.equals(Button.class)) {
                t.row();
                t.add(new Label("Disabled: ", getSkin())).right();
                ImageTextButton disabledCheckBox = new ImageTextButton("", getSkin(), "switch");
                disabledCheckBox.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("disabled", disabledCheckBox.isChecked());
                        refreshPreview();
                    }
                });
                disabledCheckBox.addListener(main.getHandListener());
                previewProperties.put("disabled", disabledCheckBox.isChecked());
                t.add(disabledCheckBox).left();
            } else if (clazz.equals(CheckBox.class)) {
                t.row();
                t.add(new Label("Disabled: ", getSkin())).right();
                ImageTextButton disabledCheckBox = new ImageTextButton("", getSkin(), "switch");
                disabledCheckBox.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("disabled", disabledCheckBox.isChecked());
                        refreshPreview();
                    }
                });
                disabledCheckBox.addListener(main.getHandListener());
                previewProperties.put("disabled", disabledCheckBox.isChecked());
                t.add(disabledCheckBox).left();
                t.row();
                t.add(new Label("Text: ", getSkin())).right();
                TextField previewTextField = new TextField(TEXT_SAMPLE, getSkin());
                previewTextField.setFocusTraversal(false);
                previewTextField.addListener(main.getIbeamListener());
                previewTextField.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("text", previewTextField.getText());
                        refreshPreview();
                    }
                });
                previewProperties.put("text", previewTextField.getText());
                t.add(previewTextField).growX();
            } else if (clazz.equals(ImageButton.class)) {
                t.row();
                t.add(new Label("Disabled: ", getSkin())).right();
                ImageTextButton disabledCheckBox = new ImageTextButton("", getSkin(), "switch");
                disabledCheckBox.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("disabled", disabledCheckBox.isChecked());
                        refreshPreview();
                    }
                });
                disabledCheckBox.addListener(main.getHandListener());
                previewProperties.put("disabled", disabledCheckBox.isChecked());
                t.add(disabledCheckBox).left();
            } else if (clazz.equals(ImageTextButton.class)) {
                t.row();
                t.add(new Label("Disabled: ", getSkin())).right();
                ImageTextButton disabledCheckBox = new ImageTextButton("", getSkin(), "switch");
                disabledCheckBox.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("disabled", disabledCheckBox.isChecked());
                        refreshPreview();
                    }
                });
                disabledCheckBox.addListener(main.getHandListener());
                previewProperties.put("disabled", disabledCheckBox.isChecked());
                t.add(disabledCheckBox).left();
                t.row();
                t.add(new Label("Text: ", getSkin())).right();
                TextField previewTextField = new TextField(TEXT_SAMPLE, getSkin());
                previewTextField.setFocusTraversal(false);
                previewTextField.addListener(main.getIbeamListener());
                previewTextField.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("text", previewTextField.getText());
                        refreshPreview();
                    }
                });
                previewProperties.put("text", previewTextField.getText());
                t.add(previewTextField).growX();
            } else if (clazz.equals(Label.class)) {
                t.row();
                t.add(new Label("Text: ", getSkin())).right();
                TextField previewTextField = new TextField(TEXT_SAMPLE, getSkin());
                previewTextField.setFocusTraversal(false);
                previewTextField.addListener(main.getIbeamListener());
                previewTextField.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("text", previewTextField.getText());
                        refreshPreview();
                    }
                });
                previewProperties.put("text", previewTextField.getText());
                t.add(previewTextField).growX();
            } else if (clazz.equals(List.class)) {
                t.row();
                t.add(new Label("List Items: ", getSkin())).right();
                TextArea listItemsTextArea = new TextArea("Lorem ipsum\ndolor sit\namet, consectetur", getSkin());
                listItemsTextArea.setFocusTraversal(false);
                listItemsTextArea.setPrefRows(3);
                listItemsTextArea.addListener(main.getIbeamListener());
                listItemsTextArea.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("text", listItemsTextArea.getText());
                        refreshPreview();
                    }
                });
                previewProperties.put("text", listItemsTextArea.getText());
                t.add(listItemsTextArea).growX();
            } else if (clazz.equals(ProgressBar.class)) {
                t.row();
                t.add(new Label("Disabled: ", getSkin())).right();
                ImageTextButton disabledCheckBox = new ImageTextButton("", getSkin(), "switch");
                disabledCheckBox.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("disabled", disabledCheckBox.isChecked());
                        refreshPreview();
                    }
                });
                disabledCheckBox.addListener(main.getHandListener());
                previewProperties.put("disabled", disabledCheckBox.isChecked());
                t.add(disabledCheckBox).left();
                t.row();
                t.add(new Label("Value: ", getSkin())).right();
                Spinner valueSpinner = new Spinner(0.0f, 1.0f, false, Spinner.Orientation.HORIZONTAL, getSkin());
                valueSpinner.getTextField().setFocusTraversal(false);
                valueSpinner.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("value", valueSpinner.getValue());
                        refreshPreview();
                    }
                });
                valueSpinner.getButtonMinus().addListener(main.getHandListener());
                valueSpinner.getButtonPlus().addListener(main.getHandListener());
                valueSpinner.getTextField().addListener(main.getIbeamListener());
                previewProperties.put("value", valueSpinner.getValue());
                t.add(valueSpinner).growX();
                t.row();
                t.add(new Label("Minimum: ", getSkin())).right();
                Spinner minimumSpinner = new Spinner(0.0f, 1.0f, false, Spinner.Orientation.HORIZONTAL, getSkin());
                minimumSpinner.getTextField().setFocusTraversal(false);
                minimumSpinner.getTextField().addListener(main.getIbeamListener());
                minimumSpinner.getButtonMinus().addListener(main.getHandListener());
                minimumSpinner.getButtonPlus().addListener(main.getHandListener());
                previewProperties.put("minimum", minimumSpinner.getValue());
                t.add(minimumSpinner).growX();
                t.row();
                t.add(new Label("Maximum: ", getSkin())).right();
                Spinner maximumSpinner = new Spinner(100.0f, 1.0f, false, Spinner.Orientation.HORIZONTAL, getSkin());
                maximumSpinner.getTextField().setFocusTraversal(false);
                maximumSpinner.getTextField().addListener(main.getIbeamListener());
                maximumSpinner.getButtonMinus().addListener(main.getHandListener());
                maximumSpinner.getButtonPlus().addListener(main.getHandListener());
                previewProperties.put("maximum", maximumSpinner.getValue());
                t.add(maximumSpinner).growX();
                minimumSpinner.setMaximum(maximumSpinner.getValue());
                maximumSpinner.setMinimum(minimumSpinner.getValue());
                minimumSpinner.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("minimum", minimumSpinner.getValue());
                        maximumSpinner.setMinimum(minimumSpinner.getValue());
                        refreshPreview();
                    }
                });
                maximumSpinner.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("maximum", maximumSpinner.getValue());
                        minimumSpinner.setMaximum(maximumSpinner.getValue());
                        refreshPreview();
                    }
                });
                t.row();
                t.add(new Label("Increment: ", getSkin())).right();
                Spinner incrementSpinner = new Spinner(1.0f, 1.0f, false, Spinner.Orientation.HORIZONTAL, getSkin());
                incrementSpinner.getTextField().setFocusTraversal(false);
                incrementSpinner.setMinimum(1);
                incrementSpinner.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("increment", incrementSpinner.getValue());
                        refreshPreview();
                    }
                });
                incrementSpinner.getTextField().addListener(main.getIbeamListener());
                incrementSpinner.getButtonMinus().addListener(main.getHandListener());
                incrementSpinner.getButtonPlus().addListener(main.getHandListener());
                previewProperties.put("increment", incrementSpinner.getValue());
                t.add(incrementSpinner).growX();
                t.row();
                t.add(new Label("Orientation: ", getSkin())).right();
                SelectBox<String> selectBox = new SelectBox<>(getSkin());
                selectBox.setItems(new String[] { "Horizontal", "Vertical" });
                if (getSelectedStyle().name.contains("vert")) {
                    previewProperties.put("orientation", true);
                    selectBox.setSelectedIndex(1);
                } else {
                    previewProperties.put("orientation", false);
                }
                selectBox.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        if (selectBox.getSelectedIndex() == 0) {
                            previewProperties.put("orientation", false);
                        } else {
                            previewProperties.put("orientation", true);
                        }
                        refreshPreview();
                    }
                });
                selectBox.addListener(main.getHandListener());
                selectBox.getList().addListener(main.getHandListener());
                t.add(selectBox).growX();
            } else if (clazz.equals(ScrollPane.class)) {
                t.row();
                t.add(new Label("Scrollbars On Top: ", getSkin())).right();
                ImageTextButton onTopCheckBox = new ImageTextButton("", getSkin(), "switch");
                onTopCheckBox.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("scrollbarsOnTop", onTopCheckBox.isChecked());
                        refreshPreview();
                    }
                });
                t.add(onTopCheckBox).left();
                onTopCheckBox.addListener(main.getHandListener());
                previewProperties.put("scrollbarsOnTop", onTopCheckBox.isChecked());
                t.row();
                t.add(new Label("H ScrollBar Position: ", getSkin())).right();
                SelectBox<String> hScrollPosBox = new SelectBox<>(getSkin());
                hScrollPosBox.setItems(new String[] { "Top", "Bottom" });
                hScrollPosBox.setSelectedIndex(1);
                hScrollPosBox.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        if (hScrollPosBox.getSelectedIndex() == 0) {
                            previewProperties.put("hScrollBarPosition", false);
                        } else {
                            previewProperties.put("hScrollBarPosition", true);
                        }
                        refreshPreview();
                    }
                });
                t.add(hScrollPosBox).growX();
                hScrollPosBox.addListener(main.getHandListener());
                hScrollPosBox.getList().addListener(main.getHandListener());
                previewProperties.put("hScrollBarPosition", true);
                t.row();
                t.add(new Label("V ScrollBar Position: ", getSkin())).right();
                SelectBox<String> vScrollPosBox = new SelectBox<>(getSkin());
                vScrollPosBox.setItems(new String[] { "Left", "Right" });
                vScrollPosBox.setSelectedIndex(1);
                vScrollPosBox.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        if (vScrollPosBox.getSelectedIndex() == 0) {
                            previewProperties.put("vScrollBarPosition", false);
                        } else {
                            previewProperties.put("vScrollBarPosition", true);
                        }
                        refreshPreview();
                    }
                });
                t.add(vScrollPosBox).growX();
                vScrollPosBox.addListener(main.getHandListener());
                vScrollPosBox.getList().addListener(main.getHandListener());
                previewProperties.put("vScrollBarPosition", true);
                t.row();
                t.add(new Label("H Scrolling Disabled: ", getSkin())).right();
                ImageTextButton hScrollCheckBox = new ImageTextButton("", getSkin(), "switch");
                hScrollCheckBox.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("hScrollDisabled", hScrollCheckBox.isChecked());
                        refreshPreview();
                    }
                });
                t.add(hScrollCheckBox).left();
                hScrollCheckBox.addListener(main.getHandListener());
                previewProperties.put("hScrollDisabled", hScrollCheckBox.isChecked());
                t.row();
                t.add(new Label("V Scrolling Disabled: ", getSkin())).right();
                ImageTextButton vScrollCheckBox = new ImageTextButton("", getSkin(), "switch");
                vScrollCheckBox.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("vScrollDisabled", vScrollCheckBox.isChecked());
                        refreshPreview();
                    }
                });
                t.add(vScrollCheckBox).left();
                vScrollCheckBox.addListener(main.getHandListener());
                previewProperties.put("vScrollDisabled", vScrollCheckBox.isChecked());
                t.row();
                t.add(new Label("Force H Scroll: ", getSkin())).right();
                ImageTextButton forceHScrollCheckBox = new ImageTextButton("", getSkin(), "switch");
                forceHScrollCheckBox.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("forceHscroll", forceHScrollCheckBox.isChecked());
                        refreshPreview();
                    }
                });
                t.add(forceHScrollCheckBox).left();
                forceHScrollCheckBox.addListener(main.getHandListener());
                previewProperties.put("forceHscroll", forceHScrollCheckBox.isChecked());
                t.row();
                t.add(new Label("Force V Scroll: ", getSkin())).right();
                ImageTextButton forceVScrollCheckBox = new ImageTextButton("", getSkin(), "switch");
                forceVScrollCheckBox.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("forceVscroll", forceVScrollCheckBox.isChecked());
                        refreshPreview();
                    }
                });
                t.add(forceVScrollCheckBox).left();
                forceVScrollCheckBox.addListener(main.getHandListener());
                previewProperties.put("forceVscroll", forceVScrollCheckBox.isChecked());
                t.row();
                t.add(new Label("Variable Size Knobs: ", getSkin())).right();
                ImageTextButton variableSizeKnobsCheckBox = new ImageTextButton("", getSkin(), "switch");
                variableSizeKnobsCheckBox.setChecked(true);
                variableSizeKnobsCheckBox.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("variableSizeKnobs", variableSizeKnobsCheckBox.isChecked());
                        refreshPreview();
                    }
                });
                t.add(variableSizeKnobsCheckBox).left();
                variableSizeKnobsCheckBox.addListener(main.getHandListener());
                previewProperties.put("variableSizeKnobs", variableSizeKnobsCheckBox.isChecked());
                t.row();
                t.add(new Label("H Overscroll: ", getSkin())).right();
                ImageTextButton hOverscrollCheckBox = new ImageTextButton("", getSkin(), "switch");
                hOverscrollCheckBox.setChecked(true);
                hOverscrollCheckBox.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("hOverscroll", hOverscrollCheckBox.isChecked());
                        refreshPreview();
                    }
                });
                t.add(hOverscrollCheckBox).left();
                hOverscrollCheckBox.addListener(main.getHandListener());
                previewProperties.put("hOverscroll", hOverscrollCheckBox.isChecked());
                t.row();
                t.add(new Label("V Overscroll: ", getSkin())).right();
                ImageTextButton vOverscrollCheckBox = new ImageTextButton("", getSkin(), "switch");
                vOverscrollCheckBox.setChecked(true);
                vOverscrollCheckBox.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("vOverscroll", vOverscrollCheckBox.isChecked());
                        refreshPreview();
                    }
                });
                t.add(vOverscrollCheckBox).left();
                vOverscrollCheckBox.addListener(main.getHandListener());
                previewProperties.put("vOverscroll", vOverscrollCheckBox.isChecked());
                t.row();
                t.add(new Label("Fade Scroll Bars: ", getSkin())).right();
                ImageTextButton fadeScrollCheckBox = new ImageTextButton("", getSkin(), "switch");
                fadeScrollCheckBox.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("fadeScroll", fadeScrollCheckBox.isChecked());
                        refreshPreview();
                    }
                });
                t.add(fadeScrollCheckBox).left();
                fadeScrollCheckBox.addListener(main.getHandListener());
                previewProperties.put("fadeScroll", fadeScrollCheckBox.isChecked());
                t.row();
                t.add(new Label("Smooth Scrolling: ", getSkin())).right();
                ImageTextButton smoothScrollCheckBox = new ImageTextButton("", getSkin(), "switch");
                smoothScrollCheckBox.setChecked(true);
                smoothScrollCheckBox.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("smoothScroll", smoothScrollCheckBox.isChecked());
                        refreshPreview();
                    }
                });
                t.add(smoothScrollCheckBox).left();
                smoothScrollCheckBox.addListener(main.getHandListener());
                previewProperties.put("smoothScroll", smoothScrollCheckBox.isChecked());
                t.row();
                t.add(new Label("Flick Scroll: ", getSkin())).right();
                ImageTextButton flickScrollCheckBox = new ImageTextButton("", getSkin(), "switch");
                flickScrollCheckBox.setChecked(true);
                flickScrollCheckBox.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("flickScroll", flickScrollCheckBox.isChecked());
                        refreshPreview();
                    }
                });
                t.add(flickScrollCheckBox).left();
                flickScrollCheckBox.addListener(main.getHandListener());
                previewProperties.put("flickScroll", flickScrollCheckBox.isChecked());
                t.row();
                t.add(new Label("Clamp: ", getSkin())).right();
                ImageTextButton clampCheckBox = new ImageTextButton("", getSkin(), "switch");
                clampCheckBox.setChecked(true);
                clampCheckBox.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("clamp", clampCheckBox.isChecked());
                        refreshPreview();
                    }
                });
                t.add(clampCheckBox).left();
                clampCheckBox.addListener(main.getHandListener());
                previewProperties.put("clamp", clampCheckBox.isChecked());
                t.row();
                t.add(new Label("Sample Text: ", getSkin())).right();
                TextArea previewTextArea = new TextArea(PARAGRAPH_SAMPLE_EXT, getSkin());
                previewTextArea.setFocusTraversal(false);
                previewTextArea.setPrefRows(5);
                previewTextArea.addListener(main.getIbeamListener());
                previewTextArea.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("text", previewTextArea.getText());
                        refreshPreview();
                    }
                });
                previewProperties.put("text", previewTextArea.getText());
                t.add(previewTextArea).growX();
                previewSizeSelectBox.setSelectedIndex(2);
            } else if (clazz.equals(SelectBox.class)) {
                t.row();
                t.add(new Label("Disabled: ", getSkin())).right();
                ImageTextButton disabledCheckBox = new ImageTextButton("", getSkin(), "switch");
                disabledCheckBox.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("disabled", disabledCheckBox.isChecked());
                        refreshPreview();
                    }
                });
                previewProperties.put("disabled", disabledCheckBox.isChecked());
                disabledCheckBox.addListener(main.getHandListener());
                t.add(disabledCheckBox).left();
                t.row();
                t.add(new Label("Max List Count: ", getSkin())).right();
                Spinner spinner = new Spinner(3, 1, true, Spinner.Orientation.HORIZONTAL, getSkin());
                spinner.getTextField().setFocusTraversal(false);
                spinner.setMinimum(1);
                spinner.getTextField().addListener(main.getIbeamListener());
                spinner.getButtonMinus().addListener(main.getHandListener());
                spinner.getButtonPlus().addListener(main.getHandListener());
                t.add(spinner).growX();
                t.row();
                t.add(new Label("List Items: ", getSkin())).right();
                TextArea listItemsTextArea = new TextArea("Lorem ipsum\ndolor sit\namet, consectetur", getSkin());
                listItemsTextArea.setFocusTraversal(false);
                listItemsTextArea.setPrefRows(3);
                listItemsTextArea.addListener(main.getIbeamListener());
                listItemsTextArea.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("text", listItemsTextArea.getText());
                        refreshPreview();
                    }
                });
                previewProperties.put("text", listItemsTextArea.getText());
                t.add(listItemsTextArea).growX();
            } else if (clazz.equals(Slider.class)) {
                t.row();
                t.add(new Label("Disabled: ", getSkin())).right();
                ImageTextButton disabledCheckBox = new ImageTextButton("", getSkin(), "switch");
                disabledCheckBox.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("disabled", disabledCheckBox.isChecked());
                        refreshPreview();
                    }
                });
                previewProperties.put("disabled", disabledCheckBox.isChecked());
                disabledCheckBox.addListener(main.getHandListener());
                t.add(disabledCheckBox).left();
                t.row();
                t.add(new Label("Minimum: ", getSkin())).right();
                Spinner minimumSpinner = new Spinner(0.0f, 1.0f, false, Spinner.Orientation.HORIZONTAL, getSkin());
                minimumSpinner.getTextField().setFocusTraversal(false);
                minimumSpinner.getTextField().addListener(main.getIbeamListener());
                t.add(minimumSpinner).growX();
                minimumSpinner.getButtonMinus().addListener(main.getHandListener());
                minimumSpinner.getButtonPlus().addListener(main.getHandListener());
                previewProperties.put("minimum", minimumSpinner.getValue());
                t.row();
                t.add(new Label("Maximum: ", getSkin())).right();
                Spinner maximumSpinner = new Spinner(100.0f, 1.0f, false, Spinner.Orientation.HORIZONTAL, getSkin());
                maximumSpinner.getTextField().setFocusTraversal(false);
                maximumSpinner.getTextField().addListener(main.getIbeamListener());
                t.add(maximumSpinner).growX();
                maximumSpinner.getButtonMinus().addListener(main.getHandListener());
                maximumSpinner.getButtonPlus().addListener(main.getHandListener());
                previewProperties.put("maximum", maximumSpinner.getValue());
                minimumSpinner.setMaximum(maximumSpinner.getValue());
                maximumSpinner.setMinimum(minimumSpinner.getValue());
                minimumSpinner.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("minimum", minimumSpinner.getValue());
                        maximumSpinner.setMinimum(minimumSpinner.getValue());
                        refreshPreview();
                    }
                });
                maximumSpinner.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("maximum", maximumSpinner.getValue());
                        minimumSpinner.setMaximum(maximumSpinner.getValue());
                        refreshPreview();
                    }
                });
                t.row();
                t.add(new Label("Increment: ", getSkin())).right();
                Spinner incrementSpinner = new Spinner(1.0f, 1.0f, false, Spinner.Orientation.HORIZONTAL, getSkin());
                incrementSpinner.getTextField().setFocusTraversal(false);
                incrementSpinner.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("increment", incrementSpinner.getValue());
                        refreshPreview();
                    }
                });
                incrementSpinner.getTextField().addListener(main.getIbeamListener());
                t.add(incrementSpinner).growX();
                incrementSpinner.getButtonMinus().addListener(main.getHandListener());
                incrementSpinner.getButtonPlus().addListener(main.getHandListener());
                incrementSpinner.setMinimum(1.0f);
                previewProperties.put("increment", incrementSpinner.getValue());
                t.row();
                t.add(new Label("Orientation: ", getSkin())).right();
                SelectBox<String> selectBox = new SelectBox<>(getSkin());
                selectBox.setItems(new String[] { "Horizontal", "Vertical" });
                if (getSelectedStyle().name.contains("vert")) {
                    previewProperties.put("orientation", true);
                    selectBox.setSelectedIndex(1);
                } else {
                    previewProperties.put("orientation", false);
                }
                selectBox.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        if (selectBox.getSelectedIndex() == 0) {
                            previewProperties.put("orientation", false);
                        } else {
                            previewProperties.put("orientation", true);
                        }
                        refreshPreview();
                    }
                });
                selectBox.addListener(main.getHandListener());
                selectBox.getList().addListener(main.getHandListener());
                t.add(selectBox).growX();
            } else if (clazz.equals(SplitPane.class)) {
                t.row();
                t.add(new Label("Orientation: ", getSkin())).right();
                SelectBox<String> selectBox = new SelectBox<>(getSkin());
                selectBox.setItems(new String[] { "Horizontal", "Vertical" });
                if (getSelectedStyle().name.contains("vert")) {
                    previewProperties.put("orientation", true);
                    selectBox.setSelectedIndex(1);
                } else {
                    previewProperties.put("orientation", false);
                }
                selectBox.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        if (selectBox.getSelectedIndex() == 0) {
                            previewProperties.put("orientation", false);
                        } else {
                            previewProperties.put("orientation", true);
                        }
                        refreshPreview();
                    }
                });
                selectBox.addListener(main.getHandListener());
                selectBox.getList().addListener(main.getHandListener());
                t.add(selectBox).growX();
                t.row();
                t.add(new Label("Sample Text: ", getSkin())).right();
                TextArea textArea = new TextArea(PARAGRAPH_SAMPLE, getSkin());
                textArea.setFocusTraversal(false);
                textArea.setPrefRows(5);
                textArea.addListener(main.getIbeamListener());
                textArea.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("text", textArea.getText());
                        refreshPreview();
                    }
                });
                previewProperties.put("text", textArea.getText());
                t.add(textArea).growX();
                previewSizeSelectBox.setSelectedIndex(2);
            } else if (clazz.equals(TextButton.class)) {
                t.row();
                t.add(new Label("Disabled: ", getSkin())).right();
                ImageTextButton disabledCheckBox = new ImageTextButton("", getSkin(), "switch");
                disabledCheckBox.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("disabled", disabledCheckBox.isChecked());
                        refreshPreview();
                    }
                });
                previewProperties.put("disabled", disabledCheckBox.isChecked());
                disabledCheckBox.addListener(main.getHandListener());
                t.add(disabledCheckBox).left();
                t.row();
                t.add(new Label("Text: ", getSkin())).right();
                TextField previewTextField = new TextField(TEXT_SAMPLE, getSkin());
                previewTextField.setFocusTraversal(false);
                previewTextField.addListener(main.getIbeamListener());
                previewTextField.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("text", previewTextField.getText());
                        refreshPreview();
                    }
                });
                previewProperties.put("text", previewTextField.getText());
                t.add(previewTextField).growX();
            } else if (clazz.equals(TextField.class)) {
                t.row();
                t.add(new Label("Disabled: ", getSkin())).right();
                ImageTextButton disabledCheckBox = new ImageTextButton("", getSkin(), "switch");
                disabledCheckBox.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("disabled", disabledCheckBox.isChecked());
                        refreshPreview();
                    }
                });
                previewProperties.put("disabled", disabledCheckBox.isChecked());
                disabledCheckBox.addListener(main.getHandListener());
                t.add(disabledCheckBox).left();
                t.row();
                t.add(new Label("Password Mode: ", getSkin())).right();
                ImageTextButton checkBox = new ImageTextButton("", getSkin(), "switch");
                checkBox.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("passwordMode", checkBox.isChecked());
                        refreshPreview();
                    }
                });
                t.add(checkBox).left();
                checkBox.addListener(main.getHandListener());
                previewProperties.put("passwordMode", checkBox.isChecked());
                t.row();
                t.add(new Label("Password Character: ", getSkin()));
                TextField pcTextField = new TextField("*", getSkin());
                pcTextField.setFocusTraversal(false);
                pcTextField.addListener(main.getIbeamListener());
                pcTextField.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("password", pcTextField.getText());
                        refreshPreview();
                    }
                });
                previewProperties.put("password", pcTextField.getText());
                t.add(pcTextField).growX();
                t.row();
                t.add(new Label("Text Alignment: ", getSkin())).right();
                SelectBox<String> selectBox = new SelectBox<>(getSkin());
                selectBox.setItems(new String[] { "Left", "Center", "Right" });
                selectBox.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        switch(selectBox.getSelectedIndex()) {
                            case 0:
                                previewProperties.put("alignment", Align.left);
                                break;
                            case 1:
                                previewProperties.put("alignment", Align.center);
                                break;
                            case 2:
                                previewProperties.put("alignment", Align.right);
                                break;
                        }
                        refreshPreview();
                    }
                });
                t.add(selectBox).growX();
                selectBox.addListener(main.getHandListener());
                selectBox.getList().addListener(main.getHandListener());
                previewProperties.put("alignment", Align.left);
                t.row();
                t.add(new Label("Text: ", getSkin())).right();
                TextField previewTextField = new TextField(TEXT_SAMPLE, getSkin());
                previewTextField.setFocusTraversal(false);
                previewTextField.addListener(main.getIbeamListener());
                previewTextField.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("text", previewTextField.getText());
                        refreshPreview();
                    }
                });
                previewProperties.put("text", previewTextField.getText());
                t.add(previewTextField).growX();
                t.row();
                t.add(new Label("Message Text: ", getSkin())).right();
                TextField messageTextField = new TextField(TEXT_SAMPLE, getSkin());
                messageTextField.setFocusTraversal(false);
                messageTextField.addListener(main.getIbeamListener());
                messageTextField.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("message", messageTextField.getText());
                        refreshPreview();
                    }
                });
                previewProperties.put("message", messageTextField.getText());
                t.add(messageTextField).growX();
            } else if (clazz.equals(TextTooltip.class)) {
                t.row();
                t.add(new Label("Text: ", getSkin())).right();
                TextField previewTextField = new TextField(TEXT_SAMPLE, getSkin());
                previewTextField.setFocusTraversal(false);
                previewTextField.addListener(main.getIbeamListener());
                previewTextField.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("text", previewTextField.getText());
                        refreshPreview();
                    }
                });
                previewProperties.put("text", previewTextField.getText());
                t.add(previewTextField).growX();
            } else if (clazz.equals(Touchpad.class)) {
            } else if (clazz.equals(Tree.class)) {
                t.row();
                t.add(new Label("Icon Spacing: ", getSkin())).right();
                Spinner spinner = new Spinner(0.0, 1.0, false, Spinner.Orientation.HORIZONTAL, getSkin());
                spinner.getTextField().setFocusTraversal(false);
                spinner.setMinimum(1);
                spinner.getTextField().addListener(main.getIbeamListener());
                spinner.getButtonMinus().addListener(main.getHandListener());
                spinner.getButtonPlus().addListener(main.getHandListener());
                t.add(spinner).growX();
                t.row();
                t.add(new Label("Y Spacing: ", getSkin())).right();
                spinner = new Spinner(0.0, 1.0, false, Spinner.Orientation.HORIZONTAL, getSkin());
                spinner.getTextField().setFocusTraversal(false);
                spinner.setMinimum(1);
                spinner.getTextField().addListener(main.getIbeamListener());
                spinner.getButtonMinus().addListener(main.getHandListener());
                spinner.getButtonPlus().addListener(main.getHandListener());
                t.add(spinner).growX();
            } else if (clazz.equals(Window.class)) {
                t.row();
                t.add(new Label("Title Text: ", getSkin())).right();
                TextField previewTextField = new TextField(TEXT_SAMPLE, getSkin());
                previewTextField.setFocusTraversal(false);
                previewTextField.addListener(main.getIbeamListener());
                previewTextField.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("title", previewTextField.getText());
                        refreshPreview();
                    }
                });
                previewProperties.put("title", previewTextField.getText());
                t.add(previewTextField).growX();
                t.row();
                t.add(new Label("Sample Text Color: ", getSkin()));
                BrowseField textColorField = new BrowseField(null, null, getSkin(), "color");
                textColorField.addListener(main.getHandListener());
                t.add(textColorField).growX();
                t.row();
                t.add(new Label("Sample Text: ", getSkin())).right();
                TextArea textArea = new TextArea(PARAGRAPH_SAMPLE, getSkin());
                textArea.setFocusTraversal(false);
                textArea.setPrefRows(5);
                textArea.addListener(main.getIbeamListener());
                textArea.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                        previewProperties.put("text", textArea.getText());
                        refreshPreview();
                    }
                });
                previewProperties.put("text", textArea.getText());
                t.add(textArea).growX();
            }
            previewSizeSelectBox.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                    previewProperties.put("size", previewSizeSelectBox.getSelectedIndex());
                    if (previewSizeSelectBox.getSelectedIndex() != 7) {
                        refreshPreview();
                    }
                }
            });
            previewProperties.put("size", previewSizeSelectBox.getSelectedIndex());
            refreshPreview();
        } else {
            t.add(new Label("Stage Color: ", getSkin())).right();
            BrowseField browseField = new BrowseField(null, null, getSkin(), "color");
            browseField.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                    main.getDialogFactory().showDialogColorPicker((Color) previewProperties.get("bgcolor"), new DialogColorPicker.ColorListener() {

                        @Override
                        public void selected(Color color) {
                            if (color != null) {
                                browseField.getTextButton().setText((int) (color.r * 255) + "," + (int) (color.g * 255) + "," + (int) (color.b * 255) + "," + (int) (color.a * 255));
                                previewProperties.put("bgcolor", color);
                                previewBgColor.set(color);
                                refreshPreview();
                            }
                        }
                    });
                }
            });
            browseField.addListener(main.getHandListener());
            t.add(browseField).growX();
            browseField.getTextButton().setText((int) (previewBgColor.r * 255) + "," + (int) (previewBgColor.g * 255) + "," + (int) (previewBgColor.b * 255) + "," + (int) (previewBgColor.a * 255));
        }
    }
}
Also used : ImageTextButton(com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton) Slider(com.badlogic.gdx.scenes.scene2d.ui.Slider) TextArea(com.badlogic.gdx.scenes.scene2d.ui.TextArea) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) TextTooltip(com.badlogic.gdx.scenes.scene2d.ui.TextTooltip) Actor(com.badlogic.gdx.scenes.scene2d.Actor) TextField(com.badlogic.gdx.scenes.scene2d.ui.TextField) Tree(com.badlogic.gdx.scenes.scene2d.ui.Tree) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) List(com.badlogic.gdx.scenes.scene2d.ui.List) ImageTextButton(com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton) TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) SelectBox(com.badlogic.gdx.scenes.scene2d.ui.SelectBox) Color(com.badlogic.gdx.graphics.Color) CheckBox(com.badlogic.gdx.scenes.scene2d.ui.CheckBox) ScrollPane(com.badlogic.gdx.scenes.scene2d.ui.ScrollPane)

Example 5 with TextArea

use of com.badlogic.gdx.scenes.scene2d.ui.TextArea in project ProjektGG by eskalon.

the class LobbyScreen method initUI.

@Override
protected void initUI() {
    // backgroundTexture = assetManager.get(BACKGROUND_IMAGE_PATH);
    Sound clickSound = assetManager.get(BUTTON_SOUND);
    // mainTable.setBackground(skin.getDrawable("parchment-small"));
    ImageTextButton leaveButton = new ImageTextButton("Verlassen", skin);
    leaveButton.addListener(new InputListener() {

        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            clickSound.play(1F);
            game.getNetworkHandler().disconnect();
            game.pushScreen("mainMenu");
            return true;
        }
    });
    NetworkHandler netHandler = game.getNetworkHandler();
    readyUpLobbyButton = new ImageTextButton("Bereit", skin);
    if (netHandler.isHost()) {
        readyUpLobbyButton.setDisabled(true);
        readyUpLobbyButton.setText("Spiel starten");
    }
    readyUpLobbyButton.addListener(new InputListener() {

        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            clickSound.play(1F);
            getLocalPlayer().toggleReady();
            netHandler.onLocalPlayerChange(getLocalPlayer());
            updateLobbyUI();
            return true;
        }
    });
    Table playerTable = new Table();
    Table settingsTable = new Table();
    Table buttonTable = new Table();
    Table chatTable = new Table();
    // settings table + player table
    buttonTable.add(readyUpLobbyButton).bottom().padBottom(20).row();
    buttonTable.add(leaveButton);
    Table chatInputTable = new Table();
    ImageTextButton sendButton = new ImageTextButton("Senden", skin);
    TextField chatInputField = new TextField("", skin);
    chatInputField.setTextFieldListener(new TextFieldListener() {

        @Override
        public void keyTyped(TextField textField, char key) {
            if (!textField.getText().isEmpty() && (key == (char) 13)) {
                // Enter
                clickSound.play(1F);
                netHandler.sendChatMessage(chatInputField.getText());
                onNewChatMessage(new NewChatMessagEvent(localNetworkId, chatInputField.getText()));
                chatInputField.setText("");
            }
        }
    });
    sendButton.addListener(new InputListener() {

        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            if (!chatInputField.getText().isEmpty()) {
                clickSound.play(1F);
                netHandler.sendChatMessage(chatInputField.getText());
                onNewChatMessage(new NewChatMessagEvent(localNetworkId, chatInputField.getText()));
                chatInputField.setText("");
            }
            return true;
        }
    });
    messagesArea = new TextArea("", skin);
    messagesArea.setDisabled(true);
    ScrollPane messagesPane = new ScrollPane(messagesArea);
    chatInputTable.add(chatInputField).left().width(325).padRight(15);
    chatInputTable.add(sendButton);
    chatTable.debug();
    chatTable.add(messagesPane).height(125).width(425).top().row();
    chatTable.add(chatInputTable).left().padTop(10).width(425).bottom();
    playerSlots = new Table[6];
    playerSlots[0] = new Table();
    playerSlots[1] = new Table();
    playerSlots[2] = new Table();
    playerSlots[3] = new Table();
    playerSlots[4] = new Table();
    playerSlots[5] = new Table();
    playerTable.add(playerSlots[0]).height(25).width(425).row();
    playerTable.add(playerSlots[1]).height(25).width(425).row();
    playerTable.add(playerSlots[2]).height(25).width(425).row();
    playerTable.add(playerSlots[3]).height(25).width(425).row();
    playerTable.add(playerSlots[4]).height(25).width(425).row();
    playerTable.add(playerSlots[5]).height(25).width(425).row();
    mainTable.add(playerTable).width(425).height(155);
    mainTable.add(settingsTable).width(155).row();
    mainTable.add(chatTable).height(165).bottom();
    mainTable.add(buttonTable).height(165);
    mainTable.setDebug(true);
// updateLobbyUI();
}
Also used : ImageTextButton(com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) TextArea(com.badlogic.gdx.scenes.scene2d.ui.TextArea) Sound(com.badlogic.gdx.audio.Sound) InputListener(com.badlogic.gdx.scenes.scene2d.InputListener) ScrollPane(com.badlogic.gdx.scenes.scene2d.ui.ScrollPane) NewChatMessagEvent(de.gg.event.NewChatMessagEvent) TextField(com.badlogic.gdx.scenes.scene2d.ui.TextField) NetworkHandler(de.gg.network.NetworkHandler) TextFieldListener(com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldListener) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent)

Aggregations

TextArea (com.badlogic.gdx.scenes.scene2d.ui.TextArea)5 Stage (com.badlogic.gdx.scenes.scene2d.Stage)3 ScrollPane (com.badlogic.gdx.scenes.scene2d.ui.ScrollPane)3 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)3 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)3 TextField (com.badlogic.gdx.scenes.scene2d.ui.TextField)3 ImageTextButton (com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton)2 Sound (com.badlogic.gdx.audio.Sound)1 Color (com.badlogic.gdx.graphics.Color)1 Actor (com.badlogic.gdx.scenes.scene2d.Actor)1 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)1 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)1 CheckBox (com.badlogic.gdx.scenes.scene2d.ui.CheckBox)1 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)1 List (com.badlogic.gdx.scenes.scene2d.ui.List)1 SelectBox (com.badlogic.gdx.scenes.scene2d.ui.SelectBox)1 Slider (com.badlogic.gdx.scenes.scene2d.ui.Slider)1 TextButton (com.badlogic.gdx.scenes.scene2d.ui.TextButton)1 TextFieldListener (com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldListener)1 TextTooltip (com.badlogic.gdx.scenes.scene2d.ui.TextTooltip)1