From 372625be82fff586176e020ce6931ce242b7d801 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 25 Sep 2024 10:26:14 -0500 Subject: [PATCH 1/2] Enhanced Random-Death Reporting Added color-coded messaging to ensure random death events are highly noticeable to users. Imported necessary utilities and refined new day processing to utilize the enhanced reporting mechanism. --- .../personnel/death/AbstractDeath.java | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/personnel/death/AbstractDeath.java b/MekHQ/src/mekhq/campaign/personnel/death/AbstractDeath.java index 29ee8487de..1a5500bcac 100644 --- a/MekHQ/src/mekhq/campaign/personnel/death/AbstractDeath.java +++ b/MekHQ/src/mekhq/campaign/personnel/death/AbstractDeath.java @@ -18,18 +18,6 @@ */ package mekhq.campaign.personnel.death; -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStream; -import java.time.LocalDate; -import java.util.HashMap; -import java.util.Map; -import java.util.ResourceBundle; - -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.Version; import megamek.common.annotations.Nullable; import megamek.common.enums.Gender; @@ -45,6 +33,20 @@ import mekhq.campaign.personnel.enums.RandomDeathMethod; import mekhq.campaign.personnel.enums.TenYearAgeRange; import mekhq.utilities.MHQXMLUtility; +import mekhq.utilities.ReportingUtilities; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.time.LocalDate; +import java.util.HashMap; +import java.util.Map; +import java.util.ResourceBundle; + +import static mekhq.utilities.ReportingUtilities.CLOSING_SPAN_TAG; public abstract class AbstractDeath { private static final MMLogger logger = MMLogger.create(AbstractDeath.class); @@ -158,6 +160,13 @@ public boolean processNewDay(final Campaign campaign, final LocalDate today, } if (randomlyDies(age, person.getGender())) { + // We double-report here, to make sure the user definitely notices that a random death has occurred. + // Prior to this change, it was exceptionally easy to miss these events. + String color = MekHQ.getMHQOptions().getFontColorNegativeHexColor(); + String formatOpener = ReportingUtilities.spanOpeningWithCustomColor(color); + campaign.addReport(String.format("%s has %sdied%s.", + person.getHyperlinkedFullTitle(), formatOpener, CLOSING_SPAN_TAG)); + person.changeStatus(campaign, today, getCause(person, ageGroup, age)); return person.getStatus().isDead(); } else { From bc8840e2b75fcf1cc36747c244503b921620515f Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 25 Sep 2024 10:26:14 -0500 Subject: [PATCH 2/2] Updated StratCon Status Message for Inactive Contracts Extended the message to clarify when no active contract is selected or the contract has not yet started. This provides better feedback to users regarding the state of their campaign. --- .../personnel/death/AbstractDeath.java | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/personnel/death/AbstractDeath.java b/MekHQ/src/mekhq/campaign/personnel/death/AbstractDeath.java index 29ee8487de..5da721ba6a 100644 --- a/MekHQ/src/mekhq/campaign/personnel/death/AbstractDeath.java +++ b/MekHQ/src/mekhq/campaign/personnel/death/AbstractDeath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022 - The MegaMek Team. All Rights Reserved. + * Copyright (c) 2020-2024 - The MegaMek Team. All Rights Reserved. * * This file is part of MekHQ. * @@ -18,18 +18,6 @@ */ package mekhq.campaign.personnel.death; -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStream; -import java.time.LocalDate; -import java.util.HashMap; -import java.util.Map; -import java.util.ResourceBundle; - -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.Version; import megamek.common.annotations.Nullable; import megamek.common.enums.Gender; @@ -45,6 +33,20 @@ import mekhq.campaign.personnel.enums.RandomDeathMethod; import mekhq.campaign.personnel.enums.TenYearAgeRange; import mekhq.utilities.MHQXMLUtility; +import mekhq.utilities.ReportingUtilities; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.time.LocalDate; +import java.util.HashMap; +import java.util.Map; +import java.util.ResourceBundle; + +import static mekhq.utilities.ReportingUtilities.CLOSING_SPAN_TAG; public abstract class AbstractDeath { private static final MMLogger logger = MMLogger.create(AbstractDeath.class); @@ -158,6 +160,13 @@ public boolean processNewDay(final Campaign campaign, final LocalDate today, } if (randomlyDies(age, person.getGender())) { + // We double-report here, to make sure the user definitely notices that a random death has occurred. + // Prior to this change, it was exceptionally easy to miss these events. + String color = MekHQ.getMHQOptions().getFontColorNegativeHexColor(); + String formatOpener = ReportingUtilities.spanOpeningWithCustomColor(color); + campaign.addReport(String.format("%s has %sdied%s.", + person.getHyperlinkedFullTitle(), formatOpener, CLOSING_SPAN_TAG)); + person.changeStatus(campaign, today, getCause(person, ageGroup, age)); return person.getStatus().isDead(); } else {