mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-10 14:58:10 -05:00
Add initial draft of structured data def parser to parse enums only for now
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Parsing/StructuredDataDef/StructuredDataDefReader.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
using namespace IW4;
|
||||
@ -15,3 +16,35 @@ void* AssetLoaderStructuredDataDefSet::CreateEmptyAsset(const std::string& asset
|
||||
structuredDataDefSet->name = memory->Dup(assetName.c_str());
|
||||
return structuredDataDefSet;
|
||||
}
|
||||
|
||||
bool AssetLoaderStructuredDataDefSet::CanLoadFromRaw() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderStructuredDataDefSet::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
const auto file = searchPath->Open(assetName);
|
||||
if (!file.IsOpen())
|
||||
return false;
|
||||
|
||||
auto* structuredDataDefSet = memory->Create<StructuredDataDefSet>();
|
||||
structuredDataDefSet->name = memory->Dup(assetName.c_str());
|
||||
|
||||
StructuredDataDefReader reader(*file.m_stream, assetName, [searchPath](const std::string& filename, const std::string& sourceFile) -> std::unique_ptr<std::istream>
|
||||
{
|
||||
auto foundFileToInclude = searchPath->Open(filename);
|
||||
if (!foundFileToInclude.IsOpen() || !foundFileToInclude.m_stream)
|
||||
return nullptr;
|
||||
|
||||
return std::move(foundFileToInclude.m_stream);
|
||||
});
|
||||
|
||||
const auto defs = reader.ReadStructureDataDefs();
|
||||
|
||||
// TODO Convert defs
|
||||
|
||||
manager->AddAsset(ASSET_TYPE_STRUCTURED_DATA_DEF, assetName, structuredDataDefSet);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user