Search in sources :

Example 11 with ImageTextButton

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

the class LobbyCreationScreen method initUI.

@Override
protected void initUI() {
    backgroundTexture = assetManager.get(BACKGROUND_IMAGE_PATH);
    Sound clickSound = assetManager.get(BUTTON_SOUND);
    Label nameLabel = new Label("Name: ", skin);
    Label portLabel = new Label("Port: ", skin);
    TextField nameField = new TextField("", skin);
    TextField portField = new TextField("55789", skin);
    portField.setTextFieldFilter(new TextField.TextFieldFilter.DigitsOnlyFilter());
    Label difficultyLabel = new Label("Schwierigkeit: ", skin);
    CheckBox easyDifficultyCheckbox = new CheckBox("Einfach", skin);
    CheckBox normalDifficultyCheckbox = new CheckBox("Normal", skin);
    CheckBox hardDifficultyCheckbox = new CheckBox("Schwer", skin);
    ButtonGroup speedGroup = new ButtonGroup();
    speedGroup.add(easyDifficultyCheckbox);
    speedGroup.add(normalDifficultyCheckbox);
    speedGroup.add(hardDifficultyCheckbox);
    normalDifficultyCheckbox.setChecked(true);
    ImageTextButton backButton = new ImageTextButton("Zur�ck", skin);
    backButton.addListener(new InputListener() {

        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            game.pushScreen("serverBrowser");
            clickSound.play(1F);
            return true;
        }
    });
    ImageTextButton createButton = new ImageTextButton("Erstellen", skin);
    createButton.addListener(new InputListener() {

        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            if (!nameField.getText().isEmpty() && !portField.getText().isEmpty()) {
                clickSound.play(1F);
                GameDifficulty difficulty = GameDifficulty.NORMAL;
                if (speedGroup.getChecked().equals(easyDifficultyCheckbox)) {
                    difficulty = GameDifficulty.EASY;
                } else if (speedGroup.getChecked().equals(normalDifficultyCheckbox)) {
                    difficulty = GameDifficulty.NORMAL;
                } else if (speedGroup.getChecked().equals(hardDifficultyCheckbox)) {
                    difficulty = GameDifficulty.HARD;
                }
                // Sever & Client starten
                game.getNetworkHandler().setUpConnectionAsHost(Integer.valueOf(portField.getText()), new GameSessionSetup(difficulty, GameMap.getMaps().get("Bamberg"), System.currentTimeMillis()));
                connectingDialog = new Dialog("Starten...", skin);
                connectingDialog.text("Server startet...");
                connectingDialog.show(stage);
            } else {
                Dialog dialog = new Dialog("Felder unausgef�llt", skin);
                dialog.text("Zum Starten m�ssen alle Felder ausgef�llt sein");
                dialog.button("Ok", true);
                dialog.key(Keys.ENTER, true);
                dialog.show(stage);
            }
            return true;
        }
    });
    Table settingsTable = new Table();
    Table settings2ColTable = new Table();
    Table settings3ColTable = new Table();
    Table buttonTable = new Table();
    settings2ColTable.add(nameLabel).padBottom(30);
    settings2ColTable.add(nameField).padBottom(30).row();
    settings2ColTable.add(portLabel);
    settings2ColTable.add(portField).row();
    settings3ColTable.add(difficultyLabel).colspan(3).row();
    settings3ColTable.add(easyDifficultyCheckbox);
    settings3ColTable.add(normalDifficultyCheckbox);
    settings3ColTable.add(hardDifficultyCheckbox);
    settingsTable.left().top().add(settings2ColTable).padBottom(40).row();
    settingsTable.add(settings3ColTable).row();
    buttonTable.add(backButton);
    buttonTable.add(createButton).padLeft(65);
    mainTable.add(settingsTable).width(580).height(405);
    mainTable.row();
    mainTable.add(buttonTable).height(50).bottom();
}
Also used : ImageTextButton(com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) GameDifficulty(de.gg.data.GameSessionSetup.GameDifficulty) Sound(com.badlogic.gdx.audio.Sound) InputListener(com.badlogic.gdx.scenes.scene2d.InputListener) ButtonGroup(com.badlogic.gdx.scenes.scene2d.ui.ButtonGroup) GameSessionSetup(de.gg.data.GameSessionSetup) CheckBox(com.badlogic.gdx.scenes.scene2d.ui.CheckBox) Dialog(com.badlogic.gdx.scenes.scene2d.ui.Dialog) TextField(com.badlogic.gdx.scenes.scene2d.ui.TextField) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent)

