From 4afb5c659886d5fb3c1e900c6c46e6f4b5bffbb6 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Mon, 7 Apr 2025 01:45:41 -0500 Subject: [PATCH 1/2] Updated Edge Handling and GUI Support - Refactored `PersonViewPanel` to display current and total edge without support role-specific logic. - Updated `resetCurrentEdge` logic in `Person` to apply universally instead of being restricted to support roles. - Marked `processWeeklyEdgeResets` in `Campaign` as deprecated, consolidating its usage into `resetCurrentEdge`. - Removed check that prevented non-support characters from having their current Edge levels stored on save. --- MekHQ/src/mekhq/campaign/Campaign.java | 11 ++++----- .../src/mekhq/campaign/personnel/Person.java | 11 ++++----- MekHQ/src/mekhq/gui/view/PersonViewPanel.java | 23 +------------------ 3 files changed, 9 insertions(+), 36 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/Campaign.java b/MekHQ/src/mekhq/campaign/Campaign.java index d6587b9818..7cc035a11a 100644 --- a/MekHQ/src/mekhq/campaign/Campaign.java +++ b/MekHQ/src/mekhq/campaign/Campaign.java @@ -4914,7 +4914,7 @@ public void processNewDayPersonnel() { processWeeklyRelationshipEvents(person); } - processWeeklyEdgeResets(person); + person.resetCurrentEdge(); if (!person.getStatus().isMIA()) { processFatigueRecovery(this, person); @@ -4990,14 +4990,11 @@ private void processAdvancedMedicalEvents(Person person) { } /** - * Process weekly Edge resets for a given person. - * - * @param person the person for whom weekly Edge resets will be processed + * @deprecated use {@link Person#resetCurrentEdge()} instead */ + @Deprecated(since = "0.50.05", forRemoval = true) private void processWeeklyEdgeResets(Person person) { - if ((person.hasSupportRole(true) || person.isEngineer())) { - person.resetCurrentEdge(); - } + person.resetCurrentEdge(); } /** diff --git a/MekHQ/src/mekhq/campaign/personnel/Person.java b/MekHQ/src/mekhq/campaign/personnel/Person.java index b233c0645d..df81988621 100644 --- a/MekHQ/src/mekhq/campaign/personnel/Person.java +++ b/MekHQ/src/mekhq/campaign/personnel/Person.java @@ -215,7 +215,7 @@ public class Person { // Supports edge usage by a ship's engineer composite crewman private int edgeUsedThisRound; - // To track how many edge points support personnel have left until next refresh + // To track how many edge points personnel have left until next refresh private int currentEdge; // phenotype and background @@ -2411,10 +2411,7 @@ public void writeToXML(final PrintWriter pw, int indent, final Campaign campaign indent, "edge", getOptionList("::", PersonnelOptions.EDGE_ADVANTAGES)); - // For support personnel, write an available edge value - if (hasSupportRole(true) || isEngineer()) { - MHQXMLUtility.writeSimpleXMLTag(pw, indent, "edgeAvailable", getCurrentEdge()); - } + MHQXMLUtility.writeSimpleXMLTag(pw, indent, "edgeAvailable", getCurrentEdge()); } if (countOptions(PersonnelOptions.MD_ADVANTAGES) > 0) { @@ -4226,14 +4223,14 @@ public void changeEdge(final int amount) { } /** - * Resets support personnel edge points to the purchased level. Used for weekly refresh. + * Resets edge points to the purchased level. Used for weekly refresh. */ public void resetCurrentEdge() { setCurrentEdge(getEdge()); } /** - * Sets support personnel edge points to the value 'currentEdge'. Used for weekly refresh. + * Sets edge points to the value 'currentEdge'. Used for weekly refresh. * * @param currentEdge - integer used to track this person's edge points available for the current week */ diff --git a/MekHQ/src/mekhq/gui/view/PersonViewPanel.java b/MekHQ/src/mekhq/gui/view/PersonViewPanel.java index 0481f0f880..cee79aa585 100644 --- a/MekHQ/src/mekhq/gui/view/PersonViewPanel.java +++ b/MekHQ/src/mekhq/gui/view/PersonViewPanel.java @@ -1614,7 +1614,7 @@ private JPanel fillSkills() { lblEdge2.setName("lblEdge2"); lblEdge1.setLabelFor(lblEdge2); - lblEdge2.setText(Integer.toString(person.getEdge())); + lblEdge2.setText("" + person.getCurrentEdge() + '/' + person.getEdge()); lblEdge2.setToolTipText(person.getEdgeTooltip()); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 1; @@ -1625,27 +1625,6 @@ private JPanel fillSkills() { gridBagConstraints.fill = GridBagConstraints.NONE; gridBagConstraints.anchor = GridBagConstraints.NORTHWEST; pnlSkills.add(lblEdge2, gridBagConstraints); - - if (campaign.getCampaignOptions().isUseSupportEdge() && person.hasSupportRole(true)) { - // Add the Edge Available field for support personnel only - lblEdgeAvail1.setName("lblEdgeAvail1"); - lblEdgeAvail1.setText(resourceMap.getString("lblEdgeAvail1.text")); - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 2; - gridBagConstraints.gridy = firsty; - gridBagConstraints.fill = GridBagConstraints.NONE; - gridBagConstraints.anchor = GridBagConstraints.NORTHWEST; - pnlSkills.add(lblEdgeAvail1, gridBagConstraints); - - lblEdgeAvail2.setName("lblEdgeAvail2"); - lblEdgeAvail1.setLabelFor(lblEdgeAvail2); - lblEdgeAvail2.setText(Integer.toString(person.getCurrentEdge())); - gridBagConstraints.gridx = 3; - gridBagConstraints.gridwidth = 1; - gridBagConstraints.weightx = 1.0; - gridBagConstraints.insets = new Insets(0, 10, 0, 0); - pnlSkills.add(lblEdgeAvail2, gridBagConstraints); - } firsty++; } From a767ba07e87fede5be558a80374f5cc398904093 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Fri, 11 Apr 2025 17:59:08 -0500 Subject: [PATCH 2/2] - Deleted the duplicate `changeWealth` method from the `Person` class. --- MekHQ/src/mekhq/campaign/personnel/Person.java | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/personnel/Person.java b/MekHQ/src/mekhq/campaign/personnel/Person.java index b57c2c33e2..a53c06aab9 100644 --- a/MekHQ/src/mekhq/campaign/personnel/Person.java +++ b/MekHQ/src/mekhq/campaign/personnel/Person.java @@ -5053,18 +5053,6 @@ public void changeWealth(final int delta) { wealth = clamp(newValue, MINIMUM_WEALTH, MAXIMUM_WEALTH); } - /** - * Adjusts the person's wealth by the specified amount. - * - *

The change in wealth can be positive or negative, depending on the provided delta value.

- * - * @param delta The amount by which to adjust the wealth. A positive value increases the wealth, while a negative - * value decreases it. - */ - public void changeWealth(final int delta) { - this.wealth += delta; - } - public boolean isHasPerformedExtremeExpenditure() { return hasPerformedExtremeExpenditure; }