Search in sources :

Example 6 with ButtonClickListener

use of de.gg.game.input.ButtonClickListener 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 7 with ButtonClickListener

use of de.gg.game.input.ButtonClickListener 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)

Example 8 with ButtonClickListener

use of de.gg.game.input.ButtonClickListener in project ProjektGG by eskalon.

the class ServerBrowserScreen method addServerToUI.

private void addServerToUI(Table serverTable, String address, DiscoveryResponsePacket packet) {
    ImageTextButton joinButton = new ImageTextButton(Lang.get("screen.server_browser.join"), skin);
    joinButton.addListener(new ButtonClickListener(application.getSoundManager()) {

        @Override
        protected void onClick() {
            application.setClient(new GameClient(application.getEventBus()));
            application.getClient().connect(connectionCallback, application.VERSION, address, packet.getPort());
            connectingDialog = SimpleTextDialog.createAndShow(stage, skin, Lang.get("ui.generic.connecting"), Lang.get("screen.server_browser.joining"), false, null);
        }
    });
    serverTable.left().top().add(new Image(packet.getPlayerCount() < packet.getMaxPlayerCount() ? skin.getDrawable("icon_on") : skin.getDrawable("icon_off"))).padRight(10).padLeft(10);
    serverTable.add(new Label(Lang.get("screen.server_browser.server_players", packet.getPlayerCount(), packet.getMaxPlayerCount()), skin)).padRight(15);
    serverTable.add(new Label(Lang.get("screen.server_browser.server_title", packet.getGameName()), skin)).expandX();
    serverTable.add(joinButton).padRight(10).padLeft(15);
    serverTable.row().padTop(20);
}
Also used : ImageTextButton(com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton) GameClient(de.gg.game.network.GameClient) ButtonClickListener(de.gg.game.input.ButtonClickListener) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) Image(com.badlogic.gdx.scenes.scene2d.ui.Image)

Example 9 with ButtonClickListener

use of de.gg.game.input.ButtonClickListener in project ProjektGG by eskalon.

the class SettingsScreen method create.

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

        @Override
        public void onBackAction() {
            if (application.getScreenManager().getLastScreen() instanceof GameMapScreen)
                application.getScreenManager().pushScreen("map", "blendingTransition");
            else
                application.getScreenManager().pushScreen("main_menu", "blendingTransition");
        }
    };
    addInputProcessor(backInput);
    mainTable.addListener(new BackInputActorListener() {

        @Override
        public void onBackAction() {
            backInput.onBackAction();
        }
    });
    EskalonSettings settings = application.getSettings();
    // VOLUME
    Label masterVolume = new Label(Lang.get("screen.settings.master_volume"), skin);
    LeftClickSlider masterSlider = new LeftClickSlider(0, 1, 0.05F, false, skin);
    masterSlider.setValue(settings.getMasterVolume());
    masterSlider.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            settings.setMasterVolume(masterSlider.getValue());
            application.getSoundManager().setMasterVolume(masterSlider.getValue());
        }
    });
    Label effectVolume = new Label(Lang.get("screen.settings.effect_volume"), skin);
    LeftClickSlider effectSlider = new LeftClickSlider(0, 1, 0.05F, false, skin);
    effectSlider.setValue(settings.getEffectVolume());
    effectSlider.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            settings.setEffectVolume(effectSlider.getValue());
            application.getSoundManager().setEffectVolume(effectSlider.getValue());
        }
    });
    Label musicVolume = new Label(Lang.get("screen.settings.music_volume"), skin);
    LeftClickSlider musicSlider = new LeftClickSlider(0, 1, 0.05F, false, skin);
    musicSlider.setValue(settings.getMusicVolume());
    musicSlider.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            settings.setMusicVolume(musicSlider.getValue());
            application.getSoundManager().setMusicVolume(musicSlider.getValue());
        }
    });
    // KEYS
    Label forwardLabel = new Label(Lang.get("screen.settings.forward_key"), skin);
    KeySelectionInputField forwardButton = new KeySelectionInputField(settings, "cameraForward", skin, stage, application.getSoundManager());
    Label leftLabel = new Label(Lang.get("screen.settings.left_key"), skin);
    KeySelectionInputField leftButton = new KeySelectionInputField(settings, "cameraLeft", skin, stage, application.getSoundManager());
    Label backwardLabel = new Label(Lang.get("screen.settings.backwards_key"), skin);
    KeySelectionInputField backwardButton = new KeySelectionInputField(settings, "cameraBackward", skin, stage, application.getSoundManager());
    Label rightLabel = new Label(Lang.get("screen.settings.right_key"), skin);
    KeySelectionInputField rightButton = new KeySelectionInputField(settings, "cameraRight", skin, stage, application.getSoundManager());
    Label speedUpLabel = new Label(Lang.get("screen.settings.speed_up_key"), skin);
    KeySelectionInputField speedUpButton = new KeySelectionInputField(settings, "speedUpTime", skin, stage, application.getSoundManager());
    Label speedDownLabel = new Label(Lang.get("screen.settings.speed_down_key"), skin);
    KeySelectionInputField speedDownButton = new KeySelectionInputField(settings, "speedDownTime", skin, stage, application.getSoundManager());
    ImageTextButton backButton = new ImageTextButton(Lang.get("ui.generic.done"), skin);
    backButton.addListener(new ButtonClickListener(application.getSoundManager()) {

        @Override
        protected void onClick() {
            if (application.getScreenManager().getLastScreen() instanceof GameMapScreen)
                application.getScreenManager().pushScreen("map", "blendingTransition");
            else
                application.getScreenManager().pushScreen("main_menu", "blendingTransition");
        }
    });
    Table settingsTable = new Table();
    Table settings2ColTable = new Table();
    settings2ColTable.padTop(20);
    Table buttonTable = new Table();
    settings2ColTable.add(forwardLabel).padBottom(22).left();
    settings2ColTable.add(forwardButton).padBottom(22);
    settings2ColTable.add(masterVolume).padBottom(28).padLeft(75).padRight(10);
    settings2ColTable.add(masterSlider).padBottom(22).row();
    settings2ColTable.add(leftLabel).padBottom(22).left();
    settings2ColTable.add(leftButton).padBottom(22);
    settings2ColTable.add(effectVolume).padBottom(28).padLeft(75).padRight(10);
    settings2ColTable.add(effectSlider).padBottom(22).row();
    settings2ColTable.add(backwardLabel).padBottom(22).left();
    settings2ColTable.add(backwardButton).padBottom(22);
    settings2ColTable.add(musicVolume).padBottom(28).padLeft(75).padRight(10);
    settings2ColTable.add(musicSlider).padBottom(22).row();
    settings2ColTable.add(rightLabel).padBottom(55).left();
    settings2ColTable.add(rightButton).padBottom(55).row();
    settings2ColTable.add(speedUpLabel).padBottom(22).padRight(13).left();
    settings2ColTable.add(speedUpButton).padBottom(22).row();
    settings2ColTable.add(speedDownLabel).padBottom(22).padRight(13).left();
    settings2ColTable.add(speedDownButton).padBottom(22);
    settingsTable.left().top().add(settings2ColTable).row();
    buttonTable.add(backButton);
    Table mTable = new Table();
    mTable.setWidth(615);
    mTable.setHeight(475);
    mTable.setBackground(skin.getDrawable("parchment2"));
    mTable.add(settingsTable).width(580).height(405).padRight(90).row();
    mTable.add(buttonTable).height(50).bottom();
    mainTable.add(mTable);
}
Also used : KeySelectionInputField(de.gg.game.ui.components.KeySelectionInputField) ImageTextButton(com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) BackInputActorListener(de.gg.game.input.BackInputProcessor.BackInputActorListener) BackInputProcessor(de.gg.game.input.BackInputProcessor) LeftClickSlider(com.badlogic.gdx.scenes.scene2d.ui.LeftClickSlider) ButtonClickListener(de.gg.game.input.ButtonClickListener) Actor(com.badlogic.gdx.scenes.scene2d.Actor) EskalonSettings(de.eskalon.commons.settings.EskalonSettings) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)

Aggregations

ImageTextButton (com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton)9 ButtonClickListener (de.gg.game.input.ButtonClickListener)9 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)7 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)5 GameClient (de.gg.game.network.GameClient)5 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)4 BackInputProcessor (de.gg.game.input.BackInputProcessor)4 ImageButton (com.badlogic.gdx.scenes.scene2d.ui.ImageButton)3 OffsettableTextField (de.gg.engine.ui.components.OffsettableTextField)3 BackInputActorListener (de.gg.game.input.BackInputProcessor.BackInputActorListener)3 GameServer (de.gg.game.network.GameServer)3 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)2 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)2 ScrollPane (com.badlogic.gdx.scenes.scene2d.ui.ScrollPane)2 TextField (com.badlogic.gdx.scenes.scene2d.ui.TextField)2 Subscribe (com.google.common.eventbus.Subscribe)2 ISuccessCallback (de.damios.guacamole.ISuccessCallback)2 Keys (com.badlogic.gdx.Input.Keys)1 Color (com.badlogic.gdx.graphics.Color)1 Actor (com.badlogic.gdx.scenes.scene2d.Actor)1