Exemple #1
0
 private void generateRandomName(
     final String gender,
     final String type,
     final List<String> usedNames,
     final String title,
     final Callback<String> callback) {
   final String newName = NameGenerator.getRandomName(gender, type, usedNames);
   String confirmMsg = "Would you like to use the name \"" + newName + "\", or try again?";
   FOptionPane.showConfirmDialog(
       confirmMsg,
       title,
       "Use this name",
       "Try again",
       true,
       new Callback<Boolean>() {
         @Override
         public void run(Boolean result) {
           if (result) {
             callback.run(newName);
           } else {
             generateRandomName(gender, type, usedNames, title, callback);
           }
         }
       });
 }
Exemple #2
0
  private void createNameEditor() {
    String name;
    if (index == 0) {
      name = FModel.getPreferences().getPref(FPref.PLAYER_NAME);
      if (name.isEmpty()) {
        name = "Human";
      }
    } else {
      name = NameGenerator.getRandomName("Any", "Any", screen.getPlayerNames());
    }

    txtPlayerName.setText(name);
    txtPlayerName.setFont(LABEL_FONT);
    txtPlayerName.setChangedHandler(nameChangedHandler);
  }
Exemple #3
0
  /**
   * @param index
   * @return
   */
  private void createNameEditor() {
    String name;
    if (index == 0) {
      name = FModel.getPreferences().getPref(FPref.PLAYER_NAME);
      if (name.isEmpty()) {
        name = "Human";
      }
    } else {
      name = NameGenerator.getRandomName("Any", "Any", lobby.getPlayerNames());
    }

    txtPlayerName.setText(name);
    txtPlayerName.setFocusable(true);
    txtPlayerName.setFont(FSkin.getFont(14));
    txtPlayerName.addActionListener(lobby.nameListener);
    txtPlayerName.addFocusListener(nameFocusListener);
  }