slight change to audio file classes

this also fixes the "Include Overworld songs in Creative" feature. The code for that functionality was already perfect, so that hasn't been touched at all. Just needed to adjust the class a little. (:
This commit is contained in:
MattNL
2022-08-09 05:16:10 -04:00
parent beca901b80
commit 3ed5598a97
2 changed files with 6 additions and 11 deletions

View File

@@ -47,17 +47,13 @@ namespace PckStudio.Classes.FileTypes
public EAudioType audioType { get; }
public List<string> SongNames { get; } = new List<string>();
public AudioCategory(EAudioParameterType parameterType, EAudioType audioType)
public AudioCategory(string name, EAudioParameterType parameterType, EAudioType audioType)
{
this.Name = name;
this.parameterType = parameterType;
this.audioType = audioType;
}
public AudioCategory(string name, EAudioParameterType parameterType, EAudioType audioType) : this(parameterType, audioType)
{
Name = name;
}
}
}
public string[] GetCredits() => Credits.Values.ToArray();
public string GetCreditsString() => string.Join("\n", Credits.Values.ToArray());
@@ -135,13 +131,13 @@ namespace PckStudio.Classes.FileTypes
/// <returns>True when category was created, otherwise false</returns>
/// <exception cref="InvalidCategoryException"></exception>
public bool AddCategory(AudioCategory.EAudioParameterType parameterType, AudioCategory.EAudioType category)
public bool AddCategory(AudioCategory.EAudioParameterType parameterType, AudioCategory.EAudioType category, string name = "")
{
if (category < AudioCategory.EAudioType.Overworld ||
category > AudioCategory.EAudioType.Unused)
throw new InvalidCategoryException(nameof(category));
bool exists = HasCategory(category);
if (!exists) _categories[(int)category] = new AudioCategory(parameterType, category);
if (!exists) _categories[(int)category] = new AudioCategory(name, parameterType, category);
return !exists;
}

View File

@@ -64,8 +64,7 @@ namespace PckStudio.Classes.IO.PCK
var parameterType = (PCKAudioFile.AudioCategory.EAudioParameterType)ReadInt(stream);
var audioType = (PCKAudioFile.AudioCategory.EAudioType)ReadInt(stream);
string name = ReadString(stream);
Console.WriteLine(name);
_file.AddCategory(parameterType, audioType);
_file.AddCategory(parameterType, audioType, name);
}
}