⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 commonsettingsdialog.java

📁 MegaMek is a networked Java clone of BattleTech, a turn-based sci-fi boardgame for 2+ players. Fight
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        tempPanel.add( rightDragScroll );                ctlScroll            = new Checkbox( Messages.getString("CommonSettingsDialog.ctlScroll") ); //$NON-NLS-1$            tempPanel.add( ctlScroll );        clickEdgeScroll            = new Checkbox( Messages.getString("CommonSettingsDialog.clickEdgeScroll") ); //$NON-NLS-1$            tempPanel.add( clickEdgeScroll );        alwaysRightClickScroll            = new Checkbox( Messages.getString("CommonSettingsDialog.alwaysRightClickScroll") ); //$NON-NLS-1$            tempPanel.add( alwaysRightClickScroll );                autoEdgeScroll            = new Checkbox( Messages.getString("CommonSettingsDialog.autoEdgeScroll") ); //$NON-NLS-1$            tempPanel.add( autoEdgeScroll );        panSetting = new Panel(new FlowLayout(FlowLayout.LEFT));        panSetting.add( new Label(Messages.getString("CommonSettingsDialog.scrollSesitivity")) ); //$NON-NLS-1$        scrollSensitivity            = new TextField(4);        panSetting.add( scrollSensitivity );        tempPanel.add( panSetting );        //locale settings        panSetting = new Panel(new FlowLayout(FlowLayout.LEFT));        panSetting.add( new Label(Messages.getString("CommonSettingsDialog.locale"))); //$NON-NLS-1$        //        locale = new TextField(8);        locale = new Choice();        locale.add(Messages.getString("CommonSettingsDialog.locale.English")); //$NON-NLS-1$        locale.add(Messages.getString("CommonSettingsDialog.locale.Deutsch")); //$NON-NLS-1$        locale.add(Messages.getString("CommonSettingsDialog.locale.Russian")); //$NON-NLS-1$        panSetting.add(locale);        tempPanel.add(panSetting);        //chatloungtab setting        chatloungeTabs             = new Checkbox( Messages.getString("CommonSettingsDialog.chatloungeTabs") ); //$NON-NLS-1$        tempPanel.add( chatloungeTabs );        //showMapsheets setting        showMapsheets            = new Checkbox( Messages.getString("CommonSettingsDialog.showMapsheets") ); //$NON-NLS-1$        tempPanel.add(showMapsheets);        return tempPanel;    }    /**     * Display the current settings in this dialog.     * <p/>     * Overrides <code>Dialog#show()</code>.     */    public void setVisible(boolean show) {        if(show) {            GUIPreferences gs = GUIPreferences.getInstance();            IClientPreferences cs = PreferenceManager.getClientPreferences();                        minimapEnabled.setState( gs.getMinimapEnabled() );            autoEndFiring.setState( gs.getAutoEndFiring() );            autoDeclareSearchlight.setState( gs.getAutoDeclareSearchlight());            nagForMASC.setState( gs.getNagForMASC() );            nagForPSR.setState( gs.getNagForPSR() );            nagForNoAction.setState( gs.getNagForNoAction() );            animateMove.setState( gs.getShowMoveStep() );            showWrecks.setState( gs.getShowWrecks() );            soundMute.setState( gs.getSoundMute() );            showMapHexPopup.setState( gs.getShowMapHexPopup() );            tooltipDelay.setText( Integer.toString(gs.getTooltipDelay() ) );            mouseWheelZoom.setState( gs.getMouseWheelZoom());                // Select the correct char set (give a nice default to start).            unitStartChar.select(0);            for ( int loop = 0; loop < unitStartChar.getItemCount(); loop++ ) {                if ( unitStartChar.getItem(loop).charAt(0) ==                     PreferenceManager.getClientPreferences().getUnitStartChar() ) {                    unitStartChar.select(loop);                    break;                }            }                maxPathfinderTime.setText( Integer.toString(cs.getMaxPathfinderTime() ) );                rightDragScroll.setState( gs.getRightDragScroll() );            ctlScroll.setState( gs.getCtlScroll() );            clickEdgeScroll.setState( gs.getClickEdgeScroll() );            alwaysRightClickScroll.setState( gs.getAlwaysRightClickScroll() );            autoEdgeScroll.setState( gs.getAutoEdgeScroll() );            scrollSensitivity.setText( Integer.toString(gs.getScrollSensitivity() ) );                keepGameLog.setState( cs.keepGameLog() );            gameLogFilename.setEnabled(keepGameLog.getState());            gameLogFilename.setText( cs.getGameLogFilename() );            //gameLogMaxSize.setEnabled(keepGameLog.getState());            //gameLogMaxSize.setText( Integer.toString(cs.getGameLogMaxSize()) );            stampFilenames.setState( cs.stampFilenames() );            stampFormat.setEnabled(stampFilenames.getState());            stampFormat.setText(cs.getStampFormat());                defaultAutoejectDisabled.setState( cs.defaultAutoejectDisabled() );            showUnitId.setState( cs.getShowUnitId() );                int index = 0;            if (cs.getLocaleString().startsWith("de"))                index = 1;            if (cs.getLocaleString().startsWith("ru"))                index = 2;            locale.select(index);                        chatloungeTabs.setState(gs.getChatLoungeTabs() );                        showMapsheets.setState(gs.getShowMapsheets());                File dir = new File("data" + File.separator +                    "images" +                     File.separator + "hexes" + File.separator);            tileSets = dir.listFiles(new FilenameFilter() {                public boolean accept(File direc, String name) {                     if(name.endsWith(".tileset")) return true;                    return false;}            });            tileSetChoice.removeAll();            for(int i=0;i<tileSets.length;i++) {                String name = tileSets[i].getName();                tileSetChoice.add(name.substring(0,name.length() - 8));                if(name.equals(cs.getMapTileset()))                    tileSetChoice.select(i);            }                getFocus.setState( gs.getFocus() );        }        super.setVisible(show);    }    /**     * Cancel any updates made in this dialog, and closes it.     */    private void cancel() {        this.setVisible( false );    }    /**     * Update the settings from this dialog's values, then closes it.     */    private void update() {        GUIPreferences gs = GUIPreferences.getInstance();        IClientPreferences cs = PreferenceManager.getClientPreferences();                gs.setMinimapEnabled(minimapEnabled.getState());        gs.setAutoEndFiring(autoEndFiring.getState());        gs.setAutoDeclareSearchlight(autoDeclareSearchlight.getState());        gs.setNagForMASC(nagForMASC.getState());        gs.setNagForPSR(nagForPSR.getState());        gs.setNagForNoAction(nagForNoAction.getState());        gs.setShowMoveStep(animateMove.getState());        gs.setShowWrecks(showWrecks.getState());        gs.setSoundMute(soundMute.getState());        gs.setShowMapHexPopup(showMapHexPopup.getState());        gs.setTooltipDelay(Integer.parseInt(tooltipDelay.getText()));        cs.setUnitStartChar(unitStartChar.getSelectedItem().charAt(0));        gs.setRightDragScroll(rightDragScroll.getState());        gs.setCtlScroll(ctlScroll.getState());        gs.setClickEdgeScroll(clickEdgeScroll.getState());        gs.setAlwaysRightClickScroll(alwaysRightClickScroll.getState());        gs.setAutoEdgeScroll(autoEdgeScroll.getState());        gs.setScrollSensitivity(Integer.parseInt(scrollSensitivity.getText()) );        gs.setMouseWheelZoom(mouseWheelZoom.getState());        cs.setMaxPathfinderTime(Integer.parseInt(maxPathfinderTime.getText()));        gs.setGetFocus(getFocus.getState());        cs.setKeepGameLog(keepGameLog.getState());        cs.setGameLogFilename(gameLogFilename.getText());        //cs.setGameLogMaxSize(Integer.parseInt(gameLogMaxSize.getText()));        cs.setStampFilenames(stampFilenames.getState());        cs.setStampFormat(stampFormat.getText());        cs.setDefaultAutoejectDisabled(defaultAutoejectDisabled.getState());        cs.setShowUnitId(showUnitId.getState());        cs.setLocale(CommonSettingsDialog.LOCALE_CHOICES[locale.getSelectedIndex()]);                gs.setChatloungeTabs(chatloungeTabs.getState());        gs.setShowMapsheets(showMapsheets.getState());                if(tileSetChoice.getSelectedIndex() >= 0)            cs.setMapTileset(tileSets[tileSetChoice.getSelectedIndex()].getName());        this.setVisible( false );    }    /**     * Handle the player pressing the action buttons.     * <p/>     * Implements the <code>ActionListener</code> interface.     *     * @param   event - the <code>ActionEvent</code> that initiated this call.     */    public void actionPerformed( ActionEvent event ) {        String command = event.getActionCommand();        if ( CommonSettingsDialog.UPDATE.equalsIgnoreCase( command ) ) {            update();        }        else if ( CommonSettingsDialog.CANCEL.equalsIgnoreCase( command ) ) {            cancel();        }    }    /**     * Handle the player clicking checkboxes.     * <p/>     * Implements the <code>ItemListener</code> interface.     *     * @param   event - the <code>ItemEvent</code> that initiated this call.     */    public void itemStateChanged( ItemEvent event ) {        Object source = event.getItemSelectable();        if ( source.equals(keepGameLog) ) {            gameLogFilename.setEnabled(keepGameLog.getState());            //gameLogMaxSize.setEnabled(keepGameLog.getState());        }        if ( source.equals(stampFilenames) ) {            stampFormat.setEnabled(stampFilenames.getState());        }        if ( event.getSource() == keys && event.getStateChange() == ItemEvent.SELECTED) {            value.setText(GUIPreferences.getInstance().getString("Advanced" + keys.getSelectedItem()));            keysIndex = keys.getSelectedIndex();        }    }    public void focusGained( FocusEvent e ) {}    public void focusLost( FocusEvent e ) {        GUIPreferences.getInstance().setValue("Advanced" + keys.getItem(keysIndex), value.getText());    }    private Panel getAdvancedSettingsPanel() {        Panel p = new Panel();        keys = new List(10, false);        String[] s = GUIPreferences.getInstance().getAdvancedProperties();        //You would think that a simple "Arrays.sort(s)" would work below,        // but it does not.  Something funky is going on with the        // collections.jar classes - specifically spelling out the comparator        // seems to fix it.  This kludge can be removed when we drop Java        // 1.1 compatability.        Arrays.sort(s, new Comparator() {                public int compare( Object a, Object b ) {                    String sa = (String)a;                    String sb = (String)b;                    return sa.compareTo(sb);                }            });        for (int i = 0; i < s.length; i++) {            keys.add(s[i].substring(s[i].indexOf("Advanced") + 8, s[i].length()));        }        keys.addItemListener(this);        p.add(keys);        value = new TextField(10);        value.addFocusListener(this);        p.add(value);        return p;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -