コード例 #1
0
ファイル: PlayerPanel.java プロジェクト: diab0l/mtg-forge
 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);
           }
         }
       });
 }
コード例 #2
0
ファイル: PlayerPanel.java プロジェクト: diab0l/mtg-forge
  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);
  }
コード例 #3
0
ファイル: PlayerPanel.java プロジェクト: diab0l/mtg-forge
  /**
   * @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);
  }