music: add option to mute ambient sound effects

This commit is contained in:
Adam
2021-11-01 19:56:26 -04:00
parent 63034431c0
commit 099221993a
2 changed files with 35 additions and 5 deletions

View File

@@ -28,10 +28,12 @@ import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
@ConfigGroup("music") @ConfigGroup(MusicConfig.GROUP)
public interface MusicConfig extends Config public interface MusicConfig extends Config
{ {
String GROUP = "music";
String GRANULAR_SLIDERS = "granularSliders"; String GRANULAR_SLIDERS = "granularSliders";
String MUTE_AMBIENT_SOUNDS = "muteAmbientSounds";
@ConfigItem( @ConfigItem(
keyName = "muteOwnAreaSounds", keyName = "muteOwnAreaSounds",
@@ -77,11 +79,22 @@ public interface MusicConfig extends Config
return false; return false;
} }
@ConfigItem(
keyName = MUTE_AMBIENT_SOUNDS,
name = "Mute ambient sounds",
description = "Mute background noise such as magic trees and furnaces",
position = 4
)
default boolean muteAmbientSounds()
{
return false;
}
@ConfigItem( @ConfigItem(
keyName = "mutePrayerSounds", keyName = "mutePrayerSounds",
name = "Mute prayer sounds", name = "Mute prayer sounds",
description = "Mute prayer activation and deactivation sounds", description = "Mute prayer activation and deactivation sounds",
position = 4 position = 5
) )
default boolean mutePrayerSounds() default boolean mutePrayerSounds()
{ {
@@ -92,7 +105,7 @@ public interface MusicConfig extends Config
keyName = GRANULAR_SLIDERS, keyName = GRANULAR_SLIDERS,
name = "Granular volume sliders", name = "Granular volume sliders",
description = "Make the volume sliders allow better control of volume", description = "Make the volume sliders allow better control of volume",
position = 5 position = 6
) )
default boolean granularSliders() default boolean granularSliders()
{ {

View File

@@ -221,12 +221,21 @@ public class MusicPlugin extends Plugin
@Subscribe @Subscribe
public void onGameStateChanged(GameStateChanged gameStateChanged) public void onGameStateChanged(GameStateChanged gameStateChanged)
{ {
if (gameStateChanged.getGameState() == GameState.LOGIN_SCREEN) GameState gameState = gameStateChanged.getGameState();
if (gameState == GameState.LOGIN_SCREEN)
{ {
// Reset music filter on logout // Reset music filter on logout
currentMusicFilter = MusicState.ALL; currentMusicFilter = MusicState.ALL;
tracks = null; tracks = null;
} }
else if (gameState == GameState.LOGGED_IN)
{
if (musicConfig.muteAmbientSounds())
{
client.getAmbientSoundEffects()
.clear();
}
}
} }
@Subscribe @Subscribe
@@ -308,7 +317,7 @@ public class MusicPlugin extends Plugin
@Subscribe @Subscribe
public void onConfigChanged(ConfigChanged configChanged) public void onConfigChanged(ConfigChanged configChanged)
{ {
if ("music".equals(configChanged.getGroup())) if (configChanged.getGroup().equals(MusicConfig.GROUP))
{ {
clientThread.invoke(() -> clientThread.invoke(() ->
{ {
@@ -324,6 +333,14 @@ public class MusicPlugin extends Plugin
teardownMusicOptions(); teardownMusicOptions();
} }
} }
else if (MusicConfig.MUTE_AMBIENT_SOUNDS.equals(configChanged.getKey()))
{
// Reload the scene to reapply ambient sounds
if (client.getGameState() == GameState.LOGGED_IN)
{
client.setGameState(GameState.LOADING);
}
}
else else
{ {
updateMusicOptions(); updateMusicOptions();