Example 12 with ImageTextButton

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

the class OptionsPane method updateTableFields.

/**
 */
private void updateTableFields(final String style) {
    ImageButton button = (ImageButton) game.screenMain.barWidgets.group.getChecked();
    String widget = button.getUserObject().toString();
    Gdx.app.log("OptionsPane", "Update fields table for widget: " + widget + ", style: " + style);
    tableFields.clear();
    tableFields.add(new Label("Name", game.skin, "title")).left().width(170);
    tableFields.add(new Label("Value", game.skin, "title")).left().width(60).padRight(50);
    tableFields.row();
    Field[] fields = ClassReflection.getFields(currentStyle.getClass());
    for (final Field field : fields) {
        try {
            // Grey optional
            if (game.opt.isFieldOptional(currentStyle.getClass(), field.getName())) {
                tableFields.add(new Label(field.getName(), game.skin, "optional")).left();
            } else {
                tableFields.add(new Label(field.getName(), game.skin, "default")).left();
            }
            Actor actor;
            // field type
            String name = field.getType().getSimpleName();
            Object obj = field.get(currentStyle);
            if (name.equals("Drawable")) {
                /**
                 * Handle Drawable object
                 */
                Drawable drawable = (Drawable) field.get(currentStyle);
                String resourceName = "";
                ImageTextButton.ImageTextButtonStyle buttonStyle = new ImageTextButton.ImageTextButtonStyle(game.skin.getDrawable("default-round"), game.skin.getDrawable("default-round-down"), game.skin.getDrawable("default-round"), game.skin.getFont("default-font"));
                if (drawable != null) {
                    resourceName = game.skinProject.resolveObjectName(Drawable.class, drawable);
                    buttonStyle.imageUp = drawable;
                } else {
                    buttonStyle.up = game.skinProject.getDrawable("default-rect");
                    buttonStyle.checked = game.skinProject.getDrawable("default-rect");
                }
                actor = new ImageTextButton(resourceName, buttonStyle);
                ((ImageTextButton) actor).setClip(true);
                actor.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeEvent event, Actor actor) {
                        showDrawableDialog(field);
                    }
                });
            } else if (name.equals("Color")) {
                /**
                 * Handle Color object
                 */
                Color color = (Color) field.get(currentStyle);
                ImageTextButton.ImageTextButtonStyle buttonStyle = new ImageTextButton.ImageTextButtonStyle(game.skin.getDrawable("default-round"), game.skin.getDrawable("default-round-down"), game.skin.getDrawable("default-round"), game.skin.getFont("default-font"));
                String resourceName = "";
                if (color != null) {
                    resourceName = game.skinProject.resolveObjectName(Color.class, color);
                    resourceName += " (" + color.toString() + ")";
                    // 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);
                    buttonStyle.imageUp = new SpriteDrawable(new Sprite(texture));
                    pixmap.dispose();
                } else {
                    buttonStyle.up = game.skinProject.getDrawable("default-rect");
                    buttonStyle.checked = game.skinProject.getDrawable("default-rect");
                }
                actor = new ImageTextButton(resourceName, buttonStyle);
                ((ImageTextButton) actor).setClip(true);
                actor.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeEvent event, Actor actor) {
                        showColorPickerDialog(field);
                    }
                });
            } else if (name.equals("BitmapFont")) {
                /**
                 * Handle BitmapFont object
                 */
                BitmapFont font = (BitmapFont) field.get(currentStyle);
                String resourceName = "";
                ImageTextButton.ImageTextButtonStyle buttonStyle = new ImageTextButton.ImageTextButtonStyle(game.skin.getDrawable("default-round"), game.skin.getDrawable("default-round-down"), game.skin.getDrawable("default-round"), game.skin.getFont("default-font"));
                if (font != null) {
                    resourceName = game.skinProject.resolveObjectName(BitmapFont.class, font);
                    buttonStyle.font = font;
                } else {
                    buttonStyle.up = game.skinProject.getDrawable("default-rect");
                    buttonStyle.checked = game.skinProject.getDrawable("default-rect");
                }
                actor = new ImageTextButton(resourceName, buttonStyle);
                ((ImageTextButton) actor).setClip(true);
                actor.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeEvent event, Actor actor) {
                        showFontPickerDialog(field);
                    }
                });
            } else if (name.equals("float")) {
                /**
                 * Handle Float object
                 */
                Float value = (Float) field.get(currentStyle);
                String resourceName = "";
                ImageTextButton.ImageTextButtonStyle buttonStyle = new ImageTextButton.ImageTextButtonStyle(game.skin.getDrawable("default-round"), game.skin.getDrawable("default-round-down"), game.skin.getDrawable("default-round"), game.skin.getFont("default-font"));
                if ((value != null) && (value != 0)) {
                    resourceName = String.valueOf(value);
                } else {
                    buttonStyle.up = game.skinProject.getDrawable("default-rect");
                    buttonStyle.checked = game.skinProject.getDrawable("default-rect");
                }
                actor = new ImageTextButton(resourceName, buttonStyle);
                ((ImageTextButton) actor).setClip(true);
                actor.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeEvent event, Actor actor) {
                        showFloatInputDialog(field);
                    }
                });
            } else if (name.equals("ListStyle")) {
                /**
                 * Handle ListStyle object
                 */
                ListStyle listStyle = (ListStyle) field.get(currentStyle);
                actor = new SelectBox<String>(game.skin, "default");
                Array<String> items = new Array<String>();
                final ObjectMap<String, ListStyle> values = game.skinProject.getAll(ListStyle.class);
                Iterator<String> it = values.keys().iterator();
                String selection = null;
                while (it.hasNext()) {
                    String key = it.next();
                    items.add(key);
                    if (listStyle == values.get(key)) {
                        selection = key;
                    }
                }
                ((SelectBox) actor).setItems(items);
                if (selection != null) {
                    ((SelectBox) actor).setSelected(selection);
                }
                actor.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeEvent event, Actor actor) {
                        String selection = (String) ((SelectBox) actor).getSelected();
                        try {
                            field.set(currentStyle, values.get(selection));
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        game.screenMain.saveToSkin();
                        refresh();
                        game.screenMain.paneOptions.updateSelectedTableFields();
                        game.screenMain.panePreview.refresh();
                    }
                });
            } else if (name.equals("ScrollPaneStyle")) {
                /**
                 * Handle ListStyle object
                 */
                ScrollPaneStyle scrollStyle = (ScrollPaneStyle) field.get(currentStyle);
                actor = new SelectBox<String>(game.skin, "default");
                Array<String> items = new Array<String>();
                final ObjectMap<String, ScrollPaneStyle> values = game.skinProject.getAll(ScrollPaneStyle.class);
                Iterator<String> it = values.keys().iterator();
                String selection = null;
                while (it.hasNext()) {
                    String key = it.next();
                    items.add(key);
                    if (scrollStyle == values.get(key)) {
                        selection = key;
                    }
                }
                ((SelectBox) actor).setItems(items);
                if (selection != null) {
                    ((SelectBox) actor).setSelected(selection);
                }
                actor.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeEvent event, Actor actor) {
                        String selection = (String) ((SelectBox) actor).getSelected();
                        try {
                            field.set(currentStyle, values.get(selection));
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        game.screenMain.saveToSkin();
                        refresh();
                        game.screenMain.paneOptions.updateSelectedTableFields();
                        game.screenMain.panePreview.refresh();
                    }
                });
            } else {
                Gdx.app.log("OptionsPane", "Unknown type: " + name);
                actor = new Label("Unknown Type", game.skin);
            }
            tableFields.add(actor).left().height(32).padRight(24).expandX().fillX();
            tableFields.row();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Also used : ListStyle(com.badlogic.gdx.scenes.scene2d.ui.List.ListStyle) ImageTextButton(com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) Texture(com.badlogic.gdx.graphics.Texture) TextField(com.badlogic.gdx.scenes.scene2d.ui.TextField) Field(com.badlogic.gdx.utils.reflect.Field) ImageButton(com.badlogic.gdx.scenes.scene2d.ui.ImageButton) ObjectMap(com.badlogic.gdx.utils.ObjectMap) Actor(com.badlogic.gdx.scenes.scene2d.Actor) Iterator(java.util.Iterator) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteDrawable(com.badlogic.gdx.scenes.scene2d.utils.SpriteDrawable) Sprite(com.badlogic.gdx.graphics.g2d.Sprite) SelectBox(com.badlogic.gdx.scenes.scene2d.ui.SelectBox) Color(com.badlogic.gdx.graphics.Color) Drawable(com.badlogic.gdx.scenes.scene2d.utils.Drawable) SpriteDrawable(com.badlogic.gdx.scenes.scene2d.utils.SpriteDrawable) Array(com.badlogic.gdx.utils.Array) Pixmap(com.badlogic.gdx.graphics.Pixmap) ScrollPaneStyle(com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.ScrollPaneStyle)

