Merge pull request #90 from Laupetin/feature/iw3-localize

feat: add localize entry loading for IW3
This commit is contained in:
Jan 2024-01-20 11:53:20 +01:00 committed by GitHub
commit 5b087518aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 61 additions and 5 deletions

View File

@ -0,0 +1,36 @@
#include "AssetLoaderLocalizeEntry.h"
#include "Localize/LocalizeCommonAssetLoader.h"
using namespace IW3;
XAssetInfoGeneric* AssetLoaderLocalizeEntry::LoadFromGlobalAssetPools(const std::string& assetName) const
{
return nullptr;
}
void* AssetLoaderLocalizeEntry::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
{
return nullptr;
}
bool AssetLoaderLocalizeEntry::CanLoadFromRaw() const
{
return true;
}
bool AssetLoaderLocalizeEntry::LoadFromRaw(
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
{
const LocalizeCommonAssetLoader commonLoader(
[memory, manager](const CommonLocalizeEntry& entry)
{
auto* localizeEntry = memory->Create<LocalizeEntry>();
localizeEntry->name = memory->Dup(entry.m_key.c_str());
localizeEntry->value = memory->Dup(entry.m_value.c_str());
manager->AddAsset(ASSET_TYPE_LOCALIZE_ENTRY, entry.m_key, localizeEntry);
});
return commonLoader.LoadLocalizeAsset(assetName, searchPath, manager, zone);
}

View File

@ -0,0 +1,19 @@
#pragma once
#include "AssetLoading/BasicAssetLoader.h"
#include "AssetLoading/IAssetLoadingManager.h"
#include "Game/IW3/IW3.h"
#include "SearchPath/ISearchPath.h"
namespace IW3
{
class AssetLoaderLocalizeEntry final : public BasicAssetLoader<ASSET_TYPE_LOCALIZE_ENTRY, LocalizeEntry>
{
public:
_NODISCARD XAssetInfoGeneric* LoadFromGlobalAssetPools(const std::string& assetName) const override;
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
_NODISCARD bool CanLoadFromRaw() const override;
bool
LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
};
} // namespace IW3

View File

@ -1,6 +1,7 @@
#include "ObjLoaderIW3.h"
#include "AssetLoaders/AssetLoaderGfxImage.h"
#include "AssetLoaders/AssetLoaderLocalizeEntry.h"
#include "AssetLoaders/AssetLoaderRawFile.h"
#include "AssetLoading/AssetLoadingManager.h"
#include "Game/IW3/GameAssetPoolIW3.h"
@ -43,7 +44,7 @@ ObjLoader::ObjLoader()
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_FONT, Font_s))
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_MENULIST, MenuList))
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_MENU, menuDef_t))
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_LOCALIZE_ENTRY, LocalizeEntry))
REGISTER_ASSET_LOADER(AssetLoaderLocalizeEntry)
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_WEAPON, WeaponDef))
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_SNDDRIVER_GLOBALS, SndDriverGlobals))
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_FX, FxEffectDef))

View File

@ -22,7 +22,7 @@ bool AssetLoaderLocalizeEntry::CanLoadFromRaw() const
bool AssetLoaderLocalizeEntry::LoadFromRaw(
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
{
LocalizeCommonAssetLoader commonLoader(
const LocalizeCommonAssetLoader commonLoader(
[memory, manager](const CommonLocalizeEntry& entry)
{
auto* localizeEntry = memory->Create<LocalizeEntry>();

View File

@ -22,7 +22,7 @@ bool AssetLoaderLocalizeEntry::CanLoadFromRaw() const
bool AssetLoaderLocalizeEntry::LoadFromRaw(
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
{
LocalizeCommonAssetLoader commonLoader(
const LocalizeCommonAssetLoader commonLoader(
[memory, manager](const CommonLocalizeEntry& entry)
{
auto* localizeEntry = memory->Create<LocalizeEntry>();

View File

@ -22,7 +22,7 @@ bool AssetLoaderLocalizeEntry::CanLoadFromRaw() const
bool AssetLoaderLocalizeEntry::LoadFromRaw(
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
{
LocalizeCommonAssetLoader commonLoader(
const LocalizeCommonAssetLoader commonLoader(
[memory, manager](const CommonLocalizeEntry& entry)
{
auto* localizeEntry = memory->Create<LocalizeEntry>();

View File

@ -22,7 +22,7 @@ bool AssetLoaderLocalizeEntry::CanLoadFromRaw() const
bool AssetLoaderLocalizeEntry::LoadFromRaw(
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
{
LocalizeCommonAssetLoader commonLoader(
const LocalizeCommonAssetLoader commonLoader(
[memory, manager](const CommonLocalizeEntry& entry)
{
auto* localizeEntry = memory->Create<LocalizeEntry>();