From b493f4cb5cbfcead60fe574189e31326a95ca704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Mon, 26 Apr 2021 13:03:47 +0200 Subject: [PATCH] ksys/snd: Add snd::InfoData --- data/uking_functions.csv | 44 +++++----- src/KingSystem/Sound/CMakeLists.txt | 2 + src/KingSystem/Sound/sndInfoData.cpp | 122 +++++++++++++++++++++++++++ src/KingSystem/Sound/sndInfoData.h | 48 +++++++++++ 4 files changed, 194 insertions(+), 22 deletions(-) create mode 100644 src/KingSystem/Sound/sndInfoData.cpp create mode 100644 src/KingSystem/Sound/sndInfoData.h diff --git a/data/uking_functions.csv b/data/uking_functions.csv index fac68bc0..2df9b93c 100644 --- a/data/uking_functions.csv +++ b/data/uking_functions.csv @@ -86759,28 +86759,28 @@ 0x000000710103d324,sub_710103D324,244, 0x000000710103d418,sub_710103D418,24, 0x000000710103d430,sub_710103D430,248, -0x000000710103d528,sub_710103D528,100, -0x000000710103d58c,sub_710103D58C,108, -0x000000710103d5f8,SoundInfoData::createInstance,156, -0x000000710103d694,sub_710103D694,60, -0x000000710103d6d0,sub_710103D6D0,68, -0x000000710103d714,SoundInfoData::init_,308, -0x000000710103d848,SoundInfoData::init,4, -0x000000710103d84c,SoundInfoData::getInfoByKey,96, -0x000000710103d8ac,SoundInfoData::getSoundSettingUserName,148, -0x000000710103d940,sub_710103D940,84, -0x000000710103d994,sub_710103D994,60, -0x000000710103d9d0,sub_710103D9D0,60, -0x000000710103da0c,sub_710103DA0C,60, -0x000000710103da48,sub_710103DA48,84, -0x000000710103da9c,sub_710103DA9C,84, -0x000000710103daf0,sub_710103DAF0,60, -0x000000710103db2c,sub_710103DB2C,60, -0x000000710103db68,sub_710103DB68,60, -0x000000710103dba4,sub_710103DBA4,84, -0x000000710103dbf8,sub_710103DBF8,84, -0x000000710103dc4c,SoundInfoData::getMiscInDoorOcclusion,60, -0x000000710103dc88,sub_710103DC88,84, +0x000000710103d528,sub_710103D528,100,_ZN4ksys3snd8InfoData18SingletonDisposer_D1Ev +0x000000710103d58c,sub_710103D58C,108,_ZN4ksys3snd8InfoData18SingletonDisposer_D0Ev +0x000000710103d5f8,SoundInfoData::createInstance,156,_ZN4ksys3snd8InfoData14createInstanceEPN4sead4HeapE +0x000000710103d694,sub_710103D694,60,_ZN4ksys3snd8InfoDataD1Ev +0x000000710103d6d0,sub_710103D6D0,68,_ZN4ksys3snd8InfoDataD0Ev +0x000000710103d714,SoundInfoData::init_,308,_ZN4ksys3snd8InfoData13loadSoundInfoEPN4sead4HeapE +0x000000710103d848,SoundInfoData::init,4,_ZN4ksys3snd8InfoData4initEPN4sead4HeapE +0x000000710103d84c,SoundInfoData::getInfoByKey,96,_ZNK4ksys3snd8InfoData7getInfoERKN4sead14SafeStringBaseIcEE +0x000000710103d8ac,SoundInfoData::getSoundSettingUserName,148,_ZNK4ksys3snd8InfoData23getSoundSettingUserNameERKN4sead14SafeStringBaseIcEE +0x000000710103d940,sub_710103D940,84,_ZNK4ksys3snd8InfoData26getReactionSettingLandTypeERKN2al9ByamlIterERKN4sead14SafeStringBaseIcEE +0x000000710103d994,sub_710103D994,60,_ZNK4ksys3snd8InfoData27getReactionSettingLandPitchERKN2al9ByamlIterE +0x000000710103d9d0,sub_710103D9D0,60,_ZNK4ksys3snd8InfoData28getReactionSettingLandVolumeERKN2al9ByamlIterE +0x000000710103da0c,sub_710103DA0C,60,_ZNK4ksys3snd8InfoData35getReactionSettingLandVelocityRatioERKN2al9ByamlIterE +0x000000710103da48,sub_710103DA48,84,_ZNK4ksys3snd8InfoData27getReactionSettingSlideTypeERKN2al9ByamlIterE +0x000000710103da9c,sub_710103DA9C,84,_ZNK4ksys3snd8InfoData32getReactionSettingSlideSlideTypeERKN2al9ByamlIterE +0x000000710103daf0,sub_710103DAF0,60,_ZNK4ksys3snd8InfoData28getReactionSettingSlidePitchERKN2al9ByamlIterE +0x000000710103db2c,sub_710103DB2C,60,_ZNK4ksys3snd8InfoData29getReactionSettingSlideVolumeERKN2al9ByamlIterE +0x000000710103db68,sub_710103DB68,60,_ZNK4ksys3snd8InfoData36getReactionSettingSlideVelocityRatioERKN2al9ByamlIterE +0x000000710103dba4,sub_710103DBA4,84,_ZNK4ksys3snd8InfoData30getWeaponOwnerSettingOwnerTypeERKN2al9ByamlIterE +0x000000710103dbf8,sub_710103DBF8,84,_ZNK4ksys3snd8InfoData33getEquipSoundSettingEquipMaterialERKN2al9ByamlIterE +0x000000710103dc4c,SoundInfoData::getMiscInDoorOcclusion,60,_ZNK4ksys3snd8InfoData22getMiscInDoorOcclusionERKN2al9ByamlIterE +0x000000710103dc88,sub_710103DC88,84,_ZNK4ksys3snd8InfoData21getMiscPlantShakeTypeERKN2al9ByamlIterE 0x000000710103dcdc,nullsub_4408,4, 0x000000710103dce0,nullsub_4409,4, 0x000000710103dce4,sub_710103DCE4,60, diff --git a/src/KingSystem/Sound/CMakeLists.txt b/src/KingSystem/Sound/CMakeLists.txt index fb85aff9..7fdd69c1 100644 --- a/src/KingSystem/Sound/CMakeLists.txt +++ b/src/KingSystem/Sound/CMakeLists.txt @@ -1,3 +1,5 @@ target_sources(uking PRIVATE + sndInfoData.cpp + sndInfoData.h sndResource.h ) diff --git a/src/KingSystem/Sound/sndInfoData.cpp b/src/KingSystem/Sound/sndInfoData.cpp new file mode 100644 index 00000000..521f4cd6 --- /dev/null +++ b/src/KingSystem/Sound/sndInfoData.cpp @@ -0,0 +1,122 @@ +#include "KingSystem/Sound/sndInfoData.h" +#include "KingSystem/Resource/resLoadRequest.h" +#include "KingSystem/Utils/Byaml/Byaml.h" + +namespace ksys::snd { + +SEAD_SINGLETON_DISPOSER_IMPL(InfoData) + +InfoData::~InfoData() { + if (mRootIter) + delete mRootIter; +} + +void InfoData::loadSoundInfo(sead::Heap* heap) { + res::LoadRequest req; + req.mRequester = "snd::InfoData"; + req._22 = true; + mResHandle.load("Actor/Sound/SoundInfo.byml", &req); + + auto* resource = sead::DynamicCast(mResHandle.getResource()); + + if (mRootIter) + delete mRootIter; + mRootIter = new (heap) al::ByamlIter(resource->getRawData()); +} + +void InfoData::init(sead::Heap* heap) { + loadSoundInfo(heap); +} + +al::ByamlIter InfoData::getInfo(const sead::SafeString& key) const { + const auto iter = mRootIter->getIterByKey(key.cstr()); + return al::ByamlIter(iter); +} + +sead::SafeString InfoData::getSoundSettingUserName(const sead::SafeString& key) const { + const auto iter = getInfo(key); + const char* name = "Dummy"; + iter.tryGetStringByKey(&name, "SoundSettingUserName"); + return name; +} + +sead::SafeString InfoData::getReactionSettingLandType(const al::ByamlIter& iter, + const sead::SafeString& key) const { + const char* value = "Auto"; + iter.tryGetStringByKey(&value, "ReactionSettingLandType"); + return value; +} + +float InfoData::getReactionSettingLandPitch(const al::ByamlIter& iter) const { + float value = 1.0; + iter.tryGetFloatByKey(&value, "ReactionSettingLandPitch"); + return value; +} + +float InfoData::getReactionSettingLandVolume(const al::ByamlIter& iter) const { + float value = 1.0; + iter.tryGetFloatByKey(&value, "ReactionSettingLandVolume"); + return value; +} + +float InfoData::getReactionSettingLandVelocityRatio(const al::ByamlIter& iter) const { + float value = 1.0; + iter.tryGetFloatByKey(&value, "ReactionSettingLandVelocityRadio"); + return value; +} + +sead::SafeString InfoData::getReactionSettingSlideType(const al::ByamlIter& iter) const { + const char* value = "Auto"; + iter.tryGetStringByKey(&value, "ReactionSettingSlideType"); + return value; +} + +sead::SafeString InfoData::getReactionSettingSlideSlideType(const al::ByamlIter& iter) const { + const char* value = "Drag"; + iter.tryGetStringByKey(&value, "ReactionSettingSlideSlideType"); + return value; +} + +float InfoData::getReactionSettingSlidePitch(const al::ByamlIter& iter) const { + float value = 1.0; + iter.tryGetFloatByKey(&value, "ReactionSettingSlidePitch"); + return value; +} + +float InfoData::getReactionSettingSlideVolume(const al::ByamlIter& iter) const { + float value = 1.0; + iter.tryGetFloatByKey(&value, "ReactionSettingSlideVolume"); + return value; +} + +float InfoData::getReactionSettingSlideVelocityRatio(const al::ByamlIter& iter) const { + float value = 1.0; + iter.tryGetFloatByKey(&value, "ReactionSettingSlideVelocityRatio"); + return value; +} + +sead::SafeString InfoData::getWeaponOwnerSettingOwnerType(const al::ByamlIter& iter) const { + const char* value = "None"; + iter.tryGetStringByKey(&value, "WeaponOwnerSettingOwnerType"); + return value; +} + +sead::SafeString InfoData::getEquipSoundSettingEquipMaterial(const al::ByamlIter& iter) const { + const char* value = "Dummy"; + iter.tryGetStringByKey(&value, "EquipSoundSettingEquipMaterial"); + return value; +} + +bool InfoData::getMiscInDoorOcclusion(const al::ByamlIter& iter) const { + bool value = true; + iter.tryGetBoolByKey(&value, "MiscInDoorOcclusion"); + return value; +} + +sead::SafeString InfoData::getMiscPlantShakeType(const al::ByamlIter& iter) const { + const char* value = "None"; + iter.tryGetStringByKey(&value, "MiscPlantShakeType"); + return value; +} + +} // namespace ksys::snd diff --git a/src/KingSystem/Sound/sndInfoData.h b/src/KingSystem/Sound/sndInfoData.h new file mode 100644 index 00000000..75f2b1e9 --- /dev/null +++ b/src/KingSystem/Sound/sndInfoData.h @@ -0,0 +1,48 @@ +#pragma once + +#include +#include "KingSystem/Resource/resHandle.h" +#include "KingSystem/Utils/Byaml/Byaml.h" + +namespace ksys::snd { + +class InfoData { + SEAD_SINGLETON_DISPOSER(InfoData) + + InfoData() = default; + virtual ~InfoData(); + +public: + void init(sead::Heap* heap); + + al::ByamlIter getInfo(const sead::SafeString& key) const; + sead::SafeString getSoundSettingUserName(const sead::SafeString& key) const; + + sead::SafeString getReactionSettingLandType(const al::ByamlIter& iter, + const sead::SafeString& key) const; + float getReactionSettingLandPitch(const al::ByamlIter& iter) const; + float getReactionSettingLandVolume(const al::ByamlIter& iter) const; + float getReactionSettingLandVelocityRatio(const al::ByamlIter& iter) const; + + sead::SafeString getReactionSettingSlideType(const al::ByamlIter& iter) const; + sead::SafeString getReactionSettingSlideSlideType(const al::ByamlIter& iter) const; + float getReactionSettingSlidePitch(const al::ByamlIter& iter) const; + float getReactionSettingSlideVolume(const al::ByamlIter& iter) const; + float getReactionSettingSlideVelocityRatio(const al::ByamlIter& iter) const; + + sead::SafeString getWeaponOwnerSettingOwnerType(const al::ByamlIter& iter) const; + + sead::SafeString getEquipSoundSettingEquipMaterial(const al::ByamlIter& iter) const; + + bool getMiscInDoorOcclusion(const al::ByamlIter& iter) const; + + sead::SafeString getMiscPlantShakeType(const al::ByamlIter& iter) const; + +private: + void loadSoundInfo(sead::Heap* heap); + + al::ByamlIter* mRootIter{}; + res::Handle mResHandle{}; +}; + +} // namespace ksys::snd