mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
Add possibility to override zone name in zone definition
This commit is contained in:
parent
e36367fe01
commit
bb94162be4
@ -64,7 +64,7 @@ bool ZoneCreator::SupportsGame(const std::string& gameName) const
|
|||||||
|
|
||||||
std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext& context) const
|
std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext& context) const
|
||||||
{
|
{
|
||||||
auto zone = std::make_unique<Zone>(context.m_zone_name, 0, &g_GameIW3);
|
auto zone = std::make_unique<Zone>(context.m_definition->m_name, 0, &g_GameIW3);
|
||||||
CreateZoneAssetPools(zone.get());
|
CreateZoneAssetPools(zone.get());
|
||||||
|
|
||||||
for (const auto& assetEntry : context.m_definition->m_assets)
|
for (const auto& assetEntry : context.m_definition->m_assets)
|
||||||
|
@ -63,7 +63,7 @@ bool ZoneCreator::SupportsGame(const std::string& gameName) const
|
|||||||
|
|
||||||
std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext& context) const
|
std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext& context) const
|
||||||
{
|
{
|
||||||
auto zone = std::make_unique<Zone>(context.m_zone_name, 0, &g_GameIW4);
|
auto zone = std::make_unique<Zone>(context.m_definition->m_name, 0, &g_GameIW4);
|
||||||
CreateZoneAssetPools(zone.get());
|
CreateZoneAssetPools(zone.get());
|
||||||
|
|
||||||
for (const auto& assetEntry : context.m_definition->m_assets)
|
for (const auto& assetEntry : context.m_definition->m_assets)
|
||||||
|
@ -63,7 +63,7 @@ bool ZoneCreator::SupportsGame(const std::string& gameName) const
|
|||||||
|
|
||||||
std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext& context) const
|
std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext& context) const
|
||||||
{
|
{
|
||||||
auto zone = std::make_unique<Zone>(context.m_zone_name, 0, &g_GameIW5);
|
auto zone = std::make_unique<Zone>(context.m_definition->m_name, 0, &g_GameIW5);
|
||||||
CreateZoneAssetPools(zone.get());
|
CreateZoneAssetPools(zone.get());
|
||||||
|
|
||||||
for (const auto& assetEntry : context.m_definition->m_assets)
|
for (const auto& assetEntry : context.m_definition->m_assets)
|
||||||
|
@ -64,7 +64,7 @@ bool ZoneCreator::SupportsGame(const std::string& gameName) const
|
|||||||
|
|
||||||
std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext& context) const
|
std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext& context) const
|
||||||
{
|
{
|
||||||
auto zone = std::make_unique<Zone>(context.m_zone_name, 0, &g_GameT5);
|
auto zone = std::make_unique<Zone>(context.m_definition->m_name, 0, &g_GameT5);
|
||||||
CreateZoneAssetPools(zone.get());
|
CreateZoneAssetPools(zone.get());
|
||||||
|
|
||||||
for (const auto& assetEntry : context.m_definition->m_assets)
|
for (const auto& assetEntry : context.m_definition->m_assets)
|
||||||
|
@ -118,7 +118,7 @@ bool ZoneCreator::SupportsGame(const std::string& gameName) const
|
|||||||
|
|
||||||
std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext& context) const
|
std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext& context) const
|
||||||
{
|
{
|
||||||
auto zone = std::make_unique<Zone>(context.m_zone_name, 0, &g_GameT6);
|
auto zone = std::make_unique<Zone>(context.m_definition->m_name, 0, &g_GameT6);
|
||||||
CreateZoneAssetPools(zone.get());
|
CreateZoneAssetPools(zone.get());
|
||||||
|
|
||||||
for (const auto& assetEntry : context.m_definition->m_assets)
|
for (const auto& assetEntry : context.m_definition->m_assets)
|
||||||
|
@ -42,6 +42,7 @@ const IZoneCreator* const ZONE_CREATORS[]
|
|||||||
|
|
||||||
class Linker::Impl
|
class Linker::Impl
|
||||||
{
|
{
|
||||||
|
static constexpr const char* METADATA_NAME = "name";
|
||||||
static constexpr const char* METADATA_GAME = "game";
|
static constexpr const char* METADATA_GAME = "game";
|
||||||
static constexpr const char* METADATA_GDT = "gdt";
|
static constexpr const char* METADATA_GDT = "gdt";
|
||||||
|
|
||||||
@ -277,6 +278,33 @@ class Linker::Impl
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool GetNameFromZoneDefinition(std::string& name, const std::string& projectName, const ZoneDefinition& zoneDefinition)
|
||||||
|
{
|
||||||
|
auto firstNameEntry = true;
|
||||||
|
const auto [rangeBegin, rangeEnd] = zoneDefinition.m_metadata_lookup.equal_range(METADATA_NAME);
|
||||||
|
for (auto i = rangeBegin; i != rangeEnd; ++i)
|
||||||
|
{
|
||||||
|
if (firstNameEntry)
|
||||||
|
{
|
||||||
|
name = i->second->m_value;
|
||||||
|
firstNameEntry = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (name != i->second->m_value)
|
||||||
|
{
|
||||||
|
std::cout << "Conflicting names in project \"" << projectName << "\": " << name << " != " << i->second << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (firstNameEntry)
|
||||||
|
name = projectName;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<ZoneDefinition> ReadZoneDefinition(const std::string& projectName, ISearchPath* sourceSearchPath) const
|
std::unique_ptr<ZoneDefinition> ReadZoneDefinition(const std::string& projectName, ISearchPath* sourceSearchPath) const
|
||||||
{
|
{
|
||||||
std::unique_ptr<ZoneDefinition> zoneDefinition;
|
std::unique_ptr<ZoneDefinition> zoneDefinition;
|
||||||
@ -299,6 +327,9 @@ class Linker::Impl
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!GetNameFromZoneDefinition(zoneDefinition->m_name, projectName, *zoneDefinition))
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
if (!IncludeAdditionalZoneDefinitions(projectName, *zoneDefinition, sourceSearchPath))
|
if (!IncludeAdditionalZoneDefinitions(projectName, *zoneDefinition, sourceSearchPath))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
@ -425,7 +456,7 @@ class Linker::Impl
|
|||||||
std::unique_ptr<Zone> CreateZoneForDefinition(const std::string& projectName, ZoneDefinition& zoneDefinition, ISearchPath* assetSearchPath, ISearchPath* gdtSearchPath,
|
std::unique_ptr<Zone> CreateZoneForDefinition(const std::string& projectName, ZoneDefinition& zoneDefinition, ISearchPath* assetSearchPath, ISearchPath* gdtSearchPath,
|
||||||
ISearchPath* sourceSearchPath) const
|
ISearchPath* sourceSearchPath) const
|
||||||
{
|
{
|
||||||
auto context = std::make_unique<ZoneCreationContext>(projectName, assetSearchPath, &zoneDefinition);
|
const auto context = std::make_unique<ZoneCreationContext>(assetSearchPath, &zoneDefinition);
|
||||||
if (!ProcessZoneDefinitionIgnores(projectName, *context, sourceSearchPath))
|
if (!ProcessZoneDefinitionIgnores(projectName, *context, sourceSearchPath))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
if (!GetGameNameFromZoneDefinition(context->m_game_name, projectName, zoneDefinition))
|
if (!GetGameNameFromZoneDefinition(context->m_game_name, projectName, zoneDefinition))
|
||||||
@ -461,6 +492,8 @@ class Linker::Impl
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::cout << "Created zone \"" << zoneFilePath.string() << "\"\n";
|
||||||
|
|
||||||
stream.close();
|
stream.close();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,8 @@ ZoneCreationContext::ZoneCreationContext()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ZoneCreationContext::ZoneCreationContext(std::string zoneName, ISearchPath* assetSearchPath, ZoneDefinition* definition)
|
ZoneCreationContext::ZoneCreationContext(ISearchPath* assetSearchPath, ZoneDefinition* definition)
|
||||||
: m_zone_name(std::move(zoneName)),
|
: m_asset_search_path(assetSearchPath),
|
||||||
m_asset_search_path(assetSearchPath),
|
|
||||||
m_definition(definition)
|
m_definition(definition)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
class ZoneCreationContext
|
class ZoneCreationContext
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::string m_zone_name;
|
|
||||||
std::string m_game_name;
|
std::string m_game_name;
|
||||||
ISearchPath* m_asset_search_path;
|
ISearchPath* m_asset_search_path;
|
||||||
ZoneDefinition* m_definition;
|
ZoneDefinition* m_definition;
|
||||||
@ -20,5 +19,5 @@ public:
|
|||||||
std::vector<AssetListEntry> m_ignored_assets;
|
std::vector<AssetListEntry> m_ignored_assets;
|
||||||
|
|
||||||
ZoneCreationContext();
|
ZoneCreationContext();
|
||||||
ZoneCreationContext(std::string zoneName, ISearchPath* assetSearchPath, ZoneDefinition* definition);
|
ZoneCreationContext(ISearchPath* assetSearchPath, ZoneDefinition* definition);
|
||||||
};
|
};
|
||||||
|
@ -29,6 +29,7 @@ public:
|
|||||||
class ZoneDefinition
|
class ZoneDefinition
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
std::string m_name;
|
||||||
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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user