mirror of
https://github.com/whoahq/whoa.git
synced 2026-02-01 16:22:45 +03:00
feat(sound): partially implement SI2::InitSoundKitDefs
This commit is contained in:
parent
d4817d8844
commit
56a63e6a33
@ -2,8 +2,11 @@
|
|||||||
#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/SOUNDKITDEF.hpp"
|
||||||
#include "ui/FrameScript.hpp"
|
#include "ui/FrameScript.hpp"
|
||||||
|
|
||||||
|
TSGrowableArray<SOUNDKITDEF*> SI2::s_SoundKitDefs;
|
||||||
|
|
||||||
int32_t SI2::Init(int32_t a1) {
|
int32_t SI2::Init(int32_t a1) {
|
||||||
// TODO
|
// TODO
|
||||||
// if (CmdLineGetBool(26)) {
|
// if (CmdLineGetBool(26)) {
|
||||||
@ -90,9 +93,79 @@ int32_t SI2::Init(int32_t a1) {
|
|||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
|
if (!a1) {
|
||||||
|
SI2::InitSoundKitDefs();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SI2::InitSoundKitDefs() {
|
||||||
|
SI2::s_SoundKitDefs.SetCount(g_soundEntriesDB.m_maxID + 1);
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < g_soundEntriesDB.GetNumRecords(); i++) {
|
||||||
|
auto soundEntriesRec = g_soundEntriesDB.GetRecordByIndex(i);
|
||||||
|
|
||||||
|
// Sound kit definition
|
||||||
|
|
||||||
|
auto soundKitDef = STORM_NEW(SOUNDKITDEF);
|
||||||
|
|
||||||
|
// Combine directory base and file into full path
|
||||||
|
|
||||||
|
for (uint32_t j = 0; j < 10; j++) {
|
||||||
|
auto file = soundEntriesRec->m_file[j];
|
||||||
|
auto directoryBase = soundEntriesRec->m_directoryBase;
|
||||||
|
|
||||||
|
if (!file || !*file) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t combinedLength = std::strlen(file) + 1;
|
||||||
|
if (*directoryBase) {
|
||||||
|
combinedLength += std::strlen(directoryBase) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto fullPath = static_cast<char*>(calloc(1, combinedLength));
|
||||||
|
|
||||||
|
if (*directoryBase) {
|
||||||
|
bool directoryEndsInSlash = directoryBase[std::strlen(directoryBase) - 1] == '\\';
|
||||||
|
|
||||||
|
if (directoryEndsInSlash) {
|
||||||
|
sprintf(fullPath, "%s%s", directoryBase, file);
|
||||||
|
} else {
|
||||||
|
sprintf(fullPath, "%s\\%s", directoryBase, file);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sprintf(fullPath, "%s", file);
|
||||||
|
}
|
||||||
|
|
||||||
|
soundKitDef->files[j] = fullPath;
|
||||||
|
soundKitDef->fileCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
soundKitDef->flags = soundEntriesRec->m_flags;
|
||||||
|
soundKitDef->name = soundEntriesRec->m_name;
|
||||||
|
soundKitDef->minDistance = soundEntriesRec->m_minDistance;
|
||||||
|
soundKitDef->distanceCutoff = soundEntriesRec->m_distanceCutoff;
|
||||||
|
soundKitDef->volume = soundEntriesRec->m_volumeFloat;
|
||||||
|
soundKitDef->ID = soundEntriesRec->m_ID;
|
||||||
|
soundKitDef->advancedID = soundEntriesRec->m_soundEntriesAdvancedID;
|
||||||
|
soundKitDef->advanced = nullptr;
|
||||||
|
|
||||||
|
if (soundKitDef->advancedID) {
|
||||||
|
soundKitDef->advanced = g_soundEntriesAdvancedDB.GetRecord(soundKitDef->advancedID);
|
||||||
|
}
|
||||||
|
|
||||||
|
SI2::s_SoundKitDefs[soundEntriesRec->GetID()] = soundKitDef;
|
||||||
|
|
||||||
|
// Sound kit lookup
|
||||||
|
|
||||||
|
// TODO SOUNDKITLOOKUP
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SI2::RegisterCVars() {
|
void SI2::RegisterCVars() {
|
||||||
CVar::Register(
|
CVar::Register(
|
||||||
"StartTalkingDelay",
|
"StartTalkingDelay",
|
||||||
|
|||||||
@ -3,15 +3,20 @@
|
|||||||
|
|
||||||
#include "sound/SI2Script.hpp"
|
#include "sound/SI2Script.hpp"
|
||||||
#include "ui/Types.hpp"
|
#include "ui/Types.hpp"
|
||||||
|
#include <storm/Array.hpp>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
class SOUNDKITDEF;
|
||||||
|
|
||||||
class SI2 {
|
class SI2 {
|
||||||
public:
|
public:
|
||||||
// Static variables
|
// Static variables
|
||||||
static FrameScript_Method s_ScriptFunctions[NUM_SCRIPT_FUNCTIONS_SI2];
|
static FrameScript_Method s_ScriptFunctions[NUM_SCRIPT_FUNCTIONS_SI2];
|
||||||
|
static TSGrowableArray<SOUNDKITDEF*> s_SoundKitDefs;
|
||||||
|
|
||||||
// Static functions
|
// Static functions
|
||||||
static int32_t Init(int32_t a1);
|
static int32_t Init(int32_t a1);
|
||||||
|
static void InitSoundKitDefs();
|
||||||
static void RegisterCVars();
|
static void RegisterCVars();
|
||||||
static void RegisterScriptFunctions();
|
static void RegisterScriptFunctions();
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user