From 20cf90f5c25f6ffb058549b73ed4f9c2124f0e17 Mon Sep 17 00:00:00 2001
From: Ralty <78720179+Raltyro@users.noreply.github.com>
Date: Mon, 28 Jul 2025 19:07:01 +0700
Subject: [PATCH] Add Music Volume
---
assets/languages/en/Options.xml | 3 +++
source/funkin/options/Options.hx | 2 ++
source/funkin/options/categories/GameplayOptions.hx | 4 +++-
source/funkin/options/type/SliderOption.hx | 5 ++++-
4 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/assets/languages/en/Options.xml b/assets/languages/en/Options.xml
index e286a5e5..7145f793 100644
--- a/assets/languages/en/Options.xml
+++ b/assets/languages/en/Options.xml
@@ -112,6 +112,9 @@
Auto Pause
If checked, switching windows will pause the game.
+ Music Volume
+ Changes only the volume of the music instead of everything.
+
SFX Volume
Changes only the volume of the SFX instead of everything.
diff --git a/source/funkin/options/Options.hx b/source/funkin/options/Options.hx
index cbb90d1b..0b0bda8d 100644
--- a/source/funkin/options/Options.hx
+++ b/source/funkin/options/Options.hx
@@ -29,6 +29,7 @@ class Options
public static var autoPause:Bool = true;
public static var antialiasing:Bool = true;
public static var volume:Float = 1;
+ public static var volumeMusic:Float = 1;
public static var volumeSFX:Float = 1;
public static var week6PixelPerfect:Bool = true;
public static var gameplayShaders:Bool = true;
@@ -225,6 +226,7 @@ class Options
gameplayShaders = true;
}
+ FlxG.sound.defaultMusicGroup.volume = volumeMusic;
FlxG.game.stage.quality = (FlxG.enableAntialiasing = antialiasing) ? BEST : LOW;
FlxG.autoPause = autoPause;
if (FlxG.updateFramerate < framerate) FlxG.drawFramerate = FlxG.updateFramerate = framerate;
diff --git a/source/funkin/options/categories/GameplayOptions.hx b/source/funkin/options/categories/GameplayOptions.hx
index c7acbd0e..7d66f351 100644
--- a/source/funkin/options/categories/GameplayOptions.hx
+++ b/source/funkin/options/categories/GameplayOptions.hx
@@ -16,6 +16,7 @@ class GameplayOptions extends TreeMenuScreen {
add(new Checkbox(getNameID('camZoomOnBeat'), getDescID('camZoomOnBeat'), 'camZoomOnBeat'));
add(new Checkbox(getNameID('autoPause'), getDescID('autoPause'), 'autoPause', __changeAutoPause));
add(offsetSetting = new NumOption(getNameID('songOffset'), getDescID('songOffset'), -999, 999, 1, 'songOffset', __changeOffset));
+ add(new SliderOption(getNameID('volumeMusic'), getDescID('volumeMusic'), 0, 1, 1, 5, 'volumeMusic', -1, __changeVolumeMusic));
add(new SliderOption(getNameID('volumeSFX'), getDescID('volumeSFX'), 0, 1, 1, 5, 'volumeSFX'));
add(new Separator());
@@ -23,8 +24,9 @@ class GameplayOptions extends TreeMenuScreen {
parent.addMenu(new AdvancedGameplayOptions())));
}
- private function __changeOffset(offset:Float) Conductor.songOffset = offset;
private function __changeAutoPause() FlxG.autoPause = Options.autoPause;
+ private function __changeOffset(offset:Float) Conductor.songOffset = offset;
+ private function __changeVolumeMusic(value:Float) FlxG.sound.defaultMusicGroup.volume = value;
var __lastBeat:Int = 0;
var __lastSongBeat:Int = 0;
diff --git a/source/funkin/options/type/SliderOption.hx b/source/funkin/options/type/SliderOption.hx
index 7ecb4a84..955b61d9 100644
--- a/source/funkin/options/type/SliderOption.hx
+++ b/source/funkin/options/type/SliderOption.hx
@@ -25,7 +25,10 @@ class SliderOption extends TextOption implements ITreeFloatOption {
override function set_text(v:String) {
super.set_text(v);
slider.x = __text.x + __text.width + 30;
- if (dynamicWidth) slider.barWidth = 1100 - __text.width;
+ if (dynamicWidth) {
+ slider.barWidth = 1100 - __text.width;
+ slider.updateHitbox();
+ }
return v;
}