Ejemplo n.º 1
0
  public void setCloseAction(final CloseAction closeAction0) {
    if (closeAction == closeAction0) {
      return;
    }
    closeAction = closeAction0;
    Singletons.getView().getNavigationBar().updateBtnCloseTooltip();

    final ForgePreferences prefs = FModel.getPreferences();
    prefs.setPref(FPref.UI_CLOSE_ACTION, closeAction0.toString());
    prefs.save();
  }
 private void resetForgeSettingsToDefault() {
   final String userPrompt =
       "This will reset all preferences to their defaults and restart Forge.\n\n"
           + "Reset and restart Forge?";
   if (FOptionPane.showConfirmDialog(userPrompt, "Reset Settings")) {
     final ForgePreferences prefs = FModel.getPreferences();
     prefs.reset();
     prefs.save();
     update();
     Singletons.getControl().restartForge();
   }
 }
Ejemplo n.º 3
0
 @Override
 public void focusLost(final FocusEvent e) {
   final Object source = e.getSource();
   if (source instanceof FTextField) { // the text box
     final FTextField nField = (FTextField) source;
     final 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();
     }
     lobby.firePlayerChangeListener(index);
   }
 }
Ejemplo n.º 4
0
 @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);
       }
     }
   }
 }
Ejemplo n.º 5
0
  public static void setPlayerName() {
    String oldPlayerName = prefs.getPref(FPref.PLAYER_NAME);
    String newPlayerName = null;

    if (StringUtils.isBlank(oldPlayerName)) {
      newPlayerName = getVerifiedPlayerName(getPlayerNameUsingFirstTimePrompt(), oldPlayerName);
    } else {
      newPlayerName =
          getVerifiedPlayerName(getPlayerNameUsingStandardPrompt(oldPlayerName), oldPlayerName);
    }

    prefs.setPref(FPref.PLAYER_NAME, newPlayerName);
    prefs.save();

    if (StringUtils.isBlank(oldPlayerName) && newPlayerName != "Human") {
      showThankYouPrompt(newPlayerName);
    }
  }