From 0af9af22b6aa8036ddc5822ed4efa9dc686b203b Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Thu, 2 Feb 2023 12:49:09 -0500 Subject: [PATCH 1/9] turn sounds --- .../i18n/megamek/client/messages.properties | 4 +- .../megamek/client/ui/swing/ClientGUI.java | 77 ++++++++++++++----- .../client/ui/swing/CommonSettingsDialog.java | 46 +++++++++-- .../ui/swing/DeployMinefieldDisplay.java | 8 +- .../client/ui/swing/DeploymentDisplay.java | 2 + .../client/ui/swing/FiringDisplay.java | 2 + .../client/ui/swing/GUIPreferences.java | 61 ++++++++++++--- .../client/ui/swing/MovementDisplay.java | 3 + .../client/ui/swing/PhysicalDisplay.java | 2 + .../client/ui/swing/ReportDisplay.java | 2 + .../ui/swing/SelectArtyAutoHitHexDisplay.java | 6 +- .../ui/swing/TargetingPhaseDisplay.java | 5 +- 12 files changed, 172 insertions(+), 46 deletions(-) diff --git a/megamek/i18n/megamek/client/messages.properties b/megamek/i18n/megamek/client/messages.properties index acf12476555..4945b501731 100644 --- a/megamek/i18n/megamek/client/messages.properties +++ b/megamek/i18n/megamek/client/messages.properties @@ -1185,7 +1185,9 @@ CommonSettingsDialog.uiTheme=UI Theme: CommonSettingsDialog.skinFile=Skin File: CommonSettingsDialog.skinFileFail.title=Failed to load skin! CommonSettingsDialog.skinFileFail.msg=Error parsing skin specification file, reverting to previous skin! -CommonSettingsDialog.soundMute=Mute sound. +CommonSettingsDialog.soundMuteChat=Mute chat notification sound. +CommonSettingsDialog.soundMuteMyTurn=Mute my turn notification sound +CommonSettingsDialog.soundMuteOthersTurn=Mute others turn notification sound CommonSettingsDialog.stampFilenames=Add a date/time stamp to all logs and savegames. CommonSettingsDialog.stampFormat=Date Format to use for above stamp: CommonSettingsDialog.tileset=Tileset: diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index 29e4f3709a8..ec00cb08473 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -265,7 +265,9 @@ public class ClientGUI extends JPanel implements BoardViewListener, /** * Cache for the "bing" soundclip. */ - private Clip bingClip; + private Clip bingClipChat; + private Clip bingClipMyTurn; + private Clip bingClipOthersTurn; /** * Map each phase to the name of the card for the main display area. @@ -338,7 +340,7 @@ public ClientGUI(Client client, MegaMekController c) { this.addComponentListener(this); this.client = client; controller = c; - loadSoundClip(); + loadSoundFiles(); panMain.setLayout(cardsMain); panSecondary.setLayout(cardsSecondary); JPanel panDisplay = new JPanel(new BorderLayout()); @@ -347,6 +349,22 @@ public ClientGUI(Client client, MegaMekController c) { add(panDisplay, BorderLayout.CENTER); } + private void loadSoundFiles() { + if (bingClipChat != null) { + bingClipChat.close(); + } + if (bingClipMyTurn != null) { + bingClipMyTurn.close(); + } + if (bingClipOthersTurn != null) { + bingClipOthersTurn.close(); + } + + bingClipChat = loadSoundClip(GUIP.getSoundBingFilenameChat()); + bingClipMyTurn = loadSoundClip(GUIP.getSoundBingFilenameMyTurn()); + bingClipOthersTurn = loadSoundClip(GUIP.getSoundBingFilenameOthersTurn()); + } + public BoardView getBoardView() { return bv; } @@ -390,28 +408,29 @@ public void setMiniReportDisplayDialog(final MiniReportDisplayDialog miniReportD /** * Try to load the "bing" sound clip. */ - private void loadSoundClip() { - if (GUIP.getSoundBingFilename() == null) { - return; + private Clip loadSoundClip(String filename) { + Clip clip = null; + + if (filename == null) { + return null; } - final File file = new File(GUIP.getSoundBingFilename()); + final File file = new File(filename); if (!file.exists()) { - LogManager.getLogger().error(Messages.getString("ClientGUI.failedToLoadAudioFile") + " " + GUIP.getSoundBingFilename()); - return; + LogManager.getLogger().error(Messages.getString("ClientGUI.failedToLoadAudioFile") + " " + filename); + return null; } try { - if (bingClip != null) { - bingClip.close(); - } - bingClip = AudioSystem.getClip(); + clip = AudioSystem.getClip(); try (AudioInputStream ais = AudioSystem.getAudioInputStream(file)) { - bingClip.open(ais); + clip.open(ais); } } catch (Exception ex) { LogManager.getLogger().error("", ex); - bingClip = null; + clip = null; } + + return clip; } /** @@ -2102,10 +2121,24 @@ public void loadPreviewImage(JLabel bp, Entity entity, Player player) { /** * Make a "bing" sound. */ - void bing() { - if (!GUIP.getSoundMute() && (bingClip != null)) { - bingClip.setFramePosition(0); - bingClip.start(); + public void bingChat() { + if ((!GUIP.getSoundMuteChat()) && (bingClipMyTurn != null)) { + bingClipChat.setFramePosition(0); + bingClipChat.start(); + } + } + + public void bingMyTurn() { + if ((!GUIP.getSoundMuteMyTurn()) && (bingClipMyTurn != null)) { + bingClipMyTurn.setFramePosition(0); + bingClipMyTurn.start(); + } + } + + public void bingOthersTurn() { + if ((!GUIP.getSoundMuteOthersTurn()) && (bingClipMyTurn != null)) { + bingClipOthersTurn.setFramePosition(0); + bingClipOthersTurn.start(); } } @@ -2139,7 +2172,9 @@ public void gamePlayerDisconnected(GamePlayerDisconnectedEvent evt) { @Override public void gamePlayerChat(GamePlayerChatEvent e) { - bing(); + if (!GUIP.getSoundMuteChat()) { + bingChat(); + } } @Override @@ -2809,6 +2844,10 @@ public void preferenceChange(PreferenceChangeEvent e) { } else if (e.getName().equals(GUIPreferences.DEFAULT_WEAPON_SORT_ORDER)) { setWeaponOrderPrefs(true); getUnitDisplay().displayEntity(getUnitDisplay().getCurrentEntity()); + } else if ((e.getName().equals(GUIPreferences.SOUND_BING_FILENAME_CHAT)) + || (e.getName().equals(GUIPreferences.SOUND_BING_FILENAME_MY_TURN)) + || (e.getName().equals(GUIPreferences.SOUND_BING_FILENAME_OTHERS_TURN))) { + loadSoundFiles(); } } } diff --git a/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java b/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java index 2c0f2a1fc5b..fd9e26a757a 100644 --- a/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java +++ b/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java @@ -135,7 +135,12 @@ private void moveElement(DefaultListModel srcModel, int srcIndex, int trg private final JCheckBox nagForNoUnJamRAC = new JCheckBox(Messages.getString("CommonSettingsDialog.nagForUnJamRAC")); private final JCheckBox animateMove = new JCheckBox(Messages.getString("CommonSettingsDialog.animateMove")); private final JCheckBox showWrecks = new JCheckBox(Messages.getString("CommonSettingsDialog.showWrecks")); - private final JCheckBox soundMute = new JCheckBox(Messages.getString("CommonSettingsDialog.soundMute")); + private final JCheckBox soundMuteChat = new JCheckBox(Messages.getString("CommonSettingsDialog.soundMuteChat")); + private JTextField tfSoundMuteChatFileName; + private final JCheckBox soundMuteMyTurn = new JCheckBox(Messages.getString("CommonSettingsDialog.soundMuteMyTurn")); + private JTextField tfSoundMuteMyTurntFileName; + private final JCheckBox soundMuteOthersTurn = new JCheckBox(Messages.getString("CommonSettingsDialog.soundMuteOthersTurn")); + private JTextField tfSoundMuteOthersFileName; private final JCheckBox showWpsinTT = new JCheckBox(Messages.getString("CommonSettingsDialog.showWpsinTT")); private final JCheckBox showArmorMiniVisTT = new JCheckBox(Messages.getString("CommonSettingsDialog.showArmorMiniVisTT")); private final JCheckBox showPilotPortraitTT = new JCheckBox(Messages.getString("CommonSettingsDialog.showPilotPortraitTT")); @@ -433,9 +438,28 @@ private JPanel getSettingsPanel() { comps.add(checkboxEntry(showWpsinTT, null)); comps.add(checkboxEntry(showArmorMiniVisTT, null)); comps.add(checkboxEntry(showPilotPortraitTT, null)); + + addLineSpacer(comps); + comps.add(checkboxEntry(soundMuteChat, null)); + tfSoundMuteChatFileName = new JTextField(5); + tfSoundMuteChatFileName.setMaximumSize(new Dimension(450, 40)); + row = new ArrayList<>(); + row.add(tfSoundMuteChatFileName); + comps.add(row); + comps.add(checkboxEntry(soundMuteMyTurn, null)); + tfSoundMuteMyTurntFileName = new JTextField(5); + tfSoundMuteMyTurntFileName.setMaximumSize(new Dimension(450, 40)); + row = new ArrayList<>(); + row.add(tfSoundMuteMyTurntFileName); + comps.add(row); + comps.add(checkboxEntry(soundMuteOthersTurn, null)); + tfSoundMuteOthersFileName = new JTextField(5); + tfSoundMuteOthersFileName.setMaximumSize(new Dimension(450, 40)); + row = new ArrayList<>(); + row.add(tfSoundMuteOthersFileName); + comps.add(row); + addLineSpacer(comps); - comps.add(checkboxEntry(soundMute, null)); - JLabel maxPathfinderTimeLabel = new JLabel(Messages.getString("CommonSettingsDialog.pathFiderTimeLimit")); maxPathfinderTime = new JTextField(5); maxPathfinderTime.setMaximumSize(new Dimension(150, 40)); @@ -574,7 +598,9 @@ public void setVisible(boolean visible) { nagForNoUnJamRAC.setSelected(GUIP.getNagForNoUnJamRAC()); animateMove.setSelected(GUIP.getShowMoveStep()); showWrecks.setSelected(GUIP.getShowWrecks()); - soundMute.setSelected(GUIP.getSoundMute()); + soundMuteChat.setSelected(GUIP.getSoundMuteChat()); + soundMuteMyTurn.setSelected(GUIP.getSoundMuteMyTurn()); + soundMuteOthersTurn.setSelected(GUIP.getSoundMuteOthersTurn()); tooltipDelay.setText(Integer.toString(GUIP.getTooltipDelay())); tooltipDismissDelay.setText(Integer.toString(GUIP.getTooltipDismissDelay())); tooltipDistSupression.setText(Integer.toString(GUIP.getTooltipDistSuppression())); @@ -594,6 +620,10 @@ public void setVisible(boolean visible) { } } + tfSoundMuteChatFileName.setText(GUIP.getSoundBingFilenameChat()); + tfSoundMuteMyTurntFileName.setText(GUIP.getSoundBingFilenameMyTurn()); + tfSoundMuteOthersFileName.setText(GUIP.getSoundBingFilenameOthersTurn()); + maxPathfinderTime.setText(Integer.toString(CP.getMaxPathfinderTime())); keepGameLog.setSelected(CP.keepGameLog()); @@ -795,7 +825,9 @@ protected void okAction() { GUIP.setNagForNoUnJamRAC(nagForNoUnJamRAC.isSelected()); GUIP.setShowMoveStep(animateMove.isSelected()); GUIP.setShowWrecks(showWrecks.isSelected()); - GUIP.setSoundMute(soundMute.isSelected()); + GUIP.setSoundMuteChat(soundMuteChat.isSelected()); + GUIP.setSoundMuteMyTurn(soundMuteMyTurn.isSelected()); + GUIP.setSoundMuteOthersTurn(soundMuteOthersTurn.isSelected()); GUIP.setShowWpsinTT(showWpsinTT.isSelected()); GUIP.setshowArmorMiniVisTT(showArmorMiniVisTT.isSelected()); GUIP.setshowPilotPortraitTT(showPilotPortraitTT.isSelected()); @@ -820,6 +852,10 @@ protected void okAction() { GUIP.setMouseWheelZoom(mouseWheelZoom.isSelected()); GUIP.setMouseWheelZoomFlip(mouseWheelZoomFlip.isSelected()); + GUIP.setSoundBingFilenameChat(tfSoundMuteChatFileName.getText()); + GUIP.setSoundBingFilenameMyTurn(tfSoundMuteMyTurntFileName.getText()); + GUIP.setSoundBingFilenameOthersTurn(tfSoundMuteOthersFileName.getText()); + try { CP.setMaxPathfinderTime(Integer.parseInt(maxPathfinderTime.getText())); } catch (Exception ex) { diff --git a/megamek/src/megamek/client/ui/swing/DeployMinefieldDisplay.java b/megamek/src/megamek/client/ui/swing/DeployMinefieldDisplay.java index 5affb35c195..b95f555b1e7 100644 --- a/megamek/src/megamek/client/ui/swing/DeployMinefieldDisplay.java +++ b/megamek/src/megamek/client/ui/swing/DeployMinefieldDisplay.java @@ -386,8 +386,8 @@ public void gameTurnChange(GameTurnChangeEvent e) { if (clientgui.getClient().isMyTurn()) { beginMyTurn(); - setStatusBarText(Messages - .getString("DeployMinefieldDisplay.its_your_turn")); + setStatusBarText(Messages.getString("DeployMinefieldDisplay.its_your_turn")); + clientgui.bingMyTurn(); } else { String playerName; if (e.getPlayer() != null) { @@ -395,8 +395,8 @@ public void gameTurnChange(GameTurnChangeEvent e) { } else { playerName = "Unknown"; } - setStatusBarText(Messages.getString("DeployMinefieldDisplay." - + "its_others_turn", playerName)); + setStatusBarText(Messages.getString("DeployMinefieldDisplay.its_others_turn", playerName)); + clientgui.bingOthersTurn(); } } diff --git a/megamek/src/megamek/client/ui/swing/DeploymentDisplay.java b/megamek/src/megamek/client/ui/swing/DeploymentDisplay.java index 16ec93de6c8..2b8e674d8b5 100644 --- a/megamek/src/megamek/client/ui/swing/DeploymentDisplay.java +++ b/megamek/src/megamek/client/ui/swing/DeploymentDisplay.java @@ -405,6 +405,7 @@ public void gameTurnChange(GameTurnChangeEvent e) { if (clientgui.getClient().isMyTurn()) { if (cen == Entity.NONE) { beginMyTurn(); + clientgui.bingMyTurn(); } setStatusBarText(Messages.getString("DeploymentDisplay.its_your_turn")); } else { @@ -416,6 +417,7 @@ public void gameTurnChange(GameTurnChangeEvent e) { playerName = "Unknown"; } setStatusBarText(Messages.getString("DeploymentDisplay.its_others_turn", playerName)); + clientgui.bingOthersTurn(); } } diff --git a/megamek/src/megamek/client/ui/swing/FiringDisplay.java b/megamek/src/megamek/client/ui/swing/FiringDisplay.java index 6e9b882ab85..523d8a47fe0 100644 --- a/megamek/src/megamek/client/ui/swing/FiringDisplay.java +++ b/megamek/src/megamek/client/ui/swing/FiringDisplay.java @@ -2192,6 +2192,7 @@ public void gameTurnChange(GameTurnChangeEvent e) { beginMyTurn(); } setStatusBarText(Messages.getString("FiringDisplay.its_your_turn")); + clientgui.bingMyTurn(); } else { endMyTurn(); String playerName; @@ -2201,6 +2202,7 @@ public void gameTurnChange(GameTurnChangeEvent e) { playerName = "Unknown"; } setStatusBarText(Messages.getString("FiringDisplay.its_others_turn", playerName)); + clientgui.bingOthersTurn(); } } } diff --git a/megamek/src/megamek/client/ui/swing/GUIPreferences.java b/megamek/src/megamek/client/ui/swing/GUIPreferences.java index a0927e893e9..a7ea78d456e 100644 --- a/megamek/src/megamek/client/ui/swing/GUIPreferences.java +++ b/megamek/src/megamek/client/ui/swing/GUIPreferences.java @@ -243,8 +243,12 @@ public class GUIPreferences extends PreferenceStoreProxy { public static final String SHOW_PILOT_PORTRAIT_TT = "showPilotPortraitTT"; public static final String SHOW_MOVE_STEP = "ShowMoveStep"; public static final String SHOW_WRECKS = "ShowWrecks"; - public static final String SOUND_BING_FILENAME = "SoundBingFilename"; - public static final String SOUND_MUTE = "SoundMute"; + public static final String SOUND_BING_FILENAME_CHAT = "SoundBingFilenameChat"; + public static final String SOUND_BING_FILENAME_MY_TURN = "SoundBingFilenameMyTurn"; + public static final String SOUND_BING_FILENAME_OTHERS_TURN = "SoundBingFilenameOthersTurn"; + public static final String SOUND_MUTE_CHAT = "SoundMuteChat"; + public static final String SOUND_MUTE_MY_TURN = "SoundMuteMyTurn"; + public static final String SOUND_MUTE_OTHERS_TURN = "SoundMuteOthersTurn"; public static final String TOOLTIP_DELAY = "TooltipDelay"; public static final String TOOLTIP_DISMISS_DELAY = "TooltipDismissDelay"; public static final String TOOLTIP_DIST_SUPRESSION = "TooltipDistSupression"; @@ -557,8 +561,12 @@ protected GUIPreferences() { store.setDefault(SHOW_MAPHEX_POPUP, true); store.setDefault(SHOW_MOVE_STEP, true); store.setDefault(SHOW_WRECKS, true); - store.setDefault(SOUND_BING_FILENAME, "data/sounds/call.wav"); - store.setDefault(SOUND_MUTE, true); + store.setDefault(SOUND_BING_FILENAME_CHAT, "data/sounds/call.wav"); + store.setDefault(SOUND_BING_FILENAME_MY_TURN, "data/sounds/call.wav"); + store.setDefault(SOUND_BING_FILENAME_OTHERS_TURN, "data/sounds/call.wav"); + store.setDefault(SOUND_MUTE_CHAT, true); + store.setDefault(SOUND_MUTE_MY_TURN, false); + store.setDefault(SOUND_MUTE_OTHERS_TURN, true); store.setDefault(TOOLTIP_DELAY, 1000); store.setDefault(TOOLTIP_DISMISS_DELAY, -1); @@ -1135,14 +1143,31 @@ public boolean getShowWrecks() { return store.getBoolean(SHOW_WRECKS); } - public String getSoundBingFilename() { - return store.getString(SOUND_BING_FILENAME); + public String getSoundBingFilenameChat() { + return store.getString(SOUND_BING_FILENAME_CHAT); } - public boolean getSoundMute() { - return store.getBoolean(SOUND_MUTE); + public String getSoundBingFilenameMyTurn() { + return store.getString(SOUND_BING_FILENAME_MY_TURN); } + public String getSoundBingFilenameOthersTurn() { + return store.getString(SOUND_BING_FILENAME_OTHERS_TURN); + } + + public boolean getSoundMuteChat() { + return store.getBoolean(SOUND_MUTE_CHAT); + } + + public boolean getSoundMuteMyTurn() { + return store.getBoolean(SOUND_MUTE_MY_TURN); + } + + public boolean getSoundMuteOthersTurn() { + return store.getBoolean(SOUND_MUTE_OTHERS_TURN); + } + + public int getTooltipDelay() { return store.getInt(TOOLTIP_DELAY); } @@ -1730,12 +1755,24 @@ public void setShowWrecks(boolean state) { store.setValue(SHOW_WRECKS, state); } - public void setSoundBingFilename(String name) { - store.setValue(SOUND_BING_FILENAME, name); + public void setSoundBingFilenameChat(String name) { + store.setValue(SOUND_BING_FILENAME_CHAT, name); + } + public void setSoundBingFilenameMyTurn(String name) { + store.setValue(SOUND_BING_FILENAME_MY_TURN, name); + } + public void setSoundBingFilenameOthersTurn(String name) { + store.setValue(SOUND_BING_FILENAME_OTHERS_TURN, name); } - public void setSoundMute(boolean state) { - store.setValue(SOUND_MUTE, state); + public void setSoundMuteChat(boolean state) { + store.setValue(SOUND_MUTE_CHAT, state); + } + public void setSoundMuteMyTurn(boolean state) { + store.setValue(SOUND_MUTE_MY_TURN, state); + } + public void setSoundMuteOthersTurn(boolean state) { + store.setValue(SOUND_MUTE_OTHERS_TURN, state); } public void setTooltipDelay(int i) { diff --git a/megamek/src/megamek/client/ui/swing/MovementDisplay.java b/megamek/src/megamek/client/ui/swing/MovementDisplay.java index 985ca069fb1..e3886345b6d 100644 --- a/megamek/src/megamek/client/ui/swing/MovementDisplay.java +++ b/megamek/src/megamek/client/ui/swing/MovementDisplay.java @@ -4155,6 +4155,7 @@ public void gameTurnChange(GameTurnChangeEvent e) { if (clientgui.getClient().getGame().getPlayerEntities(clientgui.getClient().getLocalPlayer(), false) .stream().allMatch(Entity::isDone)) { setStatusBarTextOthersTurn(e.getPlayer()); + clientgui.bingOthersTurn(); return; } @@ -4170,6 +4171,7 @@ public void gameTurnChange(GameTurnChangeEvent e) { } else if (cen == Entity.NONE) { beginMyTurn(); } + clientgui.bingMyTurn(); } else { endMyTurn(); if ((e.getPlayer() == null) @@ -4178,6 +4180,7 @@ public void gameTurnChange(GameTurnChangeEvent e) { } else { setStatusBarTextOthersTurn(e.getPlayer()); } + clientgui.bingOthersTurn(); } } diff --git a/megamek/src/megamek/client/ui/swing/PhysicalDisplay.java b/megamek/src/megamek/client/ui/swing/PhysicalDisplay.java index 8435341b7c9..d3d757dc3a3 100644 --- a/megamek/src/megamek/client/ui/swing/PhysicalDisplay.java +++ b/megamek/src/megamek/client/ui/swing/PhysicalDisplay.java @@ -1444,6 +1444,7 @@ public void gameTurnChange(GameTurnChangeEvent e) { beginMyTurn(); } setStatusBarText(Messages.getString("PhysicalDisplay.its_your_turn")); + clientgui.bingMyTurn(); } else { endMyTurn(); String playerName; @@ -1453,6 +1454,7 @@ public void gameTurnChange(GameTurnChangeEvent e) { playerName = "Unknown"; } setStatusBarText(Messages.getString("PhysicalDisplay.its_others_turn", playerName)); + clientgui.bingOthersTurn(); } } diff --git a/megamek/src/megamek/client/ui/swing/ReportDisplay.java b/megamek/src/megamek/client/ui/swing/ReportDisplay.java index e1c47dcbdb0..0296f56f6d2 100644 --- a/megamek/src/megamek/client/ui/swing/ReportDisplay.java +++ b/megamek/src/megamek/client/ui/swing/ReportDisplay.java @@ -249,6 +249,8 @@ public void gamePhaseChange(GamePhaseChangeEvent e) { setStatusBarText(phase.toString()); break; } + + clientgui.bingMyTurn(); } /** diff --git a/megamek/src/megamek/client/ui/swing/SelectArtyAutoHitHexDisplay.java b/megamek/src/megamek/client/ui/swing/SelectArtyAutoHitHexDisplay.java index f6a42cb9f49..0bf9e0e388f 100644 --- a/megamek/src/megamek/client/ui/swing/SelectArtyAutoHitHexDisplay.java +++ b/megamek/src/megamek/client/ui/swing/SelectArtyAutoHitHexDisplay.java @@ -272,7 +272,6 @@ public void hexMoused(BoardViewEvent b) { // @Override public void gameTurnChange(GameTurnChangeEvent e) { - // Are we ignoring events? if (isIgnoringEvents()) { return; @@ -283,6 +282,7 @@ public void gameTurnChange(GameTurnChangeEvent e) { if (clientgui.getClient().isMyTurn()) { beginMyTurn(); setStatusBarText(Messages.getString("SelectArtyAutoHitHexDisplay.its_your_turn")); + clientgui.bingMyTurn(); } else { String playerName; if (e.getPlayer() != null) { @@ -290,8 +290,8 @@ public void gameTurnChange(GameTurnChangeEvent e) { } else { playerName = "Unknown"; } - setStatusBarText(Messages.getString("SelectArtyAutoHitHexDisplay.its_others_turn", - playerName)); + setStatusBarText(Messages.getString("SelectArtyAutoHitHexDisplay.its_others_turn", playerName)); + clientgui.bingOthersTurn(); } } diff --git a/megamek/src/megamek/client/ui/swing/TargetingPhaseDisplay.java b/megamek/src/megamek/client/ui/swing/TargetingPhaseDisplay.java index c7986c01622..966356aee7b 100644 --- a/megamek/src/megamek/client/ui/swing/TargetingPhaseDisplay.java +++ b/megamek/src/megamek/client/ui/swing/TargetingPhaseDisplay.java @@ -1351,11 +1351,12 @@ public void gameTurnChange(GameTurnChangeEvent e) { beginMyTurn(); } setStatusBarText(Messages.getString("TargetingPhaseDisplay.its_your_turn")); + clientgui.bingMyTurn(); } else { endMyTurn(); if (e.getPlayer() != null) { - setStatusBarText(Messages.getString("TargetingPhaseDisplay.its_others_turn", - e.getPlayer().getName())); + setStatusBarText(Messages.getString("TargetingPhaseDisplay.its_others_turn", e.getPlayer().getName())); + clientgui.bingOthersTurn(); } } } From 63628cb3d85a8e7b0f4932480a1ef47ca7d0e3cd Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Thu, 2 Feb 2023 12:52:51 -0500 Subject: [PATCH 2/9] turn sounds --- megamek/src/megamek/client/ui/swing/ClientGUI.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index ec00cb08473..3c1a33374d7 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -2172,9 +2172,7 @@ public void gamePlayerDisconnected(GamePlayerDisconnectedEvent evt) { @Override public void gamePlayerChat(GamePlayerChatEvent e) { - if (!GUIP.getSoundMuteChat()) { - bingChat(); - } + bingChat(); } @Override From c1ed5240a26802f5ab3dcf39102cd99dce5cbe89 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke <116095479+kuronekochomusuke@users.noreply.github.com> Date: Sat, 4 Feb 2023 12:20:05 -0500 Subject: [PATCH 3/9] Update megamek/src/megamek/client/ui/swing/ClientGUI.java Co-authored-by: Justin Bowen <39067288+Windchild292@users.noreply.github.com> --- megamek/src/megamek/client/ui/swing/ClientGUI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index 3c1a33374d7..52f62acb5b1 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -408,7 +408,7 @@ public void setMiniReportDisplayDialog(final MiniReportDisplayDialog miniReportD /** * Try to load the "bing" sound clip. */ - private Clip loadSoundClip(String filename) { + private @Nullable Clip loadSoundClip(@Nullable String filename) { Clip clip = null; if (filename == null) { From 7d7c8702a153faff408db1cac6b8873c30f8a437 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke <116095479+kuronekochomusuke@users.noreply.github.com> Date: Sat, 4 Feb 2023 12:20:28 -0500 Subject: [PATCH 4/9] Update megamek/src/megamek/client/ui/swing/ClientGUI.java Co-authored-by: Justin Bowen <39067288+Windchild292@users.noreply.github.com> --- megamek/src/megamek/client/ui/swing/ClientGUI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index 52f62acb5b1..ac1dee2ac38 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -2122,7 +2122,7 @@ public void loadPreviewImage(JLabel bp, Entity entity, Player player) { * Make a "bing" sound. */ public void bingChat() { - if ((!GUIP.getSoundMuteChat()) && (bingClipMyTurn != null)) { + if (!GUIP.getSoundMuteChat() && (bingClipMyTurn != null)) { bingClipChat.setFramePosition(0); bingClipChat.start(); } From 0daef8482babe12fc5b44035739570d8271fcb4f Mon Sep 17 00:00:00 2001 From: kuronekochomusuke <116095479+kuronekochomusuke@users.noreply.github.com> Date: Sat, 4 Feb 2023 12:20:38 -0500 Subject: [PATCH 5/9] Update megamek/src/megamek/client/ui/swing/ClientGUI.java Co-authored-by: Justin Bowen <39067288+Windchild292@users.noreply.github.com> --- megamek/src/megamek/client/ui/swing/ClientGUI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index ac1dee2ac38..a9dd24181e2 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -2136,7 +2136,7 @@ public void bingMyTurn() { } public void bingOthersTurn() { - if ((!GUIP.getSoundMuteOthersTurn()) && (bingClipMyTurn != null)) { + if (!GUIP.getSoundMuteOthersTurn() && (bingClipMyTurn != null)) { bingClipOthersTurn.setFramePosition(0); bingClipOthersTurn.start(); } From 59b6427449d3a77e9bc02c09894f6d995bc70a0a Mon Sep 17 00:00:00 2001 From: kuronekochomusuke <116095479+kuronekochomusuke@users.noreply.github.com> Date: Sat, 4 Feb 2023 12:21:29 -0500 Subject: [PATCH 6/9] Update megamek/src/megamek/client/ui/swing/ClientGUI.java Co-authored-by: Justin Bowen <39067288+Windchild292@users.noreply.github.com> --- megamek/src/megamek/client/ui/swing/ClientGUI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index a9dd24181e2..a8668e52daf 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -2129,7 +2129,7 @@ public void bingChat() { } public void bingMyTurn() { - if ((!GUIP.getSoundMuteMyTurn()) && (bingClipMyTurn != null)) { + if (!GUIP.getSoundMuteMyTurn() && (bingClipMyTurn != null)) { bingClipMyTurn.setFramePosition(0); bingClipMyTurn.start(); } From c7973cb4ddc47e24c3c437cec1a8dded1d3fd777 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke <116095479+kuronekochomusuke@users.noreply.github.com> Date: Sat, 4 Feb 2023 12:22:37 -0500 Subject: [PATCH 7/9] Update megamek/src/megamek/client/ui/swing/GUIPreferences.java Co-authored-by: Justin Bowen <39067288+Windchild292@users.noreply.github.com> --- megamek/src/megamek/client/ui/swing/GUIPreferences.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/megamek/src/megamek/client/ui/swing/GUIPreferences.java b/megamek/src/megamek/client/ui/swing/GUIPreferences.java index a7ea78d456e..a4238922a4a 100644 --- a/megamek/src/megamek/client/ui/swing/GUIPreferences.java +++ b/megamek/src/megamek/client/ui/swing/GUIPreferences.java @@ -1758,9 +1758,11 @@ public void setShowWrecks(boolean state) { public void setSoundBingFilenameChat(String name) { store.setValue(SOUND_BING_FILENAME_CHAT, name); } + public void setSoundBingFilenameMyTurn(String name) { store.setValue(SOUND_BING_FILENAME_MY_TURN, name); } + public void setSoundBingFilenameOthersTurn(String name) { store.setValue(SOUND_BING_FILENAME_OTHERS_TURN, name); } From 247c45bd14d9ef35866cdb745950890531cddd2a Mon Sep 17 00:00:00 2001 From: kuronekochomusuke <116095479+kuronekochomusuke@users.noreply.github.com> Date: Sat, 4 Feb 2023 12:23:34 -0500 Subject: [PATCH 8/9] Update megamek/src/megamek/client/ui/swing/GUIPreferences.java Co-authored-by: Justin Bowen <39067288+Windchild292@users.noreply.github.com> --- megamek/src/megamek/client/ui/swing/GUIPreferences.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/megamek/src/megamek/client/ui/swing/GUIPreferences.java b/megamek/src/megamek/client/ui/swing/GUIPreferences.java index a4238922a4a..46d6514d138 100644 --- a/megamek/src/megamek/client/ui/swing/GUIPreferences.java +++ b/megamek/src/megamek/client/ui/swing/GUIPreferences.java @@ -1770,9 +1770,11 @@ public void setSoundBingFilenameOthersTurn(String name) { public void setSoundMuteChat(boolean state) { store.setValue(SOUND_MUTE_CHAT, state); } + public void setSoundMuteMyTurn(boolean state) { store.setValue(SOUND_MUTE_MY_TURN, state); } + public void setSoundMuteOthersTurn(boolean state) { store.setValue(SOUND_MUTE_OTHERS_TURN, state); } From d85226ce15e93a06327dd1e07e33f12b0fcc0864 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 4 Feb 2023 12:36:22 -0500 Subject: [PATCH 9/9] code cleanup --- megamek/src/megamek/client/ui/swing/ClientGUI.java | 11 +++++------ .../src/megamek/client/ui/swing/GUIPreferences.java | 1 - 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/ClientGUI.java b/megamek/src/megamek/client/ui/swing/ClientGUI.java index a8668e52daf..824d5794234 100644 --- a/megamek/src/megamek/client/ui/swing/ClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/ClientGUI.java @@ -353,9 +353,11 @@ private void loadSoundFiles() { if (bingClipChat != null) { bingClipChat.close(); } + if (bingClipMyTurn != null) { bingClipMyTurn.close(); } + if (bingClipOthersTurn != null) { bingClipOthersTurn.close(); } @@ -409,8 +411,6 @@ public void setMiniReportDisplayDialog(final MiniReportDisplayDialog miniReportD * Try to load the "bing" sound clip. */ private @Nullable Clip loadSoundClip(@Nullable String filename) { - Clip clip = null; - if (filename == null) { return null; } @@ -421,16 +421,15 @@ public void setMiniReportDisplayDialog(final MiniReportDisplayDialog miniReportD } try { - clip = AudioSystem.getClip(); + Clip clip = AudioSystem.getClip(); try (AudioInputStream ais = AudioSystem.getAudioInputStream(file)) { clip.open(ais); + return clip; } } catch (Exception ex) { LogManager.getLogger().error("", ex); - clip = null; + return null; } - - return clip; } /** diff --git a/megamek/src/megamek/client/ui/swing/GUIPreferences.java b/megamek/src/megamek/client/ui/swing/GUIPreferences.java index 46d6514d138..f49d9851bbf 100644 --- a/megamek/src/megamek/client/ui/swing/GUIPreferences.java +++ b/megamek/src/megamek/client/ui/swing/GUIPreferences.java @@ -1167,7 +1167,6 @@ public boolean getSoundMuteOthersTurn() { return store.getBoolean(SOUND_MUTE_OTHERS_TURN); } - public int getTooltipDelay() { return store.getInt(TOOLTIP_DELAY); }