mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-11 23:38:09 -05:00
chore: consider specified obj containers when post processing
This commit is contained in:
@ -1,17 +1,43 @@
|
||||
#include "IwdCreator.h"
|
||||
|
||||
#include "Utils/FileToZlibWrapper.h"
|
||||
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
|
||||
void IwdCreator::AddFile(std::string filePath)
|
||||
IwdToCreate::IwdToCreate(std::string name)
|
||||
: m_name(std::move(name))
|
||||
{
|
||||
}
|
||||
|
||||
void IwdToCreate::AddFile(std::string filePath)
|
||||
{
|
||||
m_file_paths.emplace_back(std::move(filePath));
|
||||
}
|
||||
|
||||
void IwdCreator::Finalize(ISearchPath& searchPath, const std::filesystem::path& outPath)
|
||||
void IwdToCreate::Build(ISearchPath& searchPath, const std::filesystem::path& outPath)
|
||||
{
|
||||
std::cout << std::format("Creating iwd with {} entries:\n", m_file_paths.size());
|
||||
std::cout << std::format("Creating iwd {} with {} entries:\n", m_name, m_file_paths.size());
|
||||
|
||||
for (const auto& filePath : m_file_paths)
|
||||
std::cout << std::format(" {}\n", filePath);
|
||||
}
|
||||
|
||||
IwdToCreate* IwdCreator::GetOrAddIwd(const std::string& iwdName)
|
||||
{
|
||||
const auto existingIwd = m_iwd_lookup.find(iwdName);
|
||||
if (existingIwd != m_iwd_lookup.end())
|
||||
return existingIwd->second;
|
||||
|
||||
auto newIwd = std::make_unique<IwdToCreate>(iwdName);
|
||||
auto* result = newIwd.get();
|
||||
m_iwds.emplace_back(std::move(newIwd));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void IwdCreator::Finalize(ISearchPath& searchPath, const std::filesystem::path& outPath)
|
||||
{
|
||||
for (const auto& iwdToCreate : m_iwds)
|
||||
iwdToCreate->Build(searchPath, outPath);
|
||||
}
|
||||
|
@ -4,13 +4,30 @@
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
class IwdToCreate
|
||||
{
|
||||
public:
|
||||
explicit IwdToCreate(std::string name);
|
||||
|
||||
void AddFile(std::string filePath);
|
||||
void Build(ISearchPath& searchPath, const std::filesystem::path& outPath);
|
||||
|
||||
private:
|
||||
std::string m_name;
|
||||
std::vector<std::string> m_file_paths;
|
||||
};
|
||||
|
||||
class IwdCreator : public IZoneAssetLoaderState
|
||||
{
|
||||
public:
|
||||
void AddFile(std::string filePath);
|
||||
IwdToCreate* GetOrAddIwd(const std::string& iwdName);
|
||||
void Finalize(ISearchPath& searchPath, const std::filesystem::path& outPath);
|
||||
|
||||
private:
|
||||
std::vector<std::string> m_file_paths;
|
||||
std::unordered_map<std::string, IwdToCreate*> m_iwd_lookup;
|
||||
std::vector<std::unique_ptr<IwdToCreate>> m_iwds;
|
||||
};
|
||||
|
Reference in New Issue
Block a user