public void signIn() {
    menu = Assets.menuSigninRegion;
    menuComponents = new ArrayList<MenuComponent>();
    menuTextFields = new ArrayList<TextField>();

    menuComponents.add(0, new MenuComponent(200, 300, 100, 50, Assets.menuUsernameRegion));
    menuComponents.add(1, new MenuComponent(200, 200, 100, 50, Assets.menuPasswordRegion));
    menuComponents.add(2, new MenuComponent(600, 50, 100, 50, Assets.menuSubmitRegion));

    Skin usernameSkin = new Skin(Gdx.files.internal("data/uiskin.json"));
    TextField usernameTextField = new TextField("", usernameSkin);
    usernameTextField.setPosition(300, 300);
    usernameTextField.setWidth(400);
    usernameTextField.setFocusTraversal(false);
    Skin passwordSkin = new Skin(Gdx.files.internal("data/uiskin.json"));
    TextField passwordTextField = new TextField("", passwordSkin);
    passwordTextField.setPosition(300, 200);
    passwordTextField.setPasswordMode(true);
    passwordTextField.setPasswordCharacter('a');
    passwordTextField.setWidth(400);
    passwordTextField.setFocusTraversal(false);
    menuTextFields.add(0, usernameTextField);
    menuTextFields.add(1, passwordTextField);

    menuNumber = 2;
  }
Exemple #2
0
  @Override
  public void create() {
    skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    texture1 = new Texture(Gdx.files.internal("data/badlogicsmall.jpg"));
    texture2 = new Texture(Gdx.files.internal("data/badlogic.jpg"));
    TextureRegion image = new TextureRegion(texture1);
    TextureRegion imageFlipped = new TextureRegion(image);
    imageFlipped.flip(true, true);
    TextureRegion image2 = new TextureRegion(texture2);
    // stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false, new
    // PolygonSpriteBatch());
    stage = new Stage();
    // stage.setViewport(new ExtendViewport(800, 480));
    Gdx.input.setInputProcessor(stage);

    // Group.debug = true;

    ImageButtonStyle style = new ImageButtonStyle(skin.get(ButtonStyle.class));
    style.imageUp = new TextureRegionDrawable(image);
    style.imageDown = new TextureRegionDrawable(imageFlipped);
    ImageButton iconButton = new ImageButton(style);

    Button buttonMulti = new TextButton("Multi\nLine\nToggle", skin, "toggle");
    Button imgButton = new Button(new Image(image), skin);
    Button imgToggleButton = new Button(new Image(image), skin, "toggle");

    Label myLabel = new Label("this is some text.", skin);
    myLabel.setWrap(true);

    Table t = new Table();
    t.row();
    t.add(myLabel);

    t.layout();

    CheckBox checkBox = new CheckBox("Check me", skin);
    final Slider slider = new Slider(0, 10, 1, false, skin);
    TextField textfield = new TextField("", skin);
    textfield.setMessageText("Click here!");
    SelectBox dropdown = new SelectBox(skin);
    dropdown.setItems(
        "Android1",
        "Windows1",
        "Linux1",
        "OSX1",
        "Android2",
        "Windows2",
        "Linux2",
        "OSX2",
        "Android3",
        "Windows3",
        "Linux3",
        "OSX3",
        "Android4",
        "Windows4",
        "Linux4",
        "OSX4",
        "Android5",
        "Windows5",
        "Linux5",
        "OSX5",
        "Android6",
        "Windows6",
        "Linux6",
        "OSX6",
        "Android7",
        "Windows7",
        "Linux7",
        "OSX7");
    dropdown.setSelected("Linux6");
    Image imageActor = new Image(image2);
    ScrollPane scrollPane = new ScrollPane(imageActor);
    List list = new List(skin);
    list.setItems(listEntries);
    list.getSelection().setMultiple(true);
    list.getSelection().setRequired(false);
    // list.getSelection().setToggle(true);
    ScrollPane scrollPane2 = new ScrollPane(list, skin);
    scrollPane2.setFlickScroll(false);
    SplitPane splitPane = new SplitPane(scrollPane, scrollPane2, false, skin, "default-horizontal");
    fpsLabel = new Label("fps:", skin);

    // configures an example of a TextField in password mode.
    final Label passwordLabel = new Label("Textfield in password mode: ", skin);
    final TextField passwordTextField = new TextField("", skin);
    passwordTextField.setMessageText("password");
    passwordTextField.setPasswordCharacter('*');
    passwordTextField.setPasswordMode(true);

    // window.debug();
    Window window = new Window("Dialog", skin);
    window.getButtonTable().add(new TextButton("X", skin)).height(window.getPadTop());
    window.setPosition(0, 0);
    window.defaults().spaceBottom(10);
    window.row().fill().expandX();
    window.add(iconButton);
    window.add(buttonMulti);
    window.add(imgButton);
    window.add(imgToggleButton);
    window.row();
    window.add(checkBox);
    window.add(slider).minWidth(100).fillX().colspan(3);
    window.row();
    window.add(dropdown);
    window.add(textfield).minWidth(100).expandX().fillX().colspan(3);
    window.row();
    window.add(splitPane).fill().expand().colspan(4).maxHeight(200);
    window.row();
    window.add(passwordLabel).colspan(2);
    window.add(passwordTextField).minWidth(100).expandX().fillX().colspan(2);
    window.row();
    window.add(fpsLabel).colspan(4);
    window.pack();

    // stage.addActor(new Button("Behind Window", skin));
    stage.addActor(window);

    textfield.setTextFieldListener(
        new TextFieldListener() {
          public void keyTyped(TextField textField, char key) {
            if (key == '\n') textField.getOnscreenKeyboard().show(false);
          }
        });

    slider.addListener(
        new ChangeListener() {
          public void changed(ChangeEvent event, Actor actor) {
            Gdx.app.log("UITest", "slider: " + slider.getValue());
          }
        });

    iconButton.addListener(
        new ChangeListener() {
          public void changed(ChangeEvent event, Actor actor) {
            new Dialog("Some Dialog", skin, "dialog") {
              protected void result(Object object) {
                System.out.println("Chosen: " + object);
              }
            }.text("Are you enjoying this demo?")
                .button("Yes", true)
                .button("No", false)
                .key(Keys.ENTER, true)
                .key(Keys.ESCAPE, false)
                .show(stage);
          }
        });
  }
  public void signUp() {
    shouldClear = true;
    // shouldAddScrollPane = false;
    shouldAddScrollPane = true;
    charityScrollPane = true;
    characterScrollPane = false;
    menu = Assets.menuSplashBlankRegion;
    menuComponents = new ArrayList<MenuComponent>();
    menuTextFields = new HashMap<String, TextField>();

    menuComponents.add(
        0, new MenuComponent(600, 100, 175, 75, Assets.menuButtonSmallRegion)); // submit
    menuComponents.add(
        1, new MenuComponent(400, 100, 175, 75, Assets.menuButtonSmallRegion)); // return

    // right now I am using the metric of setting the width to be 175 and height 50 (for textfields)
    // and making them 88 units below the buttons and 73 units below. thats maybe like 1 or 2 units
    // higher than it needs to be, but it looks aight

    TextField signUpTextField = new TextField(("SIGN UP!"), Assets.tfsTrans100);
    signUpTextField.setPosition(50, 330);
    signUpTextField.setWidth(700);
    signUpTextField.setHeight(150);
    signUpTextField.setAlignment(Align.center);
    signUpTextField.setFocusTraversal(false);
    signUpTextField.setDisabled(true);

    TextField returnTextField = new TextField(("RETURN"), Assets.tfsTransWhite40);
    returnTextField.setPosition(312, 27);
    returnTextField.setWidth(175); // to be centered well make the width about 325
    returnTextField.setHeight(50);
    returnTextField.setAlignment(Align.center);
    returnTextField.setFocusTraversal(false);
    returnTextField.setDisabled(true);

    TextField submitTextField = new TextField(("SUBMIT"), Assets.tfsTransWhite40);
    submitTextField.setPosition(512, 27);
    submitTextField.setWidth(175);
    submitTextField.setHeight(50);
    submitTextField.setAlignment(Align.center);
    submitTextField.setFocusTraversal(false);
    submitTextField.setDisabled(true);

    final TextField usernameTextField = new TextField("USERNAME", Assets.tfs);
    usernameTextField.setPosition(100, 300);
    usernameTextField.setWidth(300);
    usernameTextField.setHeight(50);
    usernameTextField.setFocusTraversal(false);
    usernameTextField.addListener(
        new ClickListener() {
          public void clicked(InputEvent e, float x, float y) {
            if (usernameTextField.getText().equals("USERNAME")) usernameTextField.setText("");
          }
        });
    usernameTextField.setTextFieldListener(
        new TextField.TextFieldListener() { // if enter is pressed, remove the keyboard
          @Override
          public void keyTyped(TextField textField, char c) {
            if ((c == '\r') || (c == '\n')) {
              Gdx.input.setOnscreenKeyboardVisible(false);
              unfocusAll = true;
            }
          }
        });

    final TextField passwordTextField = new TextField("PASSWORD", Assets.tfs);
    // passwordTextField.setPosition(100, 240);
    passwordTextField.setPosition(450, 300);
    passwordTextField.setPasswordMode(false);
    // passwordTextField.setPasswordCharacter('*');
    passwordTextField.setWidth(300);
    passwordTextField.setHeight(50);
    passwordTextField.setFocusTraversal(false);
    passwordTextField.addListener(
        new ClickListener() {
          public void clicked(InputEvent e, float x, float y) {
            if (passwordTextField.getText().equals("PASSWORD"))
              passwordTextField.setPasswordMode(true);
            passwordTextField.setPasswordCharacter('*');
            passwordTextField.setText("");
          }
        });
    passwordTextField.setTextFieldListener(
        new TextField.TextFieldListener() { // if enter is pressed, remove the keyboard
          @Override
          public void keyTyped(TextField textField, char c) {
            if ((c == '\r') || (c == '\n')) {
              Gdx.input.setOnscreenKeyboardVisible(false);
              unfocusAll = true;
            }
          }
        });

    /*final TextField emailTextField = new TextField("EMAIL", Assets.tfs);
    emailTextField.setPosition(450, 300);
    emailTextField.setWidth(300);
    emailTextField.setHeight(50);
    emailTextField.setFocusTraversal(false);
    emailTextField.addListener(new ClickListener() {
        public void clicked(InputEvent e, float x, float y) {
            if (emailTextField.getText().equals("EMAIL"))
                emailTextField.setText("");

        }
    });
    emailTextField.setTextFieldListener(new TextField.TextFieldListener() {//if enter is pressed, remove the keyboard
        @Override
        public void keyTyped(TextField textField, char c) {
            if ((c == '\r') || (c == '\n')) {
                Gdx.input.setOnscreenKeyboardVisible(false);
                unfocusAll = true;
            }
        }
    });*/

    final TextField charityTextField =
        new TextField(
            "SELECT A CHARITY",
            Assets.tfsTrans40); // obviously want to replace these with a real charity selection
    charityTextField.setPosition(250, 240);
    charityTextField.setDisabled(true);
    charityTextField.setWidth(300);
    charityTextField.setHeight(50);
    charityTextField.setFocusTraversal(false);

    menuTextFields.put("usernameTF", usernameTextField);
    menuTextFields.put("passwordTF", passwordTextField);
    // menuTextFields.put("emailTF", emailTextField);
    menuTextFields.put("charityTF", charityTextField);
    menuTextFields.put("returnTF", returnTextField);
    menuTextFields.put("submitTF", submitTextField);
    menuTextFields.put("signUpTF", signUpTextField);

    menuNumber = this.MENU_SIGNUP;
  }
  public void signIn() {
    shouldClear = true;
    shouldAddScrollPane = false;
    charityScrollPane = false;
    characterScrollPane = false;
    scrollPaneContainer = null;
    menu = Assets.menuSplashBlankRegion;
    menuComponents = new ArrayList<MenuComponent>();
    menuTextFields = new HashMap<String, TextField>();

    menuComponents.add(
        0, new MenuComponent(600, 100, 175, 75, Assets.menuButtonSmallRegion)); // lets go
    menuComponents.add(
        1, new MenuComponent(400, 100, 175, 75, Assets.menuButtonSmallRegion)); // sign up

    // right now I am using the metric of setting the width to be 175 and height 50 (for textfields)
    // and making them 88 units below the buttons and 73 units below. thats maybe like 1 or 2 units
    // higher than it needs to be, but it looks aight

    menuComponents.add(2, new MenuComponent(45, 45, 178, 267, Assets.menuSpenceRegion));

    TextField logInTextField = new TextField(("LOG IN"), Assets.tfsTrans100);
    logInTextField.setPosition(50, 330);
    logInTextField.setWidth(700);
    logInTextField.setHeight(150);
    logInTextField.setAlignment(Align.center);
    logInTextField.setFocusTraversal(false);
    logInTextField.setDisabled(true);

    TextField letsGoTextField = new TextField(("LETS GO"), Assets.tfsTransWhite40);
    letsGoTextField.setPosition(512, 27);
    letsGoTextField.setWidth(175); // to be centered well make the width about 325
    letsGoTextField.setHeight(50);
    letsGoTextField.setAlignment(Align.center);
    letsGoTextField.setFocusTraversal(false);
    letsGoTextField.setDisabled(true);

    TextField signUpTextField = new TextField(("SIGN UP"), Assets.tfsTransWhite40);
    signUpTextField.setPosition(312, 27);
    signUpTextField.setWidth(175);
    signUpTextField.setHeight(50);
    signUpTextField.setAlignment(Align.center);
    signUpTextField.setFocusTraversal(false);
    signUpTextField.setDisabled(true);

    final TextField usernameTextField = new TextField("USERNAME", Assets.tfs);
    usernameTextField.setPosition(50, 270);
    usernameTextField.setWidth(300);
    usernameTextField.setHeight(50);
    usernameTextField.setFocusTraversal(false);
    usernameTextField.addListener(
        new ClickListener() {
          public void clicked(InputEvent e, float x, float y) {
            if (usernameTextField.getText().equals("USERNAME")) usernameTextField.setText("");
          }
        });
    usernameTextField.setTextFieldListener(
        new TextField.TextFieldListener() { // if enter is pressed, remove the keyboard
          @Override
          public void keyTyped(TextField textField, char c) {
            if ((c == '\r') || (c == '\n')) {
              Gdx.input.setOnscreenKeyboardVisible(false);
              unfocusAll = true;
            }
          }
        });

    final TextField passwordTextField = new TextField("PASSWORD", Assets.tfs);
    passwordTextField.setPosition(450, 270);
    passwordTextField.setPasswordMode(false);
    // passwordTextField.setPasswordCharacter('*');
    passwordTextField.setWidth(300);
    passwordTextField.setHeight(50);
    passwordTextField.setFocusTraversal(false);
    passwordTextField.addListener(
        new ClickListener() {
          public void clicked(InputEvent e, float x, float y) {
            if (passwordTextField.getText().equals("PASSWORD"))
              passwordTextField.setPasswordMode(true);
            passwordTextField.setPasswordCharacter('*');
            passwordTextField.setText("");
          }
        });
    passwordTextField.setTextFieldListener(
        new TextField.TextFieldListener() { // if enter is pressed, remove the keyboard
          @Override
          public void keyTyped(TextField textField, char c) {
            if ((c == '\r') || (c == '\n')) {
              Gdx.input.setOnscreenKeyboardVisible(false);
              unfocusAll = true;
            }
          }
        });

    menuTextFields.put("usernameTF", usernameTextField);
    menuTextFields.put("passwordTF", passwordTextField);
    menuTextFields.put("letsGoTF", letsGoTextField);
    menuTextFields.put("signUpTF", signUpTextField);
    menuTextFields.put("loginTF", logInTextField);

    menuNumber = this.MENU_SIGNIN;
  }