Skip to content

Commit

Permalink
Merge pull request #919 from MegaMek/spreadable_mount_locations
Browse files Browse the repository at this point in the history
Show multiple equipment locations on the record sheet
  • Loading branch information
neoancient authored Jun 5, 2021
2 parents 13e675b + b179a87 commit 55b353b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
25 changes: 21 additions & 4 deletions src/megameklab/com/printing/StandardInventoryEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
import megamek.common.weapons.other.ISCenturionWeaponSystem;
import megameklab.com.util.CConfig;
import megameklab.com.util.StringUtils;
import megameklab.com.util.UnitUtil;

import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;

/**
* Formats text for an entry in the weapons and equipment inventory section of the record sheet.
Expand Down Expand Up @@ -318,11 +320,26 @@ private String formatLocation() {
return AERODYNE_ARCS[mount.getLocation()];
}
}
if (mount.getSecondLocation() != Entity.LOC_NONE) {
return mount.getEntity().getLocationAbbr(mount.getLocation())
+ "/" + mount.getEntity().getLocationAbbr(mount.getSecondLocation());
return mount.getEntity().joinLocationAbbr(mount.allLocations(), 2);
}

/**
* Handles some special conditions where equipment occupying three or more locations can be
* abbreviated to conserve space.
*
* @param locations The list of locations the equipment occupies
* @return The abbreviated location string
*/
private String formatMechLocations(List<Integer> locations) {
if (locations.stream().allMatch(l -> mount.getEntity().locationIsLeg(l))) {
if ((mount.getEntity().entityIsQuad() && (locations.size() == 4))
|| ((mount.getEntity() instanceof TripodMech) && (locations.size() == 3))) {
return "Legs";
}
} else if (locations.stream().allMatch(l -> ((Mech) mount.getEntity()).locationIsTorso(l))) {
return "R/L/CT";
}
return mount.getEntity().getLocationAbbr(mount.getLocation());
return "*";
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/megameklab/com/util/CriticalTableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public Object getValueAt(int row, int col) {
return BattleArmor.getBaMountLocAbbr(crit
.getBaMountLoc());
} else {
return unit.getLocationAbbr(crit.getLocation());
return unit.joinLocationAbbr(crit.allLocations(), 2);
}
case SIZE:
if (crit.getType().isVariableSize()) {
Expand Down

0 comments on commit 55b353b

Please sign in to comment.