Search in sources :

Example 1 with GameDifficulty

use of de.gg.data.GameSessionSetup.GameDifficulty 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)

Aggregations

Sound (com.badlogic.gdx.audio.Sound)1 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)1 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)1 ButtonGroup (com.badlogic.gdx.scenes.scene2d.ui.ButtonGroup)1 CheckBox (com.badlogic.gdx.scenes.scene2d.ui.CheckBox)1 Dialog (com.badlogic.gdx.scenes.scene2d.ui.Dialog)1 ImageTextButton (com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton)1 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)1 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)1 TextField (com.badlogic.gdx.scenes.scene2d.ui.TextField)1 GameSessionSetup (de.gg.data.GameSessionSetup)1 GameDifficulty (de.gg.data.GameSessionSetup.GameDifficulty)1