From 9547a74df5bb892a6e8dbf3b97d8ae86303d05c1 Mon Sep 17 00:00:00 2001 From: Pavel Braginskiy Date: Sun, 27 Oct 2024 03:21:07 -0700 Subject: [PATCH 1/3] Add RISC Heat Sink Override Kit --- .../megameklab/resources/Views.properties | 3 ++ .../megameklab/printing/InventoryWriter.java | 16 ++++++-- .../ui/generalUnit/HeatSinkView.java | 41 +++++++++++++++++-- .../ui/listeners/BuildListener.java | 17 +++++--- .../src/megameklab/ui/mek/BMChassisView.java | 2 + .../src/megameklab/ui/mek/BMStructureTab.java | 11 +++++ 6 files changed, 79 insertions(+), 11 deletions(-) diff --git a/megameklab/resources/megameklab/resources/Views.properties b/megameklab/resources/megameklab/resources/Views.properties index 950f36a70..a3a101168 100644 --- a/megameklab/resources/megameklab/resources/Views.properties +++ b/megameklab/resources/megameklab/resources/Views.properties @@ -203,6 +203,9 @@ HeatSinkView.lblCritFree.text=Engine Free: HeatSinkView.lblCritFree.tooltip=These heat sinks are an integral part of the engine and do not have to be assigned critical space.
Omni units must assign critical space to any pod-mounted heat sinks even if they would be part of the engine in standard Meks. HeatSinkView.lblWeightFree.text=Weight Free: HeatSinkView.lblWeightFree.tooltip=These heat sinks are included in the weight of the engine. +HeatSinkView.lblRiscHeatSinkKit.text=RISC Heat Sink Override Kit: +HeatSinkView.lblRiscHeatSinkKit.tooltip=Reduces chance of heat-induced shutdown. IO:AE p86.
\ + Construction only, not implemented for gameplay in MegaMek. ArmorView.cbArmorType.text=Armor Type: ArmorView.cbArmorType.tooltip=The type of armor determines the amount of protection per ton and the amount of space required. Some armors provide additional special abilities. diff --git a/megameklab/src/megameklab/printing/InventoryWriter.java b/megameklab/src/megameklab/printing/InventoryWriter.java index ea705d388..d4c5fd6ea 100644 --- a/megameklab/src/megameklab/printing/InventoryWriter.java +++ b/megameklab/src/megameklab/printing/InventoryWriter.java @@ -32,6 +32,7 @@ import java.util.function.Function; import java.util.stream.Collectors; +import megamek.common.equipment.MiscMounted; import org.apache.batik.util.SVGConstants; import org.w3c.dom.Element; import org.w3c.dom.svg.SVGRectElement; @@ -260,6 +261,15 @@ private void parseEquipment() { same.incrementQty(); } } + if (sheet.getEntity() instanceof Mek mek && mek.hasRiscHeatSinkOverrideKit()) { + var mounted = new MiscMounted(sheet.getEntity(), new MiscType() {{ + name = "RISC Heat Sink Override Kit"; + // todo: find out (from CGL?) what a good shortName is + shortName = "RISC Heat Sink Override Kit"; + internalName = "RISC Heat Sink Override Kit"; + }}); + equipment.add(new StandardInventoryEntry(mounted)); + } } private void parseBays() { @@ -933,12 +943,12 @@ public double printBayInfo(float fontSize, double lineHeight, double currY) { } bayCapacityString.append(NumberFormat.getInstance().format(capacity)); if ((i + 1) < bays.size()) { - bayTypeString.append("/"); - bayCapacityString.append("/"); + bayTypeString.append('/'); + bayCapacityString.append('/'); } doors = Math.max(doors, b.getDoors()); } - bayCapacityString.append(")"); + bayCapacityString.append(')'); String bayString = "Bay " + bayNum + ": " + bayTypeString + bayCapacityString + " (" + doors + (doors == 1 ? " Door)" : " Doors)"); sheet.addTextElement(canvas, bayColX[0], currY, bayString, fontSize, diff --git a/megameklab/src/megameklab/ui/generalUnit/HeatSinkView.java b/megameklab/src/megameklab/ui/generalUnit/HeatSinkView.java index e7363bf9a..629a3a8ce 100644 --- a/megameklab/src/megameklab/ui/generalUnit/HeatSinkView.java +++ b/megameklab/src/megameklab/ui/generalUnit/HeatSinkView.java @@ -28,9 +28,7 @@ import java.util.ResourceBundle; import java.util.concurrent.CopyOnWriteArrayList; -import javax.swing.JLabel; -import javax.swing.JSpinner; -import javax.swing.SpinnerNumberModel; +import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -94,6 +92,9 @@ public void removeListener(BuildListener l) { private final JLabel lblCritFreeCount = new JLabel(); private final JLabel lblWeightFreeText = new JLabel(); private final JLabel lblWeightFreeCount = new JLabel(); + private final JLabel lblRiscHeatSinkKit = new JLabel(); + private final JCheckBox chkRiscHeatSinkKit = new JCheckBox(); + private final SpinnerNumberModel countModel = new SpinnerNumberModel(0, 0, null, 1); private final SpinnerNumberModel baseCountModel = new SpinnerNumberModel(0, 0, null, 1); @@ -142,6 +143,8 @@ private void initUI() { add(spnCount, gbc); spnCount.addChangeListener(this); + gbc.gridx = 2; + add(new JLabel(" "), gbc); gbc.gridx = 3; lblCritFreeText.setText(resourceMap.getString("HeatSinkView.lblCritFree.text")); add(lblCritFreeText, gbc); @@ -177,12 +180,33 @@ private void initUI() { lblWeightFreeCount.setToolTipText(resourceMap.getString("HeatSinkView.lblWeightFree.tooltip")); add(lblWeightFreeCount, gbc); + + lblRiscHeatSinkKit.setText(resourceMap.getString("HeatSinkView.lblRiscHeatSinkKit.text")); + lblRiscHeatSinkKit.setToolTipText(resourceMap.getString("HeatSinkView.lblRiscHeatSinkKit.tooltip")); + chkRiscHeatSinkKit.setToolTipText(resourceMap.getString("HeatSinkView.lblRiscHeatSinkKit.tooltip")); + lblRiscHeatSinkKit.setVisible(false); + chkRiscHeatSinkKit.setVisible(false); + gbc.gridx = 0; + gbc.gridy++; + add(lblRiscHeatSinkKit, gbc); + gbc.gridx = GridBagConstraints.RELATIVE; + add(chkRiscHeatSinkKit, gbc); + chkRiscHeatSinkKit.addActionListener(this); + } private String getDisplayName(int index) { return isAero ? aeroDisplayNames[index] : MekDisplayNames[index]; } + private void showRiscKit(boolean show) { + chkRiscHeatSinkKit.setVisible(show); + lblRiscHeatSinkKit.setVisible(show); + if (!show) { + chkRiscHeatSinkKit.setSelected(false); + } + } + public void setFromMek(Mek mek) { isAero = false; isPrimitive = mek.isPrimitive(); @@ -224,6 +248,11 @@ public void setFromMek(Mek mek) { spnPrototypeCount.addChangeListener(this); lblCritFreeCount.setText(String.valueOf(UnitUtil.getCriticalFreeHeatSinks(mek, isCompact))); lblWeightFreeCount.setText(String.valueOf(mek.getEngine().getWeightFreeEngineHeatSinks())); + + showRiscKit(techManager.isLegal(Mek.getRiscHeatSinkOverrideKitAdvancement())); + if (mek.hasRiscHeatSinkOverrideKit()) { + chkRiscHeatSinkKit.setSelected(true); + } } public void setFromAero(Aero aero) { @@ -258,6 +287,8 @@ public void setFromAero(Aero aero) { spnPrototypeCount.setVisible(false); lblCritFreeText.setVisible(false); lblCritFreeCount.setVisible(false); + + showRiscKit(false); } public void refresh() { @@ -287,6 +318,8 @@ public void refresh() { if (cbHSType.getSelectedIndex() < 0) { cbHSType.setSelectedIndex(0); } + + showRiscKit(techManager.isLegal(Mek.getRiscHeatSinkOverrideKitAdvancement()) && !isAero); } public int getHeatSinkIndex() { @@ -333,6 +366,8 @@ public int getPrototypeCount() { public void actionPerformed(ActionEvent e) { if (e.getSource() == cbHSType) { reportChange(); + } else if (e.getSource() == chkRiscHeatSinkKit) { + listeners.forEach(l -> l.riscHeatSinkOverrideKitChanged(chkRiscHeatSinkKit.isSelected())); } } diff --git a/megameklab/src/megameklab/ui/listeners/BuildListener.java b/megameklab/src/megameklab/ui/listeners/BuildListener.java index 40583aa76..a8a36ac75 100644 --- a/megameklab/src/megameklab/ui/listeners/BuildListener.java +++ b/megameklab/src/megameklab/ui/listeners/BuildListener.java @@ -56,7 +56,7 @@ default void clanNameChanged(String clanName) { * Notifies of a change of the manually entered BV. When manualBV is 0 or less, * the unit * should be set to not use a manual BV value and the manual BV set to -1. - * + * * @param manualBV The entered manual BV; may be invalid (0 or less) */ void manualBVChanged(int manualBV); @@ -75,7 +75,7 @@ default void clanNameChanged(String clanName) { /** * Notifies of a change in heat sink type or count for aerospace units - * + * * @param index Either * {@link megameklab.ui.generalUnit.HeatSinkView#TYPE_SINGLE} or * {@link megameklab.ui.generalUnit.HeatSinkView#TYPE_DOUBLE_AERO} @@ -86,7 +86,7 @@ default void heatSinksChanged(int index, int count) { /** * Notifies of a change in heat sink type or count for meks - * + * * @param hsType The type of heat sink * @param count The total number of heat sinks */ @@ -97,7 +97,7 @@ default void heatSinksChanged(EquipmentType hsType, int count) { * Notifies of a change in the distribution between single and double heat sinks * on a unit with * prototype double heat sinks. - * + * * @param prototype The number of prototype double heat sinks */ default void redistributePrototypeHS(int prototype) { @@ -106,12 +106,19 @@ default void redistributePrototypeHS(int prototype) { /** * Notifies of a change in the number of heat sinks that are part of the base * chassis of an omni unit - * + * * @param count The number of fixed heat sinks */ default void heatSinkBaseCountChanged(int count) { } + /** + * Notifies of a change in the presence of a RISC Heat Sink Override Kit + * @param hasKit True if the unit now has the kit + */ + default void riscHeatSinkOverrideKitChanged(boolean hasKit) { + } + // For aerospace units and support vehicles default void fuelTonnageChanged(double tonnage) { } diff --git a/megameklab/src/megameklab/ui/mek/BMChassisView.java b/megameklab/src/megameklab/ui/mek/BMChassisView.java index 985e224ac..fbd30afe8 100644 --- a/megameklab/src/megameklab/ui/mek/BMChassisView.java +++ b/megameklab/src/megameklab/ui/mek/BMChassisView.java @@ -609,6 +609,8 @@ private void refreshFullHeadEject() { chkFullHeadEject.addActionListener(this); } + + public List getAvailableEngines() { List retVal = new ArrayList<>(); boolean isMixed = techManager.useMixedTech(); diff --git a/megameklab/src/megameklab/ui/mek/BMStructureTab.java b/megameklab/src/megameklab/ui/mek/BMStructureTab.java index 82f7dad33..da286c386 100644 --- a/megameklab/src/megameklab/ui/mek/BMStructureTab.java +++ b/megameklab/src/megameklab/ui/mek/BMStructureTab.java @@ -675,6 +675,9 @@ public void updateTechLevel() { } else { refresh.refreshEquipmentTable(); } + if (!getTechManager().isLegal(Mek.getRiscHeatSinkOverrideKitAdvancement())) { + getMek().setRiscHeatSinkOverrideKit(false); + } panChassis.refresh(); panHeat.refresh(); panArmor.refresh(); @@ -978,6 +981,14 @@ public void heatSinkBaseCountChanged(int count) { refresh.refreshPreview(); } + @Override + public void riscHeatSinkOverrideKitChanged(boolean hasKit) { + getMek().setRiscHeatSinkOverrideKit(hasKit); + refresh.refreshBuild(); + refresh.refreshStatus(); + refresh.refreshPreview(); + } + @Override public void redistributePrototypeHS(int prototype) { int netChange = prototype - getMek().countWorkingMisc(MiscType.F_IS_DOUBLE_HEAT_SINK_PROTOTYPE); From f8b13fc682526ee5d25fb2eef97253a1bbd8df5b Mon Sep 17 00:00:00 2001 From: Pavel Braginskiy Date: Sun, 27 Oct 2024 03:38:13 -0700 Subject: [PATCH 2/3] Shortname for RISC HS Override Kit --- megameklab/src/megameklab/printing/InventoryWriter.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/megameklab/src/megameklab/printing/InventoryWriter.java b/megameklab/src/megameklab/printing/InventoryWriter.java index d4c5fd6ea..842877f7a 100644 --- a/megameklab/src/megameklab/printing/InventoryWriter.java +++ b/megameklab/src/megameklab/printing/InventoryWriter.java @@ -264,8 +264,7 @@ private void parseEquipment() { if (sheet.getEntity() instanceof Mek mek && mek.hasRiscHeatSinkOverrideKit()) { var mounted = new MiscMounted(sheet.getEntity(), new MiscType() {{ name = "RISC Heat Sink Override Kit"; - // todo: find out (from CGL?) what a good shortName is - shortName = "RISC Heat Sink Override Kit"; + shortName = "RISC HS Override Kit"; internalName = "RISC Heat Sink Override Kit"; }}); equipment.add(new StandardInventoryEntry(mounted)); From 9df1c7a8fad73d913328e3398ff7e62d89425f92 Mon Sep 17 00:00:00 2001 From: Pavel Braginskiy Date: Sun, 27 Oct 2024 03:45:01 -0700 Subject: [PATCH 3/3] Don't show RISC HS Kit as being in HD --- megameklab/src/megameklab/printing/InventoryWriter.java | 1 + megameklab/src/megameklab/printing/StandardInventoryEntry.java | 3 +++ 2 files changed, 4 insertions(+) diff --git a/megameklab/src/megameklab/printing/InventoryWriter.java b/megameklab/src/megameklab/printing/InventoryWriter.java index 842877f7a..235088d15 100644 --- a/megameklab/src/megameklab/printing/InventoryWriter.java +++ b/megameklab/src/megameklab/printing/InventoryWriter.java @@ -267,6 +267,7 @@ private void parseEquipment() { shortName = "RISC HS Override Kit"; internalName = "RISC Heat Sink Override Kit"; }}); + mounted.setLocation(Mek.LOC_NONE); equipment.add(new StandardInventoryEntry(mounted)); } } diff --git a/megameklab/src/megameklab/printing/StandardInventoryEntry.java b/megameklab/src/megameklab/printing/StandardInventoryEntry.java index 13166cc2a..250b080fa 100644 --- a/megameklab/src/megameklab/printing/StandardInventoryEntry.java +++ b/megameklab/src/megameklab/printing/StandardInventoryEntry.java @@ -323,6 +323,9 @@ private boolean showTechBase() { } private String formatLocation() { + if (mount.getLocation() == Entity.LOC_NONE) { + return DASH; + } if ((mount.getEntity() instanceof Tank) && mount.getLocation() == Tank.LOC_TURRET && !((Tank) mount.getEntity()).hasNoDualTurret()) {