From 6adecb42368330017a7b54eb86956af58f3e5408 Mon Sep 17 00:00:00 2001 From: Aaron Gullickson Date: Fri, 22 Mar 2024 12:23:33 -0700 Subject: [PATCH] Add disconnectQuietly flag to ClientGUI --- megamek/src/megamek/client/ui/swing/ClientGUI.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index f28e416d3da..8e169968e9f 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -286,6 +286,9 @@ public class ClientGUI extends JPanel implements BoardViewListener, private MiniReportDisplay miniReportDisplay; private MiniReportDisplayDialog miniReportDisplayDialog; + /** Boolean indicating whether client should be disconnected without a pop-up warning **/ + private boolean disconnectQuietly = false; + /** * The JPanel containing the main display area. */ @@ -433,6 +436,10 @@ public void setPlayerListDialog(final PlayerListDialog playerListDialog) { this.playerListDialog = playerListDialog; } + public void setDisconnectQuietly(boolean quietly) { + disconnectQuietly = quietly; + } + /** * Try to load the "bing" sound clip. */ @@ -2259,8 +2266,10 @@ public void gamePlayerChange(GamePlayerChangeEvent evt) { @Override public void gamePlayerDisconnected(GamePlayerDisconnectedEvent evt) { - doAlertDialog(Messages.getString("ClientGUI.Disconnected.message"), - Messages.getString("ClientGUI.Disconnected.title"), JOptionPane.ERROR_MESSAGE); + if(!disconnectQuietly) { + doAlertDialog(Messages.getString("ClientGUI.Disconnected.message"), + Messages.getString("ClientGUI.Disconnected.title"), JOptionPane.ERROR_MESSAGE); + } frame.setVisible(false); die(); }