Added check for missing files when saving in the AudioEditor

This commit is contained in:
MattNL
2023-03-08 14:15:06 -05:00
parent aa801e5361
commit 69638ccdcc

View File

@@ -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);