|
27 | 27 | */
|
28 | 28 | package mekhq.gui.baseComponents;
|
29 | 29 |
|
| 30 | +import static java.lang.Math.max; |
| 31 | +import static java.lang.Math.min; |
| 32 | +import static megamek.client.ui.WrapLayout.wordWrap; |
| 33 | +import static megamek.client.ui.swing.util.FlatLafStyleBuilder.setFontScaling; |
| 34 | +import static mekhq.campaign.force.Force.FORCE_NONE; |
| 35 | +import static mekhq.utilities.ImageUtilities.scaleImageIconToWidth; |
| 36 | +import static mekhq.utilities.MHQInternationalization.getFormattedTextAt; |
| 37 | + |
| 38 | +import java.awt.BorderLayout; |
| 39 | +import java.awt.Component; |
| 40 | +import java.awt.Dimension; |
| 41 | +import java.awt.GridBagConstraints; |
| 42 | +import java.awt.GridBagLayout; |
| 43 | +import java.awt.Insets; |
| 44 | +import java.awt.Point; |
| 45 | +import java.awt.Toolkit; |
| 46 | +import java.util.ArrayList; |
| 47 | +import java.util.List; |
| 48 | +import java.util.UUID; |
| 49 | +import javax.swing.*; |
| 50 | +import javax.swing.event.HyperlinkEvent; |
| 51 | +import javax.swing.event.HyperlinkEvent.EventType; |
| 52 | + |
30 | 53 | import megamek.client.ui.swing.util.UIUtil;
|
31 | 54 | import megamek.common.annotations.Nullable;
|
32 | 55 | import megamek.logging.MMLogger;
|
|
38 | 61 | import mekhq.gui.CampaignGUI;
|
39 | 62 | import mekhq.gui.dialog.GlossaryDialog;
|
40 | 63 |
|
41 |
| -import javax.swing.*; |
42 |
| -import javax.swing.event.HyperlinkEvent; |
43 |
| -import javax.swing.event.HyperlinkEvent.EventType; |
44 |
| -import java.awt.*; |
45 |
| -import java.util.ArrayList; |
46 |
| -import java.util.List; |
47 |
| -import java.util.UUID; |
48 |
| - |
49 |
| -import static java.lang.Math.max; |
50 |
| -import static java.lang.Math.min; |
51 |
| -import static megamek.client.ui.WrapLayout.wordWrap; |
52 |
| -import static megamek.client.ui.swing.util.FlatLafStyleBuilder.setFontScaling; |
53 |
| -import static mekhq.campaign.force.Force.FORCE_NONE; |
54 |
| -import static mekhq.utilities.ImageUtilities.scaleImageIconToWidth; |
55 |
| -import static mekhq.utilities.MHQInternationalization.getFormattedTextAt; |
56 |
| - |
57 | 64 | /**
|
58 | 65 | * An immersive dialog used in MekHQ to display interactions between speakers,
|
59 | 66 | * messages, and actions. The dialog supports entities such as speakers, campaign,
|
@@ -85,7 +92,7 @@ public class MHQDialogImmersive extends JDialog {
|
85 | 92 | private JSpinner spinner;
|
86 | 93 | private int spinnerValue;
|
87 | 94 |
|
88 |
| - private int dialogChoice; |
| 95 | + private int dialogChoice = 0; |
89 | 96 |
|
90 | 97 | private static final MMLogger logger = MMLogger.create(MHQDialogImmersive.class);
|
91 | 98 |
|
@@ -124,17 +131,18 @@ protected int getPADDING() {
|
124 | 131 |
|
125 | 132 | /**
|
126 | 133 | * Constructs and initializes an immersive dialog with configurable layouts, speakers, actions, and messages.
|
127 |
| - * <p> |
128 |
| - * This dialog is designed to provide a rich, immersive interface featuring optional speakers on the |
| 134 | + * |
| 135 | + * <p>This dialog is designed to provide a rich, immersive interface featuring optional speakers on the |
129 | 136 | * left and right, a central message panel with configurable width, a spinner panel, and a list of actionable buttons.
|
130 |
| - * An optional out-of-character message can also be displayed below the buttons. |
| 137 | + * An optional out-of-character message can also be displayed below the buttons.</p> |
131 | 138 | *
|
132 | 139 | * @param campaign The {@link Campaign} instance tied to the dialog, providing contextual information.
|
133 | 140 | * @param leftSpeaker Optional left-side {@link Person}; use {@code null} if no left speaker is present.
|
134 | 141 | * @param rightSpeaker Optional right-side {@link Person}; use {@code null} if no right speaker is present.
|
135 | 142 | * @param centerMessage The main {@link String} message displayed in the center panel of the dialog.
|
136 | 143 | * @param buttons A {@link List} of {@link ButtonLabelTooltipPair} instances representing actions available
|
137 |
| - * in the dialog (displayed as buttons). |
| 144 | + * in the dialog (displayed as buttons). The default option is used if the user closes or cancels |
| 145 | + * the dialog. |
138 | 146 | * @param outOfCharacterMessage An optional {@link String} message displayed below the buttons;
|
139 | 147 | * use {@code null} if not applicable.
|
140 | 148 | * @param centerWidth An optional width for the center panel; uses the default value if {@code null}.
|
@@ -222,7 +230,7 @@ public MHQDialogImmersive(Campaign campaign, @Nullable Person leftSpeaker,
|
222 | 230 | int screenWidth = screenSize.width;
|
223 | 231 | setSize(min(screenWidth, getWidth()), (int) min(getHeight(), screenHeight * 0.8));
|
224 | 232 |
|
225 |
| - setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); |
| 233 | + setDefaultCloseOperation(DISPOSE_ON_CLOSE); |
226 | 234 | setModal(isModal);
|
227 | 235 | setLocationRelativeTo(null); // Needs to be after pack
|
228 | 236 | setResizable(false);
|
|
0 commit comments