mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 08:05:45 +00:00
chore: adjust IW3 asset loaders to fit IW4 format
This commit is contained in:
parent
7ef944ebd4
commit
a5873a301f
@ -12,14 +12,19 @@
|
|||||||
|
|
||||||
using namespace IW3;
|
using namespace IW3;
|
||||||
|
|
||||||
AssetLoaderImage::AssetLoaderImage(MemoryManager& memory, ISearchPath& searchPath)
|
namespace
|
||||||
|
{
|
||||||
|
class ImageLoader final : public AssetCreator<AssetImage>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ImageLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||||
: m_memory(memory),
|
: m_memory(memory),
|
||||||
m_search_path(searchPath)
|
m_search_path(searchPath)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
AssetCreationResult AssetLoaderImage::CreateAsset(const std::string& assetName, AssetCreationContext& context)
|
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||||
{
|
{
|
||||||
// Do not load any GfxImages from raw for now that are not loaded
|
// Do not load any GfxImages from raw for now that are not loaded
|
||||||
// TODO: Load iwis and add streaming info to asset
|
// TODO: Load iwis and add streaming info to asset
|
||||||
if (assetName.empty() || assetName[0] != '*')
|
if (assetName.empty() || assetName[0] != '*')
|
||||||
@ -109,4 +114,18 @@ AssetCreationResult AssetLoaderImage::CreateAsset(const std::string& assetName,
|
|||||||
}
|
}
|
||||||
|
|
||||||
return AssetCreationResult::Success(context.AddAsset<AssetImage>(assetName, image));
|
return AssetCreationResult::Success(context.AddAsset<AssetImage>(assetName, image));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
MemoryManager& m_memory;
|
||||||
|
ISearchPath& m_search_path;
|
||||||
|
};
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
namespace IW3
|
||||||
|
{
|
||||||
|
std::unique_ptr<AssetCreator<AssetImage>> CreateImageLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||||
|
{
|
||||||
|
return std::make_unique<ImageLoader>(memory, searchPath);
|
||||||
|
}
|
||||||
|
} // namespace IW3
|
||||||
|
@ -5,17 +5,9 @@
|
|||||||
#include "SearchPath/ISearchPath.h"
|
#include "SearchPath/ISearchPath.h"
|
||||||
#include "Utils/MemoryManager.h"
|
#include "Utils/MemoryManager.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace IW3
|
namespace IW3
|
||||||
{
|
{
|
||||||
class AssetLoaderImage final : public AssetCreator<AssetImage>
|
std::unique_ptr<AssetCreator<AssetImage>> CreateImageLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||||
{
|
|
||||||
public:
|
|
||||||
AssetLoaderImage(MemoryManager& memory, ISearchPath& searchPath);
|
|
||||||
|
|
||||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
MemoryManager& m_memory;
|
|
||||||
ISearchPath& m_search_path;
|
|
||||||
};
|
|
||||||
} // namespace IW3
|
} // namespace IW3
|
||||||
|
@ -1,23 +1,45 @@
|
|||||||
#include "AssetLoaderLocalizeIW3.h"
|
#include "AssetLoaderLocalizeIW3.h"
|
||||||
|
|
||||||
|
#include "Localize/CommonLocalizeLoader.h"
|
||||||
|
|
||||||
using namespace IW3;
|
using namespace IW3;
|
||||||
|
|
||||||
AssetLoaderLocalize::AssetLoaderLocalize(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
namespace
|
||||||
|
{
|
||||||
|
class LocalizeLoader final : public AssetCreator<AssetLocalize>, public CommonLocalizeLoader
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LocalizeLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||||
: CommonLocalizeLoader(searchPath, zone),
|
: CommonLocalizeLoader(searchPath, zone),
|
||||||
m_memory(memory)
|
m_memory(memory)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
AssetCreationResult AssetLoaderLocalize::CreateAsset(const std::string& assetName, AssetCreationContext& context)
|
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||||
{
|
{
|
||||||
return CreateLocalizeAsset(assetName, context);
|
return CreateLocalizeAsset(assetName, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
AssetCreationResult AssetLoaderLocalize::CreateAssetFromCommonAsset(const CommonLocalizeEntry& localizeEntry, AssetCreationContext& context)
|
protected:
|
||||||
{
|
AssetCreationResult CreateAssetFromCommonAsset(const CommonLocalizeEntry& localizeEntry, AssetCreationContext& context) override
|
||||||
|
|
||||||
|
{
|
||||||
auto* asset = m_memory.Alloc<LocalizeEntry>();
|
auto* asset = m_memory.Alloc<LocalizeEntry>();
|
||||||
asset->name = m_memory.Dup(localizeEntry.m_key.c_str());
|
asset->name = m_memory.Dup(localizeEntry.m_key.c_str());
|
||||||
asset->value = m_memory.Dup(localizeEntry.m_value.c_str());
|
asset->value = m_memory.Dup(localizeEntry.m_value.c_str());
|
||||||
|
|
||||||
return AssetCreationResult::Success(context.AddAsset<AssetLocalize>(localizeEntry.m_key, asset));
|
return AssetCreationResult::Success(context.AddAsset<AssetLocalize>(localizeEntry.m_key, asset));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
MemoryManager& m_memory;
|
||||||
|
};
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
namespace IW3
|
||||||
|
{
|
||||||
|
std::unique_ptr<AssetCreator<AssetLocalize>> CreateLocalizeLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||||
|
{
|
||||||
|
return std::make_unique<LocalizeLoader>(memory, searchPath, zone);
|
||||||
|
}
|
||||||
|
} // namespace IW3
|
||||||
|
@ -2,22 +2,13 @@
|
|||||||
|
|
||||||
#include "Asset/IAssetCreator.h"
|
#include "Asset/IAssetCreator.h"
|
||||||
#include "Game/IW3/IW3.h"
|
#include "Game/IW3/IW3.h"
|
||||||
#include "Localize/CommonLocalizeLoader.h"
|
|
||||||
#include "SearchPath/ISearchPath.h"
|
#include "SearchPath/ISearchPath.h"
|
||||||
#include "Utils/MemoryManager.h"
|
#include "Utils/MemoryManager.h"
|
||||||
|
#include "Zone/Zone.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace IW3
|
namespace IW3
|
||||||
{
|
{
|
||||||
class AssetLoaderLocalize final : public AssetCreator<AssetLocalize>, public CommonLocalizeLoader
|
std::unique_ptr<AssetCreator<AssetLocalize>> CreateLocalizeLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||||
{
|
|
||||||
public:
|
|
||||||
AssetLoaderLocalize(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
|
||||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
AssetCreationResult CreateAssetFromCommonAsset(const CommonLocalizeEntry& localizeEntry, AssetCreationContext& context) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
MemoryManager& m_memory;
|
|
||||||
};
|
|
||||||
} // namespace IW3
|
} // namespace IW3
|
||||||
|
@ -92,7 +92,7 @@ namespace
|
|||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderXModel>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderXModel>(memory));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderMaterial>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderMaterial>(memory));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderTechniqueSet>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderTechniqueSet>(memory));
|
||||||
collection.AddAssetCreator(std::make_unique<AssetLoaderImage>(memory, searchPath));
|
collection.AddAssetCreator(CreateImageLoader(memory, searchPath));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSound>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderSound>(memory));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSoundCurve>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderSoundCurve>(memory));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderLoadedSound>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderLoadedSound>(memory));
|
||||||
@ -107,17 +107,17 @@ namespace
|
|||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderFont>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderFont>(memory));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderMenuList>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderMenuList>(memory));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderMenu>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderMenu>(memory));
|
||||||
collection.AddAssetCreator(std::make_unique<AssetLoaderLocalize>(memory, searchPath, zone));
|
collection.AddAssetCreator(CreateLocalizeLoader(memory, searchPath, zone));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderWeapon>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderWeapon>(memory));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSoundDriverGlobals>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderSoundDriverGlobals>(memory));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderFx>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderFx>(memory));
|
||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderImpactFx>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderImpactFx>(memory));
|
||||||
collection.AddAssetCreator(std::make_unique<AssetLoaderRawFile>(memory, searchPath));
|
collection.AddAssetCreator(CreateRawFileLoader(memory, searchPath));
|
||||||
collection.AddAssetCreator(std::make_unique<AssetLoaderStringTable>(memory, searchPath));
|
collection.AddAssetCreator(CreateStringTableLoader(memory, searchPath));
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void ObjLoader::ConfigureCreatorCollection(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath) const
|
void ObjLoader::ConfigureCreatorCollection(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath, IGdtQueryable& gdt) const
|
||||||
{
|
{
|
||||||
ConfigureDefaultCreators(collection, zone);
|
ConfigureDefaultCreators(collection, zone);
|
||||||
ConfigureLoaders(collection, zone, searchPath);
|
ConfigureLoaders(collection, zone, searchPath);
|
||||||
|
@ -11,6 +11,6 @@ namespace IW3
|
|||||||
void LoadReferencedContainersForZone(ISearchPath& searchPath, Zone& zone) const override;
|
void LoadReferencedContainersForZone(ISearchPath& searchPath, Zone& zone) const override;
|
||||||
void UnloadContainersOfZone(Zone& zone) const override;
|
void UnloadContainersOfZone(Zone& zone) const override;
|
||||||
|
|
||||||
void ConfigureCreatorCollection(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath) const override;
|
void ConfigureCreatorCollection(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath, IGdtQueryable& gdt) const override;
|
||||||
};
|
};
|
||||||
} // namespace IW3
|
} // namespace IW3
|
||||||
|
@ -6,14 +6,19 @@
|
|||||||
|
|
||||||
using namespace IW3;
|
using namespace IW3;
|
||||||
|
|
||||||
AssetLoaderRawFile::AssetLoaderRawFile(MemoryManager& memory, ISearchPath& searchPath)
|
namespace
|
||||||
|
{
|
||||||
|
class RawFileLoader final : public AssetCreator<AssetRawFile>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RawFileLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||||
: m_memory(memory),
|
: m_memory(memory),
|
||||||
m_search_path(searchPath)
|
m_search_path(searchPath)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
AssetCreationResult AssetLoaderRawFile::CreateAsset(const std::string& assetName, AssetCreationContext& context)
|
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||||
{
|
{
|
||||||
const auto file = m_search_path.Open(assetName);
|
const auto file = m_search_path.Open(assetName);
|
||||||
if (!file.IsOpen())
|
if (!file.IsOpen())
|
||||||
return AssetCreationResult::NoAction();
|
return AssetCreationResult::NoAction();
|
||||||
@ -31,4 +36,18 @@ AssetCreationResult AssetLoaderRawFile::CreateAsset(const std::string& assetName
|
|||||||
rawFile->buffer = fileBuffer;
|
rawFile->buffer = fileBuffer;
|
||||||
|
|
||||||
return AssetCreationResult::Success(context.AddAsset<AssetRawFile>(assetName, rawFile));
|
return AssetCreationResult::Success(context.AddAsset<AssetRawFile>(assetName, rawFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
MemoryManager& m_memory;
|
||||||
|
ISearchPath& m_search_path;
|
||||||
|
};
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
namespace IW3
|
||||||
|
{
|
||||||
|
std::unique_ptr<AssetCreator<AssetRawFile>> CreateRawFileLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||||
|
{
|
||||||
|
return std::make_unique<RawFileLoader>(memory, searchPath);
|
||||||
|
}
|
||||||
|
} // namespace IW3
|
||||||
|
@ -5,17 +5,9 @@
|
|||||||
#include "SearchPath/ISearchPath.h"
|
#include "SearchPath/ISearchPath.h"
|
||||||
#include "Utils/MemoryManager.h"
|
#include "Utils/MemoryManager.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace IW3
|
namespace IW3
|
||||||
{
|
{
|
||||||
class AssetLoaderRawFile final : public AssetCreator<AssetRawFile>
|
std::unique_ptr<AssetCreator<AssetRawFile>> CreateRawFileLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||||
{
|
|
||||||
public:
|
|
||||||
AssetLoaderRawFile(MemoryManager& memory, ISearchPath& searchPath);
|
|
||||||
|
|
||||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
MemoryManager& m_memory;
|
|
||||||
ISearchPath& m_search_path;
|
|
||||||
};
|
|
||||||
} // namespace IW3
|
} // namespace IW3
|
||||||
|
@ -1,21 +1,25 @@
|
|||||||
#include "AssetLoaderStringTableIW3.h"
|
#include "AssetLoaderStringTableIW3.h"
|
||||||
|
|
||||||
#include "Game/IW3/IW3.h"
|
#include "Game/IW3/IW3.h"
|
||||||
#include "Pool/GlobalAssetPool.h"
|
|
||||||
#include "StringTable/StringTableLoader.h"
|
#include "StringTable/StringTableLoader.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
using namespace IW3;
|
using namespace IW3;
|
||||||
|
|
||||||
AssetLoaderStringTable::AssetLoaderStringTable(MemoryManager& memory, ISearchPath& searchPath)
|
namespace
|
||||||
|
{
|
||||||
|
class StringTableLoader final : public AssetCreator<AssetStringTable>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
StringTableLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||||
: m_memory(memory),
|
: m_memory(memory),
|
||||||
m_search_path(searchPath)
|
m_search_path(searchPath)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
AssetCreationResult AssetLoaderStringTable::CreateAsset(const std::string& assetName, AssetCreationContext& context)
|
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||||
{
|
{
|
||||||
const auto file = m_search_path.Open(assetName);
|
const auto file = m_search_path.Open(assetName);
|
||||||
if (!file.IsOpen())
|
if (!file.IsOpen())
|
||||||
return AssetCreationResult::NoAction();
|
return AssetCreationResult::NoAction();
|
||||||
@ -26,4 +30,18 @@ AssetCreationResult AssetLoaderStringTable::CreateAsset(const std::string& asset
|
|||||||
return AssetCreationResult::Failure();
|
return AssetCreationResult::Failure();
|
||||||
|
|
||||||
return AssetCreationResult::Success(context.AddAsset<AssetStringTable>(assetName, stringTable));
|
return AssetCreationResult::Success(context.AddAsset<AssetStringTable>(assetName, stringTable));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
MemoryManager& m_memory;
|
||||||
|
ISearchPath& m_search_path;
|
||||||
|
};
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
namespace IW3
|
||||||
|
{
|
||||||
|
std::unique_ptr<AssetCreator<AssetStringTable>> CreateStringTableLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||||
|
{
|
||||||
|
return std::make_unique<StringTableLoader>(memory, searchPath);
|
||||||
|
}
|
||||||
|
} // namespace IW3
|
||||||
|
@ -5,17 +5,9 @@
|
|||||||
#include "SearchPath/ISearchPath.h"
|
#include "SearchPath/ISearchPath.h"
|
||||||
#include "Utils/MemoryManager.h"
|
#include "Utils/MemoryManager.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace IW3
|
namespace IW3
|
||||||
{
|
{
|
||||||
class AssetLoaderStringTable final : public AssetCreator<AssetRawFile>
|
std::unique_ptr<AssetCreator<AssetStringTable>> CreateStringTableLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||||
{
|
|
||||||
public:
|
|
||||||
AssetLoaderStringTable(MemoryManager& memory, ISearchPath& searchPath);
|
|
||||||
|
|
||||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
MemoryManager& m_memory;
|
|
||||||
ISearchPath& m_search_path;
|
|
||||||
};
|
|
||||||
} // namespace IW3
|
} // namespace IW3
|
||||||
|
Loading…
x
Reference in New Issue
Block a user