コード例 #1
0
ファイル: PlayerPanel.java プロジェクト: diab0l/mtg-forge
 @Override
 public void handleEvent(FEvent e) {
   final Object source = e.getSource();
   if (source instanceof FTextField) { // the text box
     FTextField nField = (FTextField) source;
     String newName = nField.getText().trim();
     if (index == 0
         && !StringUtils.isBlank(newName)
         && StringUtils.isAlphanumericSpace(newName)
         && prefs.getPref(FPref.PLAYER_NAME) != newName) {
       prefs.setPref(FPref.PLAYER_NAME, newName);
       prefs.save();
       if (allowNetworking) {
         screen.firePlayerChangeListener(index);
       }
     }
   }
 }
コード例 #2
0
ファイル: PlayerPanel.java プロジェクト: diab0l/mtg-forge
 @Override
 public void handleEvent(FEvent e) {
   @SuppressWarnings("unchecked")
   FComboBox<Object> cb = (FComboBox<Object>) e.getSource();
   if (cb.getSelectedIndex() == -1) {
     return;
   }
   if (screen.hasVariant(GameType.Archenemy)) {
     String sel = (String) cb.getSelectedItem();
     if (sel.contains("Archenemy")) {
       screen.lastArchenemy = index;
       for (PlayerPanel pp : screen.getPlayerPanels()) {
         int i = pp.index;
         int team = i == screen.lastArchenemy ? 0 : 1;
         pp.setArchenemyTeam(team);
         pp.toggleIsPlayerArchenemy();
       }
     }
   }
 }