diff --git a/src/itdelatrisu/opsu/GameData.java b/src/itdelatrisu/opsu/GameData.java index 3f4e4404..1e794f59 100644 --- a/src/itdelatrisu/opsu/GameData.java +++ b/src/itdelatrisu/opsu/GameData.java @@ -1397,8 +1397,10 @@ private void incrementComboStreak() { * Resets the combo streak to zero. */ private void resetComboStreak() { - if (combo > 20 && !(GameMod.RELAX.isActive() || GameMod.AUTOPILOT.isActive())) - SoundController.playSound(SoundEffect.COMBOBREAK); + if (combo > 20 && !(GameMod.RELAX.isActive() || GameMod.AUTOPILOT.isActive())) { + if (!Options.isGameplaySoundDisabled()) + SoundController.playSound(SoundEffect.COMBOBREAK); + } combo = 0; if (GameMod.SUDDEN_DEATH.isActive()) health.setHealth(0f); @@ -1482,11 +1484,13 @@ public void sendSpinnerSpinResult(int result) { switch (result) { case HIT_SPINNERSPIN: hitValue = 100; - SoundController.playSound(SoundEffect.SPINNERSPIN); + if (!Options.isGameplaySoundDisabled()) + SoundController.playSound(SoundEffect.SPINNERSPIN); break; case HIT_SPINNERBONUS: hitValue = 1100; - SoundController.playSound(SoundEffect.SPINNERBONUS); + if (!Options.isGameplaySoundDisabled()) + SoundController.playSound(SoundEffect.SPINNERBONUS); break; default: return; diff --git a/src/itdelatrisu/opsu/objects/Spinner.java b/src/itdelatrisu/opsu/objects/Spinner.java index 3976881c..514edcaa 100644 --- a/src/itdelatrisu/opsu/objects/Spinner.java +++ b/src/itdelatrisu/opsu/objects/Spinner.java @@ -244,7 +244,8 @@ private int hitResult() { float ratio = rotations / rotationsNeeded; if (ratio >= 1.0f || GameMod.AUTO.isActive() || GameMod.AUTOPILOT.isActive() || GameMod.SPUN_OUT.isActive()) { result = GameData.HIT_300; - SoundController.playSound(SoundEffect.SPINNEROSU); + if (!Options.isGameplaySoundDisabled()) + SoundController.playSound(SoundEffect.SPINNEROSU); } else if (ratio >= 0.9f) result = GameData.HIT_100; else if (ratio >= 0.75f) diff --git a/src/itdelatrisu/opsu/options/OptionGroup.java b/src/itdelatrisu/opsu/options/OptionGroup.java index 268358a2..6bb7b5c8 100644 --- a/src/itdelatrisu/opsu/options/OptionGroup.java +++ b/src/itdelatrisu/opsu/options/OptionGroup.java @@ -77,6 +77,7 @@ public class OptionGroup { GameOption.MUSIC_VOLUME, GameOption.EFFECT_VOLUME, GameOption.HITSOUND_VOLUME, + GameOption.DISABLE_GAMEPLAY_SOUNDS, GameOption.DISABLE_SOUNDS, }), new OptionGroup("OFFSET ADJUSTMENT", new GameOption[] { diff --git a/src/itdelatrisu/opsu/options/Options.java b/src/itdelatrisu/opsu/options/Options.java index 885b9e0a..3c52eeee 100644 --- a/src/itdelatrisu/opsu/options/Options.java +++ b/src/itdelatrisu/opsu/options/Options.java @@ -534,6 +534,7 @@ public void setValue(int value) { @Override public String getValueString() { return String.format("%dms", val); } }, + DISABLE_GAMEPLAY_SOUNDS ("Disable sound effects in gameplay", "DisableGameplaySound", "Mute all sound effects during gameplay only.", false), DISABLE_SOUNDS ("Disable all sound effects", "DisableSound", "May resolve Linux sound driver issues.\nRequires a restart.", false) { @Override public boolean isRestartRequired() { return true; } @@ -1246,6 +1247,12 @@ public static void setDisplayMode(Container app) { */ public static int getCheckpoint() { return GameOption.CHECKPOINT.getIntegerValue() * 1000; } + /** + * Returns whether or not sound effects are disabled during gameplay. + * @return true if disabled + */ + public static boolean isGameplaySoundDisabled() { return GameOption.DISABLE_GAMEPLAY_SOUNDS.getBooleanValue(); } + /** * Returns whether or not all sound effects are disabled. * @return true if disabled diff --git a/src/itdelatrisu/opsu/states/Game.java b/src/itdelatrisu/opsu/states/Game.java index b5aa35e7..1627f593 100644 --- a/src/itdelatrisu/opsu/states/Game.java +++ b/src/itdelatrisu/opsu/states/Game.java @@ -559,13 +559,13 @@ else if (breakIndex > 1) { if (data.getHealthPercent() >= 50) { GameImage.SECTION_PASS.getImage().drawCentered(width / 2f, height / 2f); if (!breakSound) { - SoundController.playSound(SoundEffect.SECTIONPASS); + playSoundEffect(SoundEffect.SECTIONPASS); breakSound = true; } } else { GameImage.SECTION_FAIL.getImage().drawCentered(width / 2f, height / 2f); if (!breakSound) { - SoundController.playSound(SoundEffect.SECTIONFAIL); + playSoundEffect(SoundEffect.SECTIONFAIL); breakSound = true; } } @@ -630,28 +630,28 @@ else if (breakIndex > 1) { if (timeDiff >= 1500 * speedModifier) { GameImage.COUNTDOWN_READY.getImage().drawCentered(width / 2, height / 2); if (!countdownReadySound) { - SoundController.playSound(SoundEffect.READY); + playSoundEffect(SoundEffect.READY); countdownReadySound = true; } } if (timeDiff < 2000 * speedModifier) { GameImage.COUNTDOWN_3.getImage().draw(0, 0); if (!countdown3Sound) { - SoundController.playSound(SoundEffect.COUNT3); + playSoundEffect(SoundEffect.COUNT3); countdown3Sound = true; } } if (timeDiff < 1500 * speedModifier) { GameImage.COUNTDOWN_2.getImage().draw(width - GameImage.COUNTDOWN_2.getImage().getWidth(), 0); if (!countdown2Sound) { - SoundController.playSound(SoundEffect.COUNT2); + playSoundEffect(SoundEffect.COUNT2); countdown2Sound = true; } } if (timeDiff < 1000 * speedModifier) { GameImage.COUNTDOWN_1.getImage().drawCentered(width / 2, height / 2); if (!countdown1Sound) { - SoundController.playSound(SoundEffect.COUNT1); + playSoundEffect(SoundEffect.COUNT1); countdown1Sound = true; } } @@ -660,7 +660,7 @@ else if (breakIndex > 1) { go.setAlpha((timeDiff < 0) ? 1 - (timeDiff / speedModifier / -500f) : 1); go.drawCentered(width / 2, height / 2); if (!countdownGoSound) { - SoundController.playSound(SoundEffect.GO); + playSoundEffect(SoundEffect.GO); countdownGoSound = true; } } @@ -1236,7 +1236,7 @@ else if (key == Options.getGameKeyRight()) int position = (pauseTime > -1) ? pauseTime : trackPosition; if (Options.setCheckpoint(position / 1000)) { - SoundController.playSound(SoundEffect.MENUCLICK); + playSoundEffect(SoundEffect.MENUCLICK); UI.getNotificationManager().sendBarNotification("Checkpoint saved."); } } @@ -1257,7 +1257,7 @@ else if (key == Options.getGameKeyRight()) leadInTime = 0; MusicController.resume(); } - SoundController.playSound(SoundEffect.MENUHIT); + playSoundEffect(SoundEffect.MENUHIT); UI.getNotificationManager().sendBarNotification("Checkpoint loaded."); // skip to checkpoint @@ -1915,7 +1915,7 @@ private synchronized boolean skipIntro() { replayX = (int) skipButton.getX(); replayY = (int) skipButton.getY(); } - SoundController.playSound(SoundEffect.MENUHIT); + playSoundEffect(SoundEffect.MENUHIT); return true; } return false; @@ -2464,4 +2464,13 @@ private void adjustLocalMusicOffset(int sign) { BeatmapDB.updateLocalOffset(beatmap); } } + + /** + * Plays a sound, unless gameplay sounds are disabled. + * @param s the sound effect + */ + private void playSoundEffect(SoundEffect s) { + if (!Options.isGameplaySoundDisabled()) + SoundController.playSound(s); + } } diff --git a/src/itdelatrisu/opsu/states/GamePauseMenu.java b/src/itdelatrisu/opsu/states/GamePauseMenu.java index be5aa3f9..6487c8c4 100644 --- a/src/itdelatrisu/opsu/states/GamePauseMenu.java +++ b/src/itdelatrisu/opsu/states/GamePauseMenu.java @@ -132,7 +132,8 @@ else if (key == Options.getGameKeyRight()) UI.getCursor().reset(); game.enterState(Opsu.STATE_SONGMENU, new EasedFadeOutTransition(), new FadeInTransition()); } else { - SoundController.playSound(SoundEffect.MENUBACK); + if (!Options.isGameplaySoundDisabled()) + SoundController.playSound(SoundEffect.MENUBACK); gameState.setPlayState(Game.PlayState.NORMAL); game.enterState(Opsu.STATE_GAME); } @@ -160,7 +161,8 @@ public void mousePressed(int button, int x, int y) { boolean loseState = (gameState.getPlayState() == Game.PlayState.LOSE); if (continueButton.contains(x, y) && !loseState) { - SoundController.playSound(SoundEffect.MENUBACK); + if (!Options.isGameplaySoundDisabled()) + SoundController.playSound(SoundEffect.MENUBACK); gameState.setPlayState(Game.PlayState.NORMAL); game.enterState(Opsu.STATE_GAME); } else if (retryButton.contains(x, y)) {