Example 13 with ImageTextButton

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

the class GameMapScreen method create.

@Override
protected void create() {
    super.create();
    camera = new CameraWrapper(67, application.getWidth(), application.getHeight());
    camera.setPosition(application.getWidth() / 2, application.getHeight() / 2, 0);
    postProcessor = new PostProcessingPipeline(application.getWidth(), application.getHeight(), true);
    pausePostProcessingEffect = new ColorBlendEffect(application.getUICamera(), new Color(0.4F, 0.4F, 0.4F, 0.4F));
    gameRenderer = new GameRenderer(camera.getCamera(), fragmentShader.getString());
    selectionInputController = new MapSelectionInputController(application.getEventBus(), camera.getCamera());
    addInputProcessor(selectionInputController);
    movementInputController = new MapMovementInputController(camera, application.getSettings());
    addInputProcessor(movementInputController);
    gameSpeedInputProcessor = new GameSpeedInputProcessor(application.getSettings());
    addInputProcessor(gameSpeedInputProcessor);
    // CHARACTER DIALOG
    BasicDialog characterMenuDialog = new BasicDialog(Lang.get("screen.map.character_config"), skin, "big");
    ImageTextButton closeCharacterMenuButton = new ImageTextButton(Lang.get("ui.generic.close"), skin);
    closeCharacterMenuButton.addListener(new ButtonClickListener(application.getSoundManager()) {

        @Override
        protected void onClick() {
            characterMenuDialog.hide();
        }
    });
    Table characterMenuTable = new Table();
    Table changeableCharacterMenuTable = new Table();
    ImageTextButton characterMenuTab1Button = new ImageTextButton(Lang.get("screen.map.character_config.character"), skin);
    ImageTextButton characterMenuTab2Button = new ImageTextButton(Lang.get("screen.map.character_config.privileges"), skin);
    characterMenuTab1Button.addListener(new ButtonClickListener(application.getSoundManager()) {

        @Override
        protected void onClick() {
            // CHARACTER & FAMILY
            changeableCharacterMenuTable.clear();
            changeableCharacterMenuTable.add(new Label(Lang.get("screen.map.character_config.name"), skin, "dark")).padBottom(50).row();
            changeableCharacterMenuTable.add(new Label(Lang.get("screen.map.character_config.family"), skin, "dark")).row();
            changeableCharacterMenuTable.add(new Label(Lang.get("screen.map.character_config.find_so"), skin, "dark"));
        }
    });
    characterMenuTab2Button.addListener(new ButtonClickListener(application.getSoundManager()) {

        @Override
        protected void onClick() {
            // PRIVILEGES
            changeableCharacterMenuTable.clear();
            changeableCharacterMenuTable.add(new Label(Lang.get("screen.map.character_config.privileges_list"), skin, "dark")).row();
            if (application.getClient().getLocalPlayerCharacter().getPosition() != null) {
                // TODO Position privileges
                // TODO Impeachment
                ImageTextButton kickButton = new ImageTextButton(Lang.get("screen.map.character_config.privilege.impeach"), skin);
                kickButton.addListener(new ButtonClickListener(application.getSoundManager()) {

                    @Override
                    protected void onClick() {
                        short mayor = application.getClient().getSession().getWorld().getPosition(PositionType.MAYOR).getCurrentHolder();
                        if (mayor != -1)
                            application.getClient().getActionHandler().arrangeImpeachmentVote(mayor, (param) -> {
                                if ((Boolean) param == true) {
                                    SimpleTextDialog.createAndShow(stage, skin, Lang.get("screen.map.character_config.privilege.success"), Lang.get("ui.generic.wip"));
                                } else {
                                    SimpleTextDialog.createAndShow(stage, skin, Lang.get("ui.generic.error"), Lang.get("ui.generic.rmi_error"));
                                }
                            });
                    }
                });
                changeableCharacterMenuTable.add(kickButton);
            }
        }
    });
    Table characterMenuTabTable = new Table();
    characterMenuTabTable.add(characterMenuTab1Button).padRight(5);
    characterMenuTabTable.add(characterMenuTab2Button);
    characterMenuTable.add(characterMenuTabTable).padRight(30).padBottom(15).center().top().row();
    characterMenuTable.add(changeableCharacterMenuTable).padBottom(15).top().height(315).row();
    characterMenuTable.add(closeCharacterMenuButton).padRight(30).center().top();
    characterMenuDialog.add(characterMenuTable).pad(30);
    // PLAYER ICON
    iconButton = new ImageButton(skin.getDrawable(PlayerIcon.values()[0].getShieldDrawableName()));
    iconButton.addListener(new ButtonClickListener(application.getSoundManager()) {

        @Override
        protected void onClick() {
            characterMenuDialog.show(stage);
            characterMenuDialog.setPosition(0, 103);
        }
    });
    Table iconTable = new Table();
    iconTable.setBackground(skin.getDrawable("icon_background"));
    iconTable.add(iconButton).padLeft(8).padRight(10).padBottom(1);
    // INFO STUFF
    Table infoTable = new Table();
    // Gold
    Table goldTable = new Table();
    goldTable.setBackground(skin.getDrawable("info_background"));
    goldTable.add(new Image(skin.getDrawable("icon_gold_coin"))).left().top().padLeft(4).padBottom(2).padRight(4);
    goldTable.add(new Label("19 Gulden", skin, "dark")).padBottom(5).expandX().left().top();
    // Name
    Table nameTable = new Table();
    nameTable.setBackground(skin.getDrawable("info_background"));
    nameTable.add(new Label("Freiherr  Franz  von  Woyzeck", skin, "big_dark")).padBottom(2).expandX().left();
    // Notifications
    Table notificationTable = new Table();
    infoTable.add(goldTable).row();
    infoTable.add(nameTable).left().row();
    infoTable.add(notificationTable).left().padLeft(2).padTop(2).row();
    // DATE STUFF
    Table dateTimeTable = new Table();
    // Date
    Table dateTable = new Table();
    dateLabel = new Label("", skin, "dark");
    dateTable.setBackground(skin.getDrawable("date_background"));
    dateTable.add(dateLabel).padLeft(9).padBottom(5).expandX().left();
    // Clock
    Table clockTable = new Table();
    clockTable.setBackground(skin.getDrawable("clock_background"));
    dateTimeTable.add(dateTable).row();
    dateTimeTable.add(clockTable).right();
    // MISC
    Table miscTable = new Table();
    Table misc2Table = new Table();
    // Inventory
    ImageButton inventoryButton = new ImageButton(skin, "inventory");
    // Book
    ImageButton bookButton = new ImageButton(skin, "leaning_book");
    // Minimap
    Table minimapTable = new Table();
    minimapTable.setBackground(skin.getDrawable("minimap_test"));
    misc2Table.add(inventoryButton).padRight(2);
    misc2Table.add(bookButton).padTop(2).row();
    miscTable.add(misc2Table).right().row();
    miscTable.add(minimapTable);
    mainTable.setSkin(skin);
    mainTable.setFillParent(true);
    mainTable.add(iconTable).top().left();
    mainTable.add(infoTable).top().left();
    mainTable.add(dateTimeTable).right().expandX().row();
    mainTable.add("").fill();
    mainTable.add("").expand().fill();
    mainTable.add(miscTable).expandY().bottom().right();
    // PAUSE DIALOG
    pauseDialog = new BasicDialog("", skin) {

        @Override
        protected void result(Object object) {
            pauseShown = false;
            postProcessor.removeEffect(pausePostProcessingEffect);
            if (object == (Integer) 1) {
                application.getScreenManager().pushScreen("settings", "blendingTransition");
            } else {
                Log.info("Client", "Verbindung wird getrennt");
                final GameClient client = application.getClient();
                final GameServer server = application.getServer();
                // Set stuff to null to stop updates
                application.setClient(null);
                application.setServer(null);
                ThreadHandler.getInstance().executeRunnable(() -> {
                    client.disconnect();
                    if (server != null) {
                        server.stop();
                    }
                });
                DiscordGGHandler.getInstance().setMenuPresence();
                application.getScreenManager().pushScreen("main_menu", null);
            }
        }
    };
    pauseDialog.button(Lang.get("screen.map.pause.settings"), 1).button(Lang.get("screen.map.pause.disconnect"), 2);
    houseSelectionDialog = new BasicDialog("", skin);
    houseSelectionDialog.button("Test");
    stage.addListener(new InputListener() {

        @Override
        public boolean keyDown(InputEvent event, int keycode) {
            if (keycode == Keys.ESCAPE) {
                if (pauseShown) {
                    pauseDialog.hide();
                    postProcessor.removeEffect(pausePostProcessingEffect);
                } else {
                    pauseDialog.show(stage);
                    postProcessor.addEffect(pausePostProcessingEffect);
                }
                pauseShown = !pauseShown;
                return true;
            }
            return false;
        }
    });
}
Also used : InputListener(com.badlogic.gdx.scenes.scene2d.InputListener) ButtonClickListener(de.gg.game.input.ButtonClickListener) SimpleTextDialog(de.gg.game.ui.components.SimpleTextDialog) ThreadHandler(de.damios.guacamole.concurrent.ThreadHandler) BasicDialog(de.gg.game.ui.components.BasicDialog) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) GameClient(de.gg.game.network.GameClient) MapSelectionInputController(de.gg.game.input.MapSelectionInputController) PlayerIcon(de.gg.game.model.types.PlayerIcon) Asset(de.eskalon.commons.asset.AnnotationAssetManager.Asset) Lang(de.eskalon.commons.lang.Lang) HouseSelectionEvent(de.gg.game.events.HouseSelectionEvent) GameSpeedInputProcessor(de.gg.game.input.GameSpeedInputProcessor) ImageTextButton(com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton) GameSession(de.gg.game.session.GameSession) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) Log(de.damios.guacamole.gdx.Log) Subscribe(com.google.common.eventbus.Subscribe) PositionType(de.gg.game.model.types.PositionType) GameServer(de.gg.game.network.GameServer) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) ColorBlendEffect(de.eskalon.commons.graphics.postproc.impl.ColorBlendEffect) HouseEnterEvent(de.gg.game.events.HouseEnterEvent) World(de.gg.game.model.World) CameraWrapper(de.gg.engine.ui.rendering.CameraWrapper) GameRenderer(de.gg.game.ui.rendering.GameRenderer) FullHourEvent(de.gg.game.events.FullHourEvent) DiscordGGHandler(de.gg.game.misc.DiscordGGHandler) Color(com.badlogic.gdx.graphics.Color) Text(de.damios.guacamole.gdx.assets.Text) ProjektGGApplication(de.gg.game.core.ProjektGGApplication) GameClock(de.gg.game.misc.GameClock) PostProcessingPipeline(de.eskalon.commons.graphics.postproc.PostProcessingPipeline) Keys(com.badlogic.gdx.Input.Keys) MapMovementInputController(de.gg.game.input.MapMovementInputController) Player(de.gg.game.model.entities.Player) ImageButton(com.badlogic.gdx.scenes.scene2d.ui.ImageButton) ImageTextButton(com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton) GameClient(de.gg.game.network.GameClient) ColorBlendEffect(de.eskalon.commons.graphics.postproc.impl.ColorBlendEffect) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) MapSelectionInputController(de.gg.game.input.MapSelectionInputController) ImageButton(com.badlogic.gdx.scenes.scene2d.ui.ImageButton) InputListener(com.badlogic.gdx.scenes.scene2d.InputListener) ButtonClickListener(de.gg.game.input.ButtonClickListener) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) GameServer(de.gg.game.network.GameServer) GameSpeedInputProcessor(de.gg.game.input.GameSpeedInputProcessor) BasicDialog(de.gg.game.ui.components.BasicDialog) CameraWrapper(de.gg.engine.ui.rendering.CameraWrapper) PostProcessingPipeline(de.eskalon.commons.graphics.postproc.PostProcessingPipeline) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) MapMovementInputController(de.gg.game.input.MapMovementInputController) Color(com.badlogic.gdx.graphics.Color) GameRenderer(de.gg.game.ui.rendering.GameRenderer)

