|
29 | 29 | import megamek.common.loaders.BLKFile;
|
30 | 30 | import mekhq.Utilities;
|
31 | 31 | import mekhq.campaign.finances.Transaction;
|
| 32 | +import mekhq.campaign.parts.Armor; |
32 | 33 | import mekhq.campaign.parts.Part;
|
33 | 34 | import mekhq.campaign.parts.equipment.AmmoBin;
|
34 | 35 | import mekhq.campaign.personnel.Person;
|
@@ -532,6 +533,27 @@ public void actionPerformed(ActionEvent action) {
|
532 | 533 | gui.refreshUnitView();
|
533 | 534 | gui.refreshOrganization();
|
534 | 535 | }
|
| 536 | + } else if(command.equalsIgnoreCase("RESTORE_UNIT")) { |
| 537 | + for (Unit unit : units) { |
| 538 | + if(unit.isAvailable() && (unit.getPartsNeedingFixing().size() > 0)) { |
| 539 | + for(Part part : unit.getPartsNeedingFixing()) { |
| 540 | + if(part instanceof Armor) { |
| 541 | + final Armor armor = (Armor) part; |
| 542 | + armor.setAmount(armor.getTotalAmount()); |
| 543 | + } |
| 544 | + part.fix(); |
| 545 | + part.resetTimeSpent(); |
| 546 | + part.resetOvertime(); |
| 547 | + part.setTeamId(null); |
| 548 | + part.cancelReservation(); |
| 549 | + } |
| 550 | + } |
| 551 | + } |
| 552 | + gui.refreshServicedUnitList(); |
| 553 | + gui.refreshUnitList(); |
| 554 | + gui.refreshTaskList(); |
| 555 | + gui.refreshUnitView(); |
| 556 | + gui.refreshOrganization(); |
535 | 557 | }
|
536 | 558 | }
|
537 | 559 |
|
@@ -624,8 +646,7 @@ private void maybeShowPopup(MouseEvent e) {
|
624 | 646 | .getEntity(), curType, gui.getCampaign()
|
625 | 647 | .getCampaignOptions().getTechLevel())) {
|
626 | 648 | cbMenuItem = new JCheckBoxMenuItem(atype.getDesc());
|
627 |
| - if (atype.equals(curType) |
628 |
| - && atype.getMunitionType() == curType.getMunitionType()) { |
| 649 | + if (atype.equals(curType) && atype.getMunitionType() == curType.getMunitionType()) { |
629 | 650 | cbMenuItem.setSelected(true);
|
630 | 651 | } else {
|
631 | 652 | cbMenuItem.setActionCommand("SWAP_AMMO:"
|
@@ -882,6 +903,11 @@ private void maybeShowPopup(MouseEvent e) {
|
882 | 903 | menuItem.addActionListener(this);
|
883 | 904 | menuItem.setEnabled(gui.getCampaign().isGM());
|
884 | 905 | menu.add(menuItem);
|
| 906 | + menuItem = new JMenuItem("Restore Unit"); |
| 907 | + menuItem.setActionCommand("RESTORE_UNIT"); |
| 908 | + menuItem.addActionListener(this); |
| 909 | + menuItem.setEnabled(gui.getCampaign().isGM()); |
| 910 | + menu.add(menuItem); |
885 | 911 | menuItem = new JMenuItem("Set Quality...");
|
886 | 912 | menuItem.setActionCommand("SET_QUALITY");
|
887 | 913 | menuItem.addActionListener(this);
|
|
0 commit comments