From 4fd0806e77c3c82e932540f7fc94e63d20f2180e Mon Sep 17 00:00:00 2001 From: Kolo <67389779+JustKolosaki@users.noreply.github.com> Date: Sat, 18 Oct 2025 17:12:15 +0200 Subject: [PATCH 1/2] make volume settings optionally carry over to playtest --- source/funkin/play/PlayState.hx | 34 ++++++++++++++----- source/funkin/save/Save.hx | 24 +++++++++++++ .../ui/debug/charting/ChartEditorState.hx | 18 +++++++++- .../handlers/ChartEditorToolboxHandler.hx | 11 ++++++ 4 files changed, 78 insertions(+), 9 deletions(-) diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index b66bd28b89d..62b38343f68 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -239,6 +239,24 @@ class PlayState extends MusicBeatSubState */ public var playbackRate:Float = 1.0; + /** + * The volume of the instrumental track. + * @default `1.0` for 100%. + */ + public var instrumentalVolume:Float = 1.0; + + /** + * The volume of the player vocals track. + * @default `1.0` for 100%. + */ + public var playerVocalsVolume:Float = 1.0; + + /** + * The volume of the opponent vocals track. + * @default `1.0` for 100%. + */ + public var opponentVocalsVolume:Float = 1.0; + /** * An empty FlxObject contained in the scene. * The current gameplay camera will always follow this object. Tween its position to move the camera smoothly. @@ -1028,16 +1046,15 @@ class PlayState extends MusicBeatSubState } } - if (FlxG.sound.music != null) FlxG.sound.music.volume = 1; + if (FlxG.sound.music != null) FlxG.sound.music.volume = instrumentalVolume; if (vocals != null) { vocals.pause(); vocals.time = startTimestamp - Conductor.instance.instrumentalOffset; - vocals.volume = 1; - vocals.playerVolume = 1; - vocals.opponentVolume = 1; + vocals.playerVolume = playerVocalsVolume; + vocals.opponentVolume = opponentVocalsVolume; } if (!fromDeathState) @@ -2512,7 +2529,7 @@ class PlayState extends MusicBeatSubState } // Prevent the volume from being wrong. - FlxG.sound.music.volume = 1.0; + FlxG.sound.music.volume = instrumentalVolume; if (FlxG.sound.music.fadeTween != null) FlxG.sound.music.fadeTween.cancel(); if (vocals != null) @@ -2522,7 +2539,8 @@ class PlayState extends MusicBeatSubState vocals.time = startTimestamp - Conductor.instance.instrumentalOffset; vocals.pitch = playbackRate; - vocals.volume = 1.0; + vocals.playerVolume = playerVocalsVolume; + vocals.opponentVolume = opponentVocalsVolume; // trace('STARTING SONG AT:'); // trace('${FlxG.sound.music.time}'); @@ -2986,7 +3004,7 @@ class PlayState extends MusicBeatSubState playerStrumline.hitNote(note, !event.isComboBreak); if (event.doesNotesplash) playerStrumline.playNoteSplash(note.noteData.getDirection()); if (note.isHoldNote && note.holdNoteSprite != null) playerStrumline.playNoteHoldCover(note.holdNoteSprite); - if (vocals != null) vocals.playerVolume = 1; + if (vocals != null) vocals.playerVolume = playerVocalsVolume; // Display the combo meter and add the calculation to the score. if (note.scoreable) @@ -3225,7 +3243,7 @@ class PlayState extends MusicBeatSubState comboPopUps.displayRating(daRating); if (combo >= 10) comboPopUps.displayCombo(combo); - if (vocals != null) vocals.playerVolume = 1; + if (vocals != null) vocals.playerVolume = playerVocalsVolume; } /** diff --git a/source/funkin/save/Save.hx b/source/funkin/save/Save.hx index d6b7c31bc8f..05dc436c217 100644 --- a/source/funkin/save/Save.hx +++ b/source/funkin/save/Save.hx @@ -189,6 +189,7 @@ class Save implements ConsoleClass chartEditorLiveInputStyle: ChartEditorLiveInputStyle.None, theme: ChartEditorTheme.Light, playtestStartTime: false, + playtestAudioSettings: false, downscroll: false, showNoteKinds: true, metronomeVolume: 1.0, @@ -413,6 +414,23 @@ class Save implements ConsoleClass return data.optionsChartEditor.playtestStartTime; } + public var chartEditorPlaytestAudioSettings(get, set):Bool; + + function get_chartEditorPlaytestAudioSettings():Bool + { + if (data.optionsChartEditor.playtestAudioSettings == null) data.optionsChartEditor.playtestAudioSettings = false; + + return data.optionsChartEditor.playtestAudioSettings; + } + + function set_chartEditorPlaytestAudioSettings(value:Bool):Bool + { + // Set and apply. + data.optionsChartEditor.playtestAudioSettings = value; + flush(); + return data.optionsChartEditor.playtestAudioSettings; + } + public var chartEditorTheme(get, set):ChartEditorTheme; function get_chartEditorTheme():ChartEditorTheme @@ -1933,6 +1951,12 @@ typedef SaveDataChartEditorOptions = */ var ?playtestStartTime:Bool; + /** + * If true, playtest songs with the current audio settings in the Chart Editor. + * @default `false` + */ + var ?playtestAudioSettings:Bool; + /** * Theme music in the Chart Editor. * @default `true` diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index 544386f50d2..4a0a6905e09 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -604,6 +604,11 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState */ var playtestBotPlayMode:Bool = false; + /** + * If true, playtesting a chart will use the audio settings that were set here. + */ + var playtestAudioSettings:Bool = false; + /** * Enables or disables the "debugger" popup that appears when you run into a flixel error. */ @@ -2486,6 +2491,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState showNoteKindIndicators = save.chartEditorShowNoteKinds; showSubtitles = save.chartEditorShowSubtitles; playtestStartTime = save.chartEditorPlaytestStartTime; + playtestAudioSettings = save.chartEditorPlaytestAudioSettings; currentTheme = save.chartEditorTheme; metronomeVolume = save.chartEditorMetronomeVolume; hitsoundVolumePlayer = save.chartEditorHitsoundVolumePlayer; @@ -2516,6 +2522,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState save.chartEditorDownscroll = isViewDownscroll; save.chartEditorShowNoteKinds = showNoteKindIndicators; save.chartEditorPlaytestStartTime = playtestStartTime; + save.chartEditorPlaytestAudioSettings = playtestAudioSettings; save.chartEditorTheme = currentTheme; save.chartEditorMetronomeVolume = metronomeVolume; save.chartEditorHitsoundVolumePlayer = hitsoundVolumePlayer; @@ -6268,7 +6275,16 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState Cursor.hide(); - LoadingState.loadPlayState(targetStateParams, false, true, function(targetState) { + LoadingState.loadPlayState(targetStateParams, false, true, function(targetState) + { + // Apply volume settings. + if (playtestAudioSettings) + { + targetState.instrumentalVolume = (menubarItemVolumeInstrumental.value / 100.0) ?? 1.0; + targetState.playerVocalsVolume = (menubarItemVolumeVocalsPlayer.value / 100.0) ?? 1.0; + targetState.opponentVocalsVolume = (menubarItemVolumeVocalsOpponent.value / 100.0) ?? 1.0; + } + targetState.vocals = audioVocalTrackGroup; }); } diff --git a/source/funkin/ui/debug/charting/handlers/ChartEditorToolboxHandler.hx b/source/funkin/ui/debug/charting/handlers/ChartEditorToolboxHandler.hx index da385223389..32797a2522f 100644 --- a/source/funkin/ui/debug/charting/handlers/ChartEditorToolboxHandler.hx +++ b/source/funkin/ui/debug/charting/handlers/ChartEditorToolboxHandler.hx @@ -291,6 +291,17 @@ class ChartEditorToolboxHandler state.playtestSongScripts = checkboxSongScripts.selected; }; + var checkboxAudioSettings:Null = toolbox.findComponent('playtestAudioSettingsCheckbox', CheckBox); + + if (checkboxAudioSettings == null) + throw 'ChartEditorToolboxHandler.buildToolboxPlaytestPropertiesLayout() - Could not find playtestAudioSettingsCheckbox component.'; + + state.playtestAudioSettings = checkboxAudioSettings.selected; + + checkboxAudioSettings.onClick = _ -> { + state.playtestAudioSettings = checkboxAudioSettings.selected; + }; + return toolbox; } From 2d6819ccf20d15f2852caec8d9c021e554bbcf9f Mon Sep 17 00:00:00 2001 From: Kolo <67389779+JustKolosaki@users.noreply.github.com> Date: Wed, 3 Dec 2025 13:56:08 +0100 Subject: [PATCH 2/2] merge conflicts fixed --- source/funkin/save/Save.hx | 3 +++ source/funkin/ui/debug/charting/ChartEditorState.hx | 2 ++ 2 files changed, 5 insertions(+) diff --git a/source/funkin/save/Save.hx b/source/funkin/save/Save.hx index 33b88318c44..2ecc00a1036 100644 --- a/source/funkin/save/Save.hx +++ b/source/funkin/save/Save.hx @@ -282,6 +282,9 @@ class Save implements ConsoleClass @:saveProperty(data.optionsChartEditor.playtestStartTime, false) public var chartEditorPlaytestStartTime:SaveProperty; + @:saveProperty(data.optionsChartEditor.playtestAudioSettings, false) + public var chartEditorPlaytestAudioSettings:SaveProperty; + @:saveProperty(data.optionsChartEditor.theme, ChartEditorTheme.Light) public var chartEditorTheme:SaveProperty; diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index 9b0702896c7..b685e6dde3a 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -2511,6 +2511,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState showNoteKindIndicators = save.chartEditorShowNoteKinds.value; showSubtitles = save.chartEditorShowSubtitles.value; playtestStartTime = save.chartEditorPlaytestStartTime.value; + playtestAudioSettings = save.chartEditorPlaytestAudioSettings.value; currentTheme = save.chartEditorTheme.value; metronomeVolume = save.chartEditorMetronomeVolume.value; hitsoundVolumePlayer = save.chartEditorHitsoundVolumePlayer.value; @@ -2541,6 +2542,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState save.chartEditorDownscroll.value = isViewDownscroll; save.chartEditorShowNoteKinds.value = showNoteKindIndicators; save.chartEditorPlaytestStartTime.value = playtestStartTime; + save.chartEditorPlaytestAudioSettings.value = playtestAudioSettings; save.chartEditorTheme.value = currentTheme; save.chartEditorMetronomeVolume.value = metronomeVolume; save.chartEditorHitsoundVolumePlayer.value = hitsoundVolumePlayer;