use of megamek.common.weapons.battlearmor.ISBACompactNarc in project megameklab by MegaMek.
the class ImageHelperBattleArmor method printBattleArmorWeaponsNEquipment.
public static void printBattleArmorWeaponsNEquipment(BattleArmor ba, Graphics2D g2d, float offset) {
int typePoint = 34;
int damagePoint = 133;
int minPoint = 155;
int shtPoint = 172;
int medPoint = 188;
int longPoint = 204;
float linePoint = 150f + offset;
float maxHeight = 38.0f;
float lineFeed = 6.7f;
float stringHeight = 0f;
boolean newLineNeeded = false;
ArrayList<ArrayList<EquipmentInfo>> equipmentLocations = new ArrayList<ArrayList<EquipmentInfo>>(BattleArmor.LOC_TROOPER_6 + 1);
for (int pos = 0; pos <= BattleArmor.LOC_TROOPER_6; pos++) {
equipmentLocations.add(pos, new ArrayList<EquipmentInfo>());
}
boolean hasNarcCompact = false;
boolean hasMineLayer = false;
Mounted glove = null;
int numberOfGloves = 0;
for (Mounted eq : ba.getEquipment()) {
if ((eq.getType() instanceof AmmoType) || (eq.getLocation() == Entity.LOC_NONE) || !UnitUtil.isPrintableBAEquipment(eq.getType())) {
continue;
}
if (!hasNarcCompact && (eq.getType() instanceof ISBACompactNarc)) {
hasNarcCompact = true;
} else if (hasNarcCompact && (eq.getType() instanceof ISBACompactNarc)) {
continue;
}
if (!hasMineLayer && eq.getType().hasFlag(MiscType.F_MINE) && eq.getType().hasFlag(MiscType.F_BA_EQUIPMENT)) {
hasMineLayer = true;
} else if (hasMineLayer && eq.getType().hasFlag(MiscType.F_MINE) && eq.getType().hasFlag(MiscType.F_BA_EQUIPMENT)) {
continue;
}
if (UnitUtil.isManipulator(eq)) {
if ((glove != null) && (glove.getName().equals(eq.getName()))) {
numberOfGloves++;
continue;
} else {
glove = eq;
numberOfGloves = 1;
}
}
equipmentLocations.get(eq.getLocation()).add(new EquipmentInfo(ba, eq));
}
if (!ba.isFireResistant() && !ba.isStealthActive() && !ba.isReactive() && !ba.isReflective()) {
maxHeight += lineFeed;
}
if (ba.hasCamoSystem()) {
maxHeight -= lineFeed;
}
if (ba.isBurdened()) {
maxHeight -= lineFeed;
}
if (ba.hasDWP()) {
maxHeight -= lineFeed;
}
if (ba.isExoskeleton() && !ba.hasWorkingMisc(MiscType.F_EXTENDED_LIFESUPPORT)) {
maxHeight -= lineFeed;
}
Font font = ImageHelperBattleArmor.getBattleArmorWeaponsNEquipmentFont(g2d, false, maxHeight, equipmentLocations, 7.0f);
g2d.setFont(font);
stringHeight = ImageHelper.getStringHeight(g2d, "H", font);
// linePoint -= stringHeight / 2;
lineFeed = stringHeight;
for (int pos = BattleArmor.LOC_SQUAD; pos <= BattleArmor.LOC_TROOPER_6; pos++) {
ArrayList<EquipmentInfo> equipmentList = equipmentLocations.get(pos);
if (equipmentList.size() < 1) {
continue;
}
boolean indented = false;
if ((pos != BattleArmor.LOC_SQUAD) && !hasNarcCompact && !hasMineLayer) {
String loc = ba.getLocationName(pos);
g2d.setFont(UnitUtil.getNewFont(g2d, loc, false, 68, font.getSize()));
g2d.drawString(loc, typePoint, linePoint);
g2d.setFont(font);
linePoint += lineFeed;
typePoint += 5;
indented = true;
}
Collections.sort(equipmentList, StringUtils.equipmentInfoComparator());
for (EquipmentInfo eqi : equipmentList) {
newLineNeeded = false;
String name = eqi.name.trim();
if (eqi.isBACargolifter) {
float tons = (numberOfGloves * 0.5f) / 2.0f;
name += " (" + Double.toString(tons) + " ton" + ((tons % 1) == 0 ? "" : "s ") + "lifting capability)";
} else if (eqi.isManipulator && (numberOfGloves > 1)) {
if (!eqi.isBACargolifter) {
name += " (2)";
}
}
g2d.setFont(UnitUtil.getNewFont(g2d, name, false, 88, font.getSize()));
if (eqi.c3Level == EquipmentInfo.C3I) {
ImageHelper.printBC3iName(g2d, typePoint, linePoint, font, false, ba.isMixedTech() && TechConstants.isClan(ba.getTechLevel()));
} else if (eqi.c3Level == EquipmentInfo.C3S) {
ImageHelper.printBC3Name(g2d, typePoint, linePoint, font, false, ba.isMixedTech() && TechConstants.isClan(ba.getTechLevel()));
} else {
g2d.drawString(name, typePoint, linePoint);
}
// font = UnitUtil.deriveFont(7.0f);
g2d.setFont(font);
if (eqi.isWeapon) {
if (eqi.isMML) {
ImageHelper.printCenterString(g2d, "[M,S,C]", font, damagePoint, linePoint);
linePoint += lineFeed - 1.0f;
g2d.drawString("LRM", typePoint, linePoint);
ImageHelper.printCenterString(g2d, "1/Msl", font, damagePoint, linePoint);
g2d.drawString("6", minPoint, linePoint);
g2d.drawString("7", shtPoint, linePoint);
g2d.drawString("14", medPoint, linePoint);
g2d.drawString("21", longPoint, linePoint);
linePoint += lineFeed - 1.0f;
g2d.drawString("SRM", typePoint, linePoint);
ImageHelper.printCenterString(g2d, "2/Msl", font, damagePoint, linePoint);
g2d.drawString("\u2014", minPoint, linePoint);
// g2d.drawLine(minPoint, (int) linePoint - 2, minPoint + 6, (int) linePoint - 2);
g2d.drawString("3", shtPoint, linePoint);
g2d.drawString("6", medPoint, linePoint);
g2d.drawString("9", longPoint, linePoint);
} else if (eqi.isATM) {
ImageHelper.printCenterString(g2d, "[M,S,C]", font, damagePoint, linePoint);
linePoint += lineFeed - 1.0f;
g2d.drawString("Standard", typePoint, linePoint);
ImageHelper.printCenterString(g2d, "2/Msl", font, damagePoint, linePoint);
g2d.drawString("4", minPoint, linePoint);
g2d.drawString("5", shtPoint, linePoint);
g2d.drawString("10", medPoint, linePoint);
g2d.drawString("15", longPoint, linePoint);
linePoint += lineFeed - 1.0f;
g2d.drawString("Extended-Range", typePoint, linePoint);
ImageHelper.printCenterString(g2d, "1/Msl", font, damagePoint, linePoint);
g2d.drawString("4", minPoint, linePoint);
g2d.drawString("9", shtPoint, linePoint);
g2d.drawString("18", medPoint, linePoint);
g2d.drawString("27", longPoint, linePoint);
linePoint += lineFeed - 1.0f;
g2d.drawString("High-Explosive", typePoint, linePoint);
ImageHelper.printCenterString(g2d, "3/Msl", font, damagePoint, linePoint);
g2d.drawString("\u2014", minPoint, linePoint);
// g2d.drawLine(minPoint, (int) linePoint - 2, minPoint + 6, (int) linePoint - 2);
g2d.drawString("3", shtPoint, linePoint);
g2d.drawString("6", medPoint, linePoint);
g2d.drawString("9", longPoint, linePoint);
} else {
g2d.setFont(UnitUtil.getNewFont(g2d, eqi.damage, false, 30, font.getSize()));
ImageHelper.printCenterString(g2d, eqi.damage, g2d.getFont(), damagePoint, linePoint);
g2d.setFont(font);
if (eqi.minRange > 0) {
g2d.drawString(Integer.toString(eqi.minRange), minPoint, (int) linePoint);
} else {
g2d.drawString("\u2014", minPoint, linePoint);
// g2d.drawLine(minPoint, (int) linePoint - 2, minPoint + 6, (int) linePoint - 2);
}
if (eqi.shtRange > 0) {
g2d.drawString(Integer.toString(eqi.shtRange), shtPoint, (int) linePoint);
} else {
g2d.drawString("\u2014", shtPoint, linePoint);
// g2d.drawLine(shtPoint, (int) linePoint - 2, shtPoint + 6, (int) linePoint - 2);
}
if (eqi.medRange > 0) {
g2d.drawString(Integer.toString(eqi.medRange), medPoint, (int) linePoint);
} else {
g2d.drawString("\u2014", medPoint, linePoint);
// g2d.drawLine(medPoint, (int) linePoint - 2, medPoint + 6, (int) linePoint - 2);
}
if (eqi.longRange > 0) {
g2d.drawString(Integer.toString(eqi.longRange), longPoint, (int) linePoint);
} else {
g2d.drawString("\u2014", longPoint, linePoint);
// g2d.drawLine(longPoint, (int) linePoint - 2, longPoint + 6, (int) linePoint - 2);
}
}
} else {
g2d.setFont(UnitUtil.getNewFont(g2d, eqi.damage, false, 30, font.getSize()));
ImageHelper.printCenterString(g2d, eqi.damage, g2d.getFont(), damagePoint, linePoint);
g2d.setFont(font);
if (eqi.minRange > 0) {
g2d.drawString(Integer.toString(eqi.minRange), minPoint, (int) linePoint);
} else {
g2d.drawString("\u2014", minPoint, linePoint);
// g2d.drawLine(minPoint, (int) linePoint - 2, minPoint + 6, (int) linePoint - 2);
}
if (eqi.shtRange > 0) {
g2d.drawString(Integer.toString(eqi.shtRange), shtPoint, (int) linePoint);
} else {
g2d.drawString("\u2014", shtPoint, linePoint);
// g2d.drawLine(shtPoint, (int) linePoint - 2, shtPoint + 6, (int) linePoint - 2);
}
if (eqi.medRange > 0) {
g2d.drawString(Integer.toString(eqi.medRange), medPoint, (int) linePoint);
} else {
g2d.drawString("\u2014", medPoint, linePoint);
// g2d.drawLine(medPoint, (int) linePoint - 2, medPoint + 6, (int) linePoint - 2);
}
if (eqi.longRange > 0) {
g2d.drawString(Integer.toString(eqi.longRange), longPoint, (int) linePoint);
} else {
g2d.drawString("\u2014", longPoint, linePoint);
// g2d.drawLine(longPoint, (int) linePoint - 2, longPoint + 6, (int) linePoint - 2);
}
}
if (eqi.hasAmmo) {
if (!newLineNeeded) {
newLineNeeded = true;
}
StringBuilder ammoString = new StringBuilder("Ammo ");
if (eqi.isCompactNarc || eqi.isBAPopUpMine) {
for (int baPos = 0; baPos < ba.getNumberActiverTroopers(); baPos++) {
for (int ammoCount = 0; ammoCount < eqi.ammoCount; ammoCount++) {
ammoString.append("O ");
}
ammoString.append("/ ");
}
ammoString.setLength(ammoString.length() - 2);
} else {
for (int ammoCount = 1; ammoCount <= eqi.ammoCount; ammoCount++) {
ammoString.append("O ");
}
}
g2d.setFont(UnitUtil.getNewFont(g2d, ammoString.toString(), false, 138, font.getSize()));
g2d.drawString(ammoString.toString(), typePoint + 5, (int) (linePoint + lineFeed));
g2d.setFont(font);
}
if (eqi.isBAMineLayer) {
StringBuilder ammoString = new StringBuilder("Ammo ");
for (int baPos = 0; baPos < ba.getNumberActiverTroopers(); baPos++) {
ammoString.append("O O / ");
}
ammoString.setLength(ammoString.length() - 2);
g2d.setFont(UnitUtil.getNewFont(g2d, ammoString.toString(), false, 138, font.getSize()));
g2d.drawString(ammoString.toString(), typePoint + 5, (int) (linePoint + lineFeed));
g2d.setFont(font);
}
linePoint += lineFeed;
if (newLineNeeded) {
linePoint += lineFeed;
}
if (indented) {
typePoint -= 5;
}
}
}
if (ba.isBurdened() && ((ba.getJumpMP(false, true, true) > 0) || UnitUtil.canLegAttack(ba) || UnitUtil.canSwarm(ba))) {
String burdenInfo = "Must detach missiles before jumping or swarm/leg attacks.";
g2d.setFont(UnitUtil.getNewFont(g2d, burdenInfo, false, 175, 7.0f));
g2d.drawString(burdenInfo, typePoint, linePoint);
linePoint += lineFeed;
g2d.setFont(font);
}
if (ba.isExoskeleton() && !ba.hasWorkingMisc(MiscType.F_EXTENDED_LIFESUPPORT)) {
String exoInfo = "unsealed Exoskeleton";
g2d.setFont(UnitUtil.getNewFont(g2d, exoInfo, false, 175, 7.0f));
g2d.drawString(exoInfo, typePoint, linePoint);
linePoint += lineFeed;
g2d.setFont(font);
}
if (ba.hasDWP()) {
String burdenInfo;
if (ba.getJumpMP(true, true, true) > 0) {
burdenInfo = "Must detach DWP before jumping or moving full ground speed.";
} else {
burdenInfo = "Must detach DWP before moving full ground speed.";
}
g2d.setFont(UnitUtil.getNewFont(g2d, burdenInfo, false, 175, 7.0f));
g2d.drawString(burdenInfo, typePoint, linePoint);
linePoint += lineFeed;
g2d.setFont(font);
}
ImageHelperBattleArmor.printBAArmor(ba, g2d, lineFeed, offset);
}
Aggregations