Skip to content

Commit 1a43a57

Browse files
authored
Merge pull request #6403 from IllianiCBT/OutstandingScenariosNagDialogNew
Refactored Outstanding Scenarios Nag Dialog To Use Immersive Dialog Framework
2 parents e393320 + 1c88d57 commit 1a43a57

File tree

4 files changed

+48
-46
lines changed

4 files changed

+48
-46
lines changed

Diff for: MekHQ/resources/mekhq/resources/GUI.properties

+5-7
Original file line numberDiff line numberDiff line change
@@ -303,14 +303,12 @@ ignoreFutureNags.checkbox=Don't show this again
303303
button.advanceDay=Advance Day
304304
button.cancel=Cancel
305305
### Nag Messages
306-
OutstandingScenariosNagDialog.text=%s, our forces are positioned for combat but await your commands to\
307-
\ proceed. Alternatively, you may order a tactical withdrawal by advancing the day. Do you wish\
308-
\ to proceed without addressing these engagements?\
306+
NoCommanderNagDialog.text=Please be advised that no commanding officer is currently assigned\
307+
\ to our unit. This could affect operational outcomes and mission planning. Confirm your intent\
308+
\ to proceed, or assign a commander to maintain strategic efficiency.\
309309
<br>\
310-
<br>The following scenarios await resolution:%s%s
311-
OutstandingScenariosNagDialog.stratCon=<br>\
312-
<br><i>We can pay 1 CVP to tactically withdraw from any scenario marked as a <b>Turning Point</b>\
313-
\ or <b>Crisis</b>. Withdrawal is free for all other scenarios.</i>
310+
<br><i>You can assign one of your personnel as the campaign commander by right-clicking on that\
311+
\ character, navigating to Flags and selecting the Commander flag.</i>
314312
PregnantCombatantNagDialog.text=%s, pregnant personnel have been identified in our TO&E, putting\
315313
\ them at risk of harm. Reassignment is advised. Do you wish to advance the day without\
316314
\ addressing this concern?

Diff for: MekHQ/resources/mekhq/resources/NagDialogs.properties

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# suppress inspection "UnusedProperty" for whole file
12
# Buttons
23
button.cancel=I better take a look.
34
button.continue=Continue as ordered.
@@ -67,3 +68,13 @@ NoCommanderNagDialog.ic=Please be advised that no commanding officer is currentl
6768
NoCommanderNagDialog.ooc=You can assign one of your personnel as the campaign commander by\
6869
\ right-clicking on that character, navigating to Flags and selecting the Commander flag.</i>\
6970
<p>If you accidentally suppress this warning, you can re-enable it in MekHQ Options.</p>
71+
# Outstanding Scenarios
72+
OutstandingScenariosNagDialog.ic={0}, our forces are positioned for combat but await your commands to\
73+
\ proceed. Alternatively, you may order a tactical withdrawal by advancing the day. Do you wish\
74+
\ to proceed without addressing these engagements?\
75+
<p>The following scenarios await resolution:{1}</p>
76+
OutstandingScenariosNagDialog.ooc=If using <a href=''GLOSSARY:STRATCON''>StratCon</a>, you can pay 1\
77+
\ <a href=''GLOSSARY:CONTRACT_VICTORY_POINTS''>CVP</a> to tactically withdraw from any scenario\
78+
\ marked as a <a href=''GLOSSARY:TURNING_POINT''>Turning Point</a> or\
79+
\ <a href=''GLOSSARY:CRISIS_SCENARIO''>Crisis</a>. Withdrawal is free for all other scenarios.\
80+
<p>If you accidentally suppress this warning, you can re-enable it in MekHQ Options.</p>

