コード例 #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
  /* (non-Javadoc)
   * @see forge.control.home.IControlSubmenu#update()
   */
  @SuppressWarnings("serial")
  @Override
  public void initialize() {

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

    // This updates variable right now and is not standard
    view.getCbDevMode()
        .addItemListener(
            new ItemListener() {
              @Override
              public void itemStateChanged(final ItemEvent arg0) {
                if (updating) {
                  return;
                }

                final boolean toggle = view.getCbDevMode().isSelected();
                prefs.setPref(FPref.DEV_MODE_ENABLED, String.valueOf(toggle));
                ForgePreferences.DEV_MODE = toggle;
                prefs.save();
              }
            });

    // This updates background track immediately and is not standard
    view.getCbEnableMusic()
        .addItemListener(
            new ItemListener() {
              @Override
              public void itemStateChanged(final ItemEvent arg0) {
                if (updating) {
                  return;
                }

                final boolean toggle = view.getCbEnableMusic().isSelected();
                prefs.setPref(FPref.UI_ENABLE_MUSIC, String.valueOf(toggle));
                prefs.save();
                SoundSystem.instance.changeBackgroundTrack();
              }
            });

    lstControls.clear(); // just in case
    lstControls.add(Pair.of(view.getCbAnte(), FPref.UI_ANTE));
    lstControls.add(Pair.of(view.getCbAnteMatchRarity(), FPref.UI_ANTE_MATCH_RARITY));
    lstControls.add(Pair.of(view.getCbManaBurn(), FPref.UI_MANABURN));
    lstControls.add(Pair.of(view.getCbScaleLarger(), FPref.UI_SCALE_LARGER));
    lstControls.add(Pair.of(view.getCbLargeCardViewers(), FPref.UI_LARGE_CARD_VIEWERS));
    lstControls.add(Pair.of(view.getCbRandomArtInPools(), FPref.UI_RANDOM_ART_IN_POOLS));
    lstControls.add(Pair.of(view.getCbEnforceDeckLegality(), FPref.ENFORCE_DECK_LEGALITY));
    lstControls.add(Pair.of(view.getCbCloneImgSource(), FPref.UI_CLONE_MODE_SOURCE));
    lstControls.add(Pair.of(view.getCbRemoveSmall(), FPref.DECKGEN_NOSMALL));
    lstControls.add(Pair.of(view.getCbRemoveArtifacts(), FPref.DECKGEN_ARTIFACTS));
    lstControls.add(Pair.of(view.getCbSingletons(), FPref.DECKGEN_SINGLETONS));
    lstControls.add(Pair.of(view.getCbEnableAICheats(), FPref.UI_ENABLE_AI_CHEATS));
    lstControls.add(Pair.of(view.getCbDisplayFoil(), FPref.UI_OVERLAY_FOIL_EFFECT));
    lstControls.add(Pair.of(view.getCbRandomFoil(), FPref.UI_RANDOM_FOIL));
    lstControls.add(Pair.of(view.getCbEnableSounds(), FPref.UI_ENABLE_SOUNDS));
    lstControls.add(Pair.of(view.getCbAltSoundSystem(), FPref.UI_ALT_SOUND_SYSTEM));
    lstControls.add(Pair.of(view.getCbUiForTouchScreen(), FPref.UI_FOR_TOUCHSCREN));
    lstControls.add(Pair.of(view.getCbCompactMainMenu(), FPref.UI_COMPACT_MAIN_MENU));
    lstControls.add(Pair.of(view.getCbPromptFreeBlocks(), FPref.MATCHPREF_PROMPT_FREE_BLOCKS));
    lstControls.add(Pair.of(view.getCbPauseWhileMinimized(), FPref.UI_PAUSE_WHILE_MINIMIZED));
    lstControls.add(Pair.of(view.getCbWorkshopSyntax(), FPref.DEV_WORKSHOP_SYNTAX));

    lstControls.add(Pair.of(view.getCbCompactPrompt(), FPref.UI_COMPACT_PROMPT));
    lstControls.add(Pair.of(view.getCbHideReminderText(), FPref.UI_HIDE_REMINDER_TEXT));
    lstControls.add(Pair.of(view.getCbOpenPacksIndiv(), FPref.UI_OPEN_PACKS_INDIV));
    lstControls.add(Pair.of(view.getCbTokensInSeparateRow(), FPref.UI_TOKENS_IN_SEPARATE_ROW));
    lstControls.add(Pair.of(view.getCbStackCreatures(), FPref.UI_STACK_CREATURES));
    lstControls.add(Pair.of(view.getCbManaLostPrompt(), FPref.UI_MANA_LOST_PROMPT));

    lstControls.add(
        Pair.of(view.getCbFilterLandsByColorId(), FPref.UI_FILTER_LANDS_BY_COLOR_IDENTITY));

    for (final Pair<JCheckBox, FPref> kv : lstControls) {
      kv.getKey()
          .addItemListener(
              new ItemListener() {
                @Override
                public void itemStateChanged(final ItemEvent arg0) {
                  if (updating) {
                    return;
                  }

                  prefs.setPref(kv.getValue(), String.valueOf(kv.getKey().isSelected()));
                  prefs.save();
                }
              });
    }

    view.getBtnReset()
        .setCommand(
            new UiCommand() {
              @Override
              public void run() {
                CSubmenuPreferences.this.resetForgeSettingsToDefault();
              }
            });

    view.getBtnDeleteEditorUI()
        .setCommand(
            new UiCommand() {
              @Override
              public void run() {
                CSubmenuPreferences.this.resetDeckEditorLayout();
              }
            });

    view.getBtnDeleteWorkshopUI()
        .setCommand(
            new UiCommand() {
              @Override
              public void run() {
                CSubmenuPreferences.this.resetWorkshopLayout();
              }
            });

    view.getBtnDeleteMatchUI()
        .setCommand(
            new UiCommand() {
              @Override
              public void run() {
                CSubmenuPreferences.this.resetMatchScreenLayout();
              }
            });

    view.getBtnUserProfileUI()
        .setCommand(
            new UiCommand() {
              @Override
              public void run() {
                CSubmenuPreferences.this.openUserProfileDirectory();
              }
            });

    view.getBtnContentDirectoryUI()
        .setCommand(
            new UiCommand() {
              @Override
              public void run() {
                CSubmenuPreferences.this.openContentDirectory();
              }
            });

    initializeGameLogVerbosityComboBox();
    initializeCloseActionComboBox();
    initializeAiProfilesComboBox();
    initializeColorIdentityCombobox();
    initializePlayerNameButton();
  }