Elevate Engine 1
Loading...
Searching...
No Matches
WwiseProjectDBDataSource.h
Go to the documentation of this file.
1#pragma once
2
3#ifdef EE_USES_WWISE
4
5#define WWISE_DB_STANDARD_TYPES
6#include <WwiseProjectDatabase/WwiseProjectDatabase.h>
7
11
12struct WwiseCRefSoundBank;
13
14namespace Elevate
15{
16 class WwiseProjectDBDataSource : public WwiseDataSource
17 {
18 public:
19 WwiseProjectDBDataSource(const std::string& rootOutputPath, const std::string& platform)
20 {
21 Init(rootOutputPath.c_str(), platform.c_str());
22 }
23 ~WwiseProjectDBDataSource() = default;
24
25 virtual void InitializeSource() override
26 {
27 RefreshSource();
28 }
29 virtual void RefreshSource() override
30 {
31 m_treeRoot.reset(new WwiseItem());
32 m_treeRoot->Type = WwiseType::TreeRoot;
33 m_treeRoot->IsInBank = true;
34
35 PopulateSoundbanks(); // This also populates the events
36
37 PopulateSwitchGroups();
38 PopulateSwitches();
39
40 PopulateStateGroups();
41 PopulateStates();
42
43 PopulateGameParameters();
44 PopulateBusses();
45 PopulateAuxBusses();
46 }
47
48 protected:
49 void PopulateSoundbanks()
50 {
51 uint32_t count = (uint32_t)GetSoundBankCount();
52 void* arr = (void*)GetAllSoundBanksRef();
53 for (uint32_t i = 0; i < count; i++)
54 {
55 const ::WwiseCRefSoundBank* ref = GetSoundBankRefIndex(arr, i);
56 if (ref)
57 {
58 WwiseSoundbankPtr item = WwiseSoundbank::Create();
59 item->IsInitBank = ref->bIsInitBank;
60 item->IsUserBank = ref->bIsUserBank;
61 item->IsValid = ref->bIsValid;
62 item->GUID = ref->guid->ToString().String;
63 item->ShortID = (uint32_t)ref->shortId;
64 item->Language = ref->language;
65 item->Name = ref->name;
66 item->Path = ref->path;
67 item->ObjectPath = ref->objectPath;
68 m_treeRoot->AddChildren(item);
69 PopulateEvents(ref);
70 }
71 }
72 DeleteSoundBanksArrayRef(arr);
73 }
74
75 void PopulateEvents(const WwiseCRefSoundBank* bnkRef)
76 {
77 uint32_t count = (uint32_t)bnkRef->eventsCount;
78 void* arr = (void*)bnkRef->events;
79 for (uint32_t i = 0; i < count; i++)
80 {
81 const ::WwiseCRefEvent* ref = GetEvent(arr, i);
82 if (ref)
83 {
84 WwiseEventPtr item = WwiseEvent::Create();
85 item->GUID = ref->guid->ToString().String;
86 item->MaxAttenuation = ref->maxAttenuation;
87 item->MaxDuration = ref->maxDuration;
88 item->MinDuration = ref->minDuration;
89 item->Name = ref->name;
90 item->Path = ref->path;
91 item->ShortID = (uint32_t)ref->shortId;
92 item->SoundbankShortId = (uint32_t)bnkRef->shortId;
93 m_treeRoot->AddChildren(item);
94 }
95 }
96 }
97
98 void PopulateSwitchGroups()
99 {
100 uint32_t count = (uint32_t)GetSwitchGroupCount();
101 void* arr = (void*)GetAllSwitchGroupRef();
102 for (uint32_t i = 0; i < count; i++)
103 {
104 const WwiseCRefGroup* ref = GetSwitchGroup(arr, i);
105 if (ref)
106 {
107 WwiseSwitchGroupPtr item = WwiseSwitchGroup::Create();
108 item->GUID = ref->groupGuid->ToString().String;
109 item->Name = ref->groupName;
110 item->Path = ref->groupPath;
111 item->ShortID = (uint32_t)ref->groupShortId;
112 m_treeRoot->AddChildren(item);
113 }
114 }
115 DeleteSwitchGroupArrayRef(arr);
116 }
117
118 void PopulateSwitches()
119 {
120 uint32_t count = (uint32_t)GetSwitchCount();
121 void* arr = (void*)GetAllSwitchRef();
122 for (uint32_t i = 0; i < count; i++)
123 {
124 const WwiseCRefSwitch* ref = GetSwitch(arr, i);
125 if (ref)
126 {
127 WwiseSwitchPtr item = WwiseSwitch::Create();
128 item->GUID = ref->switchGuid->ToString().String;
129 item->Name = ref->switchName;
130 item->Path = ref->switchPath;
131 item->ShortID = (uint32_t)ref->switchShortId;
132 item->GroupShortId = (uint32_t)ref->groupShortId;
133 m_treeRoot->AddChildren(item);
134 }
135 }
136 DeleteSwitchArrayRef(arr);
137 }
138
139 void PopulateStateGroups()
140 {
141 uint32_t count = (uint32_t)GetStateGroupCount();
142 void* arr = (void*)GetAllStateGroupRef();
143 for (uint32_t i = 0; i < count; i++)
144 {
145 const WwiseCRefGroup* ref = GetSwitchGroup(arr, i);
146 if (ref)
147 {
148 WwiseStateGroupPtr item = WwiseStateGroup::Create();
149 item->GUID = ref->groupGuid->ToString().String;
150 item->Name = ref->groupName;
151 item->Path = ref->groupPath;
152 item->ShortID = (uint32_t)ref->groupShortId;
153 m_treeRoot->AddChildren(item);
154 }
155 }
156 DeleteStateGroupArrayRef(arr);
157 }
158
159 void PopulateStates()
160 {
161 uint32_t count = (uint32_t)GetStateCount();
162 void* arr = (void*)GetAllStateRef();
163 for (uint32_t i = 0; i < count; i++)
164 {
165 const WwiseCRefState* ref = GetState(arr, i);
166 if (ref)
167 {
168 WwiseStatePtr item = WwiseState::Create();
169 item->GUID = ref->stateGuid->ToString().String;
170 item->Name = ref->stateName;
171 item->Path = ref->statePath;
172 item->ShortID = (uint32_t)ref->stateShortId;
173 item->GroupShortId = (uint32_t)ref->groupShortId;
174 m_treeRoot->AddChildren(item);
175 }
176 }
177 DeleteSwitchArrayRef(arr);
178 }
179
180 void PopulateGameParameters()
181 {
182 uint32_t count = (uint32_t)GetGameParameterCount();
183 void* arr = (void*)GetAllGameParameterRef();
184 for (uint32_t i = 0; i < count; i++)
185 {
186 const WwiseCRefGameParameter* ref = GetGameParameter(arr, i);
187 if (ref)
188 {
189 WwiseGameParameterPtr item = WwiseGameParameter::Create();
190 item->Name = std::string(GetGameParameterName((void*)ref));
191 item->Path = GetGameParameterPath((void*)ref);
192 item->ShortID = (uint32_t)GetGameParameterShortId((void*)ref);
193 item->GUID = GetGameParameterGuid((void*)ref)->Guid.ToString();
194 m_treeRoot->AddChildren(item);
195 }
196 }
197 DeleteGameParameterArrayRef(arr);
198 }
199
200
201
202 void PopulateBusses()
203 {
204 uint32_t count = (uint32_t)GetBusCount();
205 void* arr = (void*)GetAllBusRef();
206 for (uint32_t i = 0; i < count; i++)
207 {
208 const WwiseCRefBus* ref = GetBus(arr, i);
209 if (ref)
210 {
211 WwiseBusPtr item = WwiseBus::Create();
212 item->GUID = ref->busGuid->ToString().String;
213 item->Name = ref->busName;
214 item->Path = ref->busPath;
215 item->ShortID = (uint32_t)ref->busShortId;
216 m_treeRoot->AddChildren(item);
217 }
218 }
219 DeleteBusArrayRef(arr);
220 }
221
222 void PopulateAuxBusses()
223 {
224 uint32_t count = (uint32_t)GetAuxBusCount();
225 void* arr = (void*)GetAllAuxBusRef();
226 for (uint32_t i = 0; i < count; i++)
227 {
228 const WwiseCRefAuxBus* ref = GetAuxBus(arr, i);
229 if (ref)
230 {
231 WwiseAuxBusPtr item = WwiseAuxBus::Create();
232 item->GUID = ref->auxBusGuid->ToString().String;
233 item->Name = ref->auxBusName;
234 item->Path = ref->auxBusPath;
235 item->ShortID = (uint32_t)ref->auxBusShortId;
236 m_treeRoot->AddChildren(item);
237 }
238 }
239 DeleteAuxBusArrayRef(arr);
240 }
241 };
242}
243
244#endif // #ifdef EE_USES_WWISE
static WwiseAuxBusPtr Create()
Definition WwiseItem.h:180
static WwiseBusPtr Create()
Definition WwiseItem.h:169
static WwiseEventPtr Create()
Definition WwiseItem.h:95
static WwiseGameParameterPtr Create()
Definition WwiseItem.h:158
static WwiseSoundbankPtr Create()
Definition WwiseItem.h:78
static WwiseStateGroupPtr Create()
Definition WwiseItem.h:130
static WwiseStatePtr Create()
Definition WwiseItem.h:143
static WwiseSwitchGroupPtr Create()
Definition WwiseItem.h:106
static WwiseSwitchPtr Create()
Definition WwiseItem.h:119