Diff for: MekHQ/src/mekhq/gui/dialog/nagDialogs/NagController.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public static boolean triggerDailyNags(Campaign campaign) {
195195
// Outstanding Scenarios
196196
if (OutstandingScenariosNagDialog.checkNag(campaign)) {
197197
OutstandingScenariosNagDialog outstandingScenariosNagDialog = new OutstandingScenariosNagDialog(campaign);
198-
if (outstandingScenariosNagDialog.wasAdvanceDayCanceled()) {
198+
if (outstandingScenariosNagDialog.shouldCancelAdvanceDay()) {
199199
return true;
200200
}
201201
}

Diff for: MekHQ/src/mekhq/gui/dialog/nagDialogs/OutstandingScenariosNagDialog.java

+31-38
Original file line numberDiff line numberDiff line change
@@ -27,55 +27,47 @@
2727
*/
2828
package mekhq.gui.dialog.nagDialogs;
2929

30-
import mekhq.MHQConstants;
31-
import mekhq.MekHQ;
32-
import mekhq.campaign.Campaign;
33-
import mekhq.gui.baseComponents.AbstractMHQNagDialog;
34-
30+
import static mekhq.MHQConstants.NAG_OUTSTANDING_SCENARIOS;
3531
import static mekhq.gui.dialog.nagDialogs.nagLogic.OutstandingScenariosNagLogic.getOutstandingScenarios;
3632
import static mekhq.gui.dialog.nagDialogs.nagLogic.OutstandingScenariosNagLogic.hasOutStandingScenarios;
33+
import static mekhq.utilities.MHQInternationalization.getFormattedTextAt;
34+
35+
import mekhq.MekHQ;
36+
import mekhq.campaign.Campaign;
37+
import mekhq.gui.baseComponents.immersiveDialogs.ImmersiveDialogNag;
3738

3839
/**
39-
* Represents a nag dialog for displaying the list of outstanding scenarios in a campaign.
40+
* A dialog class used to notify players about outstanding scenarios in their campaign.
4041
*
41-
* <p>
42-
* This dialog checks for active scenarios within the campaign, categorizes them by
43-
* their state (e.g., unresolved or requiring a track), and displays a list of these
44-
* scenarios to the user. Scenarios are considered "outstanding" if they are unresolved or
45-
* require attention on the current campaign date.
46-
* </p>
47-
*
48-
* <p>
49-
* The dialog includes logic to account for both AtB contracts and StratCon-enabled campaigns,
50-
* formatting the outstanding scenarios with additional details when appropriate.
51-
* </p>
42+
* <p>The {@code OutstandingScenariosNagDialog} extends {@link ImmersiveDialogNag} and provides a specialized
43+
* dialog designed to alert players when there are unresolved or pending scenarios in the campaign. It uses predefined
44+
* values, including the {@code NAG_OUTSTANDING_SCENARIOS} constant, and does not include a specific speaker, relying
45+
* instead on a default fallback mechanism.</p>
5246
*/
53-
public class OutstandingScenariosNagDialog extends AbstractMHQNagDialog {
47+
public class OutstandingScenariosNagDialog extends ImmersiveDialogNag {
48+
5449
/**
55-
* Constructs the OutstandingScenariosNagDialog for the given campaign.
50+
* Constructs a new {@code OutstandingScenariosNagDialog} instance to display the outstanding scenarios nag dialog.
5651
*
57-
* <p>
58-
* Upon initialization, this dialog prepares a formatted string of outstanding
59-
* scenarios (if any) and sets up the dialog UI for display.
60-
* </p>
52+
* <p>This constructor initializes the dialog with preconfigured parameters, such as the
53+
* {@code NAG_OUTSTANDING_SCENARIOS} constant for managing dialog suppression and the
54+
* {@code "OutstandingScenariosNagDialog"} message key for retrieving localized dialog content. No specific speaker
55+
* is provided, triggering fallback logic to determine a suitable speaker for the dialog.</p>
6156
*
62-
* @param campaign The {@link Campaign} associated with this nag dialog.
57+
* @param campaign The {@link Campaign} instance associated with this dialog. Provides access to campaign data and
58+
* settings required for constructing the dialog.
6359
*/
6460
public OutstandingScenariosNagDialog(final Campaign campaign) {
65-
super(campaign, MHQConstants.NAG_OUTSTANDING_SCENARIOS);
61+
super(campaign, null, NAG_OUTSTANDING_SCENARIOS, "OutstandingScenariosNagDialog");
62+
}
6663

67-
final String DIALOG_BODY = "OutstandingScenariosNagDialog.text";
64+
@Override
65+
protected String getInCharacterMessage(Campaign campaign, String key, String commanderAddress) {
66+
final String RESOURCE_BUNDLE = "mekhq.resources.NagDialogs";
6867

6968
String outstandingScenarios = getOutstandingScenarios(campaign);
7069

71-
String addendum = "";
72-
if (campaign.getCampaignOptions().isUseStratCon()) {
73-
addendum = resources.getString("OutstandingScenariosNagDialog.stratCon");
74-
}
75-
76-
setRightDescriptionMessage(String.format(resources.getString(DIALOG_BODY),
77-
campaign.getCommanderAddress(false), outstandingScenarios, addendum));
78-
showDialog();
70+
return getFormattedTextAt(RESOURCE_BUNDLE, key + ".ic", commanderAddress, outstandingScenarios);
7971
}
8072

8173
/**
@@ -89,13 +81,14 @@ public OutstandingScenariosNagDialog(final Campaign campaign) {
8981
* </ul>
9082
*
9183
* @param campaign the {@link Campaign} to check for nagging conditions
84+
*
9285
* @return {@code true} if the nag dialog should be displayed, {@code false} otherwise
9386
*/
9487
public static boolean checkNag(Campaign campaign) {
95-
final String NAG_KEY = MHQConstants.NAG_OUTSTANDING_SCENARIOS;
88+
final String NAG_KEY = NAG_OUTSTANDING_SCENARIOS;
9689

97-
return campaign.getCampaignOptions().isUseAtB()
98-
&& !MekHQ.getMHQOptions().getNagDialogIgnore(NAG_KEY)
99-
&& hasOutStandingScenarios(campaign);
90+
return campaign.getCampaignOptions().isUseAtB() &&
91+
!MekHQ.getMHQOptions().getNagDialogIgnore(NAG_KEY) &&
92+
hasOutStandingScenarios(campaign);
10093
}
10194
}

0 commit comments

Comments
 (0)