Skip to content

Commit e393320

Browse files
authored
Merge pull request #6402 from IllianiCBT/NoCommandNagDialogNew
Refactored No Commander Nag Dialog To Use Immersive Dialog Framework
2 parents 085556f + 3c7815d commit e393320

File tree

4 files changed

+33
-45
lines changed

4 files changed

+33
-45
lines changed

MekHQ/resources/mekhq/resources/GUI.properties

-6
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,6 @@ ignoreFutureNags.checkbox=Don't show this again
303303
button.advanceDay=Advance Day
304304
button.cancel=Cancel
305305
### Nag Messages
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.\
309-
<br>\
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>
312306
OutstandingScenariosNagDialog.text=%s, our forces are positioned for combat but await your commands to\
313307
\ proceed. Alternatively, you may order a tactical withdrawal by advancing the day. Do you wish\
314308
\ to proceed without addressing these engagements?\

MekHQ/resources/mekhq/resources/NagDialogs.properties

+7
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,10 @@ InvalidFactionNagDialog.ooc=You will need to select a new faction in the campaig
6060
\ to do this while using <a href=''GLOSSARY:STRATCON''>StratCon</a> will prevent contracts from\
6161
\ being generated.\
6262
<p>If you accidentally suppress this warning, you can re-enable it in MekHQ Options.</p>
63+
# No Commander
64+
NoCommanderNagDialog.ic=Please be advised that no commanding officer is currently assigned\
65+
\ to our unit. This could affect operational outcomes and mission planning. Confirm your intent\
66+
\ to proceed, or assign a commander to maintain strategic efficiency.
67+
NoCommanderNagDialog.ooc=You can assign one of your personnel as the campaign commander by\
68+
\ right-clicking on that character, navigating to Flags and selecting the Commander flag.</i>\
69+
<p>If you accidentally suppress this warning, you can re-enable it in MekHQ Options.</p>

MekHQ/src/mekhq/gui/dialog/nagDialogs/NagController.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public static boolean triggerDailyNags(Campaign campaign) {
9292
// No Commander
9393
if (NoCommanderNagDialog.checkNag(campaign.getFlaggedCommander())) {
9494
NoCommanderNagDialog noCommanderNagDialog = new NoCommanderNagDialog(campaign);
95-
if (noCommanderNagDialog.wasAdvanceDayCanceled()) {
95+
if (noCommanderNagDialog.shouldCancelAdvanceDay()) {
9696
return true;
9797
}
9898
}

MekHQ/src/mekhq/gui/dialog/nagDialogs/NoCommanderNagDialog.java

+25-38
Original file line numberDiff line numberDiff line change
@@ -27,50 +27,37 @@
2727
*/
2828
package mekhq.gui.dialog.nagDialogs;
2929

30+
import static mekhq.MHQConstants.NAG_NO_COMMANDER;
31+
import static mekhq.campaign.Campaign.AdministratorSpecialization.HR;
32+
import static mekhq.gui.dialog.nagDialogs.nagLogic.NoCommanderNagLogic.hasNoCommander;
33+
3034
import megamek.common.annotations.Nullable;
31-
import mekhq.MHQConstants;
3235
import mekhq.MekHQ;
3336
import mekhq.campaign.Campaign;
3437
import mekhq.campaign.personnel.Person;
35-
import mekhq.gui.baseComponents.AbstractMHQNagDialog;
36-
37-
import static mekhq.gui.dialog.nagDialogs.nagLogic.NoCommanderNagLogic.hasNoCommander;
38+
import mekhq.gui.baseComponents.immersiveDialogs.ImmersiveDialogNag;
3839

3940
/**
40-
* A dialog used to notify the user that their campaign lacks a designated commander.
41+
* A dialog class used to notify players that a commander is missing in their campaign.
4142
*
42-
* <p>
43-
* This nag dialog is displayed when the campaign does not currently have a commander,
44-
* and checks whether the user has opted to ignore such notifications in the future.
45-
* If shown, the user has the option to dismiss the dialog or address the issue.
46-
* </p>
47-
*
48-
* <strong>Features:</strong>
49-
* <ul>
50-
* <li>Handles the "No Commander" notification for campaigns.</li>
51-
* <li>Localized message fetched using resource bundles.</li>
52-
* <li>Extends the {@link AbstractMHQNagDialog} for reusable dialog behavior.</li>
53-
* </ul>
54-
*
55-
* @see AbstractMHQNagDialog
43+
* <p>The {@code NoCommanderNagDialog} extends {@link ImmersiveDialogNag} and provides a specialized dialog
44+
* designed to alert players when no commander is assigned or present in the campaign. It uses predefined values,
45+
* including the {@code HR} speaker and the {@code NAG_NO_COMMANDER} constant, to configure dialog settings and
46+
* content.</p>
5647
*/
57-
public class NoCommanderNagDialog extends AbstractMHQNagDialog {
48+
public class NoCommanderNagDialog extends ImmersiveDialogNag {
5849
/**
59-
* Constructs a {@code NoCommanderNagDialog} for a campaign.
50+
* Constructs a new {@code NoCommanderNagDialog} instance to display the no commander nag dialog.
6051
*
61-
* <p>
62-
* This dialog uses the localization key {@code "NoCommanderNagDialog.text"}
63-
* to display a message informing the user about the absence of a commander in their campaign.
64-
* </p>
52+
* <p>This constructor initializes the dialog with preconfigured parameters, such as the
53+
* {@code NAG_NO_COMMANDER} constant for managing dialog suppression, the {@code "NoCommanderNagDialog"} message key
54+
* for localization, and the {@code HR} speaker to deliver the dialog message.</p>
6555
*
66-
* @param campaign The {@link Campaign} for which the nag dialog is being triggered.
56+
* @param campaign The {@link Campaign} instance associated with this dialog. Provides access to campaign data and
57+
* settings required for constructing the dialog.
6758
*/
6859
public NoCommanderNagDialog(final Campaign campaign) {
69-
super(campaign, MHQConstants.NAG_NO_COMMANDER);
70-
71-
final String DIALOG_BODY = "NoCommanderNagDialog.text";
72-
setRightDescriptionMessage(resources.getString(DIALOG_BODY));
73-
showDialog();
60+
super(campaign, HR, NAG_NO_COMMANDER, "NoCommanderNagDialog");
7461
}
7562

7663
/**
@@ -82,15 +69,15 @@ public NoCommanderNagDialog(final Campaign campaign) {
8269
* <li>No flagged commander is assigned to the campaign.</li>
8370
* </ul>
8471
*
85-
* @param flaggedCommander The {@link Person} designated as the flagged commander, or {@code null}
86-
* if no commander is assigned.
87-
* @return {@code true} if the nag dialog should be displayed due to the absence of a commander,
88-
* {@code false} otherwise.
72+
* @param flaggedCommander The {@link Person} designated as the flagged commander, or {@code null} if no commander
73+
* is assigned.
74+
*
75+
* @return {@code true} if the nag dialog should be displayed due to the absence of a commander, {@code false}
76+
* otherwise.
8977
*/
9078
public static boolean checkNag(@Nullable Person flaggedCommander) {
91-
final String NAG_KEY = MHQConstants.NAG_NO_COMMANDER;
79+
final String NAG_KEY = NAG_NO_COMMANDER;
9280

93-
return !MekHQ.getMHQOptions().getNagDialogIgnore(NAG_KEY)
94-
&& hasNoCommander(flaggedCommander);
81+
return !MekHQ.getMHQOptions().getNagDialogIgnore(NAG_KEY) && hasNoCommander(flaggedCommander);
9582
}
9683
}

0 commit comments

Comments
 (0)