2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-06-26 14:21:49 +00:00

feat: add post processors compiling iwds and ipaks

This commit is contained in:
Jan
2025-01-02 12:48:57 +01:00
parent b5937ef975
commit a7254aa11c
26 changed files with 480 additions and 34 deletions

View File

@ -257,9 +257,10 @@ class LinkerImpl final : public Linker
return true;
}
std::unique_ptr<Zone> CreateZoneForDefinition(LinkerPathManager& paths, const std::string& targetName, ZoneDefinition& zoneDefinition) const
std::unique_ptr<Zone> CreateZoneForDefinition(
LinkerPathManager& paths, const fs::path& outDir, const fs::path& cacheDir, const std::string& targetName, ZoneDefinition& zoneDefinition) const
{
ZoneCreationContext context(&zoneDefinition, &paths.m_asset_paths.GetSearchPaths());
ZoneCreationContext context(&zoneDefinition, &paths.m_asset_paths.GetSearchPaths(), outDir, cacheDir);
if (!ProcessZoneDefinitionIgnores(paths, targetName, context))
return nullptr;
if (!LoadGdtFilesFromZoneDefinition(context.m_gdt_files, zoneDefinition, &paths.m_gdt_paths.GetSearchPaths()))
@ -268,22 +269,18 @@ class LinkerImpl final : public Linker
return zone_creator::CreateZoneForDefinition(zoneDefinition.m_game, context);
}
bool WriteZoneToFile(const LinkerPathManager& paths, const std::string& projectName, Zone* zone) const
bool WriteZoneToFile(const LinkerPathManager& paths, const fs::path& outDir, const std::string& projectName, Zone* zone) const
{
const fs::path zoneFolderPath(paths.m_linker_paths->BuildOutputFolderPath(projectName, zone->m_game->GetId()));
auto zoneFilePath(zoneFolderPath);
zoneFilePath.append(zone->m_name + ".ff");
auto zoneFilePath(outDir);
zoneFilePath.append(std::format("{}.ff", zone->m_name));
fs::create_directories(zoneFolderPath);
fs::create_directories(outDir);
std::ofstream stream(zoneFilePath, std::fstream::out | std::fstream::binary);
if (!stream.is_open())
return false;
if (m_args.m_verbose)
{
std::cout << std::format("Building zone \"{}\"\n", zoneFilePath.string());
}
std::cout << std::format("Building zone \"{}\"\n", zoneFilePath.string());
if (!ZoneWriting::WriteZone(stream, zone))
{
@ -300,12 +297,14 @@ class LinkerImpl final : public Linker
bool BuildFastFile(LinkerPathManager& paths, const std::string& projectName, const std::string& targetName, ZoneDefinition& zoneDefinition) const
{
SoundBankWriter::OutputPath = fs::path(paths.m_linker_paths->BuildOutputFolderPath(projectName, zoneDefinition.m_game));
const fs::path outDir(paths.m_linker_paths->BuildOutputFolderPath(projectName, zoneDefinition.m_game));
const fs::path cacheDir(paths.m_linker_paths->BuildCacheFolderPath(projectName, zoneDefinition.m_game));
SoundBankWriter::OutputPath = outDir;
const auto zone = CreateZoneForDefinition(paths, targetName, zoneDefinition);
const auto zone = CreateZoneForDefinition(paths, outDir, cacheDir, targetName, zoneDefinition);
auto result = zone != nullptr;
if (zone)
result = WriteZoneToFile(paths, projectName, zone.get());
result = WriteZoneToFile(paths, outDir, projectName, zone.get());
return result;
}

View File

@ -1,13 +1,17 @@
#include "ZoneCreationContext.h"
namespace fs = std::filesystem;
ZoneCreationContext::ZoneCreationContext()
: m_definition(nullptr),
m_asset_search_path(nullptr)
{
}
ZoneCreationContext::ZoneCreationContext(ZoneDefinition* definition, ISearchPath* assetSearchPath)
ZoneCreationContext::ZoneCreationContext(ZoneDefinition* definition, ISearchPath* assetSearchPath, fs::path outDir, fs::path cacheDir)
: m_definition(definition),
m_asset_search_path(assetSearchPath)
m_asset_search_path(assetSearchPath),
m_out_dir(std::move(outDir)),
m_cache_dir(std::move(cacheDir))
{
}

View File

@ -4,6 +4,7 @@
#include "Zone/AssetList/AssetList.h"
#include "Zone/Definition/ZoneDefinition.h"
#include <filesystem>
#include <memory>
#include <vector>
@ -12,9 +13,11 @@ class ZoneCreationContext
public:
ZoneDefinition* m_definition;
ISearchPath* m_asset_search_path;
std::filesystem::path m_out_dir;
std::filesystem::path m_cache_dir;
std::vector<std::unique_ptr<Gdt>> m_gdt_files;
AssetList m_ignored_assets;
ZoneCreationContext();
ZoneCreationContext(ZoneDefinition* definition, ISearchPath* assetSearchPath);
ZoneCreationContext(ZoneDefinition* definition, ISearchPath* assetSearchPath, std::filesystem::path outDir, std::filesystem::path cacheDir);
};

View File

@ -64,7 +64,8 @@ namespace zone_creator
const auto* objLoader = IObjLoader::GetObjLoaderForGame(gameId);
AssetCreatorCollection creatorCollection(*zone);
objCompiler->ConfigureCreatorCollection(creatorCollection, *zone, *context.m_definition);
objCompiler->ConfigureCreatorCollection(
creatorCollection, *zone, *context.m_definition, *context.m_asset_search_path, lookup, context.m_out_dir, context.m_cache_dir);
objLoader->ConfigureCreatorCollection(creatorCollection, *zone, *context.m_asset_search_path, lookup);
AssetCreationContext creationContext(zone.get(), &creatorCollection, &ignoredAssetLookup);