2022-02-27 07:53:44 -05:00
|
|
|
#include <STDInclude.hpp>
|
2017-01-19 16:23:59 -05:00
|
|
|
|
|
|
|
namespace Components
|
|
|
|
{
|
|
|
|
std::unordered_map<std::string, const char*> MusicalTalent::SoundAliasList;
|
|
|
|
|
2018-12-17 08:29:18 -05:00
|
|
|
void MusicalTalent::Replace(const std::string& sound, const char* file)
|
2017-01-19 16:23:59 -05:00
|
|
|
{
|
|
|
|
MusicalTalent::SoundAliasList[Utils::String::ToLower(sound)] = file;
|
|
|
|
}
|
|
|
|
|
2018-12-17 08:29:18 -05:00
|
|
|
Game::XAssetHeader MusicalTalent::ModifyAliases(Game::XAssetType type, const std::string& filename)
|
2017-01-19 16:23:59 -05:00
|
|
|
{
|
2017-01-20 16:41:03 -05:00
|
|
|
Game::XAssetHeader header = { nullptr };
|
2017-01-19 16:23:59 -05:00
|
|
|
|
|
|
|
if (MusicalTalent::SoundAliasList.find(Utils::String::ToLower(filename)) != MusicalTalent::SoundAliasList.end())
|
|
|
|
{
|
|
|
|
Game::snd_alias_list_t* aliases = Game::DB_FindXAssetHeader(type, filename.data()).sound;
|
|
|
|
|
2017-06-18 06:36:19 -04:00
|
|
|
if (aliases && aliases->count > 0 && aliases->head && aliases->head->soundFile)
|
2017-01-19 16:23:59 -05:00
|
|
|
{
|
2017-06-18 06:36:19 -04:00
|
|
|
if (aliases->head->soundFile->type == Game::snd_alias_type_t::SAT_STREAMED)
|
2017-01-19 16:23:59 -05:00
|
|
|
{
|
2018-05-09 08:33:52 -04:00
|
|
|
aliases->head->soundFile->u.streamSnd.filename.info.raw.name = MusicalTalent::SoundAliasList[Utils::String::ToLower(filename)];
|
2017-01-19 16:23:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
header.sound = aliases;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return header;
|
|
|
|
}
|
|
|
|
|
|
|
|
MusicalTalent::MusicalTalent()
|
|
|
|
{
|
2017-02-14 04:49:09 -05:00
|
|
|
if (ZoneBuilder::IsEnabled() || Dedicated::IsEnabled()) return;
|
2017-01-19 16:23:59 -05:00
|
|
|
|
|
|
|
AssetHandler::OnFind(Game::XAssetType::ASSET_TYPE_SOUND, MusicalTalent::ModifyAliases);
|
|
|
|
|
|
|
|
MusicalTalent::Replace("music_mainmenu_mp", "hz_t_menumusic.mp3");
|
|
|
|
}
|
|
|
|
}
|