From 42019820e482a991282f28859b5d10edcc328b6e Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Fri, 2 May 2025 22:26:20 -0500 Subject: [PATCH] Improvement: Converted Most Convoy Dialogs into Immersive Dialogs --- .../mekhq/resources/Resupply.properties | 55 ++++-- .../resupplyAndCaches/PerformResupply.java | 73 ++++++-- .../resupplyAndCaches/ResupplyUtilities.java | 48 +++-- .../DialogAbandonedConvoy.java | 10 +- .../DialogContractStart.java | 165 +++--------------- .../resupplyAndCaches/DialogInterception.java | 10 +- .../resupplyAndCaches/DialogItinerary.java | 2 +- .../DialogPlayerConvoyOption.java | 8 +- .../DialogResupplyFocus.java | 8 +- .../DialogRoleplayEvent.java | 5 +- 10 files changed, 196 insertions(+), 188 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/Resupply.properties b/MekHQ/resources/mekhq/resources/Resupply.properties index afada95feca..e2e82d771e9 100644 --- a/MekHQ/resources/mekhq/resources/Resupply.properties +++ b/MekHQ/resources/mekhq/resources/Resupply.properties @@ -14,6 +14,47 @@ smugglerFee.text=Local Resupply roleplayItems.prompt=Items in italics are roleplay items and are not tracked by MekHQ. documentation.prompt=Full documentation can be found in ''MekHQ/docs/Stratcon and Against the Bot'' +outOfCharacter.abandoned=All units and personnel have been killed or captured.\ +

Full documentation can be found in ''MekHQ/docs/Stratcon and Against the Bot''

+outOfCharacter.contractStart.normal=Each month your employer will offer you spare supplies from their depot. The contents\ + \ of these resupplies is tailored to your force and your warehouse. That means you will always be offered items you\ + \ are using, but if your warehouse is particularly well stocked your employer will choose to direct those spares\ + \ elsewhere.\ +

The Negotiation skill of your senior-most Admin/Logistics character significantly influences the quality\ + \ of resupplies.

\ +

Resupplies are meant to ease the logistics demands of a contract, but they are not intended to replace\ + \ normal procurement. While you are en route to the contract location considered checking the Parts in Use dialog and\ + \ seeing if there is any supplies you're likely to deplete. You don't want to run out of left arms if you have to wait\ + \ 3 months for a left arm to arrive.

\ +

Full documentation can be found in ''MekHQ/docs/Stratcon and Against the Bot''

+outOfCharacter.contractStart.guerrilla=Each month you have a chance to receive a resupply offer from a local smuggler.The\ + \ contents of these resupplies is tailored to your force and your warehouse. That means you will always be offered items\ + \ you are using, but if your warehouse is particularly well stocked smuggler will choose to direct those spares elsewhere.\ +

The Negotiation skill of your campaign commander significantly influences the quality of smuggler resupplies.

\ +

Resupplies are meant to ease the logistics demands of a contract, but they are not intended to replace normal\ + \ procurement. While you are en route to the contract location considered checking the Parts in Use dialog and\ + \ seeing if there is any supplies you're likely to deplete. You don't want to run out of left arms if you have to wait\ + \ 3 months for a left arm to arrive.

\ +

Full documentation can be found in ''MekHQ/docs/Stratcon and Against the Bot''

+outOfCharacter.intercepted=Your convoy has been intercepted and a special Crisis\ + \ scenario has been generated. Refusing to fight this engagement will result in the loss of the convoy and its contents. +outOfCharacter.convoyPicker=If you have the cargo capacity it's generally a good idea to use your own convoys. However,\ + \ this is a risk as it means placing your forces in the line of fire.\ +

You should avoid sending out convoys while the enemy has high morale. You should also try to keep the total unit\ + \ weight of your convoys below 200t as the heavier the convoy the easier it is to intercept.

+outOfCharacter.focus=Your employer will refuse to resupply parts you already have large quantities\ + \ of. For those items your employer is willing to supply a Negotiation check must be made, if the\ + \ check is failed the item will be unavailable. If all options are disabled you either have a well\ + \ stocked warehouse, or your most senior Admin/Logistics character may not be up to the task.\ +

Full documentation can be found in ''MekHQ/docs/Stratcon and Against the Bot''

+outOfCharacter.itinerary=If your resupply seems smaller than expected it's possible your warehouse is well stocked and\ + \ your employer (or smuggler) withheld supplies. Alternatively your negotiator may have performed poorly when negotiating\ + \ for resources.\ +

You negotiatiator is normally your senior-most Admin/Logistics character, however interactions with smugglers use\ + \ your campaign commander, instead.

\ +

Full documentation can be found in ''MekHQ/docs/Stratcon and Against the Bot''

+outOfCharacter.roleplay=This is a roleplay event and has no mechanical impact for now...\ +

Full documentation can be found in ''MekHQ/docs/Stratcon and Against the Bot''

convoySuccessful.text=A convoy has {0}arrived{1}, and its supplies have been distributed by\ \ your logistics personnel. @@ -153,10 +194,6 @@ focusDescription.text={0}, we might be able to lean a little on our contact and
\
Would you like to pick a focus? I''ve already disabled any options our employer is refusing to\ \ fulfill. -focusDescription.ooc=Your employer will refuse to resupply parts you already have large quantities\ - \ of. For those items your employer is willing to supply a Negotiation check must be made, if the\ - \ check is failed the item will be unavailable. If all options are disabled you either have a well\ - \ stocked warehouse, or your most senior Admin/Logistics character may not be up to the task. supplyCostFull.text=

This resupply will cost {0}.\

The value of these supplies is {1}. @@ -2203,7 +2240,7 @@ statusUpdateEnemyOverwhelming49.text={0}, we faced a series of well-timed strike \ Current assessment indicates a high likelihood of additional attacks in this sector. statusUpdateIntercepted.boilerplate={0}, hostile interception underway. Incoming contacts unrelenting.\ - \ Reinforcements needed urgently. They''re closing in fast.{1} + \ Reinforcements needed urgently. They''re closing in fast. statusUpdateIntercepted0.text={0}, rear assault underway. Hostile ''Meks penetrating our lines.\ \ Transports are fully exposed; formation in disarray. Incoming contacts on sensors.\ \ Reinforcements needed urgently. Attempting to fall back, but we''re in serious trouble. They''re closing in\ @@ -2257,12 +2294,6 @@ statusUpdateIntercepted18.text={0}, under relentless fire. Supplies compromised, statusUpdateIntercepted19.text={0}, situation hopeless. Last line of defense lost. Convoy collapsing,\ \ all units breaking down. Reinforcements needed urgently.{1} -interceptionInstructions.text=

A special scenario has been generated. Failure to complete\ - \ this scenario will result in the loss of all units, personnel, and cargo. - - - - statusUpdateAbandoned0.text={0}, we''re being overwhelmed! Enemy ''Meks are breaching our lines, and\ \ half the transports are lost! Supplies are about to be captured, and the crew\ \ is down. No reinforcements in sight! They''re breaking through the barricade -\ @@ -3510,4 +3541,4 @@ proposition99.text={0}, you''ve made significant progress in locating the Star L \ offer is straightforward and beneficial for both parties. We recommend acting promptly. propositionValue.text=We''re offering {0} for the depot''s location, sealed and unsullied. -senderUnknown.text=Sender Unknown \ No newline at end of file +senderUnknown.text=Sender Unknown diff --git a/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/PerformResupply.java b/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/PerformResupply.java index 56e6e58518c..02349d8ffb4 100644 --- a/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/PerformResupply.java +++ b/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/PerformResupply.java @@ -24,9 +24,15 @@ * * Catalyst Game Labs and the Catalyst Game Labs logo are trademarks of * InMediaRes Productions, LLC. + * + * MechWarrior Copyright Microsoft Corporation. MekHQ was created under + * Microsoft's "Game Content Usage Rules" + * and it is not endorsed by or + * affiliated with Microsoft. */ package mekhq.campaign.mission.resupplyAndCaches; +import static megamek.common.Compute.randomInt; import static mekhq.campaign.mission.enums.AtBMoraleLevel.CRITICAL; import static mekhq.campaign.mission.enums.AtBMoraleLevel.DOMINATING; import static mekhq.campaign.mission.enums.AtBMoraleLevel.STALEMATE; @@ -39,6 +45,7 @@ import static mekhq.campaign.mission.resupplyAndCaches.Resupply.RESUPPLY_ARMOR_TONNAGE; import static mekhq.campaign.mission.resupplyAndCaches.Resupply.ResupplyType.RESUPPLY_CONTRACT_END; import static mekhq.campaign.mission.resupplyAndCaches.Resupply.ResupplyType.RESUPPLY_LOOT; +import static mekhq.campaign.personnel.enums.PersonnelRole.GROUND_VEHICLE_DRIVER; import static mekhq.campaign.stratcon.StratconContractInitializer.getUnoccupiedCoords; import static mekhq.campaign.stratcon.StratconRulesManager.generateExternalScenario; import static mekhq.gui.dialog.resupplyAndCaches.DialogItinerary.itineraryDialog; @@ -58,9 +65,11 @@ import megamek.common.Compute; import megamek.common.Entity; import megamek.common.annotations.Nullable; +import megamek.common.enums.Gender; import megamek.logging.MMLogger; import mekhq.MekHQ; import mekhq.campaign.Campaign; +import mekhq.campaign.Hangar; import mekhq.campaign.force.Force; import mekhq.campaign.mission.AtBContract; import mekhq.campaign.mission.AtBDynamicScenario; @@ -71,14 +80,14 @@ import mekhq.campaign.parts.Armor; import mekhq.campaign.parts.Part; import mekhq.campaign.parts.equipment.AmmoBin; +import mekhq.campaign.personnel.Person; import mekhq.campaign.stratcon.StratconCampaignState; import mekhq.campaign.stratcon.StratconCoords; import mekhq.campaign.stratcon.StratconScenario; import mekhq.campaign.stratcon.StratconTrackState; -import mekhq.gui.dialog.resupplyAndCaches.DialogInterception; +import mekhq.gui.baseComponents.immersiveDialogs.ImmersiveDialogSimple; import mekhq.gui.dialog.resupplyAndCaches.DialogPlayerConvoyOption; import mekhq.gui.dialog.resupplyAndCaches.DialogResupplyFocus; -import mekhq.gui.dialog.resupplyAndCaches.DialogRoleplayEvent; import mekhq.gui.dialog.resupplyAndCaches.DialogSwindled; /** @@ -148,7 +157,6 @@ public static void performResupply(Resupply resupply, AtBContract contract, int return; } - final Campaign campaign = resupply.getCampaign(); final boolean isIndependent = contract.getCommandRights().isIndependent(); final boolean isGuerrilla = contract.getContractType().isGuerrillaWarfare(); final ResupplyType resupplyType = resupply.getResupplyType(); @@ -260,7 +268,7 @@ public static void makeSmugglerDelivery(Resupply resupply) { final AtBContract contract = resupply.getContract(); int swindleChance = contract.getMoraleLevel().ordinal(); - if (Compute.randomInt(10) < swindleChance) { + if (randomInt(10) < swindleChance) { new DialogSwindled(resupply); } else { final Campaign campaign = resupply.getCampaign(); @@ -387,7 +395,7 @@ public static void processConvoy(Resupply resupply, List convoyContents, @ interceptionChance = Math.max(1, interceptionChance); // With interception chance calculated, we check to see whether an interception or event has occurred. - if (Compute.randomInt(10) < interceptionChance) { + if (randomInt(10) < interceptionChance) { generateInterceptionOrConvoyEvent(resupply, playerConvoy, convoyContents, interceptionChance); } else { completeSuccessfulDelivery(resupply, convoyContents); @@ -416,7 +424,7 @@ private static void generateInterceptionOrConvoyEvent(Resupply resupply, @Nullab final Campaign campaign = resupply.getCampaign(); final AtBContract contract = resupply.getContract(); - if (Compute.randomInt(10) < interceptionChance) { + if (randomInt(10) < interceptionChance) { processConvoyInterception(resupply, convoy, convoyContents); } else { // If it is an NPC convoy, we skip roleplay events @@ -441,21 +449,23 @@ private static void generateInterceptionOrConvoyEvent(Resupply resupply, @Nullab String eventText; if (Compute.d6() <= 2) { - eventText = getFormattedTextAt(RESOURCE_BUNDLE, - STATUS_FORWARD + Compute.randomInt(100) + STATUS_AFTERWARD); + eventText = getFormattedTextAt(RESOURCE_BUNDLE, STATUS_FORWARD + randomInt(100) + STATUS_AFTERWARD); } else { - int roll = Compute.randomInt(2); + int roll = randomInt(2); if (morale.isAdvancing() || morale.isWeakened()) { morale = roll == 0 ? (morale.isAdvancing() ? DOMINATING : CRITICAL) : STALEMATE; } eventText = getFormattedTextAt(RESOURCE_BUNDLE, - STATUS_FORWARD + "Enemy" + morale + Compute.randomInt(50) + STATUS_AFTERWARD, + STATUS_FORWARD + "Enemy" + morale + randomInt(50) + STATUS_AFTERWARD, commanderAddress); } - new DialogRoleplayEvent(campaign, convoy, eventText); + Person speaker = campaign.getPerson(convoy.getForceCommanderID()); + String outOfCharacterMessage = getFormattedTextAt(RESOURCE_BUNDLE, "outOfCharacter.roleplay"); + new ImmersiveDialogSimple(campaign, speaker, null, eventText, null, outOfCharacterMessage, null, false); + completeSuccessfulDelivery(resupply, convoyContents); } } @@ -503,8 +513,8 @@ private static void processConvoyInterception(Resupply resupply, @Nullable Force final Campaign campaign = resupply.getCampaign(); final AtBContract contract = resupply.getContract(); - // Trigger a dialog to inform the user an interception has taken place - new DialogInterception(resupply, targetConvoy); + // Trigger a dialog to inform the user that an interception has taken place + displayDialog(targetConvoy, campaign, contract); // Determine which scenario template to use based on convoy state String templateAddress = GENERIC; @@ -616,6 +626,43 @@ private static void processConvoyInterception(Resupply resupply, @Nullable Force } } + private static void displayDialog(Force targetConvoy, Campaign campaign, AtBContract contract) { + Person speaker; + String inCharacterMessage = ""; + String commanderAddress = campaign.getCommanderAddress(false); + if (targetConvoy != null) { + speaker = campaign.getPerson(targetConvoy.getForceCommanderID()); + + Hangar hangar = campaign.getHangar(); + if (targetConvoy.forceContainsOnlyVTOLForces(hangar, false) || + targetConvoy.forceContainsOnlyAerialForces(hangar, false, false)) { + inCharacterMessage = getFormattedTextAt(RESOURCE_BUNDLE, + "statusUpdateIntercepted.boilerplate", + commanderAddress); + } + } else { + // We invent an NPC driver for NPC convoys + speaker = campaign.newPerson(GROUND_VEHICLE_DRIVER, contract.getEmployerCode(), Gender.RANDOMIZE); + } + + if (inCharacterMessage.isBlank()) { + inCharacterMessage = getFormattedTextAt(RESOURCE_BUNDLE, + "statusUpdateIntercepted" + randomInt(20) + ".text", + campaign.getCommanderAddress(false)); + } + + String outOfCharacterMessage = getFormattedTextAt(RESOURCE_BUNDLE, "outOfCharacter.intercepted"); + + new ImmersiveDialogSimple(campaign, + speaker, + null, + inCharacterMessage, + null, + outOfCharacterMessage, + null, + false); + } + /** * Handles the fallback scenario where a resupply convoy escapes. * diff --git a/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/ResupplyUtilities.java b/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/ResupplyUtilities.java index 413574abc39..b2f02cb2927 100644 --- a/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/ResupplyUtilities.java +++ b/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/ResupplyUtilities.java @@ -24,9 +24,26 @@ * * Catalyst Game Labs and the Catalyst Game Labs logo are trademarks of * InMediaRes Productions, LLC. + * + * MechWarrior Copyright Microsoft Corporation. MekHQ was created under + * Microsoft's "Game Content Usage Rules" + * and it is not endorsed by or + * affiliated with Microsoft. */ package mekhq.campaign.mission.resupplyAndCaches; +import static java.lang.Math.max; +import static megamek.common.Compute.randomInt; +import static mekhq.campaign.force.ForceType.CONVOY; +import static mekhq.campaign.mission.resupplyAndCaches.Resupply.CARGO_MULTIPLIER; +import static mekhq.campaign.mission.resupplyAndCaches.Resupply.RESUPPLY_AMMO_TONNAGE; +import static mekhq.campaign.mission.resupplyAndCaches.Resupply.RESUPPLY_ARMOR_TONNAGE; +import static mekhq.campaign.mission.resupplyAndCaches.Resupply.calculateTargetCargoTonnage; +import static mekhq.campaign.personnel.enums.PersonnelStatus.KIA; +import static mekhq.utilities.MHQInternationalization.getFormattedTextAt; + +import java.util.UUID; + import megamek.common.Compute; import mekhq.campaign.Campaign; import mekhq.campaign.force.Force; @@ -35,17 +52,7 @@ import mekhq.campaign.personnel.Person; import mekhq.campaign.personnel.enums.PersonnelStatus; import mekhq.campaign.unit.Unit; -import mekhq.gui.dialog.resupplyAndCaches.DialogAbandonedConvoy; - -import java.util.UUID; - -import static java.lang.Math.max; -import static mekhq.campaign.force.ForceType.CONVOY; -import static mekhq.campaign.mission.resupplyAndCaches.Resupply.CARGO_MULTIPLIER; -import static mekhq.campaign.mission.resupplyAndCaches.Resupply.RESUPPLY_AMMO_TONNAGE; -import static mekhq.campaign.mission.resupplyAndCaches.Resupply.RESUPPLY_ARMOR_TONNAGE; -import static mekhq.campaign.mission.resupplyAndCaches.Resupply.calculateTargetCargoTonnage; -import static mekhq.campaign.personnel.enums.PersonnelStatus.KIA; +import mekhq.gui.baseComponents.immersiveDialogs.ImmersiveDialogSimple; /** * Utility class for managing resupply operations and events in MekHQ campaigns. @@ -65,6 +72,8 @@ *

This utility is central to the logistics and event-handling systems present in MekHQ's resupply mechanics.

*/ public class ResupplyUtilities { + private static final String RESOURCE_BUNDLE = "mekhq.resources.Resupply"; + /** * Processes an abandoned convoy, managing the removal of units and determining the fate of the * convoy's crew members. @@ -94,7 +103,22 @@ public static void processAbandonedConvoy(Campaign campaign, AtBContract contrac } if (force.isForceType(CONVOY) && force.getScenarioId() == scenarioId) { - new DialogAbandonedConvoy(campaign, contract, force); + Person speaker = campaign.getPerson(force.getForceCommanderID()); + + String commanderAddress = campaign.getCommanderAddress(false); + String inCharacterMessage = getFormattedTextAt(RESOURCE_BUNDLE, + "statusUpdateAbandoned" + randomInt(20) + ".text", + commanderAddress); + String outOfCharacterMessage = getFormattedTextAt(RESOURCE_BUNDLE, "outOfCharacter.abandoned"); + + new ImmersiveDialogSimple(campaign, + speaker, + null, + inCharacterMessage, + null, + outOfCharacterMessage, + null, + false); for (UUID unitID : force.getAllUnits(false)) { Unit unit = campaign.getUnit(unitID); diff --git a/MekHQ/src/mekhq/gui/dialog/resupplyAndCaches/DialogAbandonedConvoy.java b/MekHQ/src/mekhq/gui/dialog/resupplyAndCaches/DialogAbandonedConvoy.java index 1828fae46de..31258791f71 100644 --- a/MekHQ/src/mekhq/gui/dialog/resupplyAndCaches/DialogAbandonedConvoy.java +++ b/MekHQ/src/mekhq/gui/dialog/resupplyAndCaches/DialogAbandonedConvoy.java @@ -24,6 +24,11 @@ * * Catalyst Game Labs and the Catalyst Game Labs logo are trademarks of * InMediaRes Productions, LLC. + * + * MechWarrior Copyright Microsoft Corporation. MekHQ was created under + * Microsoft's "Game Content Usage Rules" + * and it is not endorsed by or + * affiliated with Microsoft. */ package mekhq.gui.dialog.resupplyAndCaches; @@ -57,10 +62,9 @@ import mekhq.campaign.personnel.Person; /** - * This class provides a utility method to display a custom dialog related to abandoned convoys in the MekHQ game. The - * dialog includes detailed information and visuals, like the convoy commander or speaker, a status update message, and - * employer details. + * @deprecated Unused */ +@Deprecated(since = "0.05.06", forRemoval = true) public class DialogAbandonedConvoy extends JDialog { final int LEFT_WIDTH = UIUtil.scaleForGUI(200); final int RIGHT_WIDTH = UIUtil.scaleForGUI(400); diff --git a/MekHQ/src/mekhq/gui/dialog/resupplyAndCaches/DialogContractStart.java b/MekHQ/src/mekhq/gui/dialog/resupplyAndCaches/DialogContractStart.java index 4e4e8fcd9a1..996fe6c3926 100644 --- a/MekHQ/src/mekhq/gui/dialog/resupplyAndCaches/DialogContractStart.java +++ b/MekHQ/src/mekhq/gui/dialog/resupplyAndCaches/DialogContractStart.java @@ -24,54 +24,40 @@ * * Catalyst Game Labs and the Catalyst Game Labs logo are trademarks of * InMediaRes Productions, LLC. + * + * MechWarrior Copyright Microsoft Corporation. MekHQ was created under + * Microsoft's "Game Content Usage Rules" + * and it is not endorsed by or + * affiliated with Microsoft. */ package mekhq.gui.dialog.resupplyAndCaches; -import static megamek.utilities.ImageUtilities.scaleImageIcon; +import static mekhq.campaign.Campaign.AdministratorSpecialization.LOGISTICS; import static mekhq.campaign.force.ForceType.CONVOY; import static mekhq.campaign.mission.resupplyAndCaches.Resupply.isProhibitedUnitType; import static mekhq.campaign.mission.resupplyAndCaches.ResupplyUtilities.estimateCargoRequirements; -import static mekhq.gui.baseComponents.immersiveDialogs.ImmersiveDialogCore.getSpeakerDescription; -import static mekhq.gui.baseComponents.immersiveDialogs.ImmersiveDialogCore.getSpeakerIcon; import static mekhq.utilities.MHQInternationalization.getFormattedTextAt; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; import java.util.UUID; -import javax.swing.BorderFactory; -import javax.swing.Box; -import javax.swing.BoxLayout; -import javax.swing.ImageIcon; -import javax.swing.JButton; import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.SwingConstants; -import megamek.client.ui.swing.util.UIUtil; import megamek.common.Entity; import mekhq.campaign.Campaign; -import mekhq.campaign.Campaign.AdministratorSpecialization; import mekhq.campaign.force.Force; import mekhq.campaign.mission.AtBContract; -import mekhq.campaign.personnel.Person; import mekhq.campaign.unit.Unit; +import mekhq.gui.baseComponents.immersiveDialogs.ImmersiveDialogSimple; /** * This class provides utility methods to display dialogs related to the beginning of a contract. It generates * user-friendly messages summarizing cargo requirements, player convoy capabilities, and mission details. */ public class DialogContractStart extends JDialog { - final int LEFT_WIDTH = UIUtil.scaleForGUI(200); - final int RIGHT_WIDTH = UIUtil.scaleForGUI(400); - final int INSERT_SIZE = UIUtil.scaleForGUI(10); - private static final String RESOURCE_BUNDLE = "mekhq.resources.Resupply"; + private final Campaign campaign; + private final AtBContract contract; + /** * Displays a dialog at the start of a contract, providing summarized details about the mission and player convoy * capabilities. The content is dynamically generated based on the given {@link Campaign} and {@link AtBContract}. @@ -84,111 +70,22 @@ public class DialogContractStart extends JDialog { * @param contract the active contract. */ public DialogContractStart(Campaign campaign, AtBContract contract) { - setTitle(getFormattedTextAt(RESOURCE_BUNDLE, "incomingTransmission.title")); - - // Main Panel to hold both boxes - JPanel mainPanel = new JPanel(new GridBagLayout()); - GridBagConstraints constraints = new GridBagConstraints(); - constraints.insets = new Insets(INSERT_SIZE, INSERT_SIZE, INSERT_SIZE, INSERT_SIZE); - constraints.fill = GridBagConstraints.BOTH; - constraints.weighty = 1; - - // Left box for speaker details - JPanel leftBox = new JPanel(); - leftBox.setLayout(new BoxLayout(leftBox, BoxLayout.Y_AXIS)); - leftBox.setAlignmentX(Component.LEFT_ALIGNMENT); - - // Get speaker details - Person speaker = campaign.getSeniorAdminPerson(AdministratorSpecialization.LOGISTICS); - - String speakerName; - if (speaker != null) { - speakerName = speaker.getFullTitle(); - } else { - speakerName = campaign.getName(); - } - - // Add speaker image (icon) - ImageIcon speakerIcon = getSpeakerIcon(campaign, speaker); - if (speakerIcon != null) { - speakerIcon = scaleImageIcon(speakerIcon, 100, true); - } - JLabel imageLabel = new JLabel(); - imageLabel.setIcon(speakerIcon); - imageLabel.setAlignmentX(Component.CENTER_ALIGNMENT); - - // Speaker description (below the icon) - StringBuilder speakerDescription = getSpeakerDescription(campaign, speaker, speakerName); - JLabel leftDescription = new JLabel(String.format( - "
%s
", - LEFT_WIDTH, - speakerDescription)); - leftDescription.setAlignmentX(Component.CENTER_ALIGNMENT); - - // Add the image and description to the leftBox - leftBox.add(imageLabel); - leftBox.add(Box.createRigidArea(new Dimension(0, INSERT_SIZE))); - leftBox.add(leftDescription); - - // Add leftBox to mainPanel - constraints.gridx = 0; - constraints.gridy = 0; - constraints.weightx = 0; - mainPanel.add(leftBox, constraints); - - // Right box: Just a message - JPanel rightBox = new JPanel(new BorderLayout()); - rightBox.setBorder(BorderFactory.createEtchedBorder()); - - String message = generateContractStartMessage(campaign, contract); - - JLabel rightDescription = new JLabel(String.format( - "
%s
", - RIGHT_WIDTH, - message)); - rightBox.add(rightDescription); - - // Add rightBox to mainPanel - constraints.gridx = 1; - constraints.weightx = 1; // Allow horizontal stretching - mainPanel.add(rightBox, constraints); - - add(mainPanel, BorderLayout.CENTER); - - // Create a container panel to hold both the button panel and the new panel - JPanel containerPanel = new JPanel(); - containerPanel.setLayout(new BoxLayout(containerPanel, BoxLayout.Y_AXIS)); // Stack vertically - - // Buttons panel - JPanel buttonPanel = new JPanel(); - JButton confirmButton = new JButton(getFormattedTextAt(RESOURCE_BUNDLE, "convoyConfirm.text")); - confirmButton.addActionListener(e -> dispose()); - buttonPanel.add(confirmButton); - - // Add the button panel to the container - containerPanel.add(buttonPanel); - - // New panel (to be added below the button panel) - JPanel infoPanel = new JPanel(new BorderLayout()); - JLabel lblInfo = new JLabel(String.format("
%s
", - RIGHT_WIDTH + LEFT_WIDTH, - getFormattedTextAt(RESOURCE_BUNDLE, "documentation.prompt"))); - lblInfo.setHorizontalAlignment(SwingConstants.CENTER); - infoPanel.add(lblInfo, BorderLayout.CENTER); - infoPanel.setBorder(BorderFactory.createEtchedBorder()); - - // Add the new panel to the container (below the button panel) - containerPanel.add(infoPanel); - - // Add the container panel to the dialog (at the bottom of the layout) - add(containerPanel, BorderLayout.SOUTH); - - // Dialog settings - pack(); - setModal(true); - setLocationRelativeTo(null); - setDefaultCloseOperation(DISPOSE_ON_CLOSE); - setVisible(true); + this.campaign = campaign; + this.contract = contract; + + String outOfCharacterMessageKey = "outOfCharacter.contractStart." + + (contract.getContractType().isGuerrillaWarfare() ? + "guerrilla" : + "normal"); + + new ImmersiveDialogSimple(campaign, + campaign.getSeniorAdminPerson(LOGISTICS), + null, + generateContractStartMessage(), + null, + getFormattedTextAt(RESOURCE_BUNDLE, outOfCharacterMessageKey), + null, + false); } /** @@ -203,13 +100,10 @@ public DialogContractStart(Campaign campaign, AtBContract contract) { * readiness, excluding units that are damaged, uncrewed, or prohibited. - Formats the message using localized * templates from the resource bundle. * - * @param campaign the current {@link Campaign}. - * @param contract the current {@link AtBContract}. - * * @return an HTML-formatted string message summarizing the player's readiness and convoy details in the context of * the contract. */ - private static String generateContractStartMessage(Campaign campaign, AtBContract contract) { + private String generateContractStartMessage() { int playerConvoys = 0; double totalPlayerCargoCapacity = 0; @@ -275,9 +169,6 @@ private static String generateContractStartMessage(Campaign campaign, AtBContrac playerConvoys != 1 ? "s" : ""); } - int width = UIUtil.scaleForGUI(500); - return String.format("
%s
", - width, - convoyMessage); + return convoyMessage; } } diff --git a/MekHQ/src/mekhq/gui/dialog/resupplyAndCaches/DialogInterception.java b/MekHQ/src/mekhq/gui/dialog/resupplyAndCaches/DialogInterception.java index 4577e52d5ba..66ed4192497 100644 --- a/MekHQ/src/mekhq/gui/dialog/resupplyAndCaches/DialogInterception.java +++ b/MekHQ/src/mekhq/gui/dialog/resupplyAndCaches/DialogInterception.java @@ -24,6 +24,11 @@ * * Catalyst Game Labs and the Catalyst Game Labs logo are trademarks of * InMediaRes Productions, LLC. + * + * MechWarrior Copyright Microsoft Corporation. MekHQ was created under + * Microsoft's "Game Content Usage Rules" + * and it is not endorsed by or + * affiliated with Microsoft. */ package mekhq.gui.dialog.resupplyAndCaches; @@ -60,10 +65,9 @@ import mekhq.campaign.personnel.Person; /** - * The {@code DialogInterception} class is responsible for displaying a UI dialog when an interception scenario occurs - * during a supply or convoy mission in MekHQ. The dialog uses localized resources to generate the content dynamically - * and includes relevant visual elements like the speaker's icon, title, and mission details. + * @deprecated unused */ +@Deprecated(since = "0.05.06", forRemoval = true) public class DialogInterception extends JDialog { final int LEFT_WIDTH = UIUtil.scaleForGUI(200); final int RIGHT_WIDTH = UIUtil.scaleForGUI(400); diff --git a/MekHQ/src/mekhq/gui/dialog/resupplyAndCaches/DialogItinerary.java b/MekHQ/src/mekhq/gui/dialog/resupplyAndCaches/DialogItinerary.java index 3108c8cc064..6325ef0e53e 100644 --- a/MekHQ/src/mekhq/gui/dialog/resupplyAndCaches/DialogItinerary.java +++ b/MekHQ/src/mekhq/gui/dialog/resupplyAndCaches/DialogItinerary.java @@ -247,7 +247,7 @@ public static void itineraryDialog(Resupply resupply) { "
%s
%s
", DIALOG_WIDTH, getFormattedTextAt(RESOURCE_BUNDLE, "roleplayItems.prompt"), - getFormattedTextAt(RESOURCE_BUNDLE, "documentation.prompt"))); + getFormattedTextAt(RESOURCE_BUNDLE, "outOfCharacter.itinerary"))); infoPanel.add(lblInfo); // Create a container panel to hold both buttonPanel and infoPanel diff --git a/MekHQ/src/mekhq/gui/dialog/resupplyAndCaches/DialogPlayerConvoyOption.java b/MekHQ/src/mekhq/gui/dialog/resupplyAndCaches/DialogPlayerConvoyOption.java index ccffedc4d8a..71f9d690a00 100644 --- a/MekHQ/src/mekhq/gui/dialog/resupplyAndCaches/DialogPlayerConvoyOption.java +++ b/MekHQ/src/mekhq/gui/dialog/resupplyAndCaches/DialogPlayerConvoyOption.java @@ -24,6 +24,11 @@ * * Catalyst Game Labs and the Catalyst Game Labs logo are trademarks of * InMediaRes Productions, LLC. + * + * MechWarrior Copyright Microsoft Corporation. MekHQ was created under + * Microsoft's "Game Content Usage Rules" + * and it is not endorsed by or + * affiliated with Microsoft. */ package mekhq.gui.dialog.resupplyAndCaches; @@ -235,8 +240,7 @@ public DialogPlayerConvoyOption(Resupply resupply, boolean forcedUseOfPlayerConv // New panel (to be added below the button panel) JPanel infoPanel = new JPanel(new BorderLayout()); JLabel lblInfo = new JLabel(String.format("
%s
", - RIGHT_WIDTH + LEFT_WIDTH, - getFormattedTextAt(RESOURCE_BUNDLE, "documentation.prompt"))); + RIGHT_WIDTH + LEFT_WIDTH, getFormattedTextAt(RESOURCE_BUNDLE, "outOfCharacter.convoyPicker"))); lblInfo.setHorizontalAlignment(SwingConstants.CENTER); infoPanel.add(lblInfo, BorderLayout.CENTER); infoPanel.setBorder(BorderFactory.createEtchedBorder()); diff --git a/MekHQ/src/mekhq/gui/dialog/resupplyAndCaches/DialogResupplyFocus.java b/MekHQ/src/mekhq/gui/dialog/resupplyAndCaches/DialogResupplyFocus.java index 2b673d1cc43..ec1b97ef3be 100644 --- a/MekHQ/src/mekhq/gui/dialog/resupplyAndCaches/DialogResupplyFocus.java +++ b/MekHQ/src/mekhq/gui/dialog/resupplyAndCaches/DialogResupplyFocus.java @@ -24,6 +24,11 @@ * * Catalyst Game Labs and the Catalyst Game Labs logo are trademarks of * InMediaRes Productions, LLC. + * + * MechWarrior Copyright Microsoft Corporation. MekHQ was created under + * Microsoft's "Game Content Usage Rules" + * and it is not endorsed by or + * affiliated with Microsoft. */ package mekhq.gui.dialog.resupplyAndCaches; @@ -224,8 +229,7 @@ public DialogResupplyFocus(Resupply resupply) { // OOC panel (to be added below the button panel) JPanel infoPanel = new JPanel(new BorderLayout()); JLabel lblInfo = new JLabel(String.format("
%s
", - RIGHT_WIDTH + LEFT_WIDTH, - getFormattedTextAt(RESOURCE_BUNDLE, "focusDescription.ooc"))); + RIGHT_WIDTH + LEFT_WIDTH, getFormattedTextAt(RESOURCE_BUNDLE, "outOfCharacter.focus"))); lblInfo.setHorizontalAlignment(SwingConstants.CENTER); infoPanel.add(lblInfo, BorderLayout.CENTER); infoPanel.setBorder(BorderFactory.createEtchedBorder()); diff --git a/MekHQ/src/mekhq/gui/dialog/resupplyAndCaches/DialogRoleplayEvent.java b/MekHQ/src/mekhq/gui/dialog/resupplyAndCaches/DialogRoleplayEvent.java index e241ff94b8e..13f452c0024 100644 --- a/MekHQ/src/mekhq/gui/dialog/resupplyAndCaches/DialogRoleplayEvent.java +++ b/MekHQ/src/mekhq/gui/dialog/resupplyAndCaches/DialogRoleplayEvent.java @@ -55,10 +55,9 @@ import mekhq.campaign.personnel.Person; /** - * The {@code DialogRoleplayEvent} class handles the creation and display of roleplay event dialogs for convoy missions - * in MekHQ. These dialogs provide narrative elements to enhance the immersion of convoy missions by using dynamic - * content, player convoy details, and localized text. + * @deprecated unused */ +@Deprecated(since = "0.05.06", forRemoval = true) public class DialogRoleplayEvent extends JDialog { final int LEFT_WIDTH = UIUtil.scaleForGUI(200); final int RIGHT_WIDTH = UIUtil.scaleForGUI(400);