Skip to content

Commit 72c1771

Browse files
committed
Adding "restore unit" GM-mode menu item to the hangar.
1 parent 7164aed commit 72c1771

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

MekHQ/src/mekhq/gui/adapter/UnitTableMouseAdapter.java

+28-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import megamek.common.loaders.BLKFile;
3030
import mekhq.Utilities;
3131
import mekhq.campaign.finances.Transaction;
32+
import mekhq.campaign.parts.Armor;
3233
import mekhq.campaign.parts.Part;
3334
import mekhq.campaign.parts.equipment.AmmoBin;
3435
import mekhq.campaign.personnel.Person;
@@ -532,6 +533,27 @@ public void actionPerformed(ActionEvent action) {
532533
gui.refreshUnitView();
533534
gui.refreshOrganization();
534535
}
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();
535557
}
536558
}
537559

@@ -624,8 +646,7 @@ private void maybeShowPopup(MouseEvent e) {
624646
.getEntity(), curType, gui.getCampaign()
625647
.getCampaignOptions().getTechLevel())) {
626648
cbMenuItem = new JCheckBoxMenuItem(atype.getDesc());
627-
if (atype.equals(curType)
628-
&& atype.getMunitionType() == curType.getMunitionType()) {
649+
if (atype.equals(curType) && atype.getMunitionType() == curType.getMunitionType()) {
629650
cbMenuItem.setSelected(true);
630651
} else {
631652
cbMenuItem.setActionCommand("SWAP_AMMO:"
@@ -882,6 +903,11 @@ private void maybeShowPopup(MouseEvent e) {
882903
menuItem.addActionListener(this);
883904
menuItem.setEnabled(gui.getCampaign().isGM());
884905
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);
885911
menuItem = new JMenuItem("Set Quality...");
886912
menuItem.setActionCommand("SET_QUALITY");
887913
menuItem.addActionListener(this);

0 commit comments

Comments
 (0)