mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-05 16:07:43 +00:00
Rename AssetLoading from Linker to ZoneCreation
This commit is contained in:
parent
43966e8e00
commit
a57201d78d
@ -1,20 +0,0 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "AssetLoadingContext.h"
|
||||
#include "Zone/Zone.h"
|
||||
|
||||
class IAssetLoader
|
||||
{
|
||||
public:
|
||||
IAssetLoader() = default;
|
||||
virtual ~IAssetLoader() = default;
|
||||
IAssetLoader(const IAssetLoader& other) = default;
|
||||
IAssetLoader(IAssetLoader&& other) noexcept = default;
|
||||
IAssetLoader& operator=(const IAssetLoader& other) = default;
|
||||
IAssetLoader& operator=(IAssetLoader&& other) noexcept = default;
|
||||
|
||||
_NODISCARD virtual bool SupportsGame(const std::string& gameName) const = 0;
|
||||
_NODISCARD virtual std::unique_ptr<Zone> CreateZoneForDefinition(AssetLoadingContext& context) const = 0;
|
||||
};
|
@ -1,16 +1,16 @@
|
||||
#include "AssetLoaderIW4.h"
|
||||
#include "ZoneCreatorIW4.h"
|
||||
|
||||
#include "Game/IW4/GameIW4.h"
|
||||
#include "Game/IW4/GameAssetPoolIW4.h"
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
bool AssetLoader::SupportsGame(const std::string& gameName) const
|
||||
bool ZoneCreator::SupportsGame(const std::string& gameName) const
|
||||
{
|
||||
return gameName == g_GameIW4.GetShortName();
|
||||
}
|
||||
|
||||
std::unique_ptr<Zone> AssetLoader::CreateZoneForDefinition(AssetLoadingContext& context) const
|
||||
std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext& context) const
|
||||
{
|
||||
auto zone = std::make_unique<Zone>(context.m_zone_name, 0, &g_GameIW4);
|
||||
zone->m_pools = std::make_unique<GameAssetPoolIW4>(zone.get(), zone->m_priority);
|
@ -1,12 +1,12 @@
|
||||
#pragma once
|
||||
#include "AssetLoading/IAssetLoader.h"
|
||||
#include "ZoneCreation/IZoneCreator.h"
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
class AssetLoader final : public IAssetLoader
|
||||
class ZoneCreator final : public IZoneCreator
|
||||
{
|
||||
public:
|
||||
_NODISCARD bool SupportsGame(const std::string& gameName) const override;
|
||||
_NODISCARD std::unique_ptr<Zone> CreateZoneForDefinition(AssetLoadingContext& context) const override;
|
||||
_NODISCARD std::unique_ptr<Zone> CreateZoneForDefinition(ZoneCreationContext& context) const override;
|
||||
};
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
#include "AssetLoaderT6.h"
|
||||
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Game/T6/GameT6.h"
|
||||
#include "Game/T6/GameAssetPoolT6.h"
|
||||
|
||||
using namespace T6;
|
||||
|
||||
bool AssetLoader::SupportsGame(const std::string& gameName) const
|
||||
{
|
||||
return gameName == g_GameT6.GetShortName();
|
||||
}
|
||||
|
||||
std::unique_ptr<Zone> AssetLoader::CreateZoneForDefinition(AssetLoadingContext& context) const
|
||||
{
|
||||
auto zone = std::make_unique<Zone>(context.m_zone_name, 0, &g_GameT6);
|
||||
zone->m_pools = std::make_unique<GameAssetPoolT6>(zone.get(), zone->m_priority);
|
||||
|
||||
for (auto assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++)
|
||||
zone->m_pools->InitPoolDynamic(assetType);
|
||||
|
||||
return zone;
|
||||
}
|
58
src/Linker/Game/T6/ZoneCreatorT6.cpp
Normal file
58
src/Linker/Game/T6/ZoneCreatorT6.cpp
Normal file
@ -0,0 +1,58 @@
|
||||
#include "ZoneCreatorT6.h"
|
||||
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Game/T6/GameT6.h"
|
||||
#include "Game/T6/GameAssetPoolT6.h"
|
||||
|
||||
using namespace T6;
|
||||
|
||||
namespace T6
|
||||
{
|
||||
class SpecifiedAsset
|
||||
{
|
||||
public:
|
||||
XAssetType m_type;
|
||||
std::string m_name;
|
||||
bool m_reference;
|
||||
};
|
||||
|
||||
class AssetLoaderImpl
|
||||
{
|
||||
ZoneCreationContext& m_context;
|
||||
|
||||
void CreateZoneAssetPools(Zone* zone) const
|
||||
{
|
||||
zone->m_pools = std::make_unique<GameAssetPoolT6>(zone, zone->m_priority);
|
||||
|
||||
for (auto assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++)
|
||||
zone->m_pools->InitPoolDynamic(assetType);
|
||||
}
|
||||
|
||||
public:
|
||||
explicit AssetLoaderImpl(ZoneCreationContext& context)
|
||||
: m_context(context)
|
||||
{
|
||||
}
|
||||
|
||||
std::unique_ptr<Zone> CreateZoneForDefinition()
|
||||
{
|
||||
auto zone = std::make_unique<Zone>(m_context.m_zone_name, 0, &g_GameT6);
|
||||
CreateZoneAssetPools(zone.get());
|
||||
|
||||
std::vector<SpecifiedAsset> specifiedAssets;
|
||||
|
||||
return zone;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
bool ZoneCreator::SupportsGame(const std::string& gameName) const
|
||||
{
|
||||
return gameName == g_GameT6.GetShortName();
|
||||
}
|
||||
|
||||
std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext& context) const
|
||||
{
|
||||
AssetLoaderImpl impl(context);
|
||||
return impl.CreateZoneForDefinition();
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
#pragma once
|
||||
#include "AssetLoading/IAssetLoader.h"
|
||||
#include "ZoneCreation/IZoneCreator.h"
|
||||
|
||||
namespace T6
|
||||
{
|
||||
class AssetLoader final : public IAssetLoader
|
||||
class ZoneCreator final : public IZoneCreator
|
||||
{
|
||||
public:
|
||||
_NODISCARD bool SupportsGame(const std::string& gameName) const override;
|
||||
_NODISCARD std::unique_ptr<Zone> CreateZoneForDefinition(AssetLoadingContext& context) const override;
|
||||
_NODISCARD std::unique_ptr<Zone> CreateZoneForDefinition(ZoneCreationContext& context) const override;
|
||||
};
|
||||
}
|
@ -15,10 +15,10 @@
|
||||
#include "SearchPath/SearchPathFilesystem.h"
|
||||
#include "ObjContainer/IWD/IWD.h"
|
||||
#include "LinkerArgs.h"
|
||||
#include "AssetLoading/AssetLoadingContext.h"
|
||||
#include "AssetLoading/IAssetLoader.h"
|
||||
#include "Game/IW4/AssetLoaderIW4.h"
|
||||
#include "Game/T6/AssetLoaderT6.h"
|
||||
#include "ZoneCreation/ZoneCreationContext.h"
|
||||
#include "ZoneCreation/IZoneCreator.h"
|
||||
#include "Game/IW4/ZoneCreatorIW4.h"
|
||||
#include "Game/T6/ZoneCreatorT6.h"
|
||||
|
||||
#include "Utils/ObjFileStream.h"
|
||||
#include "Zone/AssetList/AssetList.h"
|
||||
@ -27,10 +27,10 @@
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
const IAssetLoader* const ASSET_LOADERS[]
|
||||
const IZoneCreator* const ZONE_CREATORS[]
|
||||
{
|
||||
new IW4::AssetLoader(),
|
||||
new T6::AssetLoader()
|
||||
new IW4::ZoneCreator(),
|
||||
new T6::ZoneCreator()
|
||||
};
|
||||
|
||||
class Linker::Impl
|
||||
@ -427,13 +427,13 @@ class Linker::Impl
|
||||
|
||||
std::unique_ptr<Zone> CreateZoneForDefinition(const std::string& zoneName, ZoneDefinition& zoneDefinition, ISearchPath* assetSearchPath, ISearchPath* gdtSearchPath) const
|
||||
{
|
||||
auto context = std::make_unique<AssetLoadingContext>(zoneName, assetSearchPath);
|
||||
auto context = std::make_unique<ZoneCreationContext>(zoneName, assetSearchPath);
|
||||
if (!GetGameNameFromZoneDefinition(context->m_game_name, zoneName, zoneDefinition))
|
||||
return nullptr;
|
||||
if (!LoadGdtFilesFromZoneDefinition(context->m_gdt_files, zoneName, zoneDefinition, gdtSearchPath))
|
||||
return nullptr;
|
||||
|
||||
for(const auto* assetLoader : ASSET_LOADERS)
|
||||
for(const auto* assetLoader : ZONE_CREATORS)
|
||||
{
|
||||
if(assetLoader->SupportsGame(context->m_game_name))
|
||||
return assetLoader->CreateZoneForDefinition(*context);
|
||||
|
20
src/Linker/ZoneCreation/IZoneCreator.h
Normal file
20
src/Linker/ZoneCreation/IZoneCreator.h
Normal file
@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "ZoneCreationContext.h"
|
||||
#include "Zone/Zone.h"
|
||||
|
||||
class IZoneCreator
|
||||
{
|
||||
public:
|
||||
IZoneCreator() = default;
|
||||
virtual ~IZoneCreator() = default;
|
||||
IZoneCreator(const IZoneCreator& other) = default;
|
||||
IZoneCreator(IZoneCreator&& other) noexcept = default;
|
||||
IZoneCreator& operator=(const IZoneCreator& other) = default;
|
||||
IZoneCreator& operator=(IZoneCreator&& other) noexcept = default;
|
||||
|
||||
_NODISCARD virtual bool SupportsGame(const std::string& gameName) const = 0;
|
||||
_NODISCARD virtual std::unique_ptr<Zone> CreateZoneForDefinition(ZoneCreationContext& context) const = 0;
|
||||
};
|
@ -1,11 +1,11 @@
|
||||
#include "AssetLoadingContext.h"
|
||||
#include "ZoneCreationContext.h"
|
||||
|
||||
AssetLoadingContext::AssetLoadingContext()
|
||||
ZoneCreationContext::ZoneCreationContext()
|
||||
: m_asset_search_path(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
AssetLoadingContext::AssetLoadingContext(std::string zoneName, ISearchPath* assetSearchPath)
|
||||
ZoneCreationContext::ZoneCreationContext(std::string zoneName, ISearchPath* assetSearchPath)
|
||||
: m_asset_search_path(assetSearchPath),
|
||||
m_zone_name(std::move(zoneName))
|
||||
{
|
@ -6,7 +6,7 @@
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
#include "Obj/Gdt/Gdt.h"
|
||||
|
||||
class AssetLoadingContext
|
||||
class ZoneCreationContext
|
||||
{
|
||||
public:
|
||||
ISearchPath* m_asset_search_path;
|
||||
@ -14,6 +14,6 @@ public:
|
||||
std::string m_game_name;
|
||||
std::vector<std::unique_ptr<Gdt>> m_gdt_files;
|
||||
|
||||
AssetLoadingContext();
|
||||
AssetLoadingContext(std::string zoneName, ISearchPath* assetSearchPath);
|
||||
ZoneCreationContext();
|
||||
ZoneCreationContext(std::string zoneName, ISearchPath* assetSearchPath);
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user