2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2026-01-10 18:51:49 +00:00

chore: add ability for zcg to generate files once per template

This commit is contained in:
Jan Laupetin
2026-01-05 12:15:14 +00:00
parent 11fdb4ad59
commit 660f34df69
17 changed files with 166 additions and 53 deletions

View File

@@ -0,0 +1,31 @@
#include "OncePerTemplateRenderingContext.h"
#include <algorithm>
OncePerTemplateRenderingContext::OncePerTemplateRenderingContext(std::string game,
const Architecture gameArchitecture,
std::vector<const FastFileBlock*> fastFileBlocks)
: m_game(std::move(game)),
m_architecture_mismatch(gameArchitecture != OWN_ARCHITECTURE),
m_pointer_size(GetPointerSizeForArchitecture(gameArchitecture)),
m_blocks(std::move(fastFileBlocks)),
m_default_normal_block(nullptr),
m_default_temp_block(nullptr)
{
for (const auto* block : m_blocks)
{
if (block->m_is_default)
{
if (block->m_type == FastFileBlockType::NORMAL && m_default_normal_block == nullptr)
m_default_normal_block = block;
else if (block->m_type == FastFileBlockType::TEMP && m_default_temp_block == nullptr)
m_default_temp_block = block;
}
}
}
std::unique_ptr<OncePerTemplateRenderingContext> OncePerTemplateRenderingContext::BuildContext(const IDataRepository* repository)
{
return std::make_unique<OncePerTemplateRenderingContext>(
OncePerTemplateRenderingContext(repository->GetGameName(), repository->GetArchitecture(), repository->GetAllFastFileBlocks()));
}