mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
chore: add ObjCompiling component
This commit is contained in:
parent
f9e0bdaa7b
commit
3803ae24f5
@ -126,6 +126,7 @@ include "src/ZoneLoading.lua"
|
|||||||
include "src/ZoneWriting.lua"
|
include "src/ZoneWriting.lua"
|
||||||
include "src/ZoneCommon.lua"
|
include "src/ZoneCommon.lua"
|
||||||
include "src/ObjCommon.lua"
|
include "src/ObjCommon.lua"
|
||||||
|
include "src/ObjCompiling.lua"
|
||||||
include "src/ObjImage.lua"
|
include "src/ObjImage.lua"
|
||||||
include "src/ObjLoading.lua"
|
include "src/ObjLoading.lua"
|
||||||
include "src/ObjWriting.lua"
|
include "src/ObjWriting.lua"
|
||||||
@ -143,6 +144,7 @@ group "Components"
|
|||||||
ZoneLoading:project()
|
ZoneLoading:project()
|
||||||
ZoneWriting:project()
|
ZoneWriting:project()
|
||||||
ObjCommon:project()
|
ObjCommon:project()
|
||||||
|
ObjCompiling:project()
|
||||||
ObjImage:project()
|
ObjImage:project()
|
||||||
ObjLoading:project()
|
ObjLoading:project()
|
||||||
ObjWriting:project()
|
ObjWriting:project()
|
||||||
|
@ -39,6 +39,7 @@ function Linker:project()
|
|||||||
self:include(includes)
|
self:include(includes)
|
||||||
Utils:include(includes)
|
Utils:include(includes)
|
||||||
ZoneLoading:include(includes)
|
ZoneLoading:include(includes)
|
||||||
|
ObjCompiling:include(includes)
|
||||||
ObjLoading:include(includes)
|
ObjLoading:include(includes)
|
||||||
ObjWriting:include(includes)
|
ObjWriting:include(includes)
|
||||||
ZoneWriting:include(includes)
|
ZoneWriting:include(includes)
|
||||||
@ -46,6 +47,7 @@ function Linker:project()
|
|||||||
Raw:use()
|
Raw:use()
|
||||||
|
|
||||||
links:linkto(Utils)
|
links:linkto(Utils)
|
||||||
|
links:linkto(ObjCompiling)
|
||||||
links:linkto(ZoneLoading)
|
links:linkto(ZoneLoading)
|
||||||
links:linkto(ZoneWriting)
|
links:linkto(ZoneWriting)
|
||||||
links:linkto(ObjLoading)
|
links:linkto(ObjLoading)
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
#include "ObjContainer/IPak/IPakWriter.h"
|
#include "ObjContainer/IPak/IPakWriter.h"
|
||||||
#include "ObjContainer/IWD/IWD.h"
|
#include "ObjContainer/IWD/IWD.h"
|
||||||
#include "ObjContainer/SoundBank/SoundBankWriter.h"
|
#include "ObjContainer/SoundBank/SoundBankWriter.h"
|
||||||
#include "ObjLoading.h"
|
|
||||||
#include "ObjWriting.h"
|
#include "ObjWriting.h"
|
||||||
#include "SearchPath/SearchPaths.h"
|
#include "SearchPath/SearchPaths.h"
|
||||||
#include "Utils/ObjFileStream.h"
|
#include "Utils/ObjFileStream.h"
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "Game/IW5/ZoneCreatorIW5.h"
|
#include "Game/IW5/ZoneCreatorIW5.h"
|
||||||
#include "Game/T5/ZoneCreatorT5.h"
|
#include "Game/T5/ZoneCreatorT5.h"
|
||||||
#include "Game/T6/ZoneCreatorT6.h"
|
#include "Game/T6/ZoneCreatorT6.h"
|
||||||
|
#include "IObjCompiler.h"
|
||||||
#include "IObjLoader.h"
|
#include "IObjLoader.h"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
@ -84,11 +85,19 @@ std::unique_ptr<Zone> IZoneCreator::CreateZoneForDefinition(ZoneCreationContext&
|
|||||||
|
|
||||||
HandleMetadata(*zone, context);
|
HandleMetadata(*zone, context);
|
||||||
|
|
||||||
|
const auto* objCompiler = IObjCompiler::GetObjCompilerForGame(gameId);
|
||||||
const auto* objLoader = IObjLoader::GetObjLoaderForGame(gameId);
|
const auto* objLoader = IObjLoader::GetObjLoaderForGame(gameId);
|
||||||
for (const auto& assetEntry : context.m_definition->m_assets)
|
for (const auto& assetEntry : context.m_definition->m_assets)
|
||||||
{
|
{
|
||||||
if (!objLoader->LoadAssetForZone(assetLoadingContext, assetEntry.m_asset_type, assetEntry.m_asset_name))
|
const auto compilerResult = objCompiler->CompileAssetForZone(assetLoadingContext, assetEntry.m_asset_type, assetEntry.m_asset_name);
|
||||||
|
if (compilerResult == ObjCompilerResult::FAILURE)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
if (compilerResult == ObjCompilerResult::NO_COMPILATION_DONE)
|
||||||
|
{
|
||||||
|
if (!objLoader->LoadAssetForZone(assetLoadingContext, assetEntry.m_asset_type, assetEntry.m_asset_name))
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
objLoader->FinalizeAssetsForZone(assetLoadingContext);
|
objLoader->FinalizeAssetsForZone(assetLoadingContext);
|
||||||
|
56
src/ObjCompiling.lua
Normal file
56
src/ObjCompiling.lua
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
ObjCompiling = {}
|
||||||
|
|
||||||
|
function ObjCompiling:include(includes)
|
||||||
|
if includes:handle(self:name()) then
|
||||||
|
ObjCommon:include(includes)
|
||||||
|
ObjLoading:include(includes)
|
||||||
|
ObjImage:include(includes)
|
||||||
|
ZoneCommon:include(includes)
|
||||||
|
includedirs {
|
||||||
|
path.join(ProjectFolder(), "ObjCompiling")
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function ObjCompiling:link(links)
|
||||||
|
links:add(self:name())
|
||||||
|
links:linkto(Utils)
|
||||||
|
links:linkto(ObjCommon)
|
||||||
|
links:linkto(ObjLoading)
|
||||||
|
links:linkto(ObjImage)
|
||||||
|
links:linkto(ZoneCommon)
|
||||||
|
end
|
||||||
|
|
||||||
|
function ObjCompiling:use()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function ObjCompiling:name()
|
||||||
|
return "ObjCompiling"
|
||||||
|
end
|
||||||
|
|
||||||
|
function ObjCompiling:project()
|
||||||
|
local folder = ProjectFolder()
|
||||||
|
local includes = Includes:create()
|
||||||
|
|
||||||
|
project(self:name())
|
||||||
|
targetdir(TargetDirectoryLib)
|
||||||
|
location "%{wks.location}/src/%{prj.name}"
|
||||||
|
kind "StaticLib"
|
||||||
|
language "C++"
|
||||||
|
|
||||||
|
files {
|
||||||
|
path.join(folder, "ObjCompiling/**.h"),
|
||||||
|
path.join(folder, "ObjCompiling/**.cpp")
|
||||||
|
}
|
||||||
|
|
||||||
|
vpaths {
|
||||||
|
["*"] = {
|
||||||
|
path.join(folder, "ObjCompiling")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self:include(includes)
|
||||||
|
Utils:include(includes)
|
||||||
|
json:include(includes)
|
||||||
|
end
|
8
src/ObjCompiling/Game/IW3/ObjCompilerIW3.cpp
Normal file
8
src/ObjCompiling/Game/IW3/ObjCompilerIW3.cpp
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#include "ObjCompilerIW3.h"
|
||||||
|
|
||||||
|
using namespace IW3;
|
||||||
|
|
||||||
|
ObjCompilerResult ObjCompiler::CompileAssetForZone(AssetLoadingContext& context, asset_type_t assetType, const std::string& assetName) const
|
||||||
|
{
|
||||||
|
return ObjCompilerResult::NO_COMPILATION_DONE;
|
||||||
|
}
|
12
src/ObjCompiling/Game/IW3/ObjCompilerIW3.h
Normal file
12
src/ObjCompiling/Game/IW3/ObjCompilerIW3.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "IObjCompiler.h"
|
||||||
|
|
||||||
|
namespace IW3
|
||||||
|
{
|
||||||
|
class ObjCompiler final : public IObjCompiler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ObjCompilerResult CompileAssetForZone(AssetLoadingContext& context, asset_type_t assetType, const std::string& assetName) const override;
|
||||||
|
};
|
||||||
|
} // namespace IW3
|
8
src/ObjCompiling/Game/IW4/ObjCompilerIW4.cpp
Normal file
8
src/ObjCompiling/Game/IW4/ObjCompilerIW4.cpp
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#include "ObjCompilerIW4.h"
|
||||||
|
|
||||||
|
using namespace IW4;
|
||||||
|
|
||||||
|
ObjCompilerResult ObjCompiler::CompileAssetForZone(AssetLoadingContext& context, asset_type_t assetType, const std::string& assetName) const
|
||||||
|
{
|
||||||
|
return ObjCompilerResult::NO_COMPILATION_DONE;
|
||||||
|
}
|
12
src/ObjCompiling/Game/IW4/ObjCompilerIW4.h
Normal file
12
src/ObjCompiling/Game/IW4/ObjCompilerIW4.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "IObjCompiler.h"
|
||||||
|
|
||||||
|
namespace IW4
|
||||||
|
{
|
||||||
|
class ObjCompiler final : public IObjCompiler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ObjCompilerResult CompileAssetForZone(AssetLoadingContext& context, asset_type_t assetType, const std::string& assetName) const override;
|
||||||
|
};
|
||||||
|
} // namespace IW4
|
8
src/ObjCompiling/Game/IW5/ObjCompilerIW5.cpp
Normal file
8
src/ObjCompiling/Game/IW5/ObjCompilerIW5.cpp
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#include "ObjCompilerIW5.h"
|
||||||
|
|
||||||
|
using namespace IW5;
|
||||||
|
|
||||||
|
ObjCompilerResult ObjCompiler::CompileAssetForZone(AssetLoadingContext& context, asset_type_t assetType, const std::string& assetName) const
|
||||||
|
{
|
||||||
|
return ObjCompilerResult::NO_COMPILATION_DONE;
|
||||||
|
}
|
12
src/ObjCompiling/Game/IW5/ObjCompilerIW5.h
Normal file
12
src/ObjCompiling/Game/IW5/ObjCompilerIW5.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "IObjCompiler.h"
|
||||||
|
|
||||||
|
namespace IW5
|
||||||
|
{
|
||||||
|
class ObjCompiler final : public IObjCompiler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ObjCompilerResult CompileAssetForZone(AssetLoadingContext& context, asset_type_t assetType, const std::string& assetName) const override;
|
||||||
|
};
|
||||||
|
} // namespace IW5
|
8
src/ObjCompiling/Game/T5/ObjCompilerT5.cpp
Normal file
8
src/ObjCompiling/Game/T5/ObjCompilerT5.cpp
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#include "ObjCompilerT5.h"
|
||||||
|
|
||||||
|
using namespace T5;
|
||||||
|
|
||||||
|
ObjCompilerResult ObjCompiler::CompileAssetForZone(AssetLoadingContext& context, asset_type_t assetType, const std::string& assetName) const
|
||||||
|
{
|
||||||
|
return ObjCompilerResult::NO_COMPILATION_DONE;
|
||||||
|
}
|
12
src/ObjCompiling/Game/T5/ObjCompilerT5.h
Normal file
12
src/ObjCompiling/Game/T5/ObjCompilerT5.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "IObjCompiler.h"
|
||||||
|
|
||||||
|
namespace T5
|
||||||
|
{
|
||||||
|
class ObjCompiler final : public IObjCompiler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ObjCompilerResult CompileAssetForZone(AssetLoadingContext& context, asset_type_t assetType, const std::string& assetName) const override;
|
||||||
|
};
|
||||||
|
} // namespace T5
|
8
src/ObjCompiling/Game/T6/ObjCompilerT6.cpp
Normal file
8
src/ObjCompiling/Game/T6/ObjCompilerT6.cpp
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#include "ObjCompilerT6.h"
|
||||||
|
|
||||||
|
using namespace T6;
|
||||||
|
|
||||||
|
ObjCompilerResult ObjCompiler::CompileAssetForZone(AssetLoadingContext& context, asset_type_t assetType, const std::string& assetName) const
|
||||||
|
{
|
||||||
|
return ObjCompilerResult::NO_COMPILATION_DONE;
|
||||||
|
}
|
12
src/ObjCompiling/Game/T6/ObjCompilerT6.h
Normal file
12
src/ObjCompiling/Game/T6/ObjCompilerT6.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "IObjCompiler.h"
|
||||||
|
|
||||||
|
namespace T6
|
||||||
|
{
|
||||||
|
class ObjCompiler final : public IObjCompiler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ObjCompilerResult CompileAssetForZone(AssetLoadingContext& context, asset_type_t assetType, const std::string& assetName) const override;
|
||||||
|
};
|
||||||
|
} // namespace T6
|
27
src/ObjCompiling/IObjCompiler.cpp
Normal file
27
src/ObjCompiling/IObjCompiler.cpp
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#include "IObjCompiler.h"
|
||||||
|
|
||||||
|
#include "Game/IW3/ObjCompilerIW3.h"
|
||||||
|
#include "Game/IW4/ObjCompilerIW4.h"
|
||||||
|
#include "Game/IW5/ObjCompilerIW5.h"
|
||||||
|
#include "Game/T5/ObjCompilerT5.h"
|
||||||
|
#include "Game/T6/ObjCompilerT6.h"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
const IObjCompiler* IObjCompiler::GetObjCompilerForGame(GameId game)
|
||||||
|
{
|
||||||
|
static const IObjCompiler* objCompilers[static_cast<unsigned>(GameId::COUNT)]{
|
||||||
|
new IW3::ObjCompiler(),
|
||||||
|
new IW4::ObjCompiler(),
|
||||||
|
new IW5::ObjCompiler(),
|
||||||
|
new T5::ObjCompiler(),
|
||||||
|
new T6::ObjCompiler(),
|
||||||
|
};
|
||||||
|
static_assert(std::extent_v<decltype(objCompilers)> == static_cast<unsigned>(GameId::COUNT));
|
||||||
|
|
||||||
|
assert(static_cast<unsigned>(game) < static_cast<unsigned>(GameId::COUNT));
|
||||||
|
const auto* result = objCompilers[static_cast<unsigned>(game)];
|
||||||
|
assert(result);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
30
src/ObjCompiling/IObjCompiler.h
Normal file
30
src/ObjCompiling/IObjCompiler.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "AssetLoading/AssetLoadingContext.h"
|
||||||
|
#include "SearchPath/ISearchPath.h"
|
||||||
|
#include "Zone/Zone.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
enum class ObjCompilerResult : std::uint8_t
|
||||||
|
{
|
||||||
|
COMPILED,
|
||||||
|
NO_COMPILATION_DONE,
|
||||||
|
FAILURE
|
||||||
|
};
|
||||||
|
|
||||||
|
class IObjCompiler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IObjCompiler() = default;
|
||||||
|
virtual ~IObjCompiler() = default;
|
||||||
|
IObjCompiler(const IObjCompiler& other) = default;
|
||||||
|
IObjCompiler(IObjCompiler&& other) noexcept = default;
|
||||||
|
IObjCompiler& operator=(const IObjCompiler& other) = default;
|
||||||
|
IObjCompiler& operator=(IObjCompiler&& other) noexcept = default;
|
||||||
|
|
||||||
|
virtual ObjCompilerResult CompileAssetForZone(AssetLoadingContext& context, asset_type_t assetType, const std::string& assetName) const = 0;
|
||||||
|
|
||||||
|
static const IObjCompiler* GetObjCompilerForGame(GameId game);
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user