mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
Add possibility to include asset lists in project definition
This commit is contained in:
parent
e4fd8543e3
commit
fb5c67b5ce
@ -22,7 +22,7 @@ void ZoneCreator::AddAssetTypeName(asset_type_t assetType, std::string name)
|
|||||||
m_asset_types_by_name.emplace(std::make_pair(std::move(name), assetType));
|
m_asset_types_by_name.emplace(std::make_pair(std::move(name), assetType));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Gdt*> ZoneCreator::CreateGdtList(ZoneCreationContext& context)
|
std::vector<Gdt*> ZoneCreator::CreateGdtList(const ZoneCreationContext& context)
|
||||||
{
|
{
|
||||||
std::vector<Gdt*> gdtList;
|
std::vector<Gdt*> gdtList;
|
||||||
gdtList.reserve(context.m_gdt_files.size());
|
gdtList.reserve(context.m_gdt_files.size());
|
||||||
@ -32,9 +32,9 @@ std::vector<Gdt*> ZoneCreator::CreateGdtList(ZoneCreationContext& context)
|
|||||||
return gdtList;
|
return gdtList;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneCreator::CreateIgnoredAssetMap(ZoneCreationContext& context, std::unordered_map<std::string, asset_type_t>& ignoredAssetMap) const
|
bool ZoneCreator::CreateIgnoredAssetMap(const ZoneCreationContext& context, std::unordered_map<std::string, asset_type_t>& ignoredAssetMap) const
|
||||||
{
|
{
|
||||||
for (const auto& ignoreEntry : context.m_ignored_assets)
|
for (const auto& ignoreEntry : context.m_ignored_assets.m_entries)
|
||||||
{
|
{
|
||||||
const auto foundAssetTypeEntry = m_asset_types_by_name.find(ignoreEntry.m_type);
|
const auto foundAssetTypeEntry = m_asset_types_by_name.find(ignoreEntry.m_type);
|
||||||
if (foundAssetTypeEntry == m_asset_types_by_name.end())
|
if (foundAssetTypeEntry == m_asset_types_by_name.end())
|
||||||
@ -72,7 +72,7 @@ std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext&
|
|||||||
if (!assetEntry.m_is_reference)
|
if (!assetEntry.m_is_reference)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
context.m_ignored_assets.emplace_back(assetEntry.m_asset_type, assetEntry.m_asset_name);
|
context.m_ignored_assets.m_entries.emplace_back(assetEntry.m_asset_type, assetEntry.m_asset_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(zone.get(), context.m_asset_search_path, CreateGdtList(context));
|
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(zone.get(), context.m_asset_search_path, CreateGdtList(context));
|
||||||
|
@ -12,8 +12,8 @@ namespace IW3
|
|||||||
std::unordered_map<std::string, asset_type_t> m_asset_types_by_name;
|
std::unordered_map<std::string, asset_type_t> m_asset_types_by_name;
|
||||||
|
|
||||||
void AddAssetTypeName(asset_type_t assetType, std::string name);
|
void AddAssetTypeName(asset_type_t assetType, std::string name);
|
||||||
static std::vector<Gdt*> CreateGdtList(ZoneCreationContext& context);
|
static std::vector<Gdt*> CreateGdtList(const ZoneCreationContext& context);
|
||||||
bool CreateIgnoredAssetMap(ZoneCreationContext& context, std::unordered_map<std::string, asset_type_t>& ignoredAssetMap) const;
|
bool CreateIgnoredAssetMap(const ZoneCreationContext& context, std::unordered_map<std::string, asset_type_t>& ignoredAssetMap) const;
|
||||||
void CreateZoneAssetPools(Zone* zone) const;
|
void CreateZoneAssetPools(Zone* zone) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -21,7 +21,7 @@ void ZoneCreator::AddAssetTypeName(asset_type_t assetType, std::string name)
|
|||||||
m_asset_types_by_name.emplace(std::make_pair(std::move(name), assetType));
|
m_asset_types_by_name.emplace(std::make_pair(std::move(name), assetType));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Gdt*> ZoneCreator::CreateGdtList(ZoneCreationContext& context)
|
std::vector<Gdt*> ZoneCreator::CreateGdtList(const ZoneCreationContext& context)
|
||||||
{
|
{
|
||||||
std::vector<Gdt*> gdtList;
|
std::vector<Gdt*> gdtList;
|
||||||
gdtList.reserve(context.m_gdt_files.size());
|
gdtList.reserve(context.m_gdt_files.size());
|
||||||
@ -31,9 +31,9 @@ std::vector<Gdt*> ZoneCreator::CreateGdtList(ZoneCreationContext& context)
|
|||||||
return gdtList;
|
return gdtList;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneCreator::CreateIgnoredAssetMap(ZoneCreationContext& context, std::unordered_map<std::string, asset_type_t>& ignoredAssetMap) const
|
bool ZoneCreator::CreateIgnoredAssetMap(const ZoneCreationContext& context, std::unordered_map<std::string, asset_type_t>& ignoredAssetMap) const
|
||||||
{
|
{
|
||||||
for (const auto& ignoreEntry : context.m_ignored_assets)
|
for (const auto& ignoreEntry : context.m_ignored_assets.m_entries)
|
||||||
{
|
{
|
||||||
const auto foundAssetTypeEntry = m_asset_types_by_name.find(ignoreEntry.m_type);
|
const auto foundAssetTypeEntry = m_asset_types_by_name.find(ignoreEntry.m_type);
|
||||||
if (foundAssetTypeEntry == m_asset_types_by_name.end())
|
if (foundAssetTypeEntry == m_asset_types_by_name.end())
|
||||||
@ -71,7 +71,7 @@ std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext&
|
|||||||
if (!assetEntry.m_is_reference)
|
if (!assetEntry.m_is_reference)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
context.m_ignored_assets.emplace_back(assetEntry.m_asset_type, assetEntry.m_asset_name);
|
context.m_ignored_assets.m_entries.emplace_back(assetEntry.m_asset_type, assetEntry.m_asset_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(zone.get(), context.m_asset_search_path, CreateGdtList(context));
|
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(zone.get(), context.m_asset_search_path, CreateGdtList(context));
|
||||||
|
@ -12,8 +12,8 @@ namespace IW4
|
|||||||
std::unordered_map<std::string, asset_type_t> m_asset_types_by_name;
|
std::unordered_map<std::string, asset_type_t> m_asset_types_by_name;
|
||||||
|
|
||||||
void AddAssetTypeName(asset_type_t assetType, std::string name);
|
void AddAssetTypeName(asset_type_t assetType, std::string name);
|
||||||
static std::vector<Gdt*> CreateGdtList(ZoneCreationContext& context);
|
static std::vector<Gdt*> CreateGdtList(const ZoneCreationContext& context);
|
||||||
bool CreateIgnoredAssetMap(ZoneCreationContext& context, std::unordered_map<std::string, asset_type_t>& ignoredAssetMap) const;
|
bool CreateIgnoredAssetMap(const ZoneCreationContext& context, std::unordered_map<std::string, asset_type_t>& ignoredAssetMap) const;
|
||||||
void CreateZoneAssetPools(Zone* zone) const;
|
void CreateZoneAssetPools(Zone* zone) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -21,7 +21,7 @@ void ZoneCreator::AddAssetTypeName(asset_type_t assetType, std::string name)
|
|||||||
m_asset_types_by_name.emplace(std::make_pair(std::move(name), assetType));
|
m_asset_types_by_name.emplace(std::make_pair(std::move(name), assetType));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Gdt*> ZoneCreator::CreateGdtList(ZoneCreationContext& context)
|
std::vector<Gdt*> ZoneCreator::CreateGdtList(const ZoneCreationContext& context)
|
||||||
{
|
{
|
||||||
std::vector<Gdt*> gdtList;
|
std::vector<Gdt*> gdtList;
|
||||||
gdtList.reserve(context.m_gdt_files.size());
|
gdtList.reserve(context.m_gdt_files.size());
|
||||||
@ -31,9 +31,9 @@ std::vector<Gdt*> ZoneCreator::CreateGdtList(ZoneCreationContext& context)
|
|||||||
return gdtList;
|
return gdtList;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneCreator::CreateIgnoredAssetMap(ZoneCreationContext& context, std::unordered_map<std::string, asset_type_t>& ignoredAssetMap) const
|
bool ZoneCreator::CreateIgnoredAssetMap(const ZoneCreationContext& context, std::unordered_map<std::string, asset_type_t>& ignoredAssetMap) const
|
||||||
{
|
{
|
||||||
for (const auto& ignoreEntry : context.m_ignored_assets)
|
for (const auto& ignoreEntry : context.m_ignored_assets.m_entries)
|
||||||
{
|
{
|
||||||
const auto foundAssetTypeEntry = m_asset_types_by_name.find(ignoreEntry.m_type);
|
const auto foundAssetTypeEntry = m_asset_types_by_name.find(ignoreEntry.m_type);
|
||||||
if (foundAssetTypeEntry == m_asset_types_by_name.end())
|
if (foundAssetTypeEntry == m_asset_types_by_name.end())
|
||||||
@ -71,7 +71,7 @@ std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext&
|
|||||||
if (!assetEntry.m_is_reference)
|
if (!assetEntry.m_is_reference)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
context.m_ignored_assets.emplace_back(assetEntry.m_asset_type, assetEntry.m_asset_name);
|
context.m_ignored_assets.m_entries.emplace_back(assetEntry.m_asset_type, assetEntry.m_asset_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(zone.get(), context.m_asset_search_path, CreateGdtList(context));
|
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(zone.get(), context.m_asset_search_path, CreateGdtList(context));
|
||||||
|
@ -12,8 +12,8 @@ namespace IW5
|
|||||||
std::unordered_map<std::string, asset_type_t> m_asset_types_by_name;
|
std::unordered_map<std::string, asset_type_t> m_asset_types_by_name;
|
||||||
|
|
||||||
void AddAssetTypeName(asset_type_t assetType, std::string name);
|
void AddAssetTypeName(asset_type_t assetType, std::string name);
|
||||||
static std::vector<Gdt*> CreateGdtList(ZoneCreationContext& context);
|
static std::vector<Gdt*> CreateGdtList(const ZoneCreationContext& context);
|
||||||
bool CreateIgnoredAssetMap(ZoneCreationContext& context, std::unordered_map<std::string, asset_type_t>& ignoredAssetMap) const;
|
bool CreateIgnoredAssetMap(const ZoneCreationContext& context, std::unordered_map<std::string, asset_type_t>& ignoredAssetMap) const;
|
||||||
void CreateZoneAssetPools(Zone* zone) const;
|
void CreateZoneAssetPools(Zone* zone) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -32,9 +32,9 @@ std::vector<Gdt*> ZoneCreator::CreateGdtList(ZoneCreationContext& context)
|
|||||||
return gdtList;
|
return gdtList;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneCreator::CreateIgnoredAssetMap(ZoneCreationContext& context, std::unordered_map<std::string, asset_type_t>& ignoredAssetMap) const
|
bool ZoneCreator::CreateIgnoredAssetMap(const ZoneCreationContext& context, std::unordered_map<std::string, asset_type_t>& ignoredAssetMap) const
|
||||||
{
|
{
|
||||||
for (const auto& ignoreEntry : context.m_ignored_assets)
|
for (const auto& ignoreEntry : context.m_ignored_assets.m_entries)
|
||||||
{
|
{
|
||||||
const auto foundAssetTypeEntry = m_asset_types_by_name.find(ignoreEntry.m_type);
|
const auto foundAssetTypeEntry = m_asset_types_by_name.find(ignoreEntry.m_type);
|
||||||
if (foundAssetTypeEntry == m_asset_types_by_name.end())
|
if (foundAssetTypeEntry == m_asset_types_by_name.end())
|
||||||
@ -72,7 +72,7 @@ std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext&
|
|||||||
if (!assetEntry.m_is_reference)
|
if (!assetEntry.m_is_reference)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
context.m_ignored_assets.emplace_back(assetEntry.m_asset_type, assetEntry.m_asset_name);
|
context.m_ignored_assets.m_entries.emplace_back(assetEntry.m_asset_type, assetEntry.m_asset_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(zone.get(), context.m_asset_search_path, CreateGdtList(context));
|
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(zone.get(), context.m_asset_search_path, CreateGdtList(context));
|
||||||
|
@ -13,7 +13,7 @@ namespace T5
|
|||||||
|
|
||||||
void AddAssetTypeName(asset_type_t assetType, std::string name);
|
void AddAssetTypeName(asset_type_t assetType, std::string name);
|
||||||
static std::vector<Gdt*> CreateGdtList(ZoneCreationContext& context);
|
static std::vector<Gdt*> CreateGdtList(ZoneCreationContext& context);
|
||||||
bool CreateIgnoredAssetMap(ZoneCreationContext& context, std::unordered_map<std::string, asset_type_t>& ignoredAssetMap) const;
|
bool CreateIgnoredAssetMap(const ZoneCreationContext& context, std::unordered_map<std::string, asset_type_t>& ignoredAssetMap) const;
|
||||||
void CreateZoneAssetPools(Zone* zone) const;
|
void CreateZoneAssetPools(Zone* zone) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -23,7 +23,7 @@ void ZoneCreator::AddAssetTypeName(asset_type_t assetType, std::string name)
|
|||||||
m_asset_types_by_name.emplace(std::make_pair(std::move(name), assetType));
|
m_asset_types_by_name.emplace(std::make_pair(std::move(name), assetType));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Gdt*> ZoneCreator::CreateGdtList(ZoneCreationContext& context)
|
std::vector<Gdt*> ZoneCreator::CreateGdtList(const ZoneCreationContext& context)
|
||||||
{
|
{
|
||||||
std::vector<Gdt*> gdtList;
|
std::vector<Gdt*> gdtList;
|
||||||
gdtList.reserve(context.m_gdt_files.size());
|
gdtList.reserve(context.m_gdt_files.size());
|
||||||
@ -33,9 +33,9 @@ std::vector<Gdt*> ZoneCreator::CreateGdtList(ZoneCreationContext& context)
|
|||||||
return gdtList;
|
return gdtList;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneCreator::CreateIgnoredAssetMap(ZoneCreationContext& context, std::unordered_map<std::string, asset_type_t>& ignoredAssetMap) const
|
bool ZoneCreator::CreateIgnoredAssetMap(const ZoneCreationContext& context, std::unordered_map<std::string, asset_type_t>& ignoredAssetMap) const
|
||||||
{
|
{
|
||||||
for (const auto& ignoreEntry : context.m_ignored_assets)
|
for (const auto& ignoreEntry : context.m_ignored_assets.m_entries)
|
||||||
{
|
{
|
||||||
const auto foundAssetTypeEntry = m_asset_types_by_name.find(ignoreEntry.m_type);
|
const auto foundAssetTypeEntry = m_asset_types_by_name.find(ignoreEntry.m_type);
|
||||||
if (foundAssetTypeEntry == m_asset_types_by_name.end())
|
if (foundAssetTypeEntry == m_asset_types_by_name.end())
|
||||||
@ -58,7 +58,7 @@ void ZoneCreator::CreateZoneAssetPools(Zone* zone) const
|
|||||||
zone->m_pools->InitPoolDynamic(assetType);
|
zone->m_pools->InitPoolDynamic(assetType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneCreator::HandleMetadata(Zone* zone, ZoneCreationContext& context) const
|
void ZoneCreator::HandleMetadata(Zone* zone, const ZoneCreationContext& context) const
|
||||||
{
|
{
|
||||||
std::vector<KeyValuePair> kvpList;
|
std::vector<KeyValuePair> kvpList;
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext&
|
|||||||
if (!assetEntry.m_is_reference)
|
if (!assetEntry.m_is_reference)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
context.m_ignored_assets.emplace_back(assetEntry.m_asset_type, assetEntry.m_asset_name);
|
context.m_ignored_assets.m_entries.emplace_back(assetEntry.m_asset_type, assetEntry.m_asset_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(zone.get(), context.m_asset_search_path, CreateGdtList(context));
|
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(zone.get(), context.m_asset_search_path, CreateGdtList(context));
|
||||||
|
@ -12,10 +12,10 @@ namespace T6
|
|||||||
std::unordered_map<std::string, asset_type_t> m_asset_types_by_name;
|
std::unordered_map<std::string, asset_type_t> m_asset_types_by_name;
|
||||||
|
|
||||||
void AddAssetTypeName(asset_type_t assetType, std::string name);
|
void AddAssetTypeName(asset_type_t assetType, std::string name);
|
||||||
static std::vector<Gdt*> CreateGdtList(ZoneCreationContext& context);
|
static std::vector<Gdt*> CreateGdtList(const ZoneCreationContext& context);
|
||||||
bool CreateIgnoredAssetMap(ZoneCreationContext& context, std::unordered_map<std::string, asset_type_t>& ignoredAssetMap) const;
|
bool CreateIgnoredAssetMap(const ZoneCreationContext& context, std::unordered_map<std::string, asset_type_t>& ignoredAssetMap) const;
|
||||||
void CreateZoneAssetPools(Zone* zone) const;
|
void CreateZoneAssetPools(Zone* zone) const;
|
||||||
void HandleMetadata(Zone* zone, ZoneCreationContext& context) const;
|
void HandleMetadata(Zone* zone, const ZoneCreationContext& context) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ZoneCreator();
|
ZoneCreator();
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
#include "ObjWriting.h"
|
#include "ObjWriting.h"
|
||||||
#include "ObjLoading.h"
|
#include "ObjLoading.h"
|
||||||
#include "SearchPath/SearchPaths.h"
|
#include "SearchPath/SearchPaths.h"
|
||||||
#include "SearchPath/SearchPathFilesystem.h"
|
|
||||||
#include "ObjContainer/IWD/IWD.h"
|
#include "ObjContainer/IWD/IWD.h"
|
||||||
#include "LinkerArgs.h"
|
#include "LinkerArgs.h"
|
||||||
#include "LinkerSearchPaths.h"
|
#include "LinkerSearchPaths.h"
|
||||||
@ -115,6 +114,58 @@ class LinkerImpl final : public Linker
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ReadAssetList(const std::string& zoneName, AssetList& assetList, ISearchPath* sourceSearchPath) const
|
||||||
|
{
|
||||||
|
{
|
||||||
|
const auto assetListFileName = "assetlist/" + zoneName + ".csv";
|
||||||
|
const auto assetListStream = sourceSearchPath->Open(assetListFileName);
|
||||||
|
|
||||||
|
if (assetListStream.IsOpen())
|
||||||
|
{
|
||||||
|
const AssetListInputStream stream(*assetListStream.m_stream);
|
||||||
|
AssetListEntry entry;
|
||||||
|
|
||||||
|
while (stream.NextEntry(entry))
|
||||||
|
{
|
||||||
|
assetList.m_entries.emplace_back(std::move(entry));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const auto zoneDefinition = ReadZoneDefinition(zoneName, sourceSearchPath);
|
||||||
|
|
||||||
|
if (zoneDefinition)
|
||||||
|
{
|
||||||
|
for (const auto& entry : zoneDefinition->m_assets)
|
||||||
|
{
|
||||||
|
assetList.m_entries.emplace_back(entry.m_asset_type, entry.m_asset_name);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IncludeAssetLists(ZoneDefinition& zoneDefinition, ISearchPath* sourceSearchPath) const
|
||||||
|
{
|
||||||
|
for (const auto& assetListName : zoneDefinition.m_asset_lists)
|
||||||
|
{
|
||||||
|
AssetList assetList;
|
||||||
|
if (!ReadAssetList(assetListName, assetList, sourceSearchPath))
|
||||||
|
{
|
||||||
|
std::cerr << "Failed to read asset list \"" << assetListName << "\"\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
zoneDefinition.Include(assetList);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool GetNameFromZoneDefinition(std::string& name, const std::string& projectName, const ZoneDefinition& zoneDefinition)
|
static bool GetNameFromZoneDefinition(std::string& name, const std::string& projectName, const ZoneDefinition& zoneDefinition)
|
||||||
{
|
{
|
||||||
auto firstNameEntry = true;
|
auto firstNameEntry = true;
|
||||||
@ -170,44 +221,12 @@ class LinkerImpl final : public Linker
|
|||||||
if (!IncludeAdditionalZoneDefinitions(projectName, *zoneDefinition, sourceSearchPath))
|
if (!IncludeAdditionalZoneDefinitions(projectName, *zoneDefinition, sourceSearchPath))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
if (!IncludeAssetLists(*zoneDefinition, sourceSearchPath))
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
return zoneDefinition;
|
return zoneDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReadAssetList(const std::string& zoneName, std::vector<AssetListEntry>& assetList, ISearchPath* sourceSearchPath) const
|
|
||||||
{
|
|
||||||
{
|
|
||||||
const auto assetListFileName = "assetlist/" + zoneName + ".csv";
|
|
||||||
const auto assetListStream = sourceSearchPath->Open(assetListFileName);
|
|
||||||
|
|
||||||
if (assetListStream.IsOpen())
|
|
||||||
{
|
|
||||||
const AssetListInputStream stream(*assetListStream.m_stream);
|
|
||||||
AssetListEntry entry;
|
|
||||||
|
|
||||||
while (stream.NextEntry(entry))
|
|
||||||
{
|
|
||||||
assetList.emplace_back(std::move(entry));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
const auto zoneDefinition = ReadZoneDefinition(zoneName, sourceSearchPath);
|
|
||||||
|
|
||||||
if (zoneDefinition)
|
|
||||||
{
|
|
||||||
for (const auto& entry : zoneDefinition->m_assets)
|
|
||||||
{
|
|
||||||
assetList.emplace_back(entry.m_asset_type, entry.m_asset_name);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ProcessZoneDefinitionIgnores(const std::string& projectName, ZoneCreationContext& context, ISearchPath* sourceSearchPath) const
|
bool ProcessZoneDefinitionIgnores(const std::string& projectName, ZoneCreationContext& context, ISearchPath* sourceSearchPath) const
|
||||||
{
|
{
|
||||||
if (context.m_definition->m_ignores.empty())
|
if (context.m_definition->m_ignores.empty())
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
#include "SearchPath/ISearchPath.h"
|
#include "SearchPath/ISearchPath.h"
|
||||||
#include "Obj/Gdt/Gdt.h"
|
#include "Obj/Gdt/Gdt.h"
|
||||||
@ -16,7 +15,7 @@ public:
|
|||||||
ISearchPath* m_asset_search_path;
|
ISearchPath* m_asset_search_path;
|
||||||
ZoneDefinition* m_definition;
|
ZoneDefinition* m_definition;
|
||||||
std::vector<std::unique_ptr<Gdt>> m_gdt_files;
|
std::vector<std::unique_ptr<Gdt>> m_gdt_files;
|
||||||
std::vector<AssetListEntry> m_ignored_assets;
|
AssetList m_ignored_assets;
|
||||||
|
|
||||||
ZoneCreationContext();
|
ZoneCreationContext();
|
||||||
ZoneCreationContext(ISearchPath* assetSearchPath, ZoneDefinition* definition);
|
ZoneCreationContext(ISearchPath* assetSearchPath, ZoneDefinition* definition);
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
#include "SequenceZoneDefinitionAssetList.h"
|
||||||
|
|
||||||
|
#include "Parsing/ZoneDefinition/Matcher/ZoneDefinitionMatcherFactory.h"
|
||||||
|
|
||||||
|
SequenceZoneDefinitionAssetList::SequenceZoneDefinitionAssetList()
|
||||||
|
{
|
||||||
|
const ZoneDefinitionMatcherFactory create(this);
|
||||||
|
|
||||||
|
AddMatchers({
|
||||||
|
create.Keyword("assetlist"),
|
||||||
|
create.Char(','),
|
||||||
|
create.Field().Capture(CAPTURE_ASSET_LIST_NAME)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void SequenceZoneDefinitionAssetList::ProcessMatch(ZoneDefinition* state, SequenceResult<ZoneDefinitionParserValue>& result) const
|
||||||
|
{
|
||||||
|
state->m_asset_lists.emplace_back(result.NextCapture(CAPTURE_ASSET_LIST_NAME).FieldValue());
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Parsing/ZoneDefinition/ZoneDefinitionParser.h"
|
||||||
|
|
||||||
|
class SequenceZoneDefinitionAssetList final : public ZoneDefinitionParser::sequence_t
|
||||||
|
{
|
||||||
|
static constexpr auto CAPTURE_ASSET_LIST_NAME = 1;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void ProcessMatch(ZoneDefinition* state, SequenceResult<ZoneDefinitionParserValue>& result) const override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
SequenceZoneDefinitionAssetList();
|
||||||
|
};
|
@ -1,5 +1,6 @@
|
|||||||
#include "ZoneDefinitionParser.h"
|
#include "ZoneDefinitionParser.h"
|
||||||
|
|
||||||
|
#include "Sequence/SequenceZoneDefinitionAssetList.h"
|
||||||
#include "Sequence/SequenceZoneDefinitionEntry.h"
|
#include "Sequence/SequenceZoneDefinitionEntry.h"
|
||||||
#include "Sequence/SequenceZoneDefinitionIgnore.h"
|
#include "Sequence/SequenceZoneDefinitionIgnore.h"
|
||||||
#include "Sequence/SequenceZoneDefinitionInclude.h"
|
#include "Sequence/SequenceZoneDefinitionInclude.h"
|
||||||
@ -16,6 +17,7 @@ const std::vector<AbstractParser<ZoneDefinitionParserValue, ZoneDefinition>::seq
|
|||||||
new SequenceZoneDefinitionMetaData(),
|
new SequenceZoneDefinitionMetaData(),
|
||||||
new SequenceZoneDefinitionInclude(),
|
new SequenceZoneDefinitionInclude(),
|
||||||
new SequenceZoneDefinitionIgnore(),
|
new SequenceZoneDefinitionIgnore(),
|
||||||
|
new SequenceZoneDefinitionAssetList(),
|
||||||
new SequenceZoneDefinitionEntry()
|
new SequenceZoneDefinitionEntry()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
class AssetListEntry
|
class AssetListEntry
|
||||||
{
|
{
|
||||||
@ -10,3 +11,9 @@ public:
|
|||||||
AssetListEntry();
|
AssetListEntry();
|
||||||
AssetListEntry(std::string type, std::string name);
|
AssetListEntry(std::string type, std::string name);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class AssetList
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::vector<AssetListEntry> m_entries;
|
||||||
|
};
|
@ -29,7 +29,15 @@ void ZoneDefinition::AddMetaData(std::string key, std::string value)
|
|||||||
m_metadata_lookup.emplace(std::make_pair(metaDataPtr->m_key, metaDataPtr));
|
m_metadata_lookup.emplace(std::make_pair(metaDataPtr->m_key, metaDataPtr));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneDefinition::Include(ZoneDefinition& definitionToInclude)
|
void ZoneDefinition::Include(const AssetList& assetListToInclude)
|
||||||
|
{
|
||||||
|
for (const auto& entry : assetListToInclude.m_entries)
|
||||||
|
{
|
||||||
|
m_assets.emplace_back(entry.m_type, entry.m_name, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZoneDefinition::Include(const ZoneDefinition& definitionToInclude)
|
||||||
{
|
{
|
||||||
for (const auto& metaData : definitionToInclude.m_metadata)
|
for (const auto& metaData : definitionToInclude.m_metadata)
|
||||||
{
|
{
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "Zone/AssetList/AssetList.h"
|
||||||
|
|
||||||
class ZoneDefinitionEntry
|
class ZoneDefinitionEntry
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -33,9 +35,11 @@ public:
|
|||||||
std::vector<std::unique_ptr<ZoneMetaDataEntry>> m_metadata;
|
std::vector<std::unique_ptr<ZoneMetaDataEntry>> m_metadata;
|
||||||
std::unordered_multimap<std::string, ZoneMetaDataEntry*> m_metadata_lookup;
|
std::unordered_multimap<std::string, ZoneMetaDataEntry*> m_metadata_lookup;
|
||||||
std::vector<std::string> m_includes;
|
std::vector<std::string> m_includes;
|
||||||
|
std::vector<std::string> m_asset_lists;
|
||||||
std::vector<std::string> m_ignores;
|
std::vector<std::string> m_ignores;
|
||||||
std::vector<ZoneDefinitionEntry> m_assets;
|
std::vector<ZoneDefinitionEntry> m_assets;
|
||||||
|
|
||||||
void AddMetaData(std::string key, std::string value);
|
void AddMetaData(std::string key, std::string value);
|
||||||
void Include(ZoneDefinition& definitionToInclude);
|
void Include(const AssetList& assetListToInclude);
|
||||||
|
void Include(const ZoneDefinition& definitionToInclude);
|
||||||
};
|
};
|
Loading…
x
Reference in New Issue
Block a user