📄 mechdisplay.java
字号:
wRangeR.setOpaque(true); wToHitR = new JLabel("---", JLabel.CENTER); //$NON-NLS-1$ wToHitR.setOpaque(true); c.weightx = 0.0; c.insets = new Insets(2, 9, 1, 1); c.gridx = 0; c.gridy = 7; c.gridwidth = 1; ((GridBagLayout) getLayout()).setConstraints(wTargetL, c); add(wTargetL); c.insets = new Insets(2, 1, 1, 9); c.gridx = 1; c.gridy = 7; c.gridwidth = GridBagConstraints.REMAINDER; ((GridBagLayout) getLayout()).setConstraints(wTargetR, c); add(wTargetR); c.insets = new Insets(1, 9, 1, 1); c.gridx = 0; c.gridy = 8; c.gridwidth = 1; ((GridBagLayout) getLayout()).setConstraints(wRangeL, c); add(wRangeL); c.insets = new Insets(1, 1, 1, 9); c.gridx = 1; c.gridy = 8; c.gridwidth = GridBagConstraints.REMAINDER; ((GridBagLayout) getLayout()).setConstraints(wRangeR, c); add(wRangeR); c.insets = new Insets(1, 9, 1, 1); c.gridx = 0; c.gridy = 9; c.gridwidth = 1; ((GridBagLayout) getLayout()).setConstraints(wToHitL, c); add(wToHitL); c.insets = new Insets(1, 1, 1, 9); c.gridx = 1; c.gridy = 9; c.gridwidth = GridBagConstraints.REMAINDER; ((GridBagLayout) getLayout()).setConstraints(wToHitR, c); add(wToHitR); // to-hit text toHitText = new JTextArea("", 2, 20); //$NON-NLS-1$ toHitText.setEditable(false); c.insets = new Insets(1, 9, 15, 9); c.gridx = 0; c.gridy = 10; c.gridwidth = GridBagConstraints.REMAINDER; ((GridBagLayout) getLayout()).setConstraints(toHitText, c); add(toHitText); setBackGround(); } private void setBackGround() { Image tile = getToolkit().getImage(IMAGE_DIR + "/tile.gif"); //$NON-NLS-1$ PMUtil.setImage(tile, this); int b = BackGroundDrawer.TILING_BOTH; addBgDrawer(new BackGroundDrawer(tile, b)); b = BackGroundDrawer.TILING_HORIZONTAL | BackGroundDrawer.VALIGN_TOP; tile = getToolkit().getImage(IMAGE_DIR + "/h_line.gif"); //$NON-NLS-1$ PMUtil.setImage(tile, this); addBgDrawer(new BackGroundDrawer(tile, b)); b = BackGroundDrawer.TILING_HORIZONTAL | BackGroundDrawer.VALIGN_BOTTOM; tile = getToolkit().getImage(IMAGE_DIR + "/h_line.gif"); //$NON-NLS-1$ PMUtil.setImage(tile, this); addBgDrawer(new BackGroundDrawer(tile, b)); b = BackGroundDrawer.TILING_VERTICAL | BackGroundDrawer.HALIGN_LEFT; tile = getToolkit().getImage(IMAGE_DIR + "/v_line.gif"); //$NON-NLS-1$ PMUtil.setImage(tile, this); addBgDrawer(new BackGroundDrawer(tile, b)); b = BackGroundDrawer.TILING_VERTICAL | BackGroundDrawer.HALIGN_RIGHT; tile = getToolkit().getImage(IMAGE_DIR + "/v_line.gif"); //$NON-NLS-1$ PMUtil.setImage(tile, this); addBgDrawer(new BackGroundDrawer(tile, b)); b = BackGroundDrawer.NO_TILING | BackGroundDrawer.VALIGN_TOP | BackGroundDrawer.HALIGN_LEFT; tile = getToolkit().getImage(IMAGE_DIR + "/tl_corner.gif"); //$NON-NLS-1$ PMUtil.setImage(tile, this); addBgDrawer(new BackGroundDrawer(tile, b)); b = BackGroundDrawer.NO_TILING | BackGroundDrawer.VALIGN_BOTTOM | BackGroundDrawer.HALIGN_LEFT; tile = getToolkit().getImage(IMAGE_DIR + "/bl_corner.gif"); //$NON-NLS-1$ PMUtil.setImage(tile, this); addBgDrawer(new BackGroundDrawer(tile, b)); b = BackGroundDrawer.NO_TILING | BackGroundDrawer.VALIGN_TOP | BackGroundDrawer.HALIGN_RIGHT; tile = getToolkit().getImage(IMAGE_DIR + "/tr_corner.gif"); //$NON-NLS-1$ PMUtil.setImage(tile, this); addBgDrawer(new BackGroundDrawer(tile, b)); b = BackGroundDrawer.NO_TILING | BackGroundDrawer.VALIGN_BOTTOM | BackGroundDrawer.HALIGN_RIGHT; tile = getToolkit().getImage(IMAGE_DIR + "/br_corner.gif"); //$NON-NLS-1$ PMUtil.setImage(tile, this); addBgDrawer(new BackGroundDrawer(tile, b)); } /** * updates fields for the specified mech * <p/> * fix the ammo when it's added */ public void displayMech(Entity en) { // Grab a copy of the game. IGame game = clientgui.getClient().game; // update pointer to weapons entity = en; int currentHeatBuildup = en.heat // heat from last round + en.getEngineCritHeat() // heat engine crits will add + en.heatBuildup; // heat we're building up this round if (en instanceof Mech) { if (en.infernos.isStillBurning()) { // hit with inferno ammo currentHeatBuildup += en.infernos.getHeat(); } if (!((Mech) en).hasLaserHeatSinks()) { // extreme temperatures. if (game.getOptions().intOption("temperature") > 0) { currentHeatBuildup += game.getTemperatureDifference(); } else { currentHeatBuildup -= game.getTemperatureDifference(); } } } Coords position = entity.getPosition(); if (!en.isOffBoard() && position != null) { IHex hex = game.getBoard().getHex(position); if (hex.terrainLevel(Terrains.FIRE) == 2) { currentHeatBuildup += 5; // standing in fire } if (hex.terrainLevel(Terrains.MAGMA) == 1) { currentHeatBuildup += 5; } else if (hex.terrainLevel(Terrains.MAGMA) == 2) { currentHeatBuildup += 10; } } if (en instanceof Mech && en.isStealthActive()) { currentHeatBuildup += 10; // active stealth heat } // update weapon list ((DefaultListModel) weaponList.getModel()).removeAllElements(); m_chAmmo.removeAll(); m_chAmmo.setEnabled(false); for (int i = 0; i < entity.getWeaponList().size(); i++) { Mounted mounted = entity.getWeaponList().get(i); WeaponType wtype = (WeaponType) mounted.getType(); StringBuffer wn = new StringBuffer(mounted.getDesc()); wn.append(" ["); //$NON-NLS-1$ wn.append(en.getLocationAbbr(mounted.getLocation())); if (mounted.isSplit()) { wn.append('/'); //$NON-NLS-1$ wn.append(en.getLocationAbbr(mounted.getSecondLocation())); } wn.append(']'); //$NON-NLS-1$ // determine shots left & total shots left if (wtype.getAmmoType() != AmmoType.T_NA && !wtype.hasFlag(WeaponType.F_ONESHOT)) { int shotsLeft = 0; if (mounted.getLinked() != null && !mounted.getLinked().isDumping()) { shotsLeft = mounted.getLinked().getShotsLeft(); } EquipmentType typeUsed = null; if (mounted.getLinked() != null) { typeUsed = mounted.getLinked().getType(); } int totalShotsLeft = entity.getTotalMunitionsOfType(typeUsed); wn.append(" ("); //$NON-NLS-1$ wn.append(shotsLeft); wn.append('/'); //$NON-NLS-1$ wn.append(totalShotsLeft); wn.append(')'); //$NON-NLS-1$ } // MG rapidfire if (mounted.isRapidfire()) { wn.append(Messages.getString("MechDisplay.rapidFire")); //$NON-NLS-1$ } // Hotloaded Missile Launchers if (mounted.isHotLoaded()) { wn.append(Messages.getString("MechDisplay.isHotLoaded")); //$NON-NLS-1$ } // Fire Mode - lots of things have variable modes if (wtype.hasModes()) { wn.append(' '); wn.append(mounted.curMode().getDisplayableName()); //$NON-NLS-1$ } ((DefaultListModel) weaponList.getModel()).addElement(wn.toString()); if (mounted.isUsedThisRound() && game.getPhase() == mounted.usedInPhase() && game.getPhase() == IGame.PHASE_FIRING) { // add heat from weapons fire to heat tracker currentHeatBuildup += wtype.getHeat() * mounted.howManyShots(); } } // This code block copied from the MovementPanel class, // bad coding practice (duplicate code). int heatCap = en.getHeatCapacity(); int heatCapWater = en.getHeatCapacityWithWater(); String heatCapacityStr = Integer.toString(heatCap); if (heatCap < heatCapWater) { heatCapacityStr = heatCap + " [" + heatCapWater + ']'; //$NON-NLS-1$ //$NON-NLS-2$ } // end duplicate block String heatText = Integer.toString(currentHeatBuildup); if (currentHeatBuildup > en.getHeatCapacityWithWater()) { heatText += "*"; // overheat indication //$NON-NLS-1$ } // check for negative values due to extreme temp if (currentHeatBuildup < 0) { currentHeatBuildup = 0; } currentHeatBuildupR.setText(heatText + " (" + heatCapacityStr + ')'); //$NON-NLS-1$ //$NON-NLS-2$ // If MaxTech range rules are in play, display the extreme range. if (game.getOptions().booleanOption("maxtech_range")) { //$NON-NLS-1$ wExtL.setVisible(true); wExtR.setVisible(true); } else { wExtL.setVisible(false); wExtR.setVisible(false); } } /** * Selects the weapon at the specified index in the list */ public void selectWeapon(int wn) { if (wn == -1) { weaponList.setSelectedIndex(-1); return; } int index = entity.getWeaponList().indexOf(entity.getEquipment(wn)); weaponList.setSelectedIndex(index); displaySelected(); } /** * Selects the weapon at the specified index in the list */ public int getSelectedWeaponNum() { int selected = weaponList.getSelectedIndex(); if (selected == -1) { return -1; } return entity.getEquipmentNum(entity.getWeaponList().get(selected)); } /** * displays the selected item from the list in the weapon * display panel. */ private void displaySelected() { // short circuit if not selected if (weaponList.getSelectedIndex() == -1) { m_chAmmo.removeAll(); m_chAmmo.setEnabled(false); wNameR.setText(""); //$NON-NLS-1$ wHeatR.setText("--"); //$NON-NLS-1$ wDamR.setText("--"); //$NON-NLS-1$ wMinR.setText("---"); //$NON-NLS-1$ wShortR.setText("---"); //$NON-NLS-1$ wMedR.setText("---"); //$NON-NLS-1$ wLongR.setText("---"); //$NON-NLS-1$ wExtR.setText("---"); //$NON-NLS-1$ return; } Mounted mounted = entity.getWeaponList().get(weaponList.getSelectedIndex()); WeaponType wtype = (WeaponType) mounted.getType(); // update weapon display wNameR.setText(mounted.getDesc()); wHeatR.setText(wtype.getHeat() + ""); //$NON-NLS-1$ if (wtype.getDamage() == WeaponType.DAMAGE_MISSILE) { wDamR.setText(Messages.getString("MechDisplay.Missile")); //$NON-NLS-1$ } else if (wtype.getDamage() == WeaponType.DAMAGE_VARIABLE) { wDamR.setText(Messages.getString("MechDisplay.Variable")); //$NON-NLS-1$ } else if (wtype.getDamage() == WeaponType.DAMAGE_SPECIAL) { wDamR.setText(Messages.getString("MechDisplay.Special")); //$NON-NLS-1$ } else if (wtype.getDamage() == WeaponType.DAMAGE_ARTILLERY) { StringBuffer damage = new StringBuffer(); damage.append(Integer.toString(wtype.getRackSize())) .append('/') .append(Integer.toString(wtype.getRackSize() / 2)); wDamR.setText(damage.toString()); } else { wDamR.setText(Integer.toString(wtype.getDamage())); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -