Class ContractSpecialMechanicsNagDialog

java.lang.Object
mekhq.gui.baseComponents.immersiveDialogs.ImmersiveDialogNag
mekhq.gui.dialog.nagDialogs.ContractSpecialMechanicsNagDialog

public class ContractSpecialMechanicsNagDialog extends ImmersiveDialogNag
Briefs the player, when they accept a contract, on the special mechanics that contract type brings to StratCon under the "Contracts Use Special Mechanics" option (see StratConContractMechanics).

The briefing is out-of-character and sets out the rules exactly: the contract type's own rules, followed by the shared Escalation rules if the contract escalates. As these briefings are the only tutorial the player gets for these mechanics, the text must be kept in step with the rules.

The player can acknowledge the briefing, or acknowledge it and suppress future briefings for that contract type (see getNagKey(mekhq.campaign.mission.contract.contractData.ContractObjectiveType)). Each contract type is suppressed separately, since each has its own rules.

Since:
0.51.01
  • Method Details

    • showIfDue

      public static void showIfDue(Campaign campaign, AbstractContract contract)
      Shows the briefing for a newly accepted contract, if one is due (see isBriefingDue(mekhq.campaign.Campaign, mekhq.campaign.mission.contract.AbstractContract)).
      Parameters:
      campaign - the current campaign
      contract - the contract just accepted, with its StratCon state already set up
      Since:
      0.51.01
    • isBriefingDue

      public static boolean isBriefingDue(Campaign campaign, AbstractContract contract)
      Decides whether a newly accepted contract should be briefed on its special mechanics: the "Contracts Use Special Mechanics" option is on, the contract is run on a StratCon map (special mechanics are only set up there), its contract type has special mechanics, and the player has not suppressed the briefing for its contract type.
      Parameters:
      campaign - the current campaign
      contract - the contract just accepted
      Returns:
      true if the briefing should be shown
      Since:
      0.51.01
    • getNagKey

      public static String getNagKey(ContractObjectiveType objectiveType)
      Parameters:
      objectiveType - a contract type with special mechanics
      Returns:
      the key under which the player's choice to suppress that contract type's briefing is stored
      Since:
      0.51.01
    • getBriefedContractTypes

      public static List<ContractObjectiveType> getBriefedContractTypes()
      Returns:
      every contract type that has special mechanics, and so a briefing of its own, in declaration order
      Since:
      0.51.01
    • constructDialog

      protected ImmersiveDialogCore constructDialog(Campaign campaign, String messageKey)
      Description copied from class: ImmersiveDialogNag
      Constructs an ImmersiveDialogSimple instance for the nag dialog.

      This method creates an immersive dialog, setting the speaker based on the provided specialization, and populates it with in-character and out-of-character messages along with dialog button labels.

      Overrides:
      constructDialog in class ImmersiveDialogNag
      Parameters:
      campaign - The Campaign instance to associate with the dialog. Used to fetch relevant campaign data, such as the commander's address.
      messageKey - A String key used to retrieve localized text for the dialog's in-character and out-of-character messages.
      Returns:
      The constructed ImmersiveDialogSimple instance containing the specified speaker, messages, and button labels.
    • getSpeaker

      @Nullable protected Person getSpeaker(Campaign campaign)
      The briefing comes from the employer's liaison, falling back to the campaign's senior administrator.
      Overrides:
      getSpeaker in class ImmersiveDialogNag
      Parameters:
      campaign - The campaign context.
      Returns:
      The Person assigned as the speaker. This will either be the person matching the given specialization or, if unavailable, the one assigned to the "COMMAND" specialization.
      Since:
      0.51.01
    • createButtons

      There is nothing to cancel when accepting a contract, so the player can only acknowledge the briefing, or acknowledge it and suppress future briefings for this contract type.
      Overrides:
      createButtons in class ImmersiveDialogNag
      Returns:
      A list of button-label and tooltip pairs for this dialog.
      Since:
      0.51.01
    • processDialogChoice

      protected void processDialogChoice(int choiceIndex, String nagConstant)
      Description copied from class: ImmersiveDialogNag
      Handles the processing of a dialog choice based on the given index and updates related settings or state.

      This method performs different actions depending on the value of the choiceIndex:

      • If CHOICE_CANCEL is selected, it sets the operation to cancel advancing the day.
      • If CHOICE_CONTINUE is selected, it allows advancing the day.
      • If CHOICE_SUPPRESS is selected, it suppresses future dialog prompts associated with the given nag constant and allows advancing the day.
      • Throws an exception if the choiceIndex does not match any expected value.
      Overrides:
      processDialogChoice in class ImmersiveDialogNag
      Parameters:
      choiceIndex - An int representing the user's dialog choice. Must match one of the predefined constants (e.g., CHOICE_CANCEL, CHOICE_CONTINUE, or CHOICE_SUPPRESS).
      nagConstant - A String identifying the nag constant associated with the dialog choice. Used to manage whether future prompts with this constant should be suppressed.