Example 14 with ImageTextButton

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

the class GameTownHallInteriorScreen method create.

@Override
protected void create() {
    super.create();
    addInputProcessor(new BackInputProcessor() {

        @Override
        public void onBackAction() {
            application.getScreenManager().pushScreen("map", "circle_crop");
        }
    });
    // Buy citizenship
    applyForCitizenshipButton = new ImageTextButton(Lang.get("screen.house.town_hall.apply_for_citizenship"), skin);
    applyForCitizenshipButton.addListener(new ButtonClickListener(application.getSoundManager()) {

        @Override
        protected void onClick() {
        // TODO inform server; after that disable the button;
        // then set a flag in the player to disable it
        // permanently (as there is no point in applying twice)
        }
    });
    mainTable.add(applyForCitizenshipButton).padBottom(7).row();
    // Apply for position
    applyForPositionButton = new ImageTextButton(Lang.get("screen.house.town_hall.apply_for_position"), skin);
    applyForPositionButton.addListener(new ButtonClickListener(application.getSoundManager()) {

        @Override
        protected void onClick() {
        // TODO show dialog with all available positions
        }
    });
    mainTable.add(applyForPositionButton);
}
Also used : ImageTextButton(com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton) BackInputProcessor(de.gg.game.input.BackInputProcessor) ButtonClickListener(de.gg.game.input.ButtonClickListener)

