From 69638ccdcc84d2db9b53cc8816c3cc9560586e5f Mon Sep 17 00:00:00 2001 From: MattNL Date: Wed, 8 Mar 2023 14:15:06 -0500 Subject: [PATCH] Added check for missing files when saving in the AudioEditor --- PCK-Studio/Forms/Editor/AudioEditor.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/PCK-Studio/Forms/Editor/AudioEditor.cs b/PCK-Studio/Forms/Editor/AudioEditor.cs index 97df4da8..9f657771 100644 --- a/PCK-Studio/Forms/Editor/AudioEditor.cs +++ b/PCK-Studio/Forms/Editor/AudioEditor.cs @@ -304,6 +304,7 @@ namespace PckStudio.Forms.Editor PCKAudioFile.AudioCategory overworldCategory = audioFile.GetCategory(PCKAudioFile.AudioCategory.EAudioType.Overworld); + bool songs_missing = false; foreach (var category in audioFile.Categories) { if (category.SongNames.Count < 1) @@ -312,6 +313,16 @@ namespace PckStudio.Forms.Editor return; } + foreach(var song in category.SongNames) + { + string FileName = Path.Combine(parent.GetDataPath(), song + ".binka"); + if (!File.Exists(FileName)) + { + songs_missing = true; + MessageBox.Show("\"" + song + ".binka\" does not exist in the \"Data\" folder. The game will crash when attempting to load this track.", "File missing"); + } + } + category.Name = ""; if (playOverworldInCreative.Checked && category.audioType == PCKAudioFile.AudioCategory.EAudioType.Creative) { @@ -327,6 +338,12 @@ namespace PckStudio.Forms.Editor } } + if (songs_missing) + { + MessageBox.Show("Failed to save AudioData file because there are missing song entries", "Error"); + return; + } + using (var stream = new MemoryStream()) { PCKAudioFileWriter.Write(stream, audioFile, _isLittleEndian);