mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
feat: automatically add ipak_read kvp when creating ipak
This commit is contained in:
parent
2313da1c12
commit
ac43b646cc
@ -7,6 +7,7 @@
|
||||
#include "Utils/Alignment.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <format>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
@ -394,6 +395,16 @@ void IPakToCreate::Build(ISearchPath& searchPath, const std::filesystem::path& o
|
||||
std::cout << std::format("Created ipak {} with {} entries\n", m_name, m_image_names.size());
|
||||
}
|
||||
|
||||
IPakCreator::IPakCreator()
|
||||
: m_kvp_creator(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
void IPakCreator::Inject(ZoneAssetCreationInjection& inject)
|
||||
{
|
||||
m_kvp_creator = &inject.m_zone_states.GetZoneAssetCreationState<KeyValuePairsCreator>();
|
||||
}
|
||||
|
||||
IPakToCreate* IPakCreator::GetOrAddIPak(const std::string& ipakName)
|
||||
{
|
||||
const auto existingIPak = m_ipak_lookup.find(ipakName);
|
||||
@ -404,6 +415,9 @@ IPakToCreate* IPakCreator::GetOrAddIPak(const std::string& ipakName)
|
||||
auto* result = newIPak.get();
|
||||
m_ipaks.emplace_back(std::move(newIPak));
|
||||
|
||||
assert(m_kvp_creator);
|
||||
m_kvp_creator->AddKeyValuePair(CommonKeyValuePair("ipak_read", ipakName));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Asset/IZoneAssetCreationState.h"
|
||||
#include "KeyValuePairs/KeyValuePairsCreator.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
#include <filesystem>
|
||||
@ -24,10 +25,15 @@ private:
|
||||
class IPakCreator : public IZoneAssetCreationState
|
||||
{
|
||||
public:
|
||||
IPakCreator();
|
||||
|
||||
void Inject(ZoneAssetCreationInjection& inject) override;
|
||||
|
||||
IPakToCreate* GetOrAddIPak(const std::string& ipakName);
|
||||
void Finalize(ISearchPath& searchPath, const std::filesystem::path& outPath);
|
||||
|
||||
private:
|
||||
KeyValuePairsCreator* m_kvp_creator;
|
||||
std::unordered_map<std::string, IPakToCreate*> m_ipak_lookup;
|
||||
std::vector<std::unique_ptr<IPakToCreate>> m_ipaks;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user