mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-11 07:18:11 -05:00
chore: adjust asset creation process to use separated AssetCreators
This commit is contained in:
@ -2,7 +2,4 @@
|
||||
|
||||
using namespace IW3;
|
||||
|
||||
ObjCompilerResult ObjCompiler::CompileAssetForZone(AssetLoadingContext& context, asset_type_t assetType, const std::string& assetName) const
|
||||
{
|
||||
return ObjCompilerResult::NO_COMPILATION_DONE;
|
||||
}
|
||||
void ObjCompiler::ConfigureCreatorCollection(AssetCreatorCollection& collection, Zone& zone, const ZoneDefinition& zoneDefinition) const {}
|
||||
|
@ -7,6 +7,6 @@ namespace IW3
|
||||
class ObjCompiler final : public IObjCompiler
|
||||
{
|
||||
public:
|
||||
ObjCompilerResult CompileAssetForZone(AssetLoadingContext& context, asset_type_t assetType, const std::string& assetName) const override;
|
||||
void ConfigureCreatorCollection(AssetCreatorCollection& collection, Zone& zone, const ZoneDefinition& zoneDefinition) const override;
|
||||
};
|
||||
} // namespace IW3
|
||||
|
@ -2,7 +2,4 @@
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
ObjCompilerResult ObjCompiler::CompileAssetForZone(AssetLoadingContext& context, asset_type_t assetType, const std::string& assetName) const
|
||||
{
|
||||
return ObjCompilerResult::NO_COMPILATION_DONE;
|
||||
}
|
||||
void ObjCompiler::ConfigureCreatorCollection(AssetCreatorCollection& collection, Zone& zone, const ZoneDefinition& zoneDefinition) const {}
|
||||
|
@ -7,6 +7,6 @@ namespace IW4
|
||||
class ObjCompiler final : public IObjCompiler
|
||||
{
|
||||
public:
|
||||
ObjCompilerResult CompileAssetForZone(AssetLoadingContext& context, asset_type_t assetType, const std::string& assetName) const override;
|
||||
void ConfigureCreatorCollection(AssetCreatorCollection& collection, Zone& zone, const ZoneDefinition& zoneDefinition) const override;
|
||||
};
|
||||
} // namespace IW4
|
||||
|
@ -2,7 +2,4 @@
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
ObjCompilerResult ObjCompiler::CompileAssetForZone(AssetLoadingContext& context, asset_type_t assetType, const std::string& assetName) const
|
||||
{
|
||||
return ObjCompilerResult::NO_COMPILATION_DONE;
|
||||
}
|
||||
void ObjCompiler::ConfigureCreatorCollection(AssetCreatorCollection& collection, Zone& zone, const ZoneDefinition& zoneDefinition) const {}
|
||||
|
@ -7,6 +7,6 @@ namespace IW5
|
||||
class ObjCompiler final : public IObjCompiler
|
||||
{
|
||||
public:
|
||||
ObjCompilerResult CompileAssetForZone(AssetLoadingContext& context, asset_type_t assetType, const std::string& assetName) const override;
|
||||
void ConfigureCreatorCollection(AssetCreatorCollection& collection, Zone& zone, const ZoneDefinition& zoneDefinition) const override;
|
||||
};
|
||||
} // namespace IW5
|
||||
|
@ -2,7 +2,4 @@
|
||||
|
||||
using namespace T5;
|
||||
|
||||
ObjCompilerResult ObjCompiler::CompileAssetForZone(AssetLoadingContext& context, asset_type_t assetType, const std::string& assetName) const
|
||||
{
|
||||
return ObjCompilerResult::NO_COMPILATION_DONE;
|
||||
}
|
||||
void ObjCompiler::ConfigureCreatorCollection(AssetCreatorCollection& collection, Zone& zone, const ZoneDefinition& zoneDefinition) const {}
|
||||
|
@ -7,6 +7,6 @@ namespace T5
|
||||
class ObjCompiler final : public IObjCompiler
|
||||
{
|
||||
public:
|
||||
ObjCompilerResult CompileAssetForZone(AssetLoadingContext& context, asset_type_t assetType, const std::string& assetName) const override;
|
||||
void ConfigureCreatorCollection(AssetCreatorCollection& collection, Zone& zone, const ZoneDefinition& zoneDefinition) const override;
|
||||
};
|
||||
} // namespace T5
|
||||
|
0
src/ObjCompiling/Game/T6/Image/ImageCompilerT6.cpp
Normal file
0
src/ObjCompiling/Game/T6/Image/ImageCompilerT6.cpp
Normal file
0
src/ObjCompiling/Game/T6/Image/ImageCompilerT6.h
Normal file
0
src/ObjCompiling/Game/T6/Image/ImageCompilerT6.h
Normal file
@ -0,0 +1,69 @@
|
||||
#include "KeyValuePairsCreator.h"
|
||||
|
||||
#include "Game/T6/CommonT6.h"
|
||||
#include "Game/T6/T6.h"
|
||||
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
|
||||
using namespace T6;
|
||||
|
||||
KeyValuePairsCreator::KeyValuePairsCreator(const Zone& zone, const ZoneDefinition& zoneDefinition)
|
||||
: m_zone(zone),
|
||||
m_zone_definition(zoneDefinition)
|
||||
{
|
||||
}
|
||||
|
||||
AssetCreationResult KeyValuePairsCreator::CreateAsset(const std::string& assetName, AssetCreationContext& context)
|
||||
{
|
||||
return AssetCreationResult::NoAction();
|
||||
}
|
||||
|
||||
void KeyValuePairsCreator::FinalizeZone(AssetCreationContext& context)
|
||||
{
|
||||
std::vector<KeyValuePair> kvpList;
|
||||
auto& memory = *m_zone.GetMemory();
|
||||
|
||||
for (const auto& metaData : m_zone_definition.m_properties.m_properties)
|
||||
{
|
||||
if (metaData.first.rfind("level.", 0) == 0)
|
||||
{
|
||||
const std::string strValue = metaData.first.substr(std::char_traits<char>::length("level."));
|
||||
if (strValue.empty())
|
||||
continue;
|
||||
|
||||
int keyHash;
|
||||
if (strValue[0] == '@')
|
||||
{
|
||||
char* endPtr;
|
||||
keyHash = strtol(&strValue[1], &endPtr, 16);
|
||||
|
||||
if (endPtr != &strValue[strValue.size()])
|
||||
{
|
||||
std::cerr << std::format("Could not parse metadata key \"{}\" as hash\n", metaData.first);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
keyHash = Common::Com_HashKey(strValue.c_str(), 64);
|
||||
}
|
||||
|
||||
KeyValuePair kvp{keyHash, Common::Com_HashKey(m_zone.m_name.c_str(), 64), memory.Dup(metaData.second.c_str())};
|
||||
kvpList.push_back(kvp);
|
||||
}
|
||||
}
|
||||
|
||||
if (!kvpList.empty())
|
||||
{
|
||||
auto* kvps = memory.Create<KeyValuePairs>();
|
||||
kvps->name = memory.Dup(m_zone.m_name.c_str());
|
||||
kvps->numVariables = static_cast<int>(kvpList.size());
|
||||
kvps->keyValuePairs = m_zone.GetMemory()->Alloc<KeyValuePair>(kvpList.size());
|
||||
|
||||
for (auto i = 0u; i < kvpList.size(); i++)
|
||||
kvps->keyValuePairs[i] = kvpList[i];
|
||||
|
||||
context.AddAsset(AssetRegistration<AssetKeyValuePairs>(m_zone.m_name, kvps));
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "Asset/IAssetCreator.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Zone/Definition/ZoneDefinition.h"
|
||||
|
||||
namespace T6
|
||||
{
|
||||
class KeyValuePairsCreator : public AssetCreator<AssetKeyValuePairs>
|
||||
{
|
||||
public:
|
||||
KeyValuePairsCreator(const Zone& zone, const ZoneDefinition& zoneDefinition);
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override;
|
||||
void FinalizeZone(AssetCreationContext& context) override;
|
||||
|
||||
private:
|
||||
const Zone& m_zone;
|
||||
const ZoneDefinition& m_zone_definition;
|
||||
};
|
||||
} // namespace T6
|
@ -1,8 +1,7 @@
|
||||
#include "ObjCompilerT6.h"
|
||||
|
||||
#include "Game/T6/T6.h"
|
||||
|
||||
using namespace T6;
|
||||
|
||||
ObjCompilerResult ObjCompiler::CompileAssetForZone(AssetLoadingContext& context, asset_type_t assetType, const std::string& assetName) const
|
||||
{
|
||||
return ObjCompilerResult::NO_COMPILATION_DONE;
|
||||
}
|
||||
void ObjCompiler::ConfigureCreatorCollection(AssetCreatorCollection& collection, Zone& zone, const ZoneDefinition& zoneDefinition) const {}
|
||||
|
@ -7,6 +7,6 @@ namespace T6
|
||||
class ObjCompiler final : public IObjCompiler
|
||||
{
|
||||
public:
|
||||
ObjCompilerResult CompileAssetForZone(AssetLoadingContext& context, asset_type_t assetType, const std::string& assetName) const override;
|
||||
void ConfigureCreatorCollection(AssetCreatorCollection& collection, Zone& zone, const ZoneDefinition& zoneDefinition) const override;
|
||||
};
|
||||
} // namespace T6
|
||||
|
@ -1,19 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "Asset/AssetCreatorCollection.h"
|
||||
#include "AssetLoading/AssetLoadingContext.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
#include "Zone/Definition/ZoneDefinition.h"
|
||||
#include "Zone/Zone.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
enum class ObjCompilerResult : std::uint8_t
|
||||
{
|
||||
COMPILED,
|
||||
NO_COMPILATION_DONE,
|
||||
FAILURE
|
||||
};
|
||||
|
||||
class IObjCompiler
|
||||
{
|
||||
public:
|
||||
@ -24,7 +19,7 @@ public:
|
||||
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;
|
||||
virtual void ConfigureCreatorCollection(AssetCreatorCollection& collection, Zone& zone, const ZoneDefinition& zoneDefinition) const = 0;
|
||||
|
||||
static const IObjCompiler* GetObjCompilerForGame(GameId game);
|
||||
};
|
||||
|
Reference in New Issue
Block a user