From de9e60c8868f9d31c7639b4fb8ff56592c76bc8a Mon Sep 17 00:00:00 2001 From: Lasercar <64717068+Lasercar@users.noreply.github.com> Date: Mon, 9 Jun 2025 21:29:21 +1000 Subject: [PATCH] Variation fallback --- .../handlers/ChartEditorImportExportHandler.hx | 10 ++++++++-- .../charting/toolboxes/ChartEditorDifficultyToolbox.hx | 1 - 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/source/funkin/ui/debug/charting/handlers/ChartEditorImportExportHandler.hx b/source/funkin/ui/debug/charting/handlers/ChartEditorImportExportHandler.hx index 7fafe368232..37417ae2914 100644 --- a/source/funkin/ui/debug/charting/handlers/ChartEditorImportExportHandler.hx +++ b/source/funkin/ui/debug/charting/handlers/ChartEditorImportExportHandler.hx @@ -134,10 +134,16 @@ class ChartEditorImportExportHandler state.songManifestData = newSongManifestData; } - if (!state.songMetadata.exists(state.selectedVariation)) + var variationMetadata:Null = state.songMetadata.get(state.selectedVariation); + if (variationMetadata == null) { - state.selectedVariation = Constants.DEFAULT_VARIATION; + // Use the default variation, or the first available variation if that doesn't exist for some reason. + if (state.availableDifficulties.indexOf(Constants.DEFAULT_VARIATION) < 0) state.selectedVariation = state.availableVariations[0]; + else state.selectedVariation = Constants.DEFAULT_VARIATION; + + variationMetadata = state.songMetadata.get(state.selectedVariation); } + // Use the first available difficulty as a fallback if the currently selected one cannot be found. if (state.availableDifficulties.indexOf(state.selectedDifficulty) < 0) state.selectedDifficulty = state.availableDifficulties[0]; diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorDifficultyToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorDifficultyToolbox.hx index 2fe108df527..0e6db0ddb47 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorDifficultyToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorDifficultyToolbox.hx @@ -6,7 +6,6 @@ import funkin.data.song.SongRegistry; import haxe.ui.components.Button; import haxe.ui.containers.dialogs.Dialogs; import haxe.ui.containers.dialogs.Dialog.DialogButton; -import funkin.data.song.SongData.SongMetadata; import haxe.ui.components.DropDown; import haxe.ui.components.HorizontalSlider; import funkin.util.VersionUtil;