mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-08-08 13:09:06 +00:00
Added functionality to determine what AGSC a sound ID belongs to
This commit is contained in:
parent
1f357b4250
commit
f6ae1376ac
85
src/Core/CAudioManager.cpp
Normal file
85
src/Core/CAudioManager.cpp
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
#include "CAudioManager.h"
|
||||||
|
#include "Core/GameProject/CGameProject.h"
|
||||||
|
#include "Core/GameProject/CResourceIterator.h"
|
||||||
|
|
||||||
|
CAudioManager::CAudioManager(CGameProject *pProj)
|
||||||
|
: mpProject(pProj)
|
||||||
|
{
|
||||||
|
ASSERT(mpProject);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAudioManager::LoadAssets()
|
||||||
|
{
|
||||||
|
// Clear existing assets
|
||||||
|
mAudioGroups.clear();
|
||||||
|
mpAudioLookupTable = nullptr;
|
||||||
|
mpSfxNameList = nullptr;
|
||||||
|
mSfxIdMap.clear();
|
||||||
|
|
||||||
|
// Load/sort all audio groups
|
||||||
|
for (TResourceIterator<CAudioGroup> It(mpProject->ResourceStore()); It; ++It)
|
||||||
|
{
|
||||||
|
CAudioGroup *pGroup = (CAudioGroup*) It->Load();
|
||||||
|
if (pGroup) mAudioGroups.push_back(pGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::sort(mAudioGroups.begin(), mAudioGroups.end(), [](CAudioGroup *pLeft, CAudioGroup *pRight) -> bool {
|
||||||
|
return pLeft->GroupID() < pRight->GroupID();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create SFX Define ID -> AGSC map
|
||||||
|
for (u32 iGrp = 0; iGrp < mAudioGroups.size(); iGrp++)
|
||||||
|
{
|
||||||
|
CAudioGroup *pGroup = mAudioGroups[iGrp];
|
||||||
|
|
||||||
|
for (u32 iSnd = 0; iSnd < pGroup->NumSoundDefineIDs(); iSnd++)
|
||||||
|
{
|
||||||
|
u16 DefineID = pGroup->SoundDefineIDByIndex(iSnd);
|
||||||
|
ASSERT(mSfxIdMap.find(DefineID) == mSfxIdMap.end());
|
||||||
|
mSfxIdMap[DefineID] = pGroup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load audio lookup table + sfx name list
|
||||||
|
TString AudioLookupName = (mpProject->Game() < eEchoesDemo ? "sound_lookup" : "sound_lookup_ATBL");
|
||||||
|
CAssetID AudioLookupID = mpProject->FindNamedResource(AudioLookupName);
|
||||||
|
|
||||||
|
if (AudioLookupID.IsValid())
|
||||||
|
mpAudioLookupTable = mpProject->ResourceStore()->LoadResource(AudioLookupID, "ATBL");
|
||||||
|
|
||||||
|
if (mpProject->Game() >= eEchoesDemo)
|
||||||
|
{
|
||||||
|
CAssetID SfxNameListID = mpProject->FindNamedResource("audio_name_lookup_STLC");
|
||||||
|
|
||||||
|
if (SfxNameListID.IsValid())
|
||||||
|
mpSfxNameList = mpProject->ResourceStore()->LoadResource(SfxNameListID, "STLC");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAudioManager::LogSoundInfo(u32 SoundID)
|
||||||
|
{
|
||||||
|
u16 DefineID = mpAudioLookupTable->FindSoundDefineID(SoundID);
|
||||||
|
|
||||||
|
if (DefineID == -1)
|
||||||
|
Log::Write("Invalid sound");
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto Iter = mSfxIdMap.find(DefineID);
|
||||||
|
|
||||||
|
if (Iter != mSfxIdMap.end())
|
||||||
|
{
|
||||||
|
if (mpProject->Game() >= eEchoesDemo)
|
||||||
|
{
|
||||||
|
TString SoundName = mpSfxNameList->StringByIndex(DefineID);
|
||||||
|
Log::Write("Sound Name: " + SoundName);
|
||||||
|
}
|
||||||
|
|
||||||
|
CAudioGroup *pGroup = Iter->second;
|
||||||
|
Log::Write("Sound ID: " + TString::HexString(SoundID, 4));
|
||||||
|
Log::Write("Define ID: " + TString::HexString(DefineID, 4));
|
||||||
|
Log::Write("Audio Group: " + pGroup->Entry()->Name().ToUTF8());
|
||||||
|
Log::Write("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
27
src/Core/CAudioManager.h
Normal file
27
src/Core/CAudioManager.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#ifndef CAUDIOMANAGER
|
||||||
|
#define CAUDIOMANAGER
|
||||||
|
|
||||||
|
#include "Core/Resource/CAudioGroup.h"
|
||||||
|
#include "Core/Resource/CAudioLookupTable.h"
|
||||||
|
#include "Core/Resource/CStringList.h"
|
||||||
|
#include "Core/Resource/TResPtr.h"
|
||||||
|
#include <algorithm>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
class CAudioManager
|
||||||
|
{
|
||||||
|
CGameProject *mpProject;
|
||||||
|
|
||||||
|
std::vector<TResPtr<CAudioGroup>> mAudioGroups;
|
||||||
|
TResPtr<CAudioLookupTable> mpAudioLookupTable;
|
||||||
|
TResPtr<CStringList> mpSfxNameList;
|
||||||
|
std::unordered_map<u16, CAudioGroup*> mSfxIdMap;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CAudioManager(CGameProject *pProj);
|
||||||
|
void LoadAssets();
|
||||||
|
void LogSoundInfo(u32 SoundID);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CAUDIOMANAGER
|
||||||
|
|
@ -204,7 +204,12 @@ HEADERS += \
|
|||||||
Resource/Factory/CUnsupportedParticleLoader.h \
|
Resource/Factory/CUnsupportedParticleLoader.h \
|
||||||
Resource/Resources.h \
|
Resource/Resources.h \
|
||||||
Resource/Factory/CResourceFactory.h \
|
Resource/Factory/CResourceFactory.h \
|
||||||
GameProject/DependencyListBuilders.h
|
GameProject/DependencyListBuilders.h \
|
||||||
|
Resource/CAudioGroup.h \
|
||||||
|
Resource/Factory/CAudioGroupLoader.h \
|
||||||
|
Resource/CAudioLookupTable.h \
|
||||||
|
Resource/CStringList.h \
|
||||||
|
CAudioManager.h
|
||||||
|
|
||||||
# Source Files
|
# Source Files
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
@ -300,4 +305,6 @@ SOURCES += \
|
|||||||
GameProject/CDependencyTree.cpp \
|
GameProject/CDependencyTree.cpp \
|
||||||
Resource/Factory/CUnsupportedFormatLoader.cpp \
|
Resource/Factory/CUnsupportedFormatLoader.cpp \
|
||||||
Resource/Factory/CUnsupportedParticleLoader.cpp \
|
Resource/Factory/CUnsupportedParticleLoader.cpp \
|
||||||
GameProject/DependencyListBuilders.cpp
|
GameProject/DependencyListBuilders.cpp \
|
||||||
|
Resource/Factory/CAudioGroupLoader.cpp \
|
||||||
|
CAudioManager.cpp
|
||||||
|
@ -20,6 +20,7 @@ bool CGameProject::Load(const TWideString& rkPath)
|
|||||||
Serialize(Reader);
|
Serialize(Reader);
|
||||||
|
|
||||||
mpResourceStore->LoadResourceDatabase();
|
mpResourceStore->LoadResourceDatabase();
|
||||||
|
mAudioManager.LoadAssets();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,3 +96,26 @@ void CGameProject::GetWorldList(std::list<CAssetID>& rOut) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CAssetID CGameProject::FindNamedResource(const TString& rkName) const
|
||||||
|
{
|
||||||
|
for (u32 iPkg = 0; iPkg < mPackages.size(); iPkg++)
|
||||||
|
{
|
||||||
|
CPackage *pPkg = mPackages[iPkg];
|
||||||
|
|
||||||
|
for (u32 iCol = 0; iCol < pPkg->NumCollections(); iCol++)
|
||||||
|
{
|
||||||
|
CResourceCollection *pCol = pPkg->CollectionByIndex(iCol);
|
||||||
|
|
||||||
|
for (u32 iRes = 0; iRes < pCol->NumResources(); iRes++)
|
||||||
|
{
|
||||||
|
const SNamedResource& rkRes = pCol->ResourceByIndex(iRes);
|
||||||
|
|
||||||
|
if (rkRes.Name == rkName)
|
||||||
|
return rkRes.ID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return CAssetID::InvalidID(mGame);
|
||||||
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "CPackage.h"
|
#include "CPackage.h"
|
||||||
#include "CResourceStore.h"
|
#include "CResourceStore.h"
|
||||||
|
#include "Core/CAudioManager.h"
|
||||||
#include <Common/CAssetID.h>
|
#include <Common/CAssetID.h>
|
||||||
#include <Common/EGame.h>
|
#include <Common/EGame.h>
|
||||||
#include <Common/FileUtil.h>
|
#include <Common/FileUtil.h>
|
||||||
@ -17,6 +18,7 @@ class CGameProject
|
|||||||
TWideString mResourceDBPath;
|
TWideString mResourceDBPath;
|
||||||
std::vector<CPackage*> mPackages;
|
std::vector<CPackage*> mPackages;
|
||||||
CResourceStore *mpResourceStore;
|
CResourceStore *mpResourceStore;
|
||||||
|
CAudioManager mAudioManager;
|
||||||
|
|
||||||
enum EProjectVersion
|
enum EProjectVersion
|
||||||
{
|
{
|
||||||
@ -32,6 +34,7 @@ public:
|
|||||||
CGameProject()
|
CGameProject()
|
||||||
: mGame(eUnknownGame)
|
: mGame(eUnknownGame)
|
||||||
, mProjectName("Unnamed Project")
|
, mProjectName("Unnamed Project")
|
||||||
|
, mAudioManager(this)
|
||||||
{
|
{
|
||||||
mpResourceStore = new CResourceStore(this);
|
mpResourceStore = new CResourceStore(this);
|
||||||
}
|
}
|
||||||
@ -41,6 +44,7 @@ public:
|
|||||||
, mProjectName("Unnamed Project")
|
, mProjectName("Unnamed Project")
|
||||||
, mProjectRoot(rkProjRootDir)
|
, mProjectRoot(rkProjRootDir)
|
||||||
, mResourceDBPath(L"ResourceDB.rdb")
|
, mResourceDBPath(L"ResourceDB.rdb")
|
||||||
|
, mAudioManager(this)
|
||||||
{
|
{
|
||||||
mpResourceStore = new CResourceStore(this);
|
mpResourceStore = new CResourceStore(this);
|
||||||
mProjectRoot.Replace(L"/", L"\\");
|
mProjectRoot.Replace(L"/", L"\\");
|
||||||
@ -53,6 +57,7 @@ public:
|
|||||||
void Serialize(IArchive& rArc);
|
void Serialize(IArchive& rArc);
|
||||||
void SetActive();
|
void SetActive();
|
||||||
void GetWorldList(std::list<CAssetID>& rOut) const;
|
void GetWorldList(std::list<CAssetID>& rOut) const;
|
||||||
|
CAssetID FindNamedResource(const TString& rkName) const;
|
||||||
|
|
||||||
// Directory Handling
|
// Directory Handling
|
||||||
inline TWideString ProjectRoot() const { return mProjectRoot; }
|
inline TWideString ProjectRoot() const { return mProjectRoot; }
|
||||||
@ -71,6 +76,7 @@ public:
|
|||||||
inline CPackage* PackageByIndex(u32 Index) const { return mPackages[Index]; }
|
inline CPackage* PackageByIndex(u32 Index) const { return mPackages[Index]; }
|
||||||
inline void AddPackage(CPackage *pPackage) { mPackages.push_back(pPackage); }
|
inline void AddPackage(CPackage *pPackage) { mPackages.push_back(pPackage); }
|
||||||
inline CResourceStore* ResourceStore() const { return mpResourceStore; }
|
inline CResourceStore* ResourceStore() const { return mpResourceStore; }
|
||||||
|
inline CAudioManager* AudioManager() { return &mAudioManager; }
|
||||||
inline EGame Game() const { return mGame; }
|
inline EGame Game() const { return mGame; }
|
||||||
inline bool IsActive() const { return mspActiveProject == this; }
|
inline bool IsActive() const { return mspActiveProject == this; }
|
||||||
|
|
||||||
|
@ -71,7 +71,11 @@ class TResourceIterator : public CResourceIterator
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TResourceIterator(CResourceStore *pStore = gpResourceStore)
|
TResourceIterator(CResourceStore *pStore = gpResourceStore)
|
||||||
: CResourceIterator(pStore) {}
|
: CResourceIterator(pStore)
|
||||||
|
{
|
||||||
|
if (mpCurEntry->ResourceType() != ResType::StaticType())
|
||||||
|
Next();
|
||||||
|
}
|
||||||
|
|
||||||
virtual CResourceEntry* Next()
|
virtual CResourceEntry* Next()
|
||||||
{
|
{
|
||||||
|
@ -177,7 +177,7 @@ void CPackageDependencyListBuilder::AddDependency(CResourceEntry *pCurEntry, con
|
|||||||
|
|
||||||
// Is this entry valid?
|
// Is this entry valid?
|
||||||
bool IsValid = ResType != eMidi &&
|
bool IsValid = ResType != eMidi &&
|
||||||
(ResType != eAudioGroupSet || mGame >= eEchoesDemo) &&
|
(ResType != eAudioGroup || mGame >= eEchoesDemo) &&
|
||||||
(ResType != eWorld || !pCurEntry) &&
|
(ResType != eWorld || !pCurEntry) &&
|
||||||
(ResType != eArea || !pCurEntry || pCurEntry->ResourceType() == eWorld);
|
(ResType != eArea || !pCurEntry || pCurEntry->ResourceType() == eWorld);
|
||||||
|
|
||||||
@ -359,7 +359,7 @@ void CAreaDependencyListBuilder::AddDependency(const CAssetID& rkID, std::list<C
|
|||||||
bool IsValid = ResType != eMidi &&
|
bool IsValid = ResType != eMidi &&
|
||||||
ResType != eWorld &&
|
ResType != eWorld &&
|
||||||
ResType != eArea &&
|
ResType != eArea &&
|
||||||
(ResType != eAudioGroupSet || mGame >= eEchoesDemo);
|
(ResType != eAudioGroup || mGame >= eEchoesDemo);
|
||||||
|
|
||||||
if (!IsValid) return;
|
if (!IsValid) return;
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define DEPENDENCYLISTBUILDERS
|
#define DEPENDENCYLISTBUILDERS
|
||||||
|
|
||||||
#include "CDependencyTree.h"
|
#include "CDependencyTree.h"
|
||||||
|
#include "CGameProject.h"
|
||||||
#include "CPackage.h"
|
#include "CPackage.h"
|
||||||
#include "CResourceEntry.h"
|
#include "CResourceEntry.h"
|
||||||
#include "Core/Resource/CDependencyGroup.h"
|
#include "Core/Resource/CDependencyGroup.h"
|
||||||
|
30
src/Core/Resource/CAudioGroup.h
Normal file
30
src/Core/Resource/CAudioGroup.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#ifndef CAUDIOGROUP
|
||||||
|
#define CAUDIOGROUP
|
||||||
|
|
||||||
|
#include "CResource.h"
|
||||||
|
|
||||||
|
// Very limited functionality - mostly just intended to find the AGSC that a sound ID belongs to
|
||||||
|
class CAudioGroup : public CResource
|
||||||
|
{
|
||||||
|
DECLARE_RESOURCE_TYPE(eAudioGroup)
|
||||||
|
friend class CAudioGroupLoader;
|
||||||
|
|
||||||
|
TString mGroupName;
|
||||||
|
u32 mGroupID;
|
||||||
|
std::vector<u16> mDefineIDs;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CAudioGroup(CResourceEntry *pEntry = 0)
|
||||||
|
: CResource(pEntry)
|
||||||
|
, mGroupID(-1)
|
||||||
|
{}
|
||||||
|
|
||||||
|
// Accessors
|
||||||
|
inline TString GroupName() const { return mGroupName; }
|
||||||
|
inline u32 GroupID() const { return mGroupID; }
|
||||||
|
inline u32 NumSoundDefineIDs() const { return mDefineIDs.size(); }
|
||||||
|
inline u16 SoundDefineIDByIndex(u32 Index) const { return mDefineIDs[Index]; }
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CAUDIOGROUP
|
||||||
|
|
25
src/Core/Resource/CAudioLookupTable.h
Normal file
25
src/Core/Resource/CAudioLookupTable.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#ifndef CAUDIOLOOKUPTABLE
|
||||||
|
#define CAUDIOLOOKUPTABLE
|
||||||
|
|
||||||
|
#include "CResource.h"
|
||||||
|
|
||||||
|
class CAudioLookupTable : public CResource
|
||||||
|
{
|
||||||
|
DECLARE_RESOURCE_TYPE(eAudioLookupTable)
|
||||||
|
friend class CAudioGroupLoader;
|
||||||
|
std::vector<u16> mDefineIDs;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CAudioLookupTable(CResourceEntry *pEntry = 0)
|
||||||
|
: CResource(pEntry)
|
||||||
|
{}
|
||||||
|
|
||||||
|
inline u16 FindSoundDefineID(u32 SoundID)
|
||||||
|
{
|
||||||
|
ASSERT(SoundID >= 0 && SoundID < mDefineIDs.size());
|
||||||
|
return mDefineIDs[SoundID];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CAUDIOLOOKUPTABLE
|
||||||
|
|
@ -53,7 +53,7 @@ TString GetResourceTypeName(EResType Type)
|
|||||||
case eAreaSurfaceBounds: return "Area Surface Bounds";
|
case eAreaSurfaceBounds: return "Area Surface Bounds";
|
||||||
case eAreaOctree: return "Area Octree";
|
case eAreaOctree: return "Area Octree";
|
||||||
case eAreaVisibilityTree: return "Area Visibility Tree";
|
case eAreaVisibilityTree: return "Area Visibility Tree";
|
||||||
case eAudioGroupSet: return "Audio Group Set";
|
case eAudioGroup: return "Audio Group Set";
|
||||||
case eAudioMacro: return "Audio Macro";
|
case eAudioMacro: return "Audio Macro";
|
||||||
case eAudioSample: return "Audio Sample";
|
case eAudioSample: return "Audio Sample";
|
||||||
case eAudioLookupTable: return "Audio Lookup Table";
|
case eAudioLookupTable: return "Audio Lookup Table";
|
||||||
@ -177,7 +177,7 @@ TString GetResourceCookedExtension(EResType Type, EGame Game)
|
|||||||
CResourceTypeRegistrant__##CookedExtension gResourceTypeRegistrant__##CookedExtension;
|
CResourceTypeRegistrant__##CookedExtension gResourceTypeRegistrant__##CookedExtension;
|
||||||
|
|
||||||
REGISTER_RESOURCE_TYPE(AFSM, eStateMachine, ePrimeDemo, eEchoes)
|
REGISTER_RESOURCE_TYPE(AFSM, eStateMachine, ePrimeDemo, eEchoes)
|
||||||
REGISTER_RESOURCE_TYPE(AGSC, eAudioGroupSet, ePrimeDemo, eCorruptionProto)
|
REGISTER_RESOURCE_TYPE(AGSC, eAudioGroup, ePrimeDemo, eCorruptionProto)
|
||||||
REGISTER_RESOURCE_TYPE(ANCS, eAnimSet, ePrimeDemo, eEchoes)
|
REGISTER_RESOURCE_TYPE(ANCS, eAnimSet, ePrimeDemo, eEchoes)
|
||||||
REGISTER_RESOURCE_TYPE(ANIM, eAnimation, ePrimeDemo, eReturns)
|
REGISTER_RESOURCE_TYPE(ANIM, eAnimation, ePrimeDemo, eReturns)
|
||||||
REGISTER_RESOURCE_TYPE(ATBL, eAudioLookupTable, ePrimeDemo, eCorruption)
|
REGISTER_RESOURCE_TYPE(ATBL, eAudioLookupTable, ePrimeDemo, eCorruption)
|
||||||
|
30
src/Core/Resource/CStringList.h
Normal file
30
src/Core/Resource/CStringList.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#ifndef CSTRINGLIST
|
||||||
|
#define CSTRINGLIST
|
||||||
|
|
||||||
|
#include "CResource.h"
|
||||||
|
|
||||||
|
class CStringList : public CResource
|
||||||
|
{
|
||||||
|
DECLARE_RESOURCE_TYPE(eStringList)
|
||||||
|
friend class CAudioGroupLoader;
|
||||||
|
std::vector<TString> mStringList;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CStringList(CResourceEntry *pEntry = 0)
|
||||||
|
: CResource(pEntry)
|
||||||
|
{}
|
||||||
|
|
||||||
|
inline u32 NumStrings() const
|
||||||
|
{
|
||||||
|
return mStringList.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline TString StringByIndex(u32 Index) const
|
||||||
|
{
|
||||||
|
ASSERT(Index >= 0 && Index < mStringList.size());
|
||||||
|
return mStringList[Index];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CSTRINGLIST
|
||||||
|
|
@ -18,7 +18,7 @@ enum EResType
|
|||||||
eAreaSurfaceBounds,
|
eAreaSurfaceBounds,
|
||||||
eAreaOctree,
|
eAreaOctree,
|
||||||
eAreaVisibilityTree,
|
eAreaVisibilityTree,
|
||||||
eAudioGroupSet,
|
eAudioGroup,
|
||||||
eAudioMacro,
|
eAudioMacro,
|
||||||
eAudioSample,
|
eAudioSample,
|
||||||
eAudioLookupTable,
|
eAudioLookupTable,
|
||||||
|
78
src/Core/Resource/Factory/CAudioGroupLoader.cpp
Normal file
78
src/Core/Resource/Factory/CAudioGroupLoader.cpp
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
#include "CAudioGroupLoader.h"
|
||||||
|
|
||||||
|
CAudioGroup* CAudioGroupLoader::LoadAGSC(IInputStream& rAGSC, CResourceEntry *pEntry)
|
||||||
|
{
|
||||||
|
// For now we only load sound define IDs and the group ID!
|
||||||
|
// Version check
|
||||||
|
u32 Check = rAGSC.PeekLong();
|
||||||
|
EGame Game = (Check == 0x1 ? eEchoes : ePrime);
|
||||||
|
CAudioGroup *pOut = new CAudioGroup(pEntry);
|
||||||
|
|
||||||
|
// Read header, navigate to Proj chunk
|
||||||
|
if (Game == ePrime)
|
||||||
|
{
|
||||||
|
rAGSC.ReadString();
|
||||||
|
pOut->mGroupName = rAGSC.ReadString();
|
||||||
|
u32 PoolSize = rAGSC.ReadLong();
|
||||||
|
rAGSC.Seek(PoolSize + 0x4, SEEK_CUR);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rAGSC.Seek(0x4, SEEK_CUR);
|
||||||
|
pOut->mGroupName = rAGSC.ReadString();
|
||||||
|
pOut->mGroupID = rAGSC.ReadShort();
|
||||||
|
u32 PoolSize = rAGSC.ReadLong();
|
||||||
|
rAGSC.Seek(0xC + PoolSize, SEEK_CUR);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read needed data from the Proj chunk
|
||||||
|
u32 ProjStart = rAGSC.Tell();
|
||||||
|
rAGSC.Seek(0x4, SEEK_CUR);
|
||||||
|
u16 GroupID = rAGSC.ReadShort();
|
||||||
|
u16 GroupType = rAGSC.ReadShort();
|
||||||
|
rAGSC.Seek(0x14, SEEK_CUR);
|
||||||
|
u32 SfxTableStart = rAGSC.ReadLong();
|
||||||
|
|
||||||
|
if (Game == ePrime)
|
||||||
|
pOut->mGroupID = GroupID;
|
||||||
|
else
|
||||||
|
ASSERT(pOut->mGroupID == GroupID);
|
||||||
|
|
||||||
|
if (GroupType == 1)
|
||||||
|
{
|
||||||
|
rAGSC.Seek(ProjStart + SfxTableStart, SEEK_SET);
|
||||||
|
u16 NumSounds = rAGSC.ReadShort();
|
||||||
|
rAGSC.Seek(0x2, SEEK_CUR);
|
||||||
|
|
||||||
|
for (u32 iSfx = 0; iSfx < NumSounds; iSfx++)
|
||||||
|
{
|
||||||
|
pOut->mDefineIDs.push_back( rAGSC.ReadShort() );
|
||||||
|
rAGSC.Seek(0x8, SEEK_CUR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return pOut;
|
||||||
|
}
|
||||||
|
|
||||||
|
CAudioLookupTable* CAudioGroupLoader::LoadATBL(IInputStream& rATBL, CResourceEntry *pEntry)
|
||||||
|
{
|
||||||
|
CAudioLookupTable *pOut = new CAudioLookupTable(pEntry);
|
||||||
|
u32 NumMacroIDs = rATBL.ReadLong();
|
||||||
|
|
||||||
|
for (u32 iMacro = 0; iMacro < NumMacroIDs; iMacro++)
|
||||||
|
pOut->mDefineIDs.push_back( rATBL.ReadShort() );
|
||||||
|
|
||||||
|
return pOut;
|
||||||
|
}
|
||||||
|
|
||||||
|
CStringList* CAudioGroupLoader::LoadSTLC(IInputStream& rSTLC, CResourceEntry *pEntry)
|
||||||
|
{
|
||||||
|
CStringList *pOut = new CStringList(pEntry);
|
||||||
|
u32 NumStrings = rSTLC.ReadLong();
|
||||||
|
|
||||||
|
for (u32 iStr = 0; iStr < NumStrings; iStr++)
|
||||||
|
pOut->mStringList[iStr] = rSTLC.ReadString();
|
||||||
|
|
||||||
|
return pOut;
|
||||||
|
}
|
18
src/Core/Resource/Factory/CAudioGroupLoader.h
Normal file
18
src/Core/Resource/Factory/CAudioGroupLoader.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#ifndef CAUDIOGROUPLOADER_H
|
||||||
|
#define CAUDIOGROUPLOADER_H
|
||||||
|
|
||||||
|
#include "Core/Resource/CAudioGroup.h"
|
||||||
|
#include "Core/Resource/CAudioLookupTable.h"
|
||||||
|
#include "Core/Resource/CStringList.h"
|
||||||
|
|
||||||
|
class CAudioGroupLoader
|
||||||
|
{
|
||||||
|
CAudioGroupLoader() {}
|
||||||
|
|
||||||
|
public:
|
||||||
|
static CAudioGroup* LoadAGSC(IInputStream& rAGSC, CResourceEntry *pEntry);
|
||||||
|
static CAudioLookupTable* LoadATBL(IInputStream& rATBL, CResourceEntry *pEntry);
|
||||||
|
static CStringList* LoadSTLC(IInputStream& rSTLC, CResourceEntry *pEntry);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CAUDIOGROUPLOADER_H
|
@ -4,6 +4,7 @@
|
|||||||
#include "CAnimationLoader.h"
|
#include "CAnimationLoader.h"
|
||||||
#include "CAnimSetLoader.h"
|
#include "CAnimSetLoader.h"
|
||||||
#include "CAreaLoader.h"
|
#include "CAreaLoader.h"
|
||||||
|
#include "CAudioGroupLoader.h"
|
||||||
#include "CCollisionLoader.h"
|
#include "CCollisionLoader.h"
|
||||||
#include "CDependencyGroupLoader.h"
|
#include "CDependencyGroupLoader.h"
|
||||||
#include "CFontLoader.h"
|
#include "CFontLoader.h"
|
||||||
@ -35,6 +36,8 @@ public:
|
|||||||
case eAnimation: return new CAnimation(pEntry);
|
case eAnimation: return new CAnimation(pEntry);
|
||||||
case eAnimSet: return new CAnimSet(pEntry);
|
case eAnimSet: return new CAnimSet(pEntry);
|
||||||
case eArea: return new CGameArea(pEntry);
|
case eArea: return new CGameArea(pEntry);
|
||||||
|
case eAudioGroup: return new CAudioGroup(pEntry);
|
||||||
|
case eAudioLookupTable: return new CAudioLookupTable(pEntry);
|
||||||
case eDynamicCollision: return new CCollisionMeshGroup(pEntry);
|
case eDynamicCollision: return new CCollisionMeshGroup(pEntry);
|
||||||
case eDependencyGroup: return new CDependencyGroup(pEntry);
|
case eDependencyGroup: return new CDependencyGroup(pEntry);
|
||||||
case eFont: return new CFont(pEntry);
|
case eFont: return new CFont(pEntry);
|
||||||
@ -43,6 +46,7 @@ public:
|
|||||||
case eSkeleton: return new CSkeleton(pEntry);
|
case eSkeleton: return new CSkeleton(pEntry);
|
||||||
case eSkin: return new CSkin(pEntry);
|
case eSkin: return new CSkin(pEntry);
|
||||||
case eStaticGeometryMap: return new CPoiToWorld(pEntry);
|
case eStaticGeometryMap: return new CPoiToWorld(pEntry);
|
||||||
|
case eStringList: return new CStringList(pEntry);
|
||||||
case eStringTable: return new CStringTable(pEntry);
|
case eStringTable: return new CStringTable(pEntry);
|
||||||
case eTexture: return new CTexture(pEntry);
|
case eTexture: return new CTexture(pEntry);
|
||||||
case eWorld: return new CWorld(pEntry);
|
case eWorld: return new CWorld(pEntry);
|
||||||
@ -54,7 +58,6 @@ public:
|
|||||||
{
|
{
|
||||||
// Warning: It is the caller's responsibility to check if the required resource is already in memory before calling this function.
|
// Warning: It is the caller's responsibility to check if the required resource is already in memory before calling this function.
|
||||||
if (!rInput.IsValid()) return nullptr;
|
if (!rInput.IsValid()) return nullptr;
|
||||||
|
|
||||||
CResource *pRes = nullptr;
|
CResource *pRes = nullptr;
|
||||||
|
|
||||||
switch (pEntry->ResourceType())
|
switch (pEntry->ResourceType())
|
||||||
@ -63,6 +66,8 @@ public:
|
|||||||
case eAnimEventData: pRes = CUnsupportedFormatLoader::LoadEVNT(rInput, pEntry); break;
|
case eAnimEventData: pRes = CUnsupportedFormatLoader::LoadEVNT(rInput, pEntry); break;
|
||||||
case eAnimSet: pRes = CAnimSetLoader::LoadANCSOrCHAR(rInput, pEntry); break;
|
case eAnimSet: pRes = CAnimSetLoader::LoadANCSOrCHAR(rInput, pEntry); break;
|
||||||
case eArea: pRes = CAreaLoader::LoadMREA(rInput, pEntry); break;
|
case eArea: pRes = CAreaLoader::LoadMREA(rInput, pEntry); break;
|
||||||
|
case eAudioGroup: pRes = CAudioGroupLoader::LoadAGSC(rInput, pEntry); break;
|
||||||
|
case eAudioLookupTable: pRes = CAudioGroupLoader::LoadATBL(rInput, pEntry); break;
|
||||||
case eDependencyGroup: pRes = CDependencyGroupLoader::LoadDGRP(rInput, pEntry); break;
|
case eDependencyGroup: pRes = CDependencyGroupLoader::LoadDGRP(rInput, pEntry); break;
|
||||||
case eDynamicCollision: pRes = CCollisionLoader::LoadDCLN(rInput, pEntry); break;
|
case eDynamicCollision: pRes = CCollisionLoader::LoadDCLN(rInput, pEntry); break;
|
||||||
case eFont: pRes = CFontLoader::LoadFONT(rInput, pEntry); break;
|
case eFont: pRes = CFontLoader::LoadFONT(rInput, pEntry); break;
|
||||||
@ -78,6 +83,7 @@ public:
|
|||||||
case eSkin: pRes = CSkinLoader::LoadCSKR(rInput, pEntry); break;
|
case eSkin: pRes = CSkinLoader::LoadCSKR(rInput, pEntry); break;
|
||||||
case eStateMachine2: pRes = CUnsupportedFormatLoader::LoadFSM2(rInput, pEntry); break;
|
case eStateMachine2: pRes = CUnsupportedFormatLoader::LoadFSM2(rInput, pEntry); break;
|
||||||
case eStaticGeometryMap: pRes = CPoiToWorldLoader::LoadEGMC(rInput, pEntry); break;
|
case eStaticGeometryMap: pRes = CPoiToWorldLoader::LoadEGMC(rInput, pEntry); break;
|
||||||
|
case eStringList: pRes = CAudioGroupLoader::LoadSTLC(rInput, pEntry); break;
|
||||||
case eStringTable: pRes = CStringLoader::LoadSTRG(rInput, pEntry); break;
|
case eStringTable: pRes = CStringLoader::LoadSTRG(rInput, pEntry); break;
|
||||||
case eTexture: pRes = CTextureDecoder::LoadTXTR(rInput, pEntry); break;
|
case eTexture: pRes = CTextureDecoder::LoadTXTR(rInput, pEntry); break;
|
||||||
case eWorld: pRes = CWorldLoader::LoadMLVL(rInput, pEntry); break;
|
case eWorld: pRes = CWorldLoader::LoadMLVL(rInput, pEntry); break;
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#define TRESPTR_H
|
#define TRESPTR_H
|
||||||
|
|
||||||
#include "CResource.h"
|
#include "CResource.h"
|
||||||
#include "Core/GameProject/CGameProject.h"
|
|
||||||
|
|
||||||
template <typename ResType>
|
template <typename ResType>
|
||||||
class TResPtr
|
class TResPtr
|
||||||
|
@ -1,14 +1,36 @@
|
|||||||
#include "TestDialog.h"
|
#include "TestDialog.h"
|
||||||
#include "ui_TestDialog.h"
|
#include "ui_TestDialog.h"
|
||||||
|
#include <Core/GameProject/CGameProject.h>
|
||||||
|
|
||||||
TestDialog::TestDialog(QWidget *pParent)
|
TestDialog::TestDialog(QWidget *pParent)
|
||||||
: QDialog(pParent)
|
: QDialog(pParent)
|
||||||
, ui(new Ui::TestDialog)
|
, ui(new Ui::TestDialog)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
connect(ui->spinBox, SIGNAL(valueChanged(int)), this, SLOT(OnSpinBoxChanged(int)));
|
||||||
|
connect(ui->spinBox_2, SIGNAL(valueChanged(int)), this, SLOT(OnSpinBoxChanged(int)));
|
||||||
|
connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(OnFind()));
|
||||||
}
|
}
|
||||||
|
|
||||||
TestDialog::~TestDialog()
|
TestDialog::~TestDialog()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestDialog::OnSpinBoxChanged(int NewValue)
|
||||||
|
{
|
||||||
|
if (sender() != ui->spinBox) ui->spinBox->setValue(NewValue);
|
||||||
|
if (sender() != ui->spinBox_2) ui->spinBox_2->setValue(NewValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestDialog::OnFind()
|
||||||
|
{
|
||||||
|
u32 SoundID = ui->spinBox->value();
|
||||||
|
CGameProject *pProj = CGameProject::ActiveProject();
|
||||||
|
|
||||||
|
if (pProj)
|
||||||
|
{
|
||||||
|
CAudioManager *pAudioMgr = pProj->AudioManager();
|
||||||
|
pAudioMgr->LogSoundInfo(SoundID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#define TESTDIALOG_H
|
#define TESTDIALOG_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include "Editor/PropertyEdit/CPropertyModel.h"
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class TestDialog;
|
class TestDialog;
|
||||||
@ -11,12 +10,15 @@ class TestDialog;
|
|||||||
class TestDialog : public QDialog
|
class TestDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
CPropertyModel *mpModel;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TestDialog(QWidget *pParent = 0);
|
explicit TestDialog(QWidget *pParent = 0);
|
||||||
~TestDialog();
|
~TestDialog();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void OnSpinBoxChanged(int NewValue);
|
||||||
|
void OnFind();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::TestDialog *ui;
|
Ui::TestDialog *ui;
|
||||||
};
|
};
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>300</width>
|
<width>238</width>
|
||||||
<height>535</height>
|
<height>43</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -15,38 +15,47 @@
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="CPropertyView" name="treeView">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<property name="font">
|
<item>
|
||||||
<font>
|
<widget class="QSpinBox" name="spinBox">
|
||||||
<pointsize>10</pointsize>
|
<property name="sizePolicy">
|
||||||
</font>
|
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||||
</property>
|
<horstretch>1</horstretch>
|
||||||
<property name="editTriggers">
|
<verstretch>0</verstretch>
|
||||||
<set>QAbstractItemView::AllEditTriggers</set>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="alternatingRowColors">
|
<property name="maximum">
|
||||||
<bool>true</bool>
|
<number>65536</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="selectionMode">
|
</widget>
|
||||||
<enum>QAbstractItemView::NoSelection</enum>
|
</item>
|
||||||
</property>
|
<item>
|
||||||
<property name="verticalScrollMode">
|
<widget class="QSpinBox" name="spinBox_2">
|
||||||
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
<property name="sizePolicy">
|
||||||
</property>
|
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||||
<property name="headerHidden">
|
<horstretch>1</horstretch>
|
||||||
<bool>false</bool>
|
<verstretch>0</verstretch>
|
||||||
</property>
|
</sizepolicy>
|
||||||
</widget>
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>65536</number>
|
||||||
|
</property>
|
||||||
|
<property name="displayIntegerBase">
|
||||||
|
<number>16</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Find</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>CPropertyView</class>
|
|
||||||
<extends>QTreeView</extends>
|
|
||||||
<header>Editor/PropertyEdit/CPropertyView.h</header>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user