📄 commonsettingsdialog.java
字号:
/* * MegaMek - Copyright (C) 2003, 2004, 2005 Ben Mazur (bmazur@sev.org) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. */package megamek.client.ui.AWT;import java.awt.*;import java.awt.event.*;import java.io.File;import java.io.FilenameFilter;import java.util.Arrays;import java.util.Comparator;import gov.nist.gui.TabPanel;import megamek.common.preference.IClientPreferences;import megamek.common.preference.PreferenceManager;import megamek.client.ui.AWT.widget.AdvancedLabel;public class CommonSettingsDialog extends ClientDialog implements ActionListener, ItemListener, FocusListener{ private ScrollPane scrolledPane = new ScrollPane(); private TabPanel panTabs; private Checkbox minimapEnabled; private Checkbox autoEndFiring; private Checkbox autoDeclareSearchlight; private Checkbox nagForMASC; private Checkbox nagForPSR; private Checkbox nagForNoAction; private Checkbox animateMove; private Checkbox showWrecks; private Checkbox soundMute; private Checkbox showMapHexPopup; private TextField tooltipDelay; private Choice unitStartChar; private TextField maxPathfinderTime; private Checkbox getFocus; private Checkbox rightDragScroll; private Checkbox ctlScroll; private Checkbox clickEdgeScroll; private Checkbox alwaysRightClickScroll; private Checkbox autoEdgeScroll; private TextField scrollSensitivity; private Checkbox keepGameLog; private TextField gameLogFilename; //private TextField gameLogMaxSize; private Checkbox stampFilenames; private TextField stampFormat; private Checkbox defaultAutoejectDisabled; private Checkbox showUnitId; private Choice locale; private Checkbox chatloungeTabs; private Checkbox showMapsheets; private Checkbox mouseWheelZoom; private List keys; private int keysIndex = 0; private TextField value; private Choice tileSetChoice; private File[] tileSets; private static final String CANCEL = "CANCEL"; //$NON-NLS-1$ private static final String UPDATE = "UPDATE"; //$NON-NLS-1$ private static final String[] LOCALE_CHOICES = {"en", "de", "ru"}; /** * Standard constructor. There is no default constructor for this class. * * @param owner - the <code>Frame</code> that owns this dialog. */ public CommonSettingsDialog( Frame owner) { // Initialize our superclass with a title. super( owner, Messages.getString("CommonSettingsDialog.title") ); //$NON-NLS-1$ panTabs = new TabPanel(); Panel settingsPanel = getSettingsPanel(); scrolledPane.add(settingsPanel); panTabs.add("Main", scrolledPane); panTabs.add("Advanced", getAdvancedSettingsPanel()); setLayout(new BorderLayout()); this.add(panTabs, BorderLayout.CENTER); this.add( getButtonsPanel(), BorderLayout.SOUTH ); // Close this dialog when the window manager says to. addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { cancel(); } }); // Center this dialog. pack(); // Make the thing wide enough so a horizontal scrollbar isn't // necessary. I'm not sure why the extra hardcoded 10 pixels // is needed, maybe it's a ms windows thing. setLocationAndSize(settingsPanel.getPreferredSize().width + scrolledPane.getInsets().right + 10, settingsPanel.getPreferredSize().height); } private Panel getButtonsPanel() { // Add the dialog controls. Panel buttons = new Panel(); buttons.setLayout( new GridLayout(1, 0, 20, 5) ); Button update = new Button( Messages.getString("CommonSettingsDialog.Update") ); //$NON-NLS-1$ update.setActionCommand( CommonSettingsDialog.UPDATE ); update.addActionListener( this ); buttons.add( update ); Button cancel = new Button( Messages.getString("Cancel") ); //$NON-NLS-1$ cancel.setActionCommand( CommonSettingsDialog.CANCEL ); cancel.addActionListener( this ); buttons.add( cancel ); return buttons; } private Panel getSettingsPanel() { // Lay out this dialog. Panel tempPanel = new Panel(); tempPanel.setLayout( new GridLayout(0, 1) ); // Add the setting controls. minimapEnabled = new Checkbox( Messages.getString("CommonSettingsDialog.minimapEnabled") ); //$NON-NLS-1$ tempPanel.add( minimapEnabled ); autoEndFiring = new Checkbox( Messages.getString("CommonSettingsDialog.autoEndFiring") ); //$NON-NLS-1$ tempPanel.add( autoEndFiring ); autoDeclareSearchlight = new Checkbox( Messages.getString("CommonSettingsDialog.autoDeclareSearchlight") ); //$NON-NLS-1$ tempPanel.add( autoDeclareSearchlight ); nagForMASC = new Checkbox( Messages.getString("CommonSettingsDialog.nagForMASC") ); //$NON-NLS-1$ tempPanel.add( nagForMASC ); mouseWheelZoom = new Checkbox( Messages.getString("CommonSettingsDialog.mouseWheelZoom") ); //$NON-NLS-1$ tempPanel.add( mouseWheelZoom ); nagForPSR = new Checkbox( Messages.getString("CommonSettingsDialog.nagForPSR") ); //$NON-NLS-1$ tempPanel.add( nagForPSR ); nagForNoAction = new Checkbox( Messages.getString("CommonSettingsDialog.nagForNoAction") ); //$NON-NLS-1$ tempPanel.add( nagForNoAction ); animateMove = new Checkbox( Messages.getString("CommonSettingsDialog.animateMove") ); //$NON-NLS-1$ tempPanel.add( animateMove ); showWrecks = new Checkbox( Messages.getString("CommonSettingsDialog.showWrecks") ); //$NON-NLS-1$ tempPanel.add( showWrecks ); soundMute = new Checkbox( Messages.getString("CommonSettingsDialog.soundMute") ); //$NON-NLS-1$ tempPanel.add( soundMute ); showMapHexPopup = new Checkbox( Messages.getString("CommonSettingsDialog.showMapHexPopup") ); //$NON-NLS-1$ tempPanel.add( showMapHexPopup ); Panel panSetting; panSetting = new Panel(new FlowLayout(FlowLayout.LEFT)); panSetting.add( new Label(Messages.getString("CommonSettingsDialog.tooltipDelay")) ); //$NON-NLS-1$ tooltipDelay = new TextField(4); panSetting.add( tooltipDelay ); tempPanel.add( panSetting ); panSetting = new Panel(new FlowLayout(FlowLayout.LEFT)); unitStartChar = new Choice(); // Add option for "A, B, C, D..." unitStartChar.addItem( "\u0041, \u0042, \u0043, \u0044..." ); //$NON-NLS-1$ // Add option for "ALPHA, BETA, GAMMA, DELTA..." unitStartChar.addItem( "\u0391, \u0392, \u0393, \u0394..." ); //$NON-NLS-1$ // Add option for "alpha, beta, gamma, delta..." unitStartChar.addItem( "\u03B1, \u03B2, \u03B3, \u03B4..." ); //$NON-NLS-1$ panSetting.add( unitStartChar ); panSetting.add( new Label(Messages.getString("CommonSettingsDialog.protoMechUnitCodes")) ); //$NON-NLS-1$ panSetting = new Panel(new FlowLayout(FlowLayout.LEFT)); panSetting.add( new Label(Messages.getString("CommonSettingsDialog.pathFiderTimeLimit")) ); //$NON-NLS-1$ maxPathfinderTime = new TextField(5); panSetting.add( maxPathfinderTime ); tempPanel.add( panSetting ); getFocus = new Checkbox( Messages.getString("CommonSettingsDialog.getFocus")); //$NON-NLS-1$ tempPanel.add( getFocus ); tempPanel.add( panSetting ); // player-specific settings defaultAutoejectDisabled = new Checkbox( Messages.getString("CommonSettingsDialog.defaultAutoejectDisabled") ); //$NON-NLS-1$ defaultAutoejectDisabled.addItemListener(this); tempPanel.add( defaultAutoejectDisabled ); showUnitId = new Checkbox ( Messages.getString("CommonSettingsDialog.showUnitId")); //$NON-NLS-1$ showUnitId.addItemListener(this); tempPanel.add( showUnitId ); // client-side gameLog settings keepGameLog = new Checkbox( Messages.getString("CommonSettingsDialog.keepGameLog") ); //$NON-NLS-1$ keepGameLog.addItemListener(this); tempPanel.add( keepGameLog ); panSetting = new Panel(new FlowLayout(FlowLayout.LEFT)); panSetting.add( new Label(Messages.getString("CommonSettingsDialog.logFileName")) ); //$NON-NLS-1$ gameLogFilename = new TextField(15); panSetting.add( gameLogFilename ); tempPanel.add( panSetting ); panSetting = new Panel(new FlowLayout(FlowLayout.LEFT)); panSetting.add( new Label(Messages.getString("CommonSettingsDialog.tileset")) ); //$NON-NLS-1$ tileSetChoice = new Choice(); panSetting.add( tileSetChoice ); tempPanel.add( panSetting ); /* panSetting = new Panel(new FlowLayout(FlowLayout.LEFT)); panSetting.add( new Label(Messages.getString("CommonSettingsDialog.logFileMaxSize")) ); //$NON-NLS-1$ gameLogMaxSize = new TextField(5); panSetting.add( gameLogMaxSize ); tempPanel.add( panSetting ); */ stampFilenames = new Checkbox( Messages.getString("CommonSettingsDialog.stampFilenames") ); //$NON-NLS-1$ stampFilenames.addItemListener(this); tempPanel.add( stampFilenames ); panSetting = new Panel(new FlowLayout(FlowLayout.LEFT)); panSetting.add( new Label(Messages.getString("CommonSettingsDialog.stampFormat")) ); //$NON-NLS-1$ stampFormat = new TextField(15); panSetting.add( stampFormat ); tempPanel.add( panSetting ); // scrolling options tempPanel.add( new AdvancedLabel(Messages.getString("CommonSettingsDialog.mapScrollText")) ); //$NON-NLS-1$ rightDragScroll = new Checkbox( Messages.getString("CommonSettingsDialog.rightDragScroll") ); //$NON-NLS-1$
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -