diff --git a/megamek/data/scenarios/Kell Hounds/LoweringTheBoom/LoweringTheBoom.mms b/megamek/data/scenarios/Kell Hounds/LoweringTheBoom/LoweringTheBoom.mms index 370cd895a40..a7dd533bebc 100644 --- a/megamek/data/scenarios/Kell Hounds/LoweringTheBoom/LoweringTheBoom.mms +++ b/megamek/data/scenarios/Kell Hounds/LoweringTheBoom/LoweringTheBoom.mms @@ -255,12 +255,7 @@ messages: Be careful! Some of your Meks have already sustained damage. image: loweringboom_map.png trigger: - type: and - triggers: - - type: phasestart - phase: movement - - type: round - round: 1 + type: gamestart - header: One Unit Safe text: Congratulations, one of your Meks has safely left the battlefield! diff --git a/megamek/src/megamek/client/ui/swing/AbstractClientGUI.java b/megamek/src/megamek/client/ui/swing/AbstractClientGUI.java index 15e324feb79..0b6b61249a0 100644 --- a/megamek/src/megamek/client/ui/swing/AbstractClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/AbstractClientGUI.java @@ -56,6 +56,9 @@ public abstract class AbstractClientGUI implements IClientGUI, IClientCommandHan protected final JFrame frame = new JFrame(Messages.getString("ClientGUI.title")); + /** Temporarily stores story dialogs so they can be shown one after the other */ + private final List queuedStoryDialogs = new ArrayList<>(); + protected Map clientCommands = new HashMap<>(); // BoardViews @@ -190,6 +193,23 @@ public String runCommand(String[] args) { } protected void showScriptedMessage(GameScriptedMessageEvent event) { - new MMNarrativeStoryDialog(frame, event).setVisible(true); + queuedStoryDialogs.add(new MMNarrativeStoryDialog(frame, event)); + showDialogs(); + } + + /** + * Shows a queued story dialog if no other is shown at this time. Normally, not more than one modal dialog (and its child dialogs) can + * be shown at any one time as Swing blocks access to buttons outside a first modal dialog. In MM, this is different as the server may + * send multiple story dialog packets which will all be processed and shown without user input. This method prevents that behavior so + * that only one story dialog is shown at one time. Note that when story dialogs trigger at the same time, their order is likely to be + * the order they were added to the game but packet transport can make them arrive at the client in a different order. + */ + private void showDialogs() { + if (!UIUtil.isModalDialogDisplayed()) { + while (!queuedStoryDialogs.isEmpty()) { + JDialog dialog = queuedStoryDialogs.remove(0); + dialog.setVisible(true); + } + } } } diff --git a/megamek/testresources/data/scenarios/test_setups/Messages.mms b/megamek/testresources/data/scenarios/test_setups/Messages.mms index f97848dfa04..46a8da9dea2 100644 --- a/megamek/testresources/data/scenarios/test_setups/Messages.mms +++ b/megamek/testresources/data/scenarios/test_setups/Messages.mms @@ -21,7 +21,7 @@ end: round: 4 messages: - - header: Scenario Messages + - header: Scenario Messages 1 text: | In this test setup scenario, several messages are shown at various points of the game. @@ -29,6 +29,16 @@ messages: trigger: type: gamestart + - header: Scenario Messages 2 + text: Second test message + trigger: + type: gamestart + + - header: Scenario Messages 3 + text: Second test message + trigger: + type: gamestart + - header: Round 2! text: This is a test message for the start of round 2. trigger: