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

Refactored Outstanding Scenarios Nag Dialog To Use Immersive Dialog Framework #6403

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
12 changes: 5 additions & 7 deletions MekHQ/resources/mekhq/resources/GUI.properties
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,12 @@ ignoreFutureNags.checkbox=Don't show this again
button.advanceDay=Advance Day
button.cancel=Cancel
### Nag Messages
OutstandingScenariosNagDialog.text=%s, our forces are positioned for combat but await your commands to\
\ proceed. Alternatively, you may order a tactical withdrawal by advancing the day. Do you wish\
\ to proceed without addressing these engagements?\
NoCommanderNagDialog.text=Please be advised that no commanding officer is currently assigned\
\ to our unit. This could affect operational outcomes and mission planning. Confirm your intent\
\ to proceed, or assign a commander to maintain strategic efficiency.\
<br>\
<br>The following scenarios await resolution:%s%s
OutstandingScenariosNagDialog.stratCon=<br>\
<br><i>We can pay 1 CVP to tactically withdraw from any scenario marked as a <b>Turning Point</b>\
\ or <b>Crisis</b>. Withdrawal is free for all other scenarios.</i>
<br><i>You can assign one of your p 10000 ersonnel as the campaign commander by right-clicking on that\
\ character, navigating to Flags and selecting the Commander flag.</i>
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?
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,3 +1,4 @@
# suppress inspection "UnusedProperty" for whole file
# Buttons
button.cancel=I better take a look.
button.continue=Continue as ordered.
Expand Down Expand Up @@ -67,3 +68,13 @@ NoCommanderNagDialog.ic=Please be advised that no commanding officer is currentl
NoCommanderNagDialog.ooc=You can assign one of your personnel as the campaign commander by\
\ right-clicking on that character, navigating to Flags and selecting the Commander flag.</i>\
<p>If you accidentally suppress this warning, you can re-enable it in MekHQ Options.</p>
# Outstanding Scenarios
OutstandingScenariosNagDialog.ic={0}, our forces are positioned for combat but await your commands to\
\ proceed. Alternatively, you may order a tactical withdrawal by advancing the day. Do you wish\
\ to proceed without addressing these engagements?\
<p>The following scenarios await resolution:{1}</p>
OutstandingScenariosNagDialog.ooc=If using <a href=''GLOSSARY:STRATCON''>StratCon</a>, you can pay 1\
\ <a href=''GLOSSARY:CONTRACT_VICTORY_POINTS''>CVP</a> to tactically withdraw from any scenario\
\ marked as a <a href=''GLOSSARY:TURNING_POINT''>Turning Point</a> or\
\ <a href=''GLOSSARY:CRISIS_SCENARIO''>Crisis</a>. Withdrawal is free for all other scenarios.\
<p>If you accidentally suppress this warning, you can re-enable it in MekHQ Options.</p>
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 @@ -195,7 +195,7 @@ public static boolean triggerDailyNags(Campaign campaign) {
// Outstanding Scenarios
if (OutstandingScenariosNagDialog.checkNag(campaign)) {
OutstandingScenariosNagDialog outstandingScenariosNagDialog = new OutstandingScenariosNagDialog(campaign);
if (outstandingScenariosNagDialog.wasAdvanceDayCanceled()) {
if (outstandingScenariosNagDialog.shouldCancelAdvanceDay()) {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,55 +27,47 @@
*/
package mekhq.gui.dialog.nagDialogs;

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

import static mekhq.MHQConstants.NAG_OUTSTANDING_SCENARIOS;
import static mekhq.gui.dialog.nagDialogs.nagLogic.OutstandingScenariosNagLogic.getOutstandingScenarios;
import static mekhq.gui.dialog.nagDialogs.nagLogic.OutstandingScenariosNagLogic.hasOutStandingScenarios;
import static mekhq.utilities.MHQInternationalization.getFormattedTextAt;

import mekhq.MekHQ;
import mekhq.campaign.Campaign;
import mekhq.gui.baseComponents.immersiveDialogs.ImmersiveDialogNag;

/**
* Represents a nag dialog for displaying the list of outstanding scenarios in a campaign.
* A dialog class used to notify players about outstanding scenarios in their campaign.
*
* <p>
* This dialog checks for active scenarios within the campaign, categorizes them by
* their state (e.g., unresolved or requiring a track), and displays a list of these
* scenarios to the user. Scenarios are considered "outstanding" if they are unresolved or
* require attention on the current campaign date.
* </p>
*
* <p>
* The dialog includes logic to account for both AtB contracts and StratCon-enabled campaigns,
* formatting the outstanding scenarios with additional details when appropriate.
* </p>
* <p>The {@code OutstandingScenariosNagDialog} extends {@link ImmersiveDialogNag} and provides a specialized
* dialog designed to alert players when there are unresolved or pending scenarios in the campaign. It uses predefined
* values, including the {@code NAG_OUTSTANDING_SCENARIOS} constant, and does not include a specific speaker, relying
* instead on a default fallback mechanism.</p>
*/
public class OutstandingScenariosNagDialog extends AbstractMHQNagDialog {
public class OutstandingScenariosNagDialog extends ImmersiveDialogNag {

/**
* Constructs the OutstandingScenariosNagDialog for the given campaign.
* Constructs a new {@code OutstandingScenariosNagDialog} instance to display the outstanding scenarios nag dialog.
*
* <p>
* Upon initialization, this dialog prepares a formatted string of outstanding
* scenarios (if any) and sets up the dialog UI for display.
* </p>
* <p>This constructor initializes the dialog with preconfigured parameters, such as the
* {@code NAG_OUTSTANDING_SCENARIOS} constant for managing dialog suppression and the
* {@code "OutstandingScenariosNagDialog"} message key for retrieving localized dialog content. No specific speaker
* is provided, triggering fallback logic to determine a suitable speaker for the dialog.</p>
*
* @param campaign The {@link Campaign} associated with this nag dialog.
* @param campaign The {@link Campaign} instance associated with this dialog. Provides access to campaign data and
* settings required for constructing the dialog.
*/
public OutstandingScenariosNagDialog(final Campaign campaign) {
super(campaign, MHQConstants.NAG_OUTSTANDING_SCENARIOS);
super(campaign, null, NAG_OUTSTANDING_SCENARIOS, "OutstandingScenariosNagDialog");
}

final String DIALOG_BODY = "OutstandingScenariosNagDialog.text";
@Override
protected String getInCharacterMessage(Campaign campaign, String key, String commanderAddress) {
final String RESOURCE_BUNDLE = "mekhq.resources.NagDialogs";

String outstandingScenarios = getOutstandingScenarios(campaign);

String addendum = "";
if (campaign.getCampaignOptions().isUseStratCon()) {
addendum = resources.getString("OutstandingScenariosNagDialog.stratCon");
}

setRightDescriptionMessage(String.format(resources.getString(DIALOG_BODY),
campaign.getCommanderAddress(false), outstandingScenarios, addendum));
showDialog();
return getFormattedTextAt(RESOURCE_BUNDLE, key + ".ic", commanderAddress, outstandingScenarios);
}

/**
Expand All @@ -89,13 +81,14 @@ public OutstandingScenariosNagDialog(final Campaign campaign) {
* </ul>
*
* @param campaign the {@link Campaign} to check for nagging conditions
*
* @return {@code true} if the nag dialog should be displayed, {@code false} otherwise
*/
public static boolean checkNag(Campaign campaign) {
final String NAG_KEY = MHQConstants.NAG_OUTSTANDING_SCENARIOS;
final String NAG_KEY = NAG_OUTSTANDING_SCENARIOS;

return campaign.getCampaignOptions().isUseAtB()
&& !MekHQ.getMHQOptions().getNagDialogIgnore(NAG_KEY)
&& hasOutStandingScenarios(campaign);
return campaign.getCampaignOptions().isUseAtB() &&
!MekHQ.getMHQOptions().getNagDialogIgnore(NAG_KEY) &&
hasOutStandingScenarios(campaign);
}
}
0