From 33a1b81737cf55aee328b5839eab99ac186182b3 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Tue, 24 Oct 2023 15:50:02 -0400 Subject: [PATCH] Fixes for quicksave --- assets | 2 +- .../debug/charting/ChartEditorAudioHandler.hx | 34 ++++- .../charting/ChartEditorDialogHandler.hx | 54 ++++++- .../ChartEditorImportExportHandler.hx | 57 +++++--- .../ui/debug/charting/ChartEditorState.hx | 132 ++++++++++++++---- source/funkin/util/FileUtil.hx | 22 +-- 6 files changed, 238 insertions(+), 63 deletions(-) diff --git a/assets b/assets index fd745fcb1..8e8aeb064 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit fd745fcb16c6a0de73449ae833ce1d92f022d9d6 +Subproject commit 8e8aeb06472ca294c569818cbefb1bb3dfce7854 diff --git a/source/funkin/ui/debug/charting/ChartEditorAudioHandler.hx b/source/funkin/ui/debug/charting/ChartEditorAudioHandler.hx index 6f390e604..1ceeadd5f 100644 --- a/source/funkin/ui/debug/charting/ChartEditorAudioHandler.hx +++ b/source/funkin/ui/debug/charting/ChartEditorAudioHandler.hx @@ -218,6 +218,18 @@ class ChartEditorAudioHandler snd.play(); } + public static function wipeInstrumentalData(state:ChartEditorState):Void + { + state.audioInstTrackData.clear(); + stopExistingInstrumental(state); + } + + public static function wipeVocalData(state:ChartEditorState):Void + { + state.audioVocalTrackData.clear(); + stopExistingVocals(state); + } + /** * Convert byte data into a playable sound. * @@ -238,18 +250,27 @@ class ChartEditorAudioHandler { var zipEntries = []; - for (key in state.audioInstTrackData.keys()) + var instTrackIds = state.audioInstTrackData.keys().array(); + for (key in instTrackIds) { if (key == 'default') { var data:Null = state.audioInstTrackData.get('default'); - if (data == null) continue; + if (data == null) + { + trace('[WARN] Failed to access inst track ($key)'); + continue; + } zipEntries.push(FileUtil.makeZIPEntryFromBytes('Inst.ogg', data)); } else { var data:Null = state.audioInstTrackData.get(key); - if (data == null) continue; + if (data == null) + { + trace('[WARN] Failed to access inst track ($key)'); + continue; + } zipEntries.push(FileUtil.makeZIPEntryFromBytes('Inst-${key}.ogg', data)); } } @@ -261,10 +282,15 @@ class ChartEditorAudioHandler { var zipEntries = []; + var vocalTrackIds = state.audioVocalTrackData.keys().array(); for (key in state.audioVocalTrackData.keys()) { var data:Null = state.audioVocalTrackData.get(key); - if (data == null) continue; + if (data == null) + { + trace('[WARN] Failed to access vocal track ($key)'); + continue; + } zipEntries.push(FileUtil.makeZIPEntryFromBytes('Voices-${key}.ogg', data)); } diff --git a/source/funkin/ui/debug/charting/ChartEditorDialogHandler.hx b/source/funkin/ui/debug/charting/ChartEditorDialogHandler.hx index bfb860c92..0dd916ba1 100644 --- a/source/funkin/ui/debug/charting/ChartEditorDialogHandler.hx +++ b/source/funkin/ui/debug/charting/ChartEditorDialogHandler.hx @@ -106,7 +106,31 @@ class ChartEditorDialogHandler state.stopWelcomeMusic(); // Load chart from file - ChartEditorImportExportHandler.loadFromFNFCPath(state, chartPath); + var result:Null> = ChartEditorImportExportHandler.loadFromFNFCPath(state, chartPath); + if (result != null) + { + #if !mac + NotificationManager.instance.addNotification( + { + title: 'Success', + body: result.length == 0 ? 'Loaded chart (${chartPath.toString()})' : 'Loaded chart (${chartPath.toString()})\n${result.join("\n")}', + type: result.length == 0 ? NotificationType.Success : NotificationType.Warning, + expiryMs: ChartEditorState.NOTIFICATION_DISMISS_TIME + }); + #end + } + else + { + #if !mac + NotificationManager.instance.addNotification( + { + title: 'Failure', + body: 'Failed to load chart (${chartPath.toString()})', + type: NotificationType.Error, + expiryMs: ChartEditorState.NOTIFICATION_DISMISS_TIME + }); + #end + } } if (!FileUtil.doesFileExist(chartPath)) @@ -260,7 +284,8 @@ class ChartEditorDialogHandler { try { - if (ChartEditorImportExportHandler.loadFromFNFC(state, selectedFile.bytes)) + var result:Null> = ChartEditorImportExportHandler.loadFromFNFC(state, selectedFile.bytes); + if (result != null) { #if !mac NotificationManager.instance.addNotification( @@ -299,21 +324,33 @@ class ChartEditorDialogHandler try { - if (ChartEditorImportExportHandler.loadFromFNFCPath(state, path.toString())) + var result:Null> = ChartEditorImportExportHandler.loadFromFNFCPath(state, path.toString()); + if (result != null) { #if !mac NotificationManager.instance.addNotification( { title: 'Success', - body: 'Loaded chart (${path.toString()})', - type: NotificationType.Success, + body: result.length == 0 ? 'Loaded chart (${path.toString()})' : 'Loaded chart (${path.toString()})\n${result.join("\n")}', + type: result.length == 0 ? NotificationType.Success : NotificationType.Warning, expiryMs: ChartEditorState.NOTIFICATION_DISMISS_TIME }); #end - dialog.hideDialog(DialogButton.APPLY); removeDropHandler(onDropFile); } + else + { + #if !mac + NotificationManager.instance.addNotification( + { + title: 'Failure', + body: 'Failed to load chart (${path.toString()})', + type: NotificationType.Error, + expiryMs: ChartEditorState.NOTIFICATION_DISMISS_TIME + }); + #end + } } catch (err) { @@ -359,6 +396,8 @@ class ChartEditorDialogHandler var uploadVocalsDialog:Dialog = openUploadVocalsDialog(state, closable); // var uploadVocalsDialog:Dialog uploadVocalsDialog.onDialogClosed = function(_event) { state.isHaxeUIDialogOpen = false; + state.currentWorkingFilePath = null; // Built from parts, so no .fnfc to save to. + state.switchToCurrentInstrumental(); state.postLoadInstrumental(); } } @@ -398,6 +437,8 @@ class ChartEditorDialogHandler var uploadVocalsDialog:Dialog = openUploadVocalsDialog(state, closable); // var uploadVocalsDialog:Dialog uploadVocalsDialog.onDialogClosed = function(_event) { state.isHaxeUIDialogOpen = false; + state.currentWorkingFilePath = null; // New file, so no path. + state.switchToCurrentInstrumental(); state.postLoadInstrumental(); } } @@ -848,6 +889,7 @@ class ChartEditorDialogHandler var dialogContinue:Null