8000 Updated Deployment Shortfall Nag To Use Immersive Dialog by IllianiBird · Pull Request #6382 · MegaMek/mekhq · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Updated Deployment Shortfall Nag To Use Immersive Dialog #6382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions MekHQ/resources/mekhq/resources/GUI.properties
Original file line number Diff line number Diff line change
Expand Up @@ -354,13 +354,6 @@ OutstandingScenariosNagDialog.stratCon=<br>\
PregnantCombatantNagDialog.text=%s, pregnant personnel have been identified in our TO&E, putting\
\ them at risk of harm. Reassignment is advised. Do you wish to advance the day without\
\ addressing this concern?
DeploymentShortfallNagDialog.text=%s, deployment levels fall below requirements for one or more active\
\ contracts. While advancing the day is an option, it may strain relations with our employer. Do\
\ you wish to continue without addressing this?\
<br>\
<br><i>You should head to the Briefing Room and address this shortfall. Remember, Combat Teams\
\ assigned to the Auxiliary or Reserve roles do not count towards deployment levels. Nor do\
\ Combat Teams assigned to the Training role, unless the contract is Cadre Duty.</i>
PrisonersNagDialog.text=%s, our forces are still holding prisoners of war. It is important to\
\ consider their status before advancing the day. Do you wish to continue without resolving this?\
<br>\
Expand Down
11 changes: 11 additions & 0 deletions MekHQ/resources/mekhq/resources/NagDialogs.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
# Buttons
button.cancel=I better take a look.
button.continue=Continue as ordered.
button.suppress=Continue and don''t bother me with future issues of this type.
# Admin Strain
AdminStrainNagDialog.ic={0}, my team is buckling under the strain. Memos are going unanswered. We''ve got people queuing\
\ up outside with complaints. We''ve even got reports of unpaid salaries. People are getting angry, and if we don''t\
\ solve the problem soon, they''re liable to quit.
AdminStrainNagDialog.ooc=Excess <a href=''GLOSSARY:ADMIN_STRAIN''>Administrative Strain</a> is addressed by hiring more\
\ Admin/HR personnel. If that isn''t viable, consider assigning your current Admin personnel to multiple roles.</p>\
<p>For more information, please see <i>MekHQ/docs/Personnel Modules/Turnover & Retention Module (feat. Fatigue).pdf</i></p>\
<p>If you accidentally suppress this warning, you can re-enable it in MekHQ Options.</p>
# Deployment Shortfall
DeploymentShortfallNagDialog.ic={0}, deployment levels have fallen below contractual requirements\
\ for one or more contracts. While advancing the day is an option, it may strain relations with\
\ our employer. Do you wish to continue without addressing this?
DeploymentShortfallNagDialog.ooc=You should head to the Briefing Room and address this shortfall.\
\ Remember, <a href=''GLOSSARY:COMBAT_TEAMS''>Combat Teams</a> assigned to the Auxiliary or\
\ Reserve roles do not count towards deployment levels. Nor do Combat Teams assigned to the\
\ Training role, unless the contract is Cadre Duty.\
<p>If you accidentally suppress this warning, you can re-enable it in MekHQ Options.</p>
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ public AdminStrainNagDialog(final Campaign campaign) {
MekHQ.getMHQOptions().setNagDialogIgnore(NAG_ADMIN_STRAIN, true);
cancelAdvanceDay = false;
}
default -> throw new IllegalStateException("Unexpected value in AdminStrainNagDialog: " + choiceIndex);
default -> throw new IllegalStateException("Unexpected value in " +
getClass().getSimpleName() +
": " +
choiceIndex);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,41 +27,101 @@
*/
package mekhq.gui.dialog.nagDialogs;

import mekhq.MHQConstants;
import static mekhq.MHQConstants.NAG_SHORT_DEPLOYMENT;
import static mekhq.campaign.Campaign.AdministratorSpecialization.COMMAND;
import static mekhq.gui.dialog.nagDialogs.nagLogic.DeploymentShortfallNagLogic.hasDeploymentShortfall;
import static mekhq.utilities.MHQInternationalization.getFormattedTextAt;

import java.util.ArrayList;
import java.util.List;

import mekhq.MekHQ;
import mekhq.campaign.Campaign;
import mekhq.gui.baseComponents.AbstractMHQNagDialog;

import static mekhq.gui.dialog.nagDialogs.nagLogic.DeploymentShortfallNagLogic.hasDeploymentShortfall;
import mekhq.gui.baseComponents.immersiveDialogs.ImmersiveDialogSimple;

