コード例 #1
0
  /* (non-Javadoc)
   * @see forge.control.home.IControlSubmenu#update()
   */
  @Override
  public void update() {
    updating =
        true; // prevent itemStateChanged causing prefs to be saved or other logic occurring while
    // updating values

    this.view = VSubmenuPreferences.SINGLETON_INSTANCE;
    this.prefs = FModel.getPreferences();

    setPlayerNameButtonText();
    view.getCbDevMode().setSelected(ForgePreferences.DEV_MODE);
    view.getCbEnableMusic().setSelected(prefs.getPrefBoolean(FPref.UI_ENABLE_MUSIC));

    for (final Pair<JCheckBox, FPref> kv : lstControls) {
      kv.getKey().setSelected(prefs.getPrefBoolean(kv.getValue()));
    }
    view.reloadShortcuts();

    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            view.getCbRemoveSmall().requestFocusInWindow();
          }
        });

    updating = false;
  }
コード例 #2
0
ファイル: FControl.java プロジェクト: diab0l/mtg-forge
  /** After view and model have been initialized, control can start. */
  public void initialize() {
    // Preloads skin components (using progress bar).
    FSkin.loadFull(true);

    display = FView.SINGLETON_INSTANCE.getLpnDocument();

    final ForgePreferences prefs = FModel.getPreferences();

    closeAction = CloseAction.valueOf(prefs.getPref(FPref.UI_CLOSE_ACTION));

    FView.SINGLETON_INSTANCE.setSplashProgessBarMessage("Loading quest...");
    // Preload quest data if present
    final File dirQuests = new File(ForgeConstants.QUEST_SAVE_DIR);
    final String questname = FModel.getQuestPreferences().getPref(QPref.CURRENT_QUEST);
    final File data = new File(dirQuests.getPath(), questname);
    if (data.exists()) {
      FModel.getQuest().load(QuestDataIO.loadData(data));
    }

    // Handles resizing in null layouts of layers in JLayeredPane as well as saving window layout
    final FFrame window = Singletons.getView().getFrame();
    window.addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentResized(final ComponentEvent e) {
            sizeChildren();
            window.updateNormalBounds();
            SLayoutIO.saveWindowLayout();
          }

          @Override
          public void componentMoved(final ComponentEvent e) {
            window.updateNormalBounds();
            SLayoutIO.saveWindowLayout();
          }
        });

    FView.SINGLETON_INSTANCE
        .getLpnDocument()
        .addMouseListener(SOverflowUtil.getHideOverflowListener());
    FView.SINGLETON_INSTANCE
        .getLpnDocument()
        .addComponentListener(SResizingUtil.getWindowResizeListener());

    setGlobalKeyboardHandler();

    FView.SINGLETON_INSTANCE.setSplashProgessBarMessage("Opening main window...");
    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            Singletons.getView().initialize();
          }
        });
  }
コード例 #3
0
ファイル: FControl.java プロジェクト: diab0l/mtg-forge
  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();
  }
コード例 #4
0
 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();
   }
 }
コード例 #5
0
ファイル: PlayerPanel.java プロジェクト: diab0l/mtg-forge
 @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);
   }
 }
コード例 #6
0
ファイル: LayoutMenu.java プロジェクト: diab0l/mtg-forge
 private static JMenuItem getMenuItem_ShowTabs() {
   final JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem("Panel Tabs");
   menuItem.setAccelerator(MenuUtil.getAcceleratorKey(KeyEvent.VK_T));
   menuItem.setState(!prefs.getPrefBoolean(FPref.UI_HIDE_GAME_TABS));
   menuItem.addActionListener(getShowTabsAction(menuItem));
   return menuItem;
 }
コード例 #7
0
ファイル: PlayerPanel.java プロジェクト: diab0l/mtg-forge
 private void createAvatar() {
   String[] currentPrefs = prefs.getPref(FPref.UI_AVATARS).split(",");
   if (index < currentPrefs.length) {
     setAvatarIndex(Integer.parseInt(currentPrefs[index]));
   } else {
     setAvatarIndex(AvatarSelector.getRandomAvatar(screen.getUsedAvatars()));
   }
   avatarLabel.setCommand(avatarCommand);
 }
コード例 #8
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);
       }
     }
   }
 }
コード例 #9
0
ファイル: GamePlayerUtil.java プロジェクト: DeretsunGit/forge
  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);
    }
  }
コード例 #10
0
ファイル: LayoutMenu.java プロジェクト: diab0l/mtg-forge
 private static JMenu getMenu_ThemeOptions() {
   final JMenu menu = new JMenu("Theme");
   JRadioButtonMenuItem menuItem;
   final ButtonGroup group = new ButtonGroup();
   final String currentSkin = prefs.getPref(FPref.UI_SKIN);
   for (final String skin : FSkin.getAllSkins()) {
     menuItem = new JRadioButtonMenuItem(skin);
     group.add(menuItem);
     if (skin.equals(currentSkin)) {
       menuItem.setSelected(true);
     }
     menuItem.setActionCommand(skin);
     menuItem.addActionListener(changeSkin);
     menu.add(menuItem);
   }
   return menu;
 }
コード例 #11
0
ファイル: LayoutMenu.java プロジェクト: diab0l/mtg-forge
 private static JMenuItem getMenuItem_ShowBackgroundImage() {
   final JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem("Background Image");
   menuItem.setState(prefs.getPrefBoolean(FPref.UI_MATCH_IMAGE_VISIBLE));
   menuItem.addActionListener(getShowBackgroundImageAction(menuItem));
   return menuItem;
 }
コード例 #12
0
 private void setPlayerNameButtonText() {
   final FLabel btn = view.getBtnPlayerName();
   final String name = prefs.getPref(FPref.PLAYER_NAME);
   btn.setText(StringUtils.isBlank(name) ? "Human" : name);
 }