From d215152aaff9997179c9c09a2f445f75516433cf Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Thu, 18 Jan 2024 22:28:25 -0500 Subject: [PATCH] Fix a bug where removing audio tracks wouldn't remove their visualizers. --- .../funkin/audio/visualize/PolygonVisGroup.hx | 40 ++++++++++++++++++- .../handlers/ChartEditorAudioHandler.hx | 4 ++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/source/funkin/audio/visualize/PolygonVisGroup.hx b/source/funkin/audio/visualize/PolygonVisGroup.hx index 2903eaccd..cc68f4ae0 100644 --- a/source/funkin/audio/visualize/PolygonVisGroup.hx +++ b/source/funkin/audio/visualize/PolygonVisGroup.hx @@ -8,8 +8,7 @@ class PolygonVisGroup extends FlxTypedGroup { public var playerVis:PolygonSpectogram; public var opponentVis:PolygonSpectogram; - - var instVis:PolygonSpectogram; + public var instVis:PolygonSpectogram; public function new() { @@ -51,6 +50,43 @@ class PolygonVisGroup extends FlxTypedGroup instVis = vis; } + public function clearPlayerVis():Void + { + if (playerVis != null) + { + remove(playerVis); + playerVis.destroy(); + playerVis = null; + } + } + + public function clearOpponentVis():Void + { + if (opponentVis != null) + { + remove(opponentVis); + opponentVis.destroy(); + opponentVis = null; + } + } + + public function clearInstVis():Void + { + if (instVis != null) + { + remove(instVis); + instVis.destroy(); + instVis = null; + } + } + + public function clearAllVis():Void + { + clearPlayerVis(); + clearOpponentVis(); + clearInstVis(); + } + /** * Overrides the add function to add a visualizer to the group. * @param vis The visualizer to add. diff --git a/source/funkin/ui/debug/charting/handlers/ChartEditorAudioHandler.hx b/source/funkin/ui/debug/charting/handlers/ChartEditorAudioHandler.hx index d7fbd42c2..f402574fd 100644 --- a/source/funkin/ui/debug/charting/handlers/ChartEditorAudioHandler.hx +++ b/source/funkin/ui/debug/charting/handlers/ChartEditorAudioHandler.hx @@ -223,6 +223,10 @@ class ChartEditorAudioHandler { state.audioVocalTrackGroup.clear(); } + if (state.audioVisGroup != null) + { + state.audioVisGroup.clearAllVis(); + } } /**