/**
* A nag dialog that alerts the user if short deployments are detected in the campaign's active contracts.
*
* <p>
* This dialog checks whether any active AtB (Against the Bot) contracts have a deployment deficit
* and alerts the player to address the issue. The check is performed weekly (on Sundays) and only
* when the campaign is currently located on a planet. If deployment requirements are not met,
* the dialog is displayed to prompt the user to correct the situation.
* This dialog checks whether any active AtB (Against the Bot) contracts have a deployment deficit and alerts the player
* to address the issue. The check is performed weekly (on Sundays) and only when the campaign is currently located on a
* planet. If deployment requirements are not met, the dialog is displayed to prompt the user to correct the situation.
* </p>
*/
public class DeploymentShortfallNagDialog extends AbstractMHQNagDialog {
public class DeploymentShortfallNagDialog {
private final String RESOURCE_BUNDLE = "mekhq.resources.NagDialogs";

private final int CHOICE_CANCEL = 0;
private final int CHOICE_CONTINUE = 1;
private final int CHOICE_SUPPRESS = 2;

private final Campaign campaign;
private boolean cancelAdvanceDay;

/**
* Constructs the shortfall deployment nag dialog for a given campaign.
*
* <p>
* This constructor initializes the dialog with the specified campaign and
* formats the resource message to display information about deployment shortfalls.
* This constructor initializes the dialog with the specified campaign and formats the resource message to display
* information about deployment shortfalls.
* </p>
*
* @param campaign The {@link Campaign} object representing the current campaign.
*/
public DeploymentShortfallNagDialog(final Campaign campaign) {
super(campaign, MHQConstants.NAG_SHORT_DEPLOYMENT);
this.campaign = campaign;

ImmersiveDialogSimple dialog = new ImmersiveDialogSimple(campaign,
campaign.getSeniorAdminPerson(COMMAND),
null,
getFormattedTextAt(RESOURCE_BUNDLE,
"DeploymentShortfallNagDialog.ic",
campaign.getCommanderAddress(false)),
getButtonLabels(),
getFormattedTextAt(RESOURCE_BUNDLE, "DeploymentShortfallNagDialog.ooc"),
true);

int choiceIndex = dialog.getDialogChoice();

switch (choiceIndex) {
case CHOICE_CANCEL -> cancelAdvanceDay = true;
case CHOICE_CONTINUE -> cancelAdvanceDay = false;
case CHOICE_SUPPRESS -> {
MekHQ.getMHQOptions().setNagDialogIgnore(NAG_SHORT_DEPLOYMENT, true);
cancelAdvanceDay = false;
}
default -> throw new IllegalStateException("Unexpected value in " +
getClass().getSimpleName() +
": " +
choiceIndex);
}
}

final String DIALOG_BODY = "DeploymentShortfallNagDialog.text";
setRightDescriptionMessage(String.format(resources.getString(DIALOG_BODY),
campaign.getCommanderAddress(false)));
showDialog();
/**
* Retrieves a list of button labels from the resource bundle.
*
* <p>The method collects and returns button labels such as "Cancel", "Continue", and "Suppress" after
* formatting them using the provided resource bundle.</p>
*
* @return a {@link List} of formatted button labels as {@link String}.
*/
private List<String> getButtonLabels() {
List<String> buttonLabels = new ArrayList<>();

buttonLabels.add(getFormattedTextAt(RESOURCE_BUNDLE, "button.cancel"));
buttonLabels.add(getFormattedTextAt(RESOURCE_BUNDLE, "button.continue"));
buttonLabels.add(getFormattedTextAt(RESOURCE_BUNDLE, "button.suppress"));

return buttonLabels;
}

/**
* Determines whether the advance day operation should be canceled.
*
* @return {@code true} if advancing the day should be canceled, {@code false} otherwise.
*/
public boolean shouldCancelAdvanceDay() {
return cancelAdvanceDay;
}

/**
Expand All @@ -80,10 +140,8 @@ public DeploymentShortfallNagDialog(final Campaign campaign) {
* @return {@code true} if the nag dialog should be displayed due to deployment shortfalls; {@code false} otherwise.
*/
public static boolean checkNag(boolean isUseAtB, Campaign campaign) {
final String NAG_KEY = MHQConstants.NAG_SHORT_DEPLOYMENT;
final String NAG_KEY = NAG_SHORT_DEPLOYMENT;

return isUseAtB
&& !MekHQ.getMHQOptions().getNagDialogIgnore(NAG_KEY)
&& hasDeploymentShortfall(campaign);
return isUseAtB && !MekHQ.getMHQOptions().getNagDialogIgnore(NAG_KEY) && hasDeploymentShortfall(campaign);
}
}
2 changes: 1 addition & 1 deletion MekHQ/src/mekhq/gui/dialog/nagDialogs/NagController.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public static boolean triggerDailyNags(Campaign campaign) {

if (DeploymentShortfallNagDialog.checkNag(isUseAtB, campaign)) {
DeploymentShortfallNagDialog deploymentShortfallNagDialog = new DeploymentShortfallNagDialog(campaign);
if (deploymentShortfallNagDialog.wasAdvanceDayCanceled()) {
if (deploymentShortfallNagDialog.shouldCancelAdvanceDay()) {
return true;
}
}
Expand Down
0