Example 15 with ImageTextButton

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

the class LobbyScreen method create.

@Override
protected void create() {
    super.create();
    setImage(backgroundTexture);
    PlayerLobbyConfigDialog playerConfigDialog = new PlayerLobbyConfigDialog(application, skin);
    ImageTextButton playerSettingsButton = new ImageTextButton(Lang.get("screen.lobby.configure"), skin);
    playerSettingsButton.addListener(new ButtonClickListener(application.getSoundManager()) {

        @Override
        protected void onClick() {
            playerConfigDialog.initUIValues(application.getClient().getLobbyPlayers(), application.getClient().getLocalLobbyPlayer());
            playerConfigDialog.show(stage);
        }
    });
    ImageTextButton leaveButton = new ImageTextButton(Lang.get("screen.lobby.disconnect"), skin);
    leaveButton.addListener(new ButtonClickListener(application.getSoundManager()) {

        @Override
        protected void onClick() {
            Log.info("Client", "Disconnecting from Lobby");
            final GameClient client = application.getClient();
            final GameServer server = application.getServer();
            application.setClient(null);
            application.setServer(null);
            ThreadHandler.getInstance().executeRunnable(() -> {
                client.disconnect();
                Log.info("Client", "Client disconnected");
                if (server != null) {
                    server.stop();
                }
                Log.info("Server", "Server stopped");
            });
            application.getScreenManager().pushScreen("server_browser", null);
        }
    });
    readyUpLobbyButton = new ImageTextButton(Lang.get("screen.lobby.ready"), skin);
    readyUpLobbyButton.addListener(new ButtonClickListener(application.getSoundManager()) {

        @Override
        protected void onClick() {
            // TODO warum nicht readyUp(); ?
            application.getClient().getLocalLobbyPlayer().toggleReady();
            application.getClient().getActionHandler().changeLocalPlayer(application.getClient().getLocalLobbyPlayer());
            updateLobbyUI();
        }
    });
    settingsArea = new Label("", skin);
    settingsArea.setAlignment(Align.topLeft);
    settingsArea.setWrap(true);
    Table playerTable = new Table();
    Table buttonTable = new Table();
    Table chatTable = new Table();
    buttonTable.add(playerSettingsButton).bottom().padBottom(18).row();
    buttonTable.add(readyUpLobbyButton).padBottom(18).row();
    buttonTable.add(leaveButton).padBottom(50);
    Table chatInputTable = new Table();
    ImageTextButton sendButton = new ImageTextButton(Lang.get("screen.lobby.send"), skin);
    chatInputField = new OffsettableTextField("", skin, "large", 8);
    chatInputField.setTextFieldListener(new TextFieldListener() {

        @Override
        public void keyTyped(TextField textField, char key) {
            if (!textField.getText().isEmpty() && key == '\n') {
                // Enter
                application.getSoundManager().playSoundEffect("button_click");
                application.getClient().getActionHandler().sendChatmessage(chatInputField.getText());
                application.getClient().getChatMessages().add(new ChatMessage(application.getClient().getLocalLobbyPlayer(), chatInputField.getText()));
                setUIValues();
                chatInputField.setText("");
            }
        }
    });
    sendButton.addListener(new ButtonClickListener(application.getSoundManager()) {

        @Override
        protected void onClick() {
            application.getClient().getActionHandler().sendChatmessage(chatInputField.getText());
            application.getClient().getChatMessages().add(new ChatMessage(application.getClient().getLocalLobbyPlayer(), chatInputField.getText()));
            setUIValues();
            chatInputField.setText("");
        }

        @Override
        protected boolean arePreconditionsMet() {
            return !chatInputField.getText().isEmpty();
        }
    });
    messagesArea = new Label("", skin, "text");
    messagesArea.setWidth(425);
    messagesArea.setWrap(true);
    Table messagesTable = new Table();
    messagesTable.add(messagesArea).padLeft(10).left().top().expand();
    messagesPane = new ScrollPane(messagesTable, skin, "with-background");
    messagesPane.setForceScroll(false, true);
    chatInputTable.add(chatInputField).left().width(325).padRight(15);
    chatInputTable.add(sendButton);
    chatTable.add(messagesPane).height(135).width(465).top().row();
    chatTable.add(chatInputTable).left().padTop(10).width(465).bottom();
    playerSlots = new Table[maxPlayerCount];
    for (int i = 0; i < playerSlots.length; i++) {
        playerSlots[i] = new Table();
        playerTable.add(playerSlots[i]).height(29).width(465).row();
    }
    Table mTable = new Table();
    mTable.setWidth(615);
    mTable.setHeight(475);
    mTable.setBackground(skin.getDrawable("parchment1"));
    mTable.add(playerTable).width(465).height(185).padBottom(15);
    mTable.add(settingsArea).width(155).height(185).row();
    mTable.add(chatTable).height(185).bottom();
    mTable.add(buttonTable).height(185);
    mainTable.add(mTable);
}
Also used : ImageTextButton(com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) GameClient(de.gg.game.network.GameClient) ChatMessage(de.gg.game.ui.data.ChatMessage) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) ButtonClickListener(de.gg.game.input.ButtonClickListener) ScrollPane(com.badlogic.gdx.scenes.scene2d.ui.ScrollPane) OffsettableTextField(de.gg.engine.ui.components.OffsettableTextField) TextField(com.badlogic.gdx.scenes.scene2d.ui.TextField) OffsettableTextField(de.gg.engine.ui.components.OffsettableTextField) PlayerLobbyConfigDialog(de.gg.game.ui.dialogs.PlayerLobbyConfigDialog) TextFieldListener(com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldListener) GameServer(de.gg.game.network.GameServer)

Aggregations

ImageTextButton (com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton)17 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)13 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)11 ButtonClickListener (de.gg.game.input.ButtonClickListener)9 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)8 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)8 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)6 TextField (com.badlogic.gdx.scenes.scene2d.ui.TextField)6 GameClient (de.gg.game.network.GameClient)5 Sound (com.badlogic.gdx.audio.Sound)4 Actor (com.badlogic.gdx.scenes.scene2d.Actor)4 ImageButton (com.badlogic.gdx.scenes.scene2d.ui.ImageButton)4 ScrollPane (com.badlogic.gdx.scenes.scene2d.ui.ScrollPane)4 BackInputProcessor (de.gg.game.input.BackInputProcessor)4 Color (com.badlogic.gdx.graphics.Color)3 Texture (com.badlogic.gdx.graphics.Texture)3 CheckBox (com.badlogic.gdx.scenes.scene2d.ui.CheckBox)3 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)3 GameServer (de.gg.game.network.GameServer)3 ButtonGroup (com.badlogic.gdx.scenes.scene2d.ui.ButtonGroup)2