📄 custommechdialog.java
字号:
.append( this.entity.getId() ); labCallsign.setText( callsign.toString() ); c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.CENTER; gridbag.setConstraints(labCallsign, c); tempPanel.add(labCallsign); // Get the Protomechs of this entity's player // that *aren't* in the entity's unit. Enumeration otherUnitEntities = client.game.getSelectedEntities ( new EntitySelector() { private final int ownerId = CustomMechDialog.this.entity.getOwnerId(); private final char unitNumber = CustomMechDialog.this.entity.getUnitNumber(); public boolean accept( Entity entity ) { if ( entity instanceof Protomech && ownerId == entity.getOwnerId() && unitNumber != entity.getUnitNumber() ) return true; return false; } } ); // If we got any other entites, show the unit number controls. if ( otherUnitEntities.hasMoreElements() ) { c.gridwidth = 1; c.anchor = GridBagConstraints.EAST; gridbag.setConstraints(labUnitNum, c); tempPanel.add(labUnitNum); c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.WEST; gridbag.setConstraints(choUnitNum, c); tempPanel.add(choUnitNum); refreshUnitNum(otherUnitEntities); } } // Can't set up munitions on infantry. if ( !(entity instanceof Infantry) ) { setupMunitions(); c.anchor = GridBagConstraints.CENTER; gridbag.setConstraints(panMunitions, c); tempPanel.add(panMunitions); } // Set up rapidfire mg if (clientgui.getClient().game.getOptions().booleanOption("maxtech_burst")) { //$NON-NLS-1$ c.gridwidth = 1; setupRapidfireMGs(); c.anchor = GridBagConstraints.CENTER; gridbag.setConstraints(panRapidfireMGs, c); tempPanel.add(panRapidfireMGs); } // Set up searchlight if (clientgui.getClient().game.getOptions().booleanOption("night_battle")) { //$NON-NLS-1$ c.gridwidth = 1; c.anchor = GridBagConstraints.EAST; gridbag.setConstraints(labSearchlight, c); tempPanel.add(labSearchlight); c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.WEST; gridbag.setConstraints(chSearchlight, c); tempPanel.add(chSearchlight); chSearchlight.setState(entity.hasSpotlight()); } // Set up mines setupMines(); c.anchor = GridBagConstraints.CENTER; gridbag.setConstraints(panMines, c); tempPanel.add(panMines); setupButtons(); c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.CENTER; gridbag.setConstraints(panButtons, c); tempPanel.add(panButtons); fldName.setText(entity.getCrew().getName()); fldName.addActionListener(this); fldGunnery.setText(new Integer(entity.getCrew().getGunnery()).toString()); fldGunnery.addActionListener(this); fldPiloting.setText(new Integer(entity.getCrew().getPiloting()).toString()); fldPiloting.addActionListener(this); if (!editable) { fldName.setEnabled(false); fldGunnery.setEnabled(false); fldPiloting.setEnabled(false); choC3.setEnabled(false); choDeployment.setEnabled(false); chAutoEject.setEnabled(false); chSearchlight.setEnabled(false); choTargSys.setEnabled(false); disableMunitionEditing(); disableMGSetting(); disableMineSetting(); chOffBoard.setEnabled(false); choOffBoardDirection.setEnabled(false); fldOffBoardDistance.setEnabled(false); } scrAll.add(tempPanel); // add the scrollable panel this.add(scrAll); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { setVisible(false); } }); pack(); //Why do we have to add all this stuff together to get the // right size? I hate GUI programming...especially AWT. int w = tempPanel.getPreferredSize().width + scrAll.getInsets().right; int h = tempPanel.getPreferredSize().height + panButtons.getPreferredSize().height + scrAll.getInsets().bottom; setLocationAndSize(w,h); } private void setupButtons() { butOkay.addActionListener(this); butCancel.addActionListener(this); butNext.addActionListener(this); butPrev.addActionListener(this); // layout panButtons.setLayout(new GridLayout(1, 4, 10, 0)); panButtons.add(butPrev); panButtons.add(butOkay); panButtons.add(butCancel); panButtons.add(butNext); butNext.setEnabled(getNextEntity(true) != null); butPrev.setEnabled(getNextEntity(false) != null); } private void setupRapidfireMGs() { GridBagLayout gbl = new GridBagLayout(); panRapidfireMGs.setLayout(gbl); GridBagConstraints gbc = new GridBagConstraints(); int row = 0; for (Mounted m : entity.getWeaponList()) { WeaponType wtype = (WeaponType)m.getType(); if (!wtype.hasFlag(WeaponType.F_MG)) { continue; } gbc.gridy = row++; RapidfireMGPanel rmp = new RapidfireMGPanel(m); gbl.setConstraints(rmp, gbc); panRapidfireMGs.add(rmp); m_vMGs.addElement(rmp); } } private void setupMines() { GridBagLayout gbl = new GridBagLayout(); panMines.setLayout(gbl); GridBagConstraints gbc = new GridBagConstraints(); int row = 0; for (Mounted m : entity.getMisc()) { if (!m.getType().hasFlag((MiscType.F_MINE))) { continue; } gbc.gridy = row++; MineChoicePanel mcp = new MineChoicePanel(m); gbl.setConstraints(mcp, gbc); panMines.add(mcp); m_vMines.addElement(mcp); } } private void setupMunitions() { GridBagLayout gbl = new GridBagLayout(); panMunitions.setLayout(gbl); GridBagConstraints gbc = new GridBagConstraints(); int row = 0; for (Mounted m : entity.getAmmo()) { AmmoType at = (AmmoType)m.getType(); Vector vTypes = new Vector(); Vector vAllTypes = AmmoType.getMunitionsFor(at.getAmmoType()); if (vAllTypes == null) { continue; } for (int x = 0, n = vAllTypes.size(); x < n; x++) { AmmoType atCheck = (AmmoType)vAllTypes.elementAt(x); boolean bTechMatch = TechConstants.isLegal(entity.getTechLevel(), atCheck.getTechLevel()); // allow all lvl2 IS units to use level 1 ammo // lvl1 IS units don't need to be allowed to use lvl1 ammo, // because there is no special lvl1 ammo, therefore it doesn't // need to show up in this display. if (!bTechMatch && entity.getTechLevel() == TechConstants.T_IS_LEVEL_2 && atCheck.getTechLevel() == TechConstants.T_IS_LEVEL_1) { bTechMatch = true; } // if is_eq_limits is unchecked allow l1 guys to use l2 stuff if (!clientgui.getClient().game.getOptions().booleanOption("is_eq_limits") //$NON-NLS-1$ && entity.getTechLevel() == TechConstants.T_IS_LEVEL_1 && atCheck.getTechLevel() == TechConstants.T_IS_LEVEL_2) { bTechMatch = true; } // Possibly allow level 3 ammos, possibly not. if (clientgui.getClient().game.getOptions().booleanOption("allow_level_3_ammo")) { if (!clientgui.getClient().game.getOptions().booleanOption("is_eq_limits")) { if (entity.getTechLevel() == TechConstants.T_CLAN_LEVEL_2 && atCheck.getTechLevel() == TechConstants.T_CLAN_LEVEL_3) { bTechMatch = true; } if (((entity.getTechLevel() == TechConstants.T_IS_LEVEL_1) || (entity.getTechLevel() == TechConstants.T_IS_LEVEL_2)) && (atCheck.getTechLevel() == TechConstants.T_IS_LEVEL_3)) { bTechMatch = true; } } } else if ((atCheck.getTechLevel() == TechConstants.T_IS_LEVEL_3) || (atCheck.getTechLevel() == TechConstants.T_CLAN_LEVEL_3)) { bTechMatch = false; } //allow mixed Tech Mechs to use both IS and Clan ammo of any // level (since mixed tech is always level 3) if (entity.isMixedTech()) { bTechMatch = true; } // If clan_ignore_eq_limits is unchecked, // do NOT allow Clans to use IS-only ammo. // N.B. play bit-shifting games to allow "incendiary" // to be combined to other munition types. long muniType = atCheck.getMunitionType(); muniType &= ~AmmoType.M_INCENDIARY_LRM; if ( !clientgui.getClient().game.getOptions().booleanOption("clan_ignore_eq_limits") //$NON-NLS-1$ && entity.isClan() && ( muniType == AmmoType.M_SEMIGUIDED || muniType == AmmoType.M_SWARM_I || muniType == AmmoType.M_FLARE || muniType == AmmoType.M_FRAGMENTATION || muniType == AmmoType.M_THUNDER_AUGMENTED || muniType == AmmoType.M_THUNDER_INFERNO || muniType == AmmoType.M_THUNDER_VIBRABOMB || muniType == AmmoType.M_THUNDER_ACTIVE || muniType == AmmoType.M_INFERNO_IV || muniType == AmmoType.M_VIBRABOMB_IV || muniType == AmmoType.M_LISTEN_KILL || muniType == AmmoType.M_ANTI_TSM)) { bTechMatch = false; } if ( !clientgui.getClient().game.getOptions().booleanOption("minefields") && //$NON-NLS-1$ AmmoType.canDeliverMinefield(atCheck) ) { continue; } // Only Protos can use Proto-specific ammo if ( atCheck.hasFlag(AmmoType.F_PROTOMECH) && !(entity instanceof Protomech) ) { continue; } // When dealing with machine guns, Protos can only // use proto-specific machine gun ammo if ( entity instanceof Protomech && atCheck.hasFlag(AmmoType.F_MG) && !atCheck.hasFlag(AmmoType.F_PROTOMECH) ) { continue; } // Battle Armor ammo can't be selected at all. // All other ammo types need to match on rack size and tech. if ( bTechMatch && atCheck.getRackSize() == at.getRackSize() && !atCheck.hasFlag(AmmoType.F_BATTLEARMOR) && atCheck.getTonnage(entity) == at.getTonnage(entity) ) { vTypes.addElement(atCheck); } } if (vTypes.size() < 2 && !client.game.getOptions().booleanOption("lobby_ammo_dump")) { //$NON-NLS-1$ continue; } gbc.gridy = row++; // Protomechs need special choice panels. MunitionChoicePanel mcp = null; if ( entity instanceof Protomech ) { mcp = new ProtomechMunitionChoicePanel(m, vTypes); } else { mcp = new MunitionChoicePanel(m, vTypes); } gbl.setConstraints(mcp, gbc); panMunitions.add(mcp); m_vMunitions.addElement(mcp); } } class MineChoicePanel extends Panel { private Choice m_choice; private Mounted m_mounted; public MineChoicePanel(Mounted m) { m_mounted = m; m_choice = new Choice(); m_choice.add(Messages.getString("CustomMechDialog.Conventional")); //$NON-NLS-1$ m_choice.add(Messages.getString("CustomMechDialog.Vibrabomb")); //$NON-NLS-1$ //m_choice.add("Messages.getString("CustomMechDialog.Command-detonated")); //$NON-NLS-1$ int loc; 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();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -