This PR adds the ability for BGM tracks to be encrypted away inside the PGE resource pack system such that it will be more difficult for users to extract the songs from the game.
Because of this, we load the tracks in memory now reading directly from a buffer. (Luckily miniaudio makes this really easy to tack onto the existing pipeline)
Another additional change had to be made with manual loading of sounds. If we want to store a sound ID and track it ourselves, we are now required to specify it's a sound effect to prevent it from getting read as a resource pack item.
Reviewed-on: #65
//Prepares a BGM for loading. This means we call UpdateLoop() repeatedly until the loading of the music is complete. Names are found in bgm.txt configuration file.
//Prepares a BGM for loading. This means we call UpdateLoop() repeatedly until the loading of the music is complete. Names are found in bgm.txt configuration file.
constsize_tLoadSound(conststd::string&path,constSoundEffectFlagsoundType=BGM);//Setting sound effect to true avoids loading it from a resource pack.
constsize_tLoadResource(conststd::string&path);
voidUnloadSound(constintid);
voidUnloadSound(constintid);
public:// PLAYBACK CONTROLS
public:// PLAYBACK CONTROLS
@ -153,6 +158,15 @@ namespace olc
// this is where the sounds are kept
// this is where the sounds are kept
std::vector<ma_sound*>vecSounds;
std::vector<ma_sound*>vecSounds;
std::vector<ma_sound*>vecOneOffSounds;
std::vector<ma_sound*>vecOneOffSounds;
structResourceData{
ma_engine*engine;
ResourceBufferdata;
std::stringpathName;
~ResourceData(){
if(ma_resource_manager_unregister_data(ma_engine_get_resource_manager(engine),pathName.data())!=MA_SUCCESS)ERR(std::format("WARNING! Could not clear resources for {}!",pathName));
if(ma_resource_manager_register_encoded_data(ma_engine_get_resource_manager(&engine),path.data(),vecResourceData[id].data.vMemory.data(),vecResourceData[id].data.vMemory.size())!=MA_SUCCESS)ERR(std::format("WARNING! Could not load resources for {}!",path));