From e147474cbb368b20b9c9443c1ee31f0097435322 Mon Sep 17 00:00:00 2001 From: Carl Spain Date: Mon, 24 Feb 2020 11:38:10 -0600 Subject: [PATCH 1/6] Indicate variable weight, slots, bv, and cost on equipment table. --- .../com/util/EquipmentTableModel.java | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/megameklab/com/util/EquipmentTableModel.java b/src/megameklab/com/util/EquipmentTableModel.java index 1a4a514ca..c20c7b2fe 100644 --- a/src/megameklab/com/util/EquipmentTableModel.java +++ b/src/megameklab/com/util/EquipmentTableModel.java @@ -27,17 +27,7 @@ import javax.swing.table.AbstractTableModel; import javax.swing.table.DefaultTableCellRenderer; -import megamek.common.Aero; -import megamek.common.AmmoType; -import megamek.common.Entity; -import megamek.common.EquipmentType; -import megamek.common.ITechManager; -import megamek.common.MiscType; -import megamek.common.Mounted; -import megamek.common.RangeType; -import megamek.common.Tank; -import megamek.common.TechAdvancement; -import megamek.common.WeaponType; +import megamek.common.*; import megamek.common.verifier.TestProtomech; import megamek.common.weapons.autocannons.UACWeapon; import megamek.common.weapons.gaussrifles.HAGWeapon; @@ -352,16 +342,23 @@ public Object getValueAt(int row, int col) { return "-"; } } else if (col == COL_TON) { + final double weight = type.getTonnage(entity); if ((atype != null) && (entity.hasETypeFlag(Entity.ETYPE_BATTLEARMOR) || entity.hasETypeFlag(Entity.ETYPE_PROTOMECH))) { return atype.getKgPerShot() + " kg/shot"; - } else if (type.getTonnage(entity) < 0.1) { - return String.format("%.2f kg", type.getTonnage(entity) * 1000); + } else if (type.isVariableTonnage()) { + return "variable"; + } else if (weight > 0.0 && weight < 0.1) { + return String.format("%.0f kg", type.getTonnage(entity) * 1000); } else { - return String.valueOf(type.getTonnage(entity)); + return formatter.format(weight); } } else if (col == COL_CRIT) { - if (entity.isSupportVehicle()) { + if (type.isVariableCriticals() + && (entity.isSupportVehicle() || (entity instanceof Mech))) { + // Only Mechs and support vehicles require multiple slots for equipment + return "variable"; + } else if (entity.isSupportVehicle()) { return type.getSupportVeeSlots(entity); } else if (entity instanceof Tank) { return type.getTankslots(entity); @@ -372,9 +369,15 @@ public Object getValueAt(int row, int col) { } else if (col == COL_TRATING) { return type.getFullRatingName(entity.isClan()); } else if (col == COL_COST) { + if (type.isVariableCost()) { + return "variable"; + } return formatter.format(type .getCost(entity, false, Entity.LOC_NONE)); } else if (col == COL_BV) { + if (type.isVariableBV()) { + return "variable"; + } return type.getBV(entity); } else if (col == COL_DPROTOTYPE) { return entity.isMixedTech()? type.getTechAdvancement().getPrototypeDateName() : From def3391ca7a9eda7eac509b18ad653910b25ab94 Mon Sep 17 00:00:00 2001 From: Carl Spain Date: Mon, 24 Feb 2020 11:48:34 -0600 Subject: [PATCH 2/6] Always show protomech, BA, and small SV equipment by kg. --- src/megameklab/com/util/EquipmentTableModel.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/megameklab/com/util/EquipmentTableModel.java b/src/megameklab/com/util/EquipmentTableModel.java index c20c7b2fe..05c578ba1 100644 --- a/src/megameklab/com/util/EquipmentTableModel.java +++ b/src/megameklab/com/util/EquipmentTableModel.java @@ -28,6 +28,7 @@ import javax.swing.table.DefaultTableCellRenderer; import megamek.common.*; +import megamek.common.verifier.TestEntity; import megamek.common.verifier.TestProtomech; import megamek.common.weapons.autocannons.UACWeapon; import megamek.common.weapons.gaussrifles.HAGWeapon; @@ -345,10 +346,10 @@ public Object getValueAt(int row, int col) { final double weight = type.getTonnage(entity); if ((atype != null) && (entity.hasETypeFlag(Entity.ETYPE_BATTLEARMOR) || entity.hasETypeFlag(Entity.ETYPE_PROTOMECH))) { - return atype.getKgPerShot() + " kg/shot"; + return String.format("%.2f kg/shot", atype.getKgPerShot()); } else if (type.isVariableTonnage()) { return "variable"; - } else if (weight > 0.0 && weight < 0.1) { + } else if (TestEntity.usesKgStandard(entity) || ((weight > 0.0) && (weight < 0.1))) { return String.format("%.0f kg", type.getTonnage(entity) * 1000); } else { return formatter.format(weight); From 7f0b067e3b76ad0c3b06b47a19e0b22ed8a03314 Mon Sep 17 00:00:00 2001 From: Carl Spain Date: Mon, 24 Feb 2020 11:50:37 -0600 Subject: [PATCH 3/6] Warnings cleanup --- src/megameklab/com/util/EquipmentTableModel.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/megameklab/com/util/EquipmentTableModel.java b/src/megameklab/com/util/EquipmentTableModel.java index 05c578ba1..673306ee0 100644 --- a/src/megameklab/com/util/EquipmentTableModel.java +++ b/src/megameklab/com/util/EquipmentTableModel.java @@ -16,7 +16,6 @@ package megameklab.com.util; -import java.awt.Color; import java.awt.Component; import java.text.DecimalFormat; import java.util.ArrayList; @@ -98,7 +97,6 @@ public String getColumnName(int column) { case COL_NAME: return "Name"; case COL_DAMAGE: - return "Damage"; case COL_DIVISOR: return "Damage"; case COL_SPECIAL: @@ -426,9 +424,10 @@ private static String getDamageString(WeaponType wtype, boolean isAero) { attackValue[RangeType.RANGE_LONG] = (int)wtype.getLongAV(); attackValue[RangeType.RANGE_EXTREME] = (int)wtype.getExtAV(); boolean allEq = true; - for (int i = 2; i <= wtype.maxRange && allEq; i++) { + for (int i = 2; i <= wtype.maxRange; i++) { if (attackValue[i - 1] != attackValue[i]) { allEq = false; + break; } } StringBuilder avString = new StringBuilder(); From 38518ddf1e0cc3cd09518d9cdc1189ecd258c0a7 Mon Sep 17 00:00:00 2001 From: Carl Spain Date: Mon, 24 Feb 2020 11:54:55 -0600 Subject: [PATCH 4/6] Remove ammo from the "other" category on the BA equipment tab. --- src/megameklab/com/util/UnitUtil.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/megameklab/com/util/UnitUtil.java b/src/megameklab/com/util/UnitUtil.java index 72497d4e8..c7cbdf681 100644 --- a/src/megameklab/com/util/UnitUtil.java +++ b/src/megameklab/com/util/UnitUtil.java @@ -2923,13 +2923,19 @@ public static boolean isSupportVehicleEquipment(EquipmentType eq, Entity unit) { } } + /** + * @param eq A {@link WeaponType} or {@link MiscType} + * @param ba The BattleArmor instance + * @return Whether the BA can use the equipment + */ public static boolean isBAEquipment(EquipmentType eq, BattleArmor ba) { if (eq instanceof MiscType) { return eq.hasFlag(MiscType.F_BA_EQUIPMENT); } else if (eq instanceof WeaponType) { return isBattleArmorWeapon(eq, ba); } - return true; + // This leaves ammotype, which is filtered according to having a weapon that can use it + return false; } public static boolean isBattleArmorAPWeapon(EquipmentType etype){ From 2b4866d58a5d615af1f669f4c0679f8db010f6c9 Mon Sep 17 00:00:00 2001 From: Carl Spain Date: Mon, 24 Feb 2020 12:20:32 -0600 Subject: [PATCH 5/6] Filter out weapons, armor, and other structural components from the BA equipment tab. --- src/megameklab/com/ui/BattleArmor/tabs/EquipmentTab.java | 6 ++++-- src/megameklab/com/util/UnitUtil.java | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/megameklab/com/ui/BattleArmor/tabs/EquipmentTab.java b/src/megameklab/com/ui/BattleArmor/tabs/EquipmentTab.java index 7b155e3d4..08906f03b 100644 --- a/src/megameklab/com/ui/BattleArmor/tabs/EquipmentTab.java +++ b/src/megameklab/com/ui/BattleArmor/tabs/EquipmentTab.java @@ -575,7 +575,9 @@ public boolean include(Entry= 5.0)) { + return false; + } if ((eq instanceof MiscType) && !eq.hasFlag(MiscType.F_SUPPORT_TANK_EQUIPMENT)) { return false; } else if ((eq instanceof WeaponType) From 1360f6628ecfd4b9e68617e5682b5e245d594975 Mon Sep 17 00:00:00 2001 From: Carl Spain Date: Mon, 24 Feb 2020 12:37:23 -0600 Subject: [PATCH 6/6] Change infantry armor kit divisor column heading from damage to divisor. --- src/megameklab/com/util/EquipmentTableModel.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/megameklab/com/util/EquipmentTableModel.java b/src/megameklab/com/util/EquipmentTableModel.java index 673306ee0..cc1478de1 100644 --- a/src/megameklab/com/util/EquipmentTableModel.java +++ b/src/megameklab/com/util/EquipmentTableModel.java @@ -97,8 +97,9 @@ public String getColumnName(int column) { case COL_NAME: return "Name"; case COL_DAMAGE: - case COL_DIVISOR: return "Damage"; + case COL_DIVISOR: + return "Divisor"; case COL_SPECIAL: return "Special"; case COL_HEAT: