📄 custommechdialog.java
字号:
c.gridx = 0; c.gridy = 0; c.anchor = GridBagConstraints.EAST; g.setConstraints(lLoc, c); add(lLoc); c.gridx = 1; c.gridy = 0; c.anchor = GridBagConstraints.WEST; g.setConstraints(m_choice, c); m_choice.select(m.getMineType()); add(m_choice); } public void applyChoice() { m_mounted.setMineType(m_choice.getSelectedIndex()); } public void setEnabled(boolean enabled) { m_choice.setEnabled(enabled); } } class MunitionChoicePanel extends Panel { private Vector m_vTypes; private Choice m_choice; private Mounted m_mounted; protected Label labDump = new Label(Messages.getString("CustomMechDialog.labDump")); //$NON-NLS-1$ protected Checkbox chDump = new Checkbox(); protected Label labHotLoad= new Label(Messages.getString("CustomMechDialog.switchToHotLoading")); //$NON-NLS-1$ protected Checkbox chHotLoad = new Checkbox(); public MunitionChoicePanel(Mounted m, Vector vTypes) { m_vTypes = vTypes; m_mounted = m; AmmoType curType = (AmmoType)m.getType(); m_choice = new Choice(); Enumeration e = m_vTypes.elements(); for (int x = 0; e.hasMoreElements(); x++) { AmmoType at = (AmmoType)e.nextElement(); m_choice.add(at.getName()); if (at.getMunitionType() == curType.getMunitionType()) { m_choice.select(x); } } int loc; if (m.getLocation() == Entity.LOC_NONE) { // oneshot weapons don't have a location of their own Mounted linkedBy = m.getLinkedBy(); loc = linkedBy.getLocation(); } else { loc = m.getLocation(); } String sDesc = "(" + entity.getLocationAbbr(loc) + ")"; //$NON-NLS-1$ //$NON-NLS-2$ Label lLoc = new Label(sDesc); GridBagLayout g = new GridBagLayout(); setLayout(g); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.anchor = GridBagConstraints.EAST; g.setConstraints(lLoc, c); add(lLoc); c.gridx = 1; c.gridy = 0; c.anchor = GridBagConstraints.WEST; g.setConstraints(m_choice, c); add(m_choice); if (clientgui.getClient().game.getOptions().booleanOption("lobby_ammo_dump") ) { //$NON-NLS-1$ c.gridx = 0; c.gridy = 1; c.anchor = GridBagConstraints.EAST; g.setConstraints(labDump, c); add(labDump); c.gridx = 1; c.gridy = 1; c.anchor = GridBagConstraints.WEST; g.setConstraints(chDump, c); add(chDump); if (clientgui.getClient().game.getOptions().booleanOption("maxtech_hotload") && curType.hasFlag(AmmoType.F_HOTLOAD) ) { //$NON-NLS-1$ c.gridx = 0; c.gridy = 2; c.anchor = GridBagConstraints.EAST; g.setConstraints(labHotLoad, c); add(labHotLoad); c.gridx = 1; c.gridy = 2; c.anchor = GridBagConstraints.WEST; g.setConstraints(chHotLoad, c); add(chHotLoad); } }else if (clientgui.getClient().game.getOptions().booleanOption("maxtech_hotload") && curType.hasFlag(AmmoType.F_HOTLOAD) ) { //$NON-NLS-1$ c.gridx = 0; c.gridy = 1; c.anchor = GridBagConstraints.EAST; g.setConstraints(labHotLoad, c); add(labHotLoad); c.gridx = 1; c.gridy = 1; c.anchor = GridBagConstraints.WEST; g.setConstraints(chHotLoad, c); add(chHotLoad); } } public void applyChoice() { int n = m_choice.getSelectedIndex(); AmmoType at = (AmmoType)m_vTypes.elementAt(n); m_mounted.changeAmmoType(at); if (chDump.getState()) { m_mounted.setShotsLeft(0); } if (clientgui.getClient().game.getOptions().booleanOption("maxtech_hotload")){ if ( chHotLoad.getState() != m_mounted.isHotLoaded() ) m_mounted.setHotLoad(chHotLoad.getState()); } } public void setEnabled(boolean enabled) { m_choice.setEnabled(enabled); } /** * Get the number of shots in the mount. * * @return the <code>int</code> number of shots in the mount. */ /* package */ int getShotsLeft() { return m_mounted.getShotsLeft(); } /** * Set the number of shots in the mount. * * @param shots the <code>int</code> number of shots for the mount. */ /* package */ void setShotsLeft( int shots ) { m_mounted.setShotsLeft( shots ); } } /** * When a Protomech selects ammo, you need to adjust the shots on the * unit for the weight of the selected munition. */ class ProtomechMunitionChoicePanel extends MunitionChoicePanel { private final float m_origShotsLeft; private final AmmoType m_origAmmo; public ProtomechMunitionChoicePanel(Mounted m, Vector vTypes) { super( m, vTypes ); m_origAmmo = (AmmoType) m.getType(); m_origShotsLeft = m.getShotsLeft(); } /** * All ammo must be applied in ratios to the starting load. */ public void applyChoice() { super.applyChoice(); // Calculate the number of shots for the new ammo. // N.B. Some special ammos are twice as heavy as normal // so they have half the number of shots (rounded down). setShotsLeft( Math.round( getShotsLeft() * m_origShotsLeft / m_origAmmo.getShots() ) ); if (chDump.getState()) { setShotsLeft(0); } } } class RapidfireMGPanel extends Panel { private Mounted m_mounted; protected Checkbox chRapid = new Checkbox(); public RapidfireMGPanel(Mounted m) { m_mounted = m; int loc = m.getLocation(); String sDesc = Messages.getString("CustomMechDialog.switchToRapidFire", new Object[]{entity.getLocationAbbr(loc)}); //$NON-NLS-1$ Label labRapid = new Label(sDesc); GridBagLayout g = new GridBagLayout(); setLayout(g); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.anchor = GridBagConstraints.EAST; g.setConstraints(labRapid, c); add(labRapid); c.gridx = 1; c.gridy = 0; c.anchor = GridBagConstraints.WEST; g.setConstraints(chRapid, c); chRapid.setState(m.isRapidfire()); add(chRapid); } public void applyChoice() { boolean b = chRapid.getState(); m_mounted.setRapidfire(b); } public void setEnabled(boolean enabled) { chRapid.setEnabled(enabled); } } public void disableMunitionEditing() { for (int i = 0; i < m_vMunitions.size(); i++) { ((MunitionChoicePanel)m_vMunitions.elementAt(i)).setEnabled(false); } } public void disableMGSetting() { for (int i = 0; i < m_vMGs.size(); i++) { ((RapidfireMGPanel)m_vMGs.elementAt(i)).setEnabled(false); } } public void disableMineSetting() { for (int i = 0; i < m_vMines.size(); i++) { ((MineChoicePanel)m_vMines.elementAt(i)).setEnabled(false); } } public void setOptions() { IOption option; for (Enumeration i = optionComps.elements(); i.hasMoreElements();) { DialogOptionComponent comp = (DialogOptionComponent)i.nextElement(); option = comp.getOption(); if ( (comp.getValue() == Messages.getString("CustomMechDialog.None")) ) { //NON-NLS-$1 entity.getCrew().getOptions().getOption(option.getName()).setValue("None"); //NON-NLS-$1 } else entity.getCrew().getOptions().getOption(option.getName()).setValue(comp.getValue()); } } public void resetOptions() { IOption option; for (Enumeration i = optionComps.elements(); i.hasMoreElements();) { DialogOptionComponent comp = (DialogOptionComponent)i.nextElement(); option = comp.getOption(); option.setValue(false); entity.getCrew().getOptions().getOption(option.getName()).setValue(comp.getValue()); } } public void refreshOptions() { panOptions.removeAll(); optionComps = new Vector(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); panOptions.setLayout(gridbag); c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.HORIZONTAL; c.insets = new Insets(0, 0, 0, 0); c.ipadx = 0; c.ipady = 0; for (Enumeration i = options.getGroups(); i.hasMoreElements();) { IOptionGroup group = (IOptionGroup)i.nextElement(); addGroup(group, gridbag, c); for (Enumeration j = group.getOptions(); j.hasMoreElements();) { IOption option = (IOption)j.nextElement(); addOption(option, gridbag, c, editable); } } validate(); } private void addGroup(IOptionGroup group, GridBagLayout gridbag, GridBagConstraints c) { Label groupLabel = new Label(group.getDisplayableName()); gridbag.setConstraints(groupLabel, c); panOptions.add(groupLabel); } private void addOption(IOption option, GridBagLayout gridbag, GridBagConstraints c, boolean editable) { DialogOptionComponent optionComp = new DialogOptionComponent(this, option, editable); if (option.getName().equals("weapon_specialist")) { //$NON-NLS-1$ optionComp.addValue(Messages.getString("CustomMechDialog.None")); //$NON-NLS-1$ Hashtable uniqueWeapons = new Hashtable(); for (int i = 0; i < entity.getWeaponList().size(); i++) { Mounted m = entity.getWeaponList().get(i); uniqueWeapons.put(m.getName(),new Boolean(true)); } for (Enumeration e = uniqueWeapons.keys(); e.hasMoreElements(); ) { optionComp.addValue((String)e.nextElement()); } optionComp.setSelected(option.stringValue()); } gridbag.setConstraints(optionComp, c); panOptions.add(optionComp); optionComps.addElement(optionComp); } public void showDescFor(IOption option) { texDesc.setText(option.getDescription()); } // TODO : implement me!!! public void optionClicked( DialogOptionComponent comp, IOption option, boolean state ) { } public boolean isOkay() { return okay; } private void refreshDeployment() { choDeployment.removeAll(); choDeployment.add(Messages.getString("CustomMechDialog.StartOfGame")); //$NON-NLS-1$ if ( entity.getDeployRound() < 1 )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -