feat(sound): add SESound::SetUserData

This commit is contained in:
fallenoak 2025-11-26 19:28:14 -06:00
parent 12ad89551d
commit 94c825bb04
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
4 changed files with 25 additions and 2 deletions

View File

@ -591,3 +591,11 @@ void SESound::Play() {
this->m_internal->Play(); this->m_internal->Play();
} }
} }
void SESound::SetUserData(SEUserData* userData) {
if (!this->m_internal) {
return;
}
this->m_internal->m_userData = userData;
}

View File

@ -2,10 +2,11 @@
#define SOUND_SE_SOUND_HPP #define SOUND_SE_SOUND_HPP
#include "sound/SESoundInternal.hpp" #include "sound/SESoundInternal.hpp"
#include "sound/SEUserData.hpp"
#include <cstdint>
#include <fmod.hpp> #include <fmod.hpp>
#include <storm/Hash.hpp> #include <storm/Hash.hpp>
#include <storm/Thread.hpp> #include <storm/Thread.hpp>
#include <cstdint>
struct SOUND_INTERNAL_LOOKUP : TSHashObject<SOUND_INTERNAL_LOOKUP, HASHKEY_NONE> { struct SOUND_INTERNAL_LOOKUP : TSHashObject<SOUND_INTERNAL_LOOKUP, HASHKEY_NONE> {
SESoundInternal* m_internal; SESoundInternal* m_internal;
@ -38,6 +39,7 @@ class SESound {
bool IsPlaying(); bool IsPlaying();
int32_t Load(const char* filename, int32_t a3, FMOD::SoundGroup* soundGroup1, FMOD::SoundGroup* soundGroup2, bool a6, bool a7, uint32_t a8, int32_t a9, uint32_t a10); int32_t Load(const char* filename, int32_t a3, FMOD::SoundGroup* soundGroup1, FMOD::SoundGroup* soundGroup2, bool a6, bool a7, uint32_t a8, int32_t a9, uint32_t a10);
void Play(); void Play();
void SetUserData(SEUserData* userData);
private: private:
// Private static functions // Private static functions

View File

@ -6,6 +6,7 @@
#include <cstdint> #include <cstdint>
class SESound; class SESound;
class SEUserData;
class SFile; class SFile;
class SoundCacheNode : public TSLinkedNode<SoundCacheNode> { class SoundCacheNode : public TSLinkedNode<SoundCacheNode> {
@ -29,6 +30,7 @@ class SESoundInternal : public TSLinkedNode<SESoundInternal> {
FMOD::System* m_fmodSystem; FMOD::System* m_fmodSystem;
FMOD::Channel* m_fmodChannel = nullptr; FMOD::Channel* m_fmodChannel = nullptr;
SESound* m_sound = nullptr; SESound* m_sound = nullptr;
SEUserData* m_userData = nullptr;
// TODO // TODO
int32_t m_useCache = 0; int32_t m_useCache = 0;
int32_t m_type = 0; int32_t m_type = 0;

View File

@ -1,11 +1,12 @@
#include "sound/SI2.hpp" #include "sound/SI2.hpp"
#include "SoundKitProperties.hpp"
#include "console/CVar.hpp" #include "console/CVar.hpp"
#include "sound/CVarHandlers.hpp" #include "sound/CVarHandlers.hpp"
#include "sound/SESound.hpp" #include "sound/SESound.hpp"
#include "sound/SI2USERDATA.hpp"
#include "sound/SOUNDKITDEF.hpp" #include "sound/SOUNDKITDEF.hpp"
#include "sound/SOUNDKITLOOKUP.hpp" #include "sound/SOUNDKITLOOKUP.hpp"
#include "sound/SOUNDKITOBJECT.hpp" #include "sound/SOUNDKITOBJECT.hpp"
#include "sound/SoundKitProperties.hpp"
#include "ui/FrameScript.hpp" #include "ui/FrameScript.hpp"
TSGrowableArray<SOUNDKITDEF*> SI2::s_SoundKitDefs; TSGrowableArray<SOUNDKITDEF*> SI2::s_SoundKitDefs;
@ -383,6 +384,16 @@ int32_t SI2::PlaySoundKit(int32_t id, int32_t a2, SOUNDKITOBJECT* object, SoundK
// TODO // TODO
auto userData = STORM_NEW(SI2USERDATA);
userData->m_name = soundKitDef->name ? soundKitDef->name : "<UNKNOWN ERROR>";
userData->m_ID = id;
userData->m_def = soundKitDef;
userData->m_type = properties->m_type;
// TODO
sound->SetUserData(userData);
// TODO
sound->CompleteLoad(); sound->CompleteLoad();
// TODO // TODO