mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-10 23:08:05 -05:00
chore: fix loading and writing code for IW5
This commit is contained in:
@ -1,17 +0,0 @@
|
||||
#include "AssetLoaderAddonMapEnts.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderAddonMapEnts::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* addonMapEnts = memory->Create<AddonMapEnts>();
|
||||
memset(addonMapEnts, 0, sizeof(AddonMapEnts));
|
||||
addonMapEnts->name = memory->Dup(assetName.c_str());
|
||||
return addonMapEnts;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderAddonMapEnts final : public BasicAssetLoader<AssetAddonMapEnts>
|
||||
{
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
} // namespace IW5
|
@ -1,17 +0,0 @@
|
||||
#include "AssetLoaderClipMap.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderClipMap::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* clipMap = memory->Create<clipMap_t>();
|
||||
memset(clipMap, 0, sizeof(clipMap_t));
|
||||
clipMap->name = memory->Dup(assetName.c_str());
|
||||
return clipMap;
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderClipMap : public BasicAssetLoader<AssetClipMap>
|
||||
{
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
} // namespace IW5
|
@ -1,17 +0,0 @@
|
||||
#include "AssetLoaderComWorld.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderComWorld::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* comWorld = memory->Create<ComWorld>();
|
||||
memset(comWorld, 0, sizeof(ComWorld));
|
||||
comWorld->name = memory->Dup(assetName.c_str());
|
||||
return comWorld;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderComWorld final : public BasicAssetLoader<AssetComWorld>
|
||||
{
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
} // namespace IW5
|
@ -1,17 +0,0 @@
|
||||
#include "AssetLoaderFont.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderFont::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* font = memory->Create<Font_s>();
|
||||
memset(font, 0, sizeof(Font_s));
|
||||
font->fontName = memory->Dup(assetName.c_str());
|
||||
return font;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderFont final : public BasicAssetLoader<AssetFont>
|
||||
{
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
} // namespace IW5
|
@ -1,17 +0,0 @@
|
||||
#include "AssetLoaderFx.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderFx::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* fx = memory->Create<FxEffectDef>();
|
||||
memset(fx, 0, sizeof(FxEffectDef));
|
||||
fx->name = memory->Dup(assetName.c_str());
|
||||
return fx;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderFx final : public BasicAssetLoader<AssetFx>
|
||||
{
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
} // namespace IW5
|
@ -1,17 +0,0 @@
|
||||
#include "AssetLoaderFxImpactTable.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderFxImpactTable::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* fxImpactTable = memory->Create<FxImpactTable>();
|
||||
memset(fxImpactTable, 0, sizeof(FxImpactTable));
|
||||
fxImpactTable->name = memory->Dup(assetName.c_str());
|
||||
return fxImpactTable;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderFxImpactTable final : public BasicAssetLoader<AssetImpactFx>
|
||||
{
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
} // namespace IW5
|
@ -1,17 +0,0 @@
|
||||
#include "AssetLoaderFxWorld.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderFxWorld::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* fxWorld = memory->Create<FxWorld>();
|
||||
memset(fxWorld, 0, sizeof(FxWorld));
|
||||
fxWorld->name = memory->Dup(assetName.c_str());
|
||||
return fxWorld;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderFxWorld final : public BasicAssetLoader<AssetFxWorld>
|
||||
{
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
} // namespace IW5
|
@ -1,60 +0,0 @@
|
||||
#include "AssetLoaderGfxImage.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "Image/IwiLoader.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderGfxImage::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* asset = memory->Alloc<AssetImage::Type>();
|
||||
asset->name = memory->Dup(assetName.c_str());
|
||||
return asset;
|
||||
}
|
||||
|
||||
bool AssetLoaderGfxImage::CanLoadFromRaw() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderGfxImage::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
const auto fileName = std::format("images/{}.iwi", assetName);
|
||||
const auto file = searchPath->Open(fileName);
|
||||
if (!file.IsOpen())
|
||||
return false;
|
||||
|
||||
const auto fileSize = static_cast<size_t>(file.m_length);
|
||||
const auto fileData = std::make_unique<char[]>(fileSize);
|
||||
file.m_stream->read(fileData.get(), fileSize);
|
||||
|
||||
std::istringstream ss(std::string(fileData.get(), fileSize));
|
||||
const auto texture = iwi::LoadIwi(ss);
|
||||
if (!texture)
|
||||
{
|
||||
std::cerr << std::format("Failed to load texture from: {}\n", fileName);
|
||||
return false;
|
||||
}
|
||||
|
||||
auto* image = memory->Create<GfxImage>();
|
||||
memset(image, 0, sizeof(GfxImage));
|
||||
|
||||
image->name = memory->Dup(assetName.c_str());
|
||||
image->noPicmip = !texture->HasMipMaps();
|
||||
image->width = static_cast<uint16_t>(texture->GetWidth());
|
||||
image->height = static_cast<uint16_t>(texture->GetHeight());
|
||||
image->depth = static_cast<uint16_t>(texture->GetDepth());
|
||||
|
||||
image->texture.loadDef = memory->Alloc<GfxImageLoadDef>();
|
||||
|
||||
manager->AddAsset<AssetImage>(assetName, image);
|
||||
|
||||
return true;
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
#pragma once
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderGfxImage final : public BasicAssetLoader<AssetImage>
|
||||
{
|
||||
public:
|
||||
_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 IW5
|
@ -1,17 +0,0 @@
|
||||
#include "AssetLoaderGfxLightDef.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderGfxLightDef::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* lightDef = memory->Create<GfxLightDef>();
|
||||
memset(lightDef, 0, sizeof(GfxLightDef));
|
||||
lightDef->name = memory->Dup(assetName.c_str());
|
||||
return lightDef;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderGfxLightDef final : public BasicAssetLoader<AssetLightDef>
|
||||
{
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
} // namespace IW5
|
@ -1,17 +0,0 @@
|
||||
#include "AssetLoaderGfxWorld.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderGfxWorld::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* gfxWorld = memory->Create<GfxWorld>();
|
||||
memset(gfxWorld, 0, sizeof(GfxWorld));
|
||||
gfxWorld->name = memory->Dup(assetName.c_str());
|
||||
return gfxWorld;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderGfxWorld final : public BasicAssetLoader<AssetGfxWorld>
|
||||
{
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
} // namespace IW5
|
@ -1,17 +0,0 @@
|
||||
#include "AssetLoaderGlassWorld.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderGlassWorld::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* glassWorld = memory->Create<GlassWorld>();
|
||||
memset(glassWorld, 0, sizeof(GlassWorld));
|
||||
glassWorld->name = memory->Dup(assetName.c_str());
|
||||
return glassWorld;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderGlassWorld final : public BasicAssetLoader<AssetGlassWorld>
|
||||
{
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
} // namespace IW5
|
@ -1,43 +0,0 @@
|
||||
#include "AssetLoaderLeaderboard.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "Game/IW5/Leaderboard/JsonLeaderboardDefLoader.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderLeaderboard::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* leaderboard = memory->Create<LeaderboardDef>();
|
||||
memset(leaderboard, 0, sizeof(LeaderboardDef));
|
||||
leaderboard->name = memory->Dup(assetName.c_str());
|
||||
return leaderboard;
|
||||
}
|
||||
|
||||
bool AssetLoaderLeaderboard::CanLoadFromRaw() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderLeaderboard::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
const auto file = searchPath->Open(std::format("leaderboards/{}.json", assetName));
|
||||
if (!file.IsOpen())
|
||||
return false;
|
||||
|
||||
auto* leaderboardDef = memory->Alloc<LeaderboardDef>();
|
||||
leaderboardDef->name = memory->Dup(assetName.c_str());
|
||||
|
||||
if (LoadLeaderboardAsJson(*file.m_stream, *leaderboardDef, memory))
|
||||
manager->AddAsset<AssetLeaderboard>(assetName, leaderboardDef);
|
||||
else
|
||||
std::cerr << std::format("Failed to load leaderboard \"{}\"\n", assetName);
|
||||
|
||||
return true;
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderLeaderboard final : public BasicAssetLoader<AssetLeaderboard>
|
||||
{
|
||||
public:
|
||||
_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 IW5
|
@ -1,17 +0,0 @@
|
||||
#include "AssetLoaderLoadedSound.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderLoadedSound::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* loadedSound = memory->Create<LoadedSound>();
|
||||
memset(loadedSound, 0, sizeof(LoadedSound));
|
||||
loadedSound->name = memory->Dup(assetName.c_str());
|
||||
return loadedSound;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderLoadedSound final : public BasicAssetLoader<AssetLoadedSound>
|
||||
{
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
} // namespace IW5
|
@ -1,17 +0,0 @@
|
||||
#include "AssetLoaderMapEnts.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderMapEnts::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* mapEnts = memory->Create<MapEnts>();
|
||||
memset(mapEnts, 0, sizeof(MapEnts));
|
||||
mapEnts->name = memory->Dup(assetName.c_str());
|
||||
return mapEnts;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderMapEnts final : public BasicAssetLoader<AssetMapEnts>
|
||||
{
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
} // namespace IW5
|
@ -1,57 +0,0 @@
|
||||
#include "AssetLoaderMaterial.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "Game/IW5/Material/JsonMaterialLoader.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderMaterial::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* asset = memory->Alloc<AssetMaterial::Type>();
|
||||
asset->info.name = memory->Dup(assetName.c_str());
|
||||
return asset;
|
||||
}
|
||||
|
||||
bool AssetLoaderMaterial::CanLoadFromRaw() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string AssetLoaderMaterial::GetFileNameForAsset(const std::string& assetName)
|
||||
{
|
||||
std::string sanitizedFileName(assetName);
|
||||
if (sanitizedFileName[0] == '*')
|
||||
{
|
||||
std::ranges::replace(sanitizedFileName, '*', '_');
|
||||
const auto parenthesisPos = sanitizedFileName.find('(');
|
||||
if (parenthesisPos != std::string::npos)
|
||||
sanitizedFileName.erase(parenthesisPos);
|
||||
sanitizedFileName = "generated/" + sanitizedFileName;
|
||||
}
|
||||
|
||||
return std::format("materials/{}.json", sanitizedFileName);
|
||||
}
|
||||
|
||||
bool AssetLoaderMaterial::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
const auto file = searchPath->Open(GetFileNameForAsset(assetName));
|
||||
if (!file.IsOpen())
|
||||
return false;
|
||||
|
||||
auto* material = memory->Alloc<Material>();
|
||||
material->info.name = memory->Dup(assetName.c_str());
|
||||
|
||||
std::vector<XAssetInfoGeneric*> dependencies;
|
||||
if (LoadMaterialAsJson(*file.m_stream, *material, memory, manager, dependencies))
|
||||
manager->AddAsset<AssetMaterial>(assetName, material, std::move(dependencies));
|
||||
else
|
||||
std::cerr << std::format("Failed to load material \"{}\"\n", assetName);
|
||||
|
||||
return true;
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
#pragma once
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderMaterial final : public BasicAssetLoader<AssetMaterial>
|
||||
{
|
||||
static std::string GetFileNameForAsset(const std::string& assetName);
|
||||
|
||||
public:
|
||||
_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 IW5
|
@ -1,17 +0,0 @@
|
||||
#include "AssetLoaderMenuDef.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderMenuDef::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* menu = memory->Create<menuDef_t>();
|
||||
memset(menu, 0, sizeof(menuDef_t));
|
||||
menu->window.name = memory->Dup(assetName.c_str());
|
||||
return menu;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderMenuDef final : public BasicAssetLoader<AssetMenu>
|
||||
{
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
} // namespace IW5
|
@ -1,233 +0,0 @@
|
||||
#include "AssetLoaderMenuList.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "Game/IW5/Menu/MenuConversionZoneStateIW5.h"
|
||||
#include "Game/IW5/Menu/MenuConverterIW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Parsing/Menu/MenuFileReader.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class MenuLoader
|
||||
{
|
||||
public:
|
||||
static bool ProcessParsedResults(const std::string& fileName,
|
||||
ISearchPath* searchPath,
|
||||
MemoryManager* memory,
|
||||
IAssetLoadingManager* manager,
|
||||
menu::ParsingResult* parsingResult,
|
||||
menu::MenuAssetZoneState* zoneState,
|
||||
MenuConversionZoneState* conversionState,
|
||||
std::vector<menuDef_t*>& menus,
|
||||
std::vector<XAssetInfoGeneric*>& menuListDependencies)
|
||||
{
|
||||
const auto menuCount = parsingResult->m_menus.size();
|
||||
const auto functionCount = parsingResult->m_functions.size();
|
||||
const auto menuLoadCount = parsingResult->m_menus_to_load.size();
|
||||
auto totalItemCount = 0u;
|
||||
for (const auto& menu : parsingResult->m_menus)
|
||||
totalItemCount += menu->m_items.size();
|
||||
|
||||
std::cout << "Successfully read menu file \"" << fileName << "\" (" << menuLoadCount << " loads, " << menuCount << " menus, " << functionCount
|
||||
<< " functions, " << totalItemCount << " items)\n";
|
||||
|
||||
// Add all functions to the zone state to make them available for all menus to be converted
|
||||
for (auto& function : parsingResult->m_functions)
|
||||
zoneState->AddFunction(std::move(function));
|
||||
|
||||
// Prepare a list of all menus of this file
|
||||
std::vector<XAssetInfo<menuDef_t>*> allMenusOfFile;
|
||||
allMenusOfFile.reserve(parsingResult->m_menus.size());
|
||||
|
||||
// Convert all menus and add them as assets
|
||||
for (auto& menu : parsingResult->m_menus)
|
||||
{
|
||||
MenuConverter converter(ObjLoading::Configuration.MenuNoOptimization, searchPath, memory, manager);
|
||||
auto* menuAsset = converter.ConvertMenu(*menu);
|
||||
if (menuAsset == nullptr)
|
||||
{
|
||||
std::cout << "Failed to convert menu file \"" << menu->m_name << "\"\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
menus.push_back(menuAsset);
|
||||
auto* menuAssetInfo = manager->AddAsset<AssetMenu>(menu->m_name, menuAsset, std::move(converter.GetDependencies()));
|
||||
|
||||
if (menuAssetInfo)
|
||||
{
|
||||
allMenusOfFile.push_back(menuAssetInfo);
|
||||
menuListDependencies.push_back(menuAssetInfo);
|
||||
}
|
||||
|
||||
zoneState->AddMenu(std::move(menu));
|
||||
}
|
||||
|
||||
// Register this file with all loaded menus
|
||||
conversionState->AddLoadedFile(fileName, std::move(allMenusOfFile));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static MenuList* CreateMenuListAsset(const std::string& assetName, MemoryManager* memory, const std::vector<menuDef_t*>& menus)
|
||||
{
|
||||
auto* menuListAsset = memory->Create<MenuList>();
|
||||
menuListAsset->name = memory->Dup(assetName.c_str());
|
||||
menuListAsset->menuCount = static_cast<int>(menus.size());
|
||||
|
||||
if (menuListAsset->menuCount > 0)
|
||||
{
|
||||
menuListAsset->menus = memory->Alloc<menuDef_t*>(menuListAsset->menuCount);
|
||||
for (auto i = 0; i < menuListAsset->menuCount; i++)
|
||||
menuListAsset->menus[i] = menus[i];
|
||||
}
|
||||
else
|
||||
menuListAsset->menus = nullptr;
|
||||
|
||||
return menuListAsset;
|
||||
}
|
||||
|
||||
static std::unique_ptr<menu::ParsingResult>
|
||||
ParseMenuFile(const std::string& menuFileName, ISearchPath* searchPath, const menu::MenuAssetZoneState* zoneState)
|
||||
{
|
||||
const auto file = searchPath->Open(menuFileName);
|
||||
if (!file.IsOpen())
|
||||
return nullptr;
|
||||
|
||||
menu::MenuFileReader reader(*file.m_stream,
|
||||
menuFileName,
|
||||
menu::FeatureLevel::IW5,
|
||||
[searchPath](const std::string& filename, const std::string& sourceFile) -> std::unique_ptr<std::istream>
|
||||
{
|
||||
auto foundFileToInclude = searchPath->Open(filename);
|
||||
if (!foundFileToInclude.IsOpen() || !foundFileToInclude.m_stream)
|
||||
return nullptr;
|
||||
|
||||
return std::move(foundFileToInclude.m_stream);
|
||||
});
|
||||
|
||||
reader.IncludeZoneState(zoneState);
|
||||
reader.SetPermissiveMode(ObjLoading::Configuration.MenuPermissiveParsing);
|
||||
|
||||
return reader.ReadMenuFile();
|
||||
}
|
||||
};
|
||||
} // namespace IW5
|
||||
|
||||
void* AssetLoaderMenuList::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* menuList = memory->Create<MenuList>();
|
||||
memset(menuList, 0, sizeof(MenuList));
|
||||
menuList->name = memory->Dup(assetName.c_str());
|
||||
return menuList;
|
||||
}
|
||||
|
||||
bool AssetLoaderMenuList::CanLoadFromRaw() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BuildMenuFileQueue(std::deque<std::string>& menuLoadQueue,
|
||||
const std::string& menuListAssetName,
|
||||
ISearchPath* searchPath,
|
||||
MemoryManager* memory,
|
||||
IAssetLoadingManager* manager,
|
||||
menu::MenuAssetZoneState* zoneState,
|
||||
MenuConversionZoneState* conversionState,
|
||||
std::vector<menuDef_t*>& menus,
|
||||
std::vector<XAssetInfoGeneric*>& menuListDependencies)
|
||||
{
|
||||
const auto alreadyLoadedMenuListFileMenus = conversionState->m_menus_by_filename.find(menuListAssetName);
|
||||
|
||||
if (alreadyLoadedMenuListFileMenus == conversionState->m_menus_by_filename.end())
|
||||
{
|
||||
const auto menuListResult = MenuLoader::ParseMenuFile(menuListAssetName, searchPath, zoneState);
|
||||
if (menuListResult)
|
||||
{
|
||||
MenuLoader::ProcessParsedResults(
|
||||
menuListAssetName, searchPath, memory, manager, menuListResult.get(), zoneState, conversionState, menus, menuListDependencies);
|
||||
|
||||
for (const auto& menuToLoad : menuListResult->m_menus_to_load)
|
||||
menuLoadQueue.push_back(menuToLoad);
|
||||
|
||||
zoneState->AddMenusToLoad(menuListAssetName, std::move(menuListResult->m_menus_to_load));
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void LoadMenuFileFromQueue(const std::string& menuFilePath,
|
||||
ISearchPath* searchPath,
|
||||
MemoryManager* memory,
|
||||
IAssetLoadingManager* manager,
|
||||
menu::MenuAssetZoneState* zoneState,
|
||||
MenuConversionZoneState* conversionState,
|
||||
std::vector<menuDef_t*>& menus,
|
||||
std::vector<XAssetInfoGeneric*>& menuListDependencies)
|
||||
{
|
||||
const auto alreadyLoadedMenuFile = conversionState->m_menus_by_filename.find(menuFilePath);
|
||||
if (alreadyLoadedMenuFile != conversionState->m_menus_by_filename.end())
|
||||
{
|
||||
std::cout << "Already loaded \"" << menuFilePath << "\", skipping\n";
|
||||
for (auto* menu : alreadyLoadedMenuFile->second)
|
||||
{
|
||||
menus.push_back(menu->Asset());
|
||||
menuListDependencies.push_back(menu);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const auto menuFileResult = MenuLoader::ParseMenuFile(menuFilePath, searchPath, zoneState);
|
||||
if (menuFileResult)
|
||||
{
|
||||
MenuLoader::ProcessParsedResults(
|
||||
menuFilePath, searchPath, memory, manager, menuFileResult.get(), zoneState, conversionState, menus, menuListDependencies);
|
||||
if (!menuFileResult->m_menus_to_load.empty())
|
||||
std::cout << "WARNING: Menu file has menus to load even though it is not a menu list, ignoring: \"" << menuFilePath << "\"\n";
|
||||
}
|
||||
else
|
||||
std::cerr << "Could not read menu file \"" << menuFilePath << "\"\n";
|
||||
}
|
||||
|
||||
bool AssetLoaderMenuList::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
std::vector<menuDef_t*> menus;
|
||||
std::vector<XAssetInfoGeneric*> menuListDependencies;
|
||||
|
||||
auto* zoneState = manager->GetAssetLoadingContext()->GetZoneAssetLoaderState<menu::MenuAssetZoneState>();
|
||||
auto* conversionState = manager->GetAssetLoadingContext()->GetZoneAssetLoaderState<MenuConversionZoneState>();
|
||||
|
||||
std::deque<std::string> menuLoadQueue;
|
||||
if (!BuildMenuFileQueue(menuLoadQueue, assetName, searchPath, memory, manager, zoneState, conversionState, menus, menuListDependencies))
|
||||
return false;
|
||||
|
||||
while (!menuLoadQueue.empty())
|
||||
{
|
||||
const auto& menuFileToLoad = menuLoadQueue.front();
|
||||
|
||||
LoadMenuFileFromQueue(menuFileToLoad, searchPath, memory, manager, zoneState, conversionState, menus, menuListDependencies);
|
||||
|
||||
menuLoadQueue.pop_front();
|
||||
}
|
||||
|
||||
auto* menuListAsset = MenuLoader::CreateMenuListAsset(assetName, memory, menus);
|
||||
|
||||
if (menuListAsset)
|
||||
manager->AddAsset<AssetMenuList>(assetName, menuListAsset, menuListDependencies);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AssetLoaderMenuList::FinalizeAssetsForZone(AssetLoadingContext& context) const
|
||||
{
|
||||
context.GetZoneAssetLoaderState<MenuConversionZoneState>()->FinalizeSupportingData();
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderMenuList final : public BasicAssetLoader<AssetMenuList>
|
||||
{
|
||||
public:
|
||||
_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;
|
||||
void FinalizeAssetsForZone(AssetLoadingContext& context) const override;
|
||||
};
|
||||
} // namespace IW5
|
@ -1,17 +0,0 @@
|
||||
#include "AssetLoaderPathData.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderPathData::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* pathData = memory->Create<PathData>();
|
||||
memset(pathData, 0, sizeof(PathData));
|
||||
pathData->name = memory->Dup(assetName.c_str());
|
||||
return pathData;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderPathData final : public BasicAssetLoader<AssetPathData>
|
||||
{
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
} // namespace IW5
|
@ -1,17 +0,0 @@
|
||||
#include "AssetLoaderPhysCollmap.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderPhysCollmap::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* collmap = memory->Create<PhysCollmap>();
|
||||
memset(collmap, 0, sizeof(PhysCollmap));
|
||||
collmap->name = memory->Dup(assetName.c_str());
|
||||
return collmap;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderPhysCollmap final : public BasicAssetLoader<AssetPhysCollMap>
|
||||
{
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
} // namespace IW5
|
@ -1,17 +0,0 @@
|
||||
#include "AssetLoaderPhysPreset.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderPhysPreset::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* physPreset = memory->Create<PhysPreset>();
|
||||
memset(physPreset, 0, sizeof(PhysPreset));
|
||||
physPreset->name = memory->Dup(assetName.c_str());
|
||||
return physPreset;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderPhysPreset final : public BasicAssetLoader<AssetPhysPreset>
|
||||
{
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
} // namespace IW5
|
@ -1,17 +0,0 @@
|
||||
#include "AssetLoaderPixelShader.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderPixelShader::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* pixelShader = memory->Create<MaterialPixelShader>();
|
||||
memset(pixelShader, 0, sizeof(MaterialPixelShader));
|
||||
pixelShader->name = memory->Dup(assetName.c_str());
|
||||
return pixelShader;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderPixelShader final : public BasicAssetLoader<AssetPixelShader>
|
||||
{
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
} // namespace IW5
|
@ -1,80 +0,0 @@
|
||||
#include "AssetLoaderRawFile.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
#include <zlib.h>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderRawFile::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* rawFile = memory->Create<RawFile>();
|
||||
memset(rawFile, 0, sizeof(RawFile));
|
||||
rawFile->name = memory->Dup(assetName.c_str());
|
||||
return rawFile;
|
||||
}
|
||||
|
||||
bool AssetLoaderRawFile::CanLoadFromRaw() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderRawFile::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
const auto file = searchPath->Open(assetName);
|
||||
if (!file.IsOpen())
|
||||
return false;
|
||||
|
||||
const auto uncompressedBuffer = std::make_unique<char[]>(static_cast<size_t>(file.m_length));
|
||||
file.m_stream->read(uncompressedBuffer.get(), file.m_length);
|
||||
if (file.m_stream->gcount() != file.m_length)
|
||||
return false;
|
||||
|
||||
const auto compressionBufferSize = static_cast<size_t>(file.m_length + COMPRESSED_BUFFER_SIZE_PADDING);
|
||||
auto* compressedBuffer = memory->Alloc<char>(compressionBufferSize);
|
||||
|
||||
z_stream_s zs{};
|
||||
|
||||
zs.zalloc = Z_NULL;
|
||||
zs.zfree = Z_NULL;
|
||||
zs.opaque = Z_NULL;
|
||||
zs.avail_in = static_cast<uInt>(file.m_length);
|
||||
zs.avail_out = compressionBufferSize;
|
||||
zs.next_in = reinterpret_cast<const Bytef*>(uncompressedBuffer.get());
|
||||
zs.next_out = reinterpret_cast<Bytef*>(compressedBuffer);
|
||||
|
||||
int ret = deflateInit(&zs, Z_DEFAULT_COMPRESSION);
|
||||
|
||||
if (ret != Z_OK)
|
||||
{
|
||||
throw std::runtime_error("Initializing deflate failed");
|
||||
}
|
||||
|
||||
ret = deflate(&zs, Z_FINISH);
|
||||
|
||||
if (ret != Z_STREAM_END)
|
||||
{
|
||||
std::cerr << "Deflate failed for loading rawfile \"" << assetName << "\"\n";
|
||||
deflateEnd(&zs);
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto compressedSize = compressionBufferSize - zs.avail_out;
|
||||
|
||||
auto* rawFile = memory->Create<RawFile>();
|
||||
rawFile->name = memory->Dup(assetName.c_str());
|
||||
rawFile->compressedLen = static_cast<int>(compressedSize);
|
||||
rawFile->len = static_cast<int>(file.m_length);
|
||||
rawFile->buffer = static_cast<const char*>(compressedBuffer);
|
||||
|
||||
deflateEnd(&zs);
|
||||
|
||||
manager->AddAsset<AssetRawFile>(assetName, rawFile);
|
||||
|
||||
return true;
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
#pragma once
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderRawFile final : public BasicAssetLoader<AssetRawFile>
|
||||
{
|
||||
static constexpr size_t COMPRESSED_BUFFER_SIZE_PADDING = 64;
|
||||
|
||||
public:
|
||||
_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 IW5
|
@ -1,78 +0,0 @@
|
||||
#include "AssetLoaderScriptFile.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderScriptFile::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* scriptFile = memory->Create<ScriptFile>();
|
||||
memset(scriptFile, 0, sizeof(ScriptFile));
|
||||
scriptFile->name = memory->Dup(assetName.c_str());
|
||||
return scriptFile;
|
||||
}
|
||||
|
||||
bool AssetLoaderScriptFile::CanLoadFromRaw() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// See https://github.com/xensik/gsc-tool#file-format for an in-depth explanation about the .gscbin format
|
||||
bool AssetLoaderScriptFile::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
const auto file = searchPath->Open(assetName + ".gscbin");
|
||||
if (!file.IsOpen())
|
||||
return false;
|
||||
|
||||
const auto fileBuffer = std::make_unique<char[]>(static_cast<size_t>(file.m_length));
|
||||
file.m_stream->read(fileBuffer.get(), file.m_length);
|
||||
if (file.m_stream->gcount() != file.m_length)
|
||||
return false;
|
||||
|
||||
auto* scriptFile = memory->Create<ScriptFile>();
|
||||
scriptFile->name = memory->Dup(assetName.c_str());
|
||||
|
||||
// Retrieve data from the buffer
|
||||
size_t offset = 0;
|
||||
|
||||
// Read past the name pointer, we will use the one from assetName
|
||||
offset += strlen(fileBuffer.get()) + 1;
|
||||
|
||||
memcpy(&scriptFile->compressedLen, fileBuffer.get() + offset, sizeof(scriptFile->compressedLen));
|
||||
offset += sizeof(scriptFile->compressedLen);
|
||||
|
||||
memcpy(&scriptFile->len, fileBuffer.get() + offset, sizeof(scriptFile->len));
|
||||
offset += sizeof(scriptFile->len);
|
||||
|
||||
memcpy(&scriptFile->bytecodeLen, fileBuffer.get() + offset, sizeof(scriptFile->bytecodeLen));
|
||||
offset += sizeof(scriptFile->bytecodeLen);
|
||||
|
||||
if (scriptFile->compressedLen <= 0 || scriptFile->bytecodeLen <= 0)
|
||||
{
|
||||
std::cerr << "Error: Invalid length of the buffers in " << assetName << " specified\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (offset + (scriptFile->compressedLen + scriptFile->bytecodeLen) > file.m_length)
|
||||
{
|
||||
std::cerr << "Error: Specified length in " << assetName << " GSC BIN structure exceeds the actual file size\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
scriptFile->buffer = memory->Alloc<char>(scriptFile->compressedLen);
|
||||
memcpy(const_cast<char*>(scriptFile->buffer), fileBuffer.get() + offset, scriptFile->compressedLen);
|
||||
offset += scriptFile->compressedLen;
|
||||
|
||||
scriptFile->bytecode = memory->Alloc<unsigned char>(scriptFile->bytecodeLen);
|
||||
memcpy(scriptFile->bytecode, fileBuffer.get() + offset, scriptFile->bytecodeLen);
|
||||
|
||||
manager->AddAsset<AssetScript>(assetName, scriptFile);
|
||||
|
||||
return true;
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
#pragma once
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderScriptFile final : public BasicAssetLoader<AssetScript>
|
||||
{
|
||||
public:
|
||||
_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 IW5
|
@ -1,17 +0,0 @@
|
||||
#include "AssetLoaderSoundAliasList.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderSoundAliasList::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* sndAliasList = memory->Create<snd_alias_list_t>();
|
||||
memset(sndAliasList, 0, sizeof(snd_alias_list_t));
|
||||
sndAliasList->aliasName = memory->Dup(assetName.c_str());
|
||||
return sndAliasList;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderSoundAliasList final : public BasicAssetLoader<AssetSound>
|
||||
{
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
} // namespace IW5
|
@ -1,17 +0,0 @@
|
||||
#include "AssetLoaderSoundCurve.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderSoundCurve::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* sndCurve = memory->Create<SndCurve>();
|
||||
memset(sndCurve, 0, sizeof(SndCurve));
|
||||
sndCurve->filename = memory->Dup(assetName.c_str());
|
||||
return sndCurve;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderSoundCurve final : public BasicAssetLoader<AssetSoundCurve>
|
||||
{
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
} // namespace IW5
|
@ -1,40 +0,0 @@
|
||||
#include "AssetLoaderStringTable.h"
|
||||
|
||||
#include "Csv/CsvStream.h"
|
||||
#include "Game/IW5/CommonIW5.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
#include "StringTable/StringTableLoader.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderStringTable::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* stringTable = memory->Create<StringTable>();
|
||||
memset(stringTable, 0, sizeof(StringTable));
|
||||
stringTable->name = memory->Dup(assetName.c_str());
|
||||
return stringTable;
|
||||
}
|
||||
|
||||
bool AssetLoaderStringTable::CanLoadFromRaw() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderStringTable::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
const auto file = searchPath->Open(assetName);
|
||||
if (!file.IsOpen())
|
||||
return false;
|
||||
|
||||
string_table::StringTableLoaderV2<StringTable, Common::StringTable_HashString> loader;
|
||||
auto* stringTable = loader.LoadFromStream(assetName, *memory, *file.m_stream);
|
||||
|
||||
manager->AddAsset<AssetStringTable>(assetName, stringTable);
|
||||
|
||||
return true;
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderStringTable final : public BasicAssetLoader<AssetStringTable>
|
||||
{
|
||||
public:
|
||||
_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 IW5
|
@ -1,17 +0,0 @@
|
||||
#include "AssetLoaderStructuredDataDef.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderStructuredDataDef::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* structuredDataDefSet = memory->Create<StructuredDataDefSet>();
|
||||
memset(structuredDataDefSet, 0, sizeof(StructuredDataDefSet));
|
||||
structuredDataDefSet->name = memory->Dup(assetName.c_str());
|
||||
return structuredDataDefSet;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderStructuredDataDef final : public BasicAssetLoader<AssetStructuredDataDef>
|
||||
{
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
} // namespace IW5
|
@ -1,17 +0,0 @@
|
||||
#include "AssetLoaderSurfaceFxTable.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderSurfaceFxTable::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* surfaceFxTable = memory->Create<SurfaceFxTable>();
|
||||
memset(surfaceFxTable, 0, sizeof(SurfaceFxTable));
|
||||
surfaceFxTable->name = memory->Dup(assetName.c_str());
|
||||
return surfaceFxTable;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderSurfaceFxTable final : public BasicAssetLoader<AssetSurfaceFx>
|
||||
{
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
} // namespace IW5
|
@ -1,17 +0,0 @@
|
||||
#include "AssetLoaderTechniqueSet.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderTechniqueSet::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* techniqueSet = memory->Create<MaterialTechniqueSet>();
|
||||
memset(techniqueSet, 0, sizeof(MaterialTechniqueSet));
|
||||
techniqueSet->name = memory->Dup(assetName.c_str());
|
||||
return techniqueSet;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderTechniqueSet final : public BasicAssetLoader<AssetTechniqueSet>
|
||||
{
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
} // namespace IW5
|
@ -1,17 +0,0 @@
|
||||
#include "AssetLoaderTracerDef.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderTracerDef::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* tracerDef = memory->Create<TracerDef>();
|
||||
memset(tracerDef, 0, sizeof(TracerDef));
|
||||
tracerDef->name = memory->Dup(assetName.c_str());
|
||||
return tracerDef;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderTracerDef final : public BasicAssetLoader<AssetTracer>
|
||||
{
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
} // namespace IW5
|
@ -1,17 +0,0 @@
|
||||
#include "AssetLoaderVehicleDef.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderVehicleDef::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* vehicleDef = memory->Create<VehicleDef>();
|
||||
memset(vehicleDef, 0, sizeof(VehicleDef));
|
||||
vehicleDef->name = memory->Dup(assetName.c_str());
|
||||
return vehicleDef;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderVehicleDef final : public BasicAssetLoader<AssetVehicle>
|
||||
{
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
} // namespace IW5
|
@ -1,17 +0,0 @@
|
||||
#include "AssetLoaderVehicleTrack.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderVehicleTrack::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* vehicleTrack = memory->Create<VehicleTrack>();
|
||||
memset(vehicleTrack, 0, sizeof(VehicleTrack));
|
||||
vehicleTrack->name = memory->Dup(assetName.c_str());
|
||||
return vehicleTrack;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderVehicleTrack final : public BasicAssetLoader<AssetVehicleTrack>
|
||||
{
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
} // namespace IW5
|
@ -1,17 +0,0 @@
|
||||
#include "AssetLoaderVertexDecl.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderVertexDecl::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* vertexDecl = memory->Create<MaterialVertexDeclaration>();
|
||||
memset(vertexDecl, 0, sizeof(MaterialVertexDeclaration));
|
||||
vertexDecl->name = memory->Dup(assetName.c_str());
|
||||
return vertexDecl;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderVertexDecl final : public BasicAssetLoader<AssetVertexDecl>
|
||||
{
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
} // namespace IW5
|
@ -1,17 +0,0 @@
|
||||
#include "AssetLoaderVertexShader.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderVertexShader::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* vertexShader = memory->Create<MaterialVertexShader>();
|
||||
memset(vertexShader, 0, sizeof(MaterialVertexShader));
|
||||
vertexShader->name = memory->Dup(assetName.c_str());
|
||||
return vertexShader;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderVertexShader final : public BasicAssetLoader<AssetVertexShader>
|
||||
{
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
} // namespace IW5
|
@ -1,20 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderWeapon final : public BasicAssetLoader<AssetWeapon>
|
||||
{
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
_NODISCARD bool CanLoadFromGdt() const override;
|
||||
bool LoadFromGdt(
|
||||
const std::string& assetName, IGdtQueryable* gdtQueryable, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
_NODISCARD bool CanLoadFromRaw() const override;
|
||||
bool
|
||||
LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
};
|
||||
} // namespace IW5
|
@ -1,45 +0,0 @@
|
||||
#include "AssetLoaderWeaponAttachment.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "Game/IW5/Weapon/JsonWeaponAttachmentLoader.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderWeaponAttachment::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* attachment = memory->Create<WeaponAttachment>();
|
||||
memset(attachment, 0, sizeof(WeaponAttachment));
|
||||
attachment->szInternalName = memory->Dup(assetName.c_str());
|
||||
|
||||
return attachment;
|
||||
}
|
||||
|
||||
bool AssetLoaderWeaponAttachment::CanLoadFromRaw() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderWeaponAttachment::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
const auto file = searchPath->Open(std::format("attachment/{}.json", assetName));
|
||||
if (!file.IsOpen())
|
||||
return false;
|
||||
|
||||
auto* attachment = memory->Alloc<WeaponAttachment>();
|
||||
attachment->szInternalName = memory->Dup(assetName.c_str());
|
||||
|
||||
std::vector<XAssetInfoGeneric*> dependencies;
|
||||
std::vector<IndirectAssetReference> indirectAssetReferences;
|
||||
if (LoadWeaponAttachmentAsJson(*file.m_stream, *attachment, memory, manager, dependencies, indirectAssetReferences))
|
||||
manager->AddAsset<AssetAttachment>(assetName, attachment, std::move(dependencies), std::vector<scr_string_t>(), std::move(indirectAssetReferences));
|
||||
else
|
||||
std::cerr << "Failed to load attachment \"" << assetName << "\"\n";
|
||||
|
||||
return true;
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
#pragma once
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderWeaponAttachment final : public BasicAssetLoader<AssetAttachment>
|
||||
{
|
||||
public:
|
||||
_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 IW5
|
@ -1,17 +0,0 @@
|
||||
#include "AssetLoaderXAnim.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderXAnim::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* anim = memory->Create<XAnimParts>();
|
||||
memset(anim, 0, sizeof(XAnimParts));
|
||||
anim->name = memory->Dup(assetName.c_str());
|
||||
return anim;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderXAnim final : public BasicAssetLoader<AssetXAnim>
|
||||
{
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
} // namespace IW5
|
@ -1,47 +0,0 @@
|
||||
#include "AssetLoaderXModel.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "Game/IW5/XModel/XModelLoaderIW5.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderXModel::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* asset = memory->Alloc<AssetXModel::Type>();
|
||||
asset->name = memory->Dup(assetName.c_str());
|
||||
return asset;
|
||||
}
|
||||
|
||||
bool AssetLoaderXModel::CanLoadFromRaw() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderXModel::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
const auto file = searchPath->Open(std::format("xmodel/{}.json", assetName));
|
||||
if (!file.IsOpen())
|
||||
return false;
|
||||
|
||||
auto* xmodel = memory->Alloc<XModel>();
|
||||
xmodel->name = memory->Dup(assetName.c_str());
|
||||
|
||||
std::vector<XAssetInfoGeneric*> dependencies;
|
||||
if (LoadXModel(*file.m_stream, *xmodel, memory, manager, dependencies))
|
||||
{
|
||||
manager->AddAsset<AssetXModel>(assetName, xmodel, std::move(dependencies));
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << std::format("Failed to load xmodel \"{}\"\n", assetName);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
#pragma once
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderXModel final : public BasicAssetLoader<AssetXModel>
|
||||
{
|
||||
static std::string GetFileNameForAsset(const std::string& assetName);
|
||||
|
||||
public:
|
||||
_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 IW5
|
@ -1,17 +0,0 @@
|
||||
#include "AssetLoaderXModelSurfs.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
void* AssetLoaderXModelSurfs::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
auto* modelSurfs = memory->Create<XModelSurfs>();
|
||||
memset(modelSurfs, 0, sizeof(XModelSurfs));
|
||||
modelSurfs->name = memory->Dup(assetName.c_str());
|
||||
return modelSurfs;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderXModelSurfs final : public BasicAssetLoader<AssetXModelSurfs>
|
||||
{
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
} // namespace IW5
|
69
src/ObjLoading/Game/IW5/Image/LoaderImageIW5.cpp
Normal file
69
src/ObjLoading/Game/IW5/Image/LoaderImageIW5.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
#include "LoaderImageIW5.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "Image/IwiLoader.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr auto MAX_IMAGE_NAME_SIZE = 0x800;
|
||||
|
||||
class ImageLoader final : public AssetCreator<AssetImage>
|
||||
{
|
||||
public:
|
||||
ImageLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
: m_memory(memory),
|
||||
m_search_path(searchPath)
|
||||
{
|
||||
}
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||
{
|
||||
const auto fileName = std::format("images/{}.iwi", assetName);
|
||||
const auto file = m_search_path.Open(fileName);
|
||||
if (!file.IsOpen())
|
||||
return AssetCreationResult::NoAction();
|
||||
|
||||
const auto fileSize = static_cast<size_t>(file.m_length);
|
||||
const auto fileData = std::make_unique<char[]>(fileSize);
|
||||
file.m_stream->read(fileData.get(), fileSize);
|
||||
|
||||
std::istringstream ss(std::string(fileData.get(), fileSize));
|
||||
const auto texture = iwi::LoadIwi(ss);
|
||||
if (!texture)
|
||||
{
|
||||
std::cerr << std::format("Failed to load texture from: {}\n", fileName);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
|
||||
auto* image = m_memory.Alloc<GfxImage>();
|
||||
image->name = m_memory.Dup(assetName.c_str());
|
||||
image->noPicmip = !texture->HasMipMaps();
|
||||
image->width = static_cast<uint16_t>(texture->GetWidth());
|
||||
image->height = static_cast<uint16_t>(texture->GetHeight());
|
||||
image->depth = static_cast<uint16_t>(texture->GetDepth());
|
||||
|
||||
image->texture.loadDef = m_memory.Alloc<GfxImageLoadDef>();
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset<AssetImage>(assetName, image));
|
||||
}
|
||||
|
||||
private:
|
||||
MemoryManager& m_memory;
|
||||
ISearchPath& m_search_path;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetImage>> CreateImageLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
{
|
||||
return std::make_unique<ImageLoader>(memory, searchPath);
|
||||
}
|
||||
} // namespace IW5
|
13
src/ObjLoading/Game/IW5/Image/LoaderImageIW5.h
Normal file
13
src/ObjLoading/Game/IW5/Image/LoaderImageIW5.h
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "Asset/IAssetCreator.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetImage>> CreateImageLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace IW5
|
@ -1,6 +1,7 @@
|
||||
#include "InfoStringToStructConverter.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
|
||||
using namespace IW5;
|
||||
@ -8,12 +9,12 @@ using namespace IW5;
|
||||
InfoStringToStructConverter::InfoStringToStructConverter(const InfoString& infoString,
|
||||
void* structure,
|
||||
ZoneScriptStrings& zoneScriptStrings,
|
||||
MemoryManager* memory,
|
||||
IAssetLoadingManager* manager,
|
||||
MemoryManager& memory,
|
||||
AssetCreationContext& context,
|
||||
GenericAssetRegistration& registration,
|
||||
const cspField_t* fields,
|
||||
const size_t fieldCount)
|
||||
: InfoStringToStructConverterBase(infoString, structure, zoneScriptStrings, memory),
|
||||
m_loading_manager(manager),
|
||||
: InfoStringToStructConverterBase(infoString, structure, zoneScriptStrings, memory, context, registration),
|
||||
m_fields(fields),
|
||||
m_field_count(fieldCount)
|
||||
{
|
||||
@ -58,15 +59,15 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons
|
||||
return true;
|
||||
}
|
||||
|
||||
auto* fx = m_loading_manager->LoadDependency<AssetFx>(value);
|
||||
auto* fx = m_context.LoadDependency<AssetFx>(value);
|
||||
|
||||
if (fx == nullptr)
|
||||
{
|
||||
std::cout << "Failed to load fx asset \"" << value << "\"\n";
|
||||
std::cerr << std::format("Failed to load fx asset \"{}\"\n", value);
|
||||
return false;
|
||||
}
|
||||
|
||||
m_dependencies.emplace(fx);
|
||||
m_registration.AddDependency(fx);
|
||||
*reinterpret_cast<FxEffectDef**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = fx->Asset();
|
||||
|
||||
return true;
|
||||
@ -80,15 +81,15 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons
|
||||
return true;
|
||||
}
|
||||
|
||||
auto* xmodel = m_loading_manager->LoadDependency<AssetXModel>(value);
|
||||
auto* xmodel = m_context.LoadDependency<AssetXModel>(value);
|
||||
|
||||
if (xmodel == nullptr)
|
||||
{
|
||||
std::cout << "Failed to load xmodel asset \"" << value << "\"\n";
|
||||
std::cerr << std::format("Failed to load xmodel asset \"{}\"\n", value);
|
||||
return false;
|
||||
}
|
||||
|
||||
m_dependencies.emplace(xmodel);
|
||||
m_registration.AddDependency(xmodel);
|
||||
*reinterpret_cast<XModel**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = xmodel->Asset();
|
||||
|
||||
return true;
|
||||
@ -102,15 +103,15 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons
|
||||
return true;
|
||||
}
|
||||
|
||||
auto* material = m_loading_manager->LoadDependency<AssetMaterial>(value);
|
||||
auto* material = m_context.LoadDependency<AssetMaterial>(value);
|
||||
|
||||
if (material == nullptr)
|
||||
{
|
||||
std::cout << "Failed to load material asset \"" << value << "\"\n";
|
||||
std::cerr << std::format("Failed to load material asset \"{}\"\n", value);
|
||||
return false;
|
||||
}
|
||||
|
||||
m_dependencies.emplace(material);
|
||||
m_registration.AddDependency(material);
|
||||
*reinterpret_cast<Material**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = material->Asset();
|
||||
|
||||
return true;
|
||||
@ -124,15 +125,15 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons
|
||||
return true;
|
||||
}
|
||||
|
||||
auto* tracer = m_loading_manager->LoadDependency<AssetTracer>(value);
|
||||
auto* tracer = m_context.LoadDependency<AssetTracer>(value);
|
||||
|
||||
if (tracer == nullptr)
|
||||
{
|
||||
std::cout << "Failed to load tracer asset \"" << value << "\"\n";
|
||||
std::cerr << std::format("Failed to load tracer asset \"{}\"\n", value);
|
||||
return false;
|
||||
}
|
||||
|
||||
m_dependencies.emplace(tracer);
|
||||
m_registration.AddDependency(tracer);
|
||||
*reinterpret_cast<TracerDef**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = tracer->Asset();
|
||||
|
||||
return true;
|
||||
@ -160,15 +161,15 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons
|
||||
return true;
|
||||
}
|
||||
|
||||
auto* collmap = m_loading_manager->LoadDependency<AssetPhysCollMap>(value);
|
||||
auto* collmap = m_context.LoadDependency<AssetPhysCollMap>(value);
|
||||
|
||||
if (collmap == nullptr)
|
||||
{
|
||||
std::cout << "Failed to load collmap asset \"" << value << "\"\n";
|
||||
std::cerr << std::format("Failed to load collmap asset \"{}\"\n", value);
|
||||
return false;
|
||||
}
|
||||
|
||||
m_dependencies.emplace(collmap);
|
||||
m_registration.AddDependency(collmap);
|
||||
*reinterpret_cast<PhysCollmap**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = collmap->Asset();
|
||||
|
||||
return true;
|
||||
@ -182,12 +183,12 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons
|
||||
return true;
|
||||
}
|
||||
|
||||
auto* name = m_memory->Alloc<snd_alias_list_name>();
|
||||
name->soundName = m_memory->Dup(value.c_str());
|
||||
auto* name = m_memory.Alloc<snd_alias_list_name>();
|
||||
name->soundName = m_memory.Dup(value.c_str());
|
||||
|
||||
reinterpret_cast<SndAliasCustom*>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset)->name = name;
|
||||
|
||||
m_indirect_asset_references.emplace(ASSET_TYPE_SOUND, value);
|
||||
m_registration.AddIndirectAssetReference(m_context.LoadIndirectAssetReference<AssetSound>(value));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "InfoString/InfoStringToStructConverterBase.h"
|
||||
@ -7,24 +8,22 @@ namespace IW5
|
||||
{
|
||||
class InfoStringToStructConverter : public InfoStringToStructConverterBase
|
||||
{
|
||||
protected:
|
||||
IAssetLoadingManager* m_loading_manager;
|
||||
const cspField_t* m_fields;
|
||||
size_t m_field_count;
|
||||
|
||||
static bool GetHashValue(const std::string& value, unsigned int& hash);
|
||||
|
||||
virtual bool ConvertExtensionField(const cspField_t& field, const std::string& value) = 0;
|
||||
bool ConvertBaseField(const cspField_t& field, const std::string& value);
|
||||
|
||||
public:
|
||||
InfoStringToStructConverter(const InfoString& infoString,
|
||||
void* structure,
|
||||
ZoneScriptStrings& zoneScriptStrings,
|
||||
MemoryManager* memory,
|
||||
IAssetLoadingManager* manager,
|
||||
MemoryManager& memory,
|
||||
AssetCreationContext& context,
|
||||
GenericAssetRegistration& registration,
|
||||
const cspField_t* fields,
|
||||
size_t fieldCount);
|
||||
bool Convert() override;
|
||||
|
||||
protected:
|
||||
virtual bool ConvertExtensionField(const cspField_t& field, const std::string& value) = 0;
|
||||
bool ConvertBaseField(const cspField_t& field, const std::string& value);
|
||||
|
||||
const cspField_t* m_fields;
|
||||
size_t m_field_count;
|
||||
};
|
||||
} // namespace IW5
|
||||
|
@ -122,9 +122,9 @@ namespace
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
bool LoadLeaderboardAsJson(std::istream& stream, LeaderboardDef& leaderboard, MemoryManager* memory)
|
||||
bool LoadLeaderboardAsJson(std::istream& stream, LeaderboardDef& leaderboard, MemoryManager& memory)
|
||||
{
|
||||
const JsonLoader loader(stream, *memory);
|
||||
const JsonLoader loader(stream, memory);
|
||||
|
||||
return loader.Load(leaderboard);
|
||||
}
|
||||
|
@ -7,5 +7,5 @@
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
bool LoadLeaderboardAsJson(std::istream& stream, LeaderboardDef& leaderboard, MemoryManager* memory);
|
||||
bool LoadLeaderboardAsJson(std::istream& stream, LeaderboardDef& leaderboard, MemoryManager& memory);
|
||||
} // namespace IW5
|
||||
|
53
src/ObjLoading/Game/IW5/Leaderboard/LoaderLeaderboardIW5.cpp
Normal file
53
src/ObjLoading/Game/IW5/Leaderboard/LoaderLeaderboardIW5.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
#include "LoaderLeaderboardIW5.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "JsonLeaderboardDefLoader.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
namespace
|
||||
{
|
||||
class LeaderboardLoader final : public AssetCreator<AssetLeaderboard>
|
||||
{
|
||||
public:
|
||||
LeaderboardLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
: m_memory(memory),
|
||||
m_search_path(searchPath)
|
||||
{
|
||||
}
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||
{
|
||||
const auto file = m_search_path.Open(std::format("leaderboards/{}.json", assetName));
|
||||
if (!file.IsOpen())
|
||||
return AssetCreationResult::NoAction();
|
||||
|
||||
auto* leaderboardDef = m_memory.Alloc<LeaderboardDef>();
|
||||
leaderboardDef->name = m_memory.Dup(assetName.c_str());
|
||||
|
||||
if (!LoadLeaderboardAsJson(*file.m_stream, *leaderboardDef, m_memory))
|
||||
{
|
||||
std::cerr << std::format("Failed to load leaderboard \"{}\"\n", assetName);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset<AssetLeaderboard>(assetName, leaderboardDef));
|
||||
}
|
||||
|
||||
private:
|
||||
MemoryManager& m_memory;
|
||||
ISearchPath& m_search_path;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetLeaderboard>> CreateLeaderboardLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
{
|
||||
return std::make_unique<LeaderboardLoader>(memory, searchPath);
|
||||
}
|
||||
} // namespace IW5
|
13
src/ObjLoading/Game/IW5/Leaderboard/LoaderLeaderboardIW5.h
Normal file
13
src/ObjLoading/Game/IW5/Leaderboard/LoaderLeaderboardIW5.h
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "Asset/IAssetCreator.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetLeaderboard>> CreateLeaderboardLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace IW5
|
@ -1,23 +0,0 @@
|
||||
#include "AssetLoaderLocalizeIW5.h"
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
AssetLoaderLocalize::AssetLoaderLocalize(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
: CommonLocalizeLoader(searchPath, zone),
|
||||
m_memory(memory)
|
||||
{
|
||||
}
|
||||
|
||||
AssetCreationResult AssetLoaderLocalize::CreateAsset(const std::string& assetName, AssetCreationContext& context)
|
||||
{
|
||||
return CreateLocalizeAsset(assetName, context);
|
||||
}
|
||||
|
||||
AssetCreationResult AssetLoaderLocalize::CreateAssetFromCommonAsset(const CommonLocalizeEntry& localizeEntry, AssetCreationContext& context)
|
||||
{
|
||||
auto* asset = m_memory.Alloc<LocalizeEntry>();
|
||||
asset->name = m_memory.Dup(localizeEntry.m_key.c_str());
|
||||
asset->value = m_memory.Dup(localizeEntry.m_value.c_str());
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset<AssetLocalize>(localizeEntry.m_key, asset));
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Asset/AssetCreationContext.h"
|
||||
#include "Asset/IAssetCreator.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "Localize/CommonLocalizeLoader.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
#include "Zone/Zone.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetLoaderLocalize final : public AssetCreator<AssetLocalize>, public CommonLocalizeLoader
|
||||
{
|
||||
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 IW5
|
44
src/ObjLoading/Game/IW5/Localize/LoaderLocalizeIW5.cpp
Normal file
44
src/ObjLoading/Game/IW5/Localize/LoaderLocalizeIW5.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
#include "LoaderLocalizeIW5.h"
|
||||
|
||||
#include "Localize/CommonLocalizeLoader.h"
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
namespace
|
||||
{
|
||||
class LocalizeLoader final : public AssetCreator<AssetLocalize>, public CommonLocalizeLoader
|
||||
{
|
||||
public:
|
||||
LocalizeLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
: CommonLocalizeLoader(searchPath, zone),
|
||||
m_memory(memory)
|
||||
{
|
||||
}
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||
{
|
||||
return CreateLocalizeAsset(assetName, context);
|
||||
}
|
||||
|
||||
protected:
|
||||
AssetCreationResult CreateAssetFromCommonAsset(const CommonLocalizeEntry& localizeEntry, AssetCreationContext& context) override
|
||||
{
|
||||
auto* asset = m_memory.Alloc<LocalizeEntry>();
|
||||
asset->name = m_memory.Dup(localizeEntry.m_key.c_str());
|
||||
asset->value = m_memory.Dup(localizeEntry.m_value.c_str());
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset<AssetLocalize>(localizeEntry.m_key, asset));
|
||||
}
|
||||
|
||||
private:
|
||||
MemoryManager& m_memory;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetLocalize>> CreateLocalizeLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
{
|
||||
return std::make_unique<LocalizeLoader>(memory, searchPath, zone);
|
||||
}
|
||||
} // namespace IW5
|
14
src/ObjLoading/Game/IW5/Localize/LoaderLocalizeIW5.h
Normal file
14
src/ObjLoading/Game/IW5/Localize/LoaderLocalizeIW5.h
Normal file
@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "Asset/IAssetCreator.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
#include "Zone/Zone.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetLocalize>> CreateLocalizeLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||
} // namespace IW5
|
@ -16,12 +16,11 @@ namespace
|
||||
class JsonLoader
|
||||
{
|
||||
public:
|
||||
JsonLoader(std::istream& stream, MemoryManager& memory, IAssetLoadingManager& manager, std::vector<XAssetInfoGeneric*>& dependencies)
|
||||
JsonLoader(std::istream& stream, MemoryManager& memory, AssetCreationContext& context, AssetRegistration<AssetMaterial>& registration)
|
||||
: m_stream(stream),
|
||||
m_memory(memory),
|
||||
m_manager(manager),
|
||||
m_dependencies(dependencies)
|
||||
|
||||
m_context(context),
|
||||
m_registration(registration)
|
||||
{
|
||||
}
|
||||
|
||||
@ -159,13 +158,13 @@ namespace
|
||||
|
||||
textureDef.semantic = jTexture.semantic;
|
||||
|
||||
auto* imageAsset = m_manager.LoadDependency<AssetImage>(jTexture.image);
|
||||
auto* imageAsset = m_context.LoadDependency<AssetImage>(jTexture.image);
|
||||
if (!imageAsset)
|
||||
{
|
||||
PrintError(material, std::format("Could not find textureDef image: {}", jTexture.image));
|
||||
return false;
|
||||
}
|
||||
m_dependencies.push_back(imageAsset);
|
||||
m_registration.AddDependency(imageAsset);
|
||||
|
||||
if (jTexture.water)
|
||||
{
|
||||
@ -365,13 +364,13 @@ namespace
|
||||
material.stateFlags = static_cast<unsigned char>(jMaterial.stateFlags);
|
||||
material.cameraRegion = jMaterial.cameraRegion;
|
||||
|
||||
auto* techniqueSet = m_manager.LoadDependency<AssetTechniqueSet>(jMaterial.techniqueSet);
|
||||
auto* techniqueSet = m_context.LoadDependency<AssetTechniqueSet>(jMaterial.techniqueSet);
|
||||
if (!techniqueSet)
|
||||
{
|
||||
PrintError(material, "Could not find technique set");
|
||||
return false;
|
||||
}
|
||||
m_dependencies.push_back(techniqueSet);
|
||||
m_registration.AddDependency(techniqueSet);
|
||||
material.techniqueSet = techniqueSet->Asset();
|
||||
|
||||
if (!jMaterial.textures.empty())
|
||||
@ -430,17 +429,17 @@ namespace
|
||||
|
||||
std::istream& m_stream;
|
||||
MemoryManager& m_memory;
|
||||
IAssetLoadingManager& m_manager;
|
||||
std::vector<XAssetInfoGeneric*>& m_dependencies;
|
||||
AssetCreationContext& m_context;
|
||||
AssetRegistration<AssetMaterial>& m_registration;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
bool LoadMaterialAsJson(
|
||||
std::istream& stream, Material& material, MemoryManager* memory, IAssetLoadingManager* manager, std::vector<XAssetInfoGeneric*>& dependencies)
|
||||
std::istream& stream, Material& material, MemoryManager& memory, AssetCreationContext& context, AssetRegistration<AssetMaterial>& registration)
|
||||
{
|
||||
const JsonLoader loader(stream, *memory, *manager, dependencies);
|
||||
const JsonLoader loader(stream, memory, context, registration);
|
||||
|
||||
return loader.Load(material);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
#include "Asset/AssetCreationContext.h"
|
||||
#include "Asset/AssetRegistration.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
|
||||
@ -9,5 +10,5 @@
|
||||
namespace IW5
|
||||
{
|
||||
bool LoadMaterialAsJson(
|
||||
std::istream& stream, Material& material, MemoryManager* memory, IAssetLoadingManager* manager, std::vector<XAssetInfoGeneric*>& dependencies);
|
||||
std::istream& stream, Material& material, MemoryManager& memory, AssetCreationContext& context, AssetRegistration<AssetMaterial>& registration);
|
||||
} // namespace IW5
|
||||
|
70
src/ObjLoading/Game/IW5/Material/LoaderMaterialIW5.cpp
Normal file
70
src/ObjLoading/Game/IW5/Material/LoaderMaterialIW5.cpp
Normal file
@ -0,0 +1,70 @@
|
||||
#include "LoaderMaterialIW5.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "JsonMaterialLoader.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
namespace
|
||||
{
|
||||
class MaterialLoader final : public AssetCreator<AssetMaterial>
|
||||
{
|
||||
public:
|
||||
MaterialLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
: m_memory(memory),
|
||||
m_search_path(searchPath)
|
||||
{
|
||||
}
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||
{
|
||||
const auto file = m_search_path.Open(GetFileNameForAsset(assetName));
|
||||
if (!file.IsOpen())
|
||||
return AssetCreationResult::NoAction();
|
||||
|
||||
auto* material = m_memory.Alloc<Material>();
|
||||
material->info.name = m_memory.Dup(assetName.c_str());
|
||||
|
||||
AssetRegistration<AssetMaterial> registration(assetName, material);
|
||||
if (!LoadMaterialAsJson(*file.m_stream, *material, m_memory, context, registration))
|
||||
{
|
||||
std::cerr << std::format("Failed to load material \"{}\"\n", assetName);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
||||
}
|
||||
|
||||
private:
|
||||
std::string GetFileNameForAsset(const std::string& assetName)
|
||||
{
|
||||
std::string sanitizedFileName(assetName);
|
||||
if (sanitizedFileName[0] == '*')
|
||||
{
|
||||
std::ranges::replace(sanitizedFileName, '*', '_');
|
||||
const auto parenthesisPos = sanitizedFileName.find('(');
|
||||
if (parenthesisPos != std::string::npos)
|
||||
sanitizedFileName.erase(parenthesisPos);
|
||||
sanitizedFileName = std::format("generated/{}", sanitizedFileName);
|
||||
}
|
||||
|
||||
return std::format("materials/{}.json", sanitizedFileName);
|
||||
}
|
||||
|
||||
MemoryManager& m_memory;
|
||||
ISearchPath& m_search_path;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetMaterial>> CreateMaterialLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
{
|
||||
return std::make_unique<MaterialLoader>(memory, searchPath);
|
||||
}
|
||||
} // namespace IW5
|
13
src/ObjLoading/Game/IW5/Material/LoaderMaterialIW5.h
Normal file
13
src/ObjLoading/Game/IW5/Material/LoaderMaterialIW5.h
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "Asset/IAssetCreator.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetMaterial>> CreateMaterialLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace IW5
|
230
src/ObjLoading/Game/IW5/Menu/LoaderMenuListIW5.cpp
Normal file
230
src/ObjLoading/Game/IW5/Menu/LoaderMenuListIW5.cpp
Normal file
@ -0,0 +1,230 @@
|
||||
#include "LoaderMenuListIW5.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "Game/IW5/Menu/MenuConversionZoneStateIW5.h"
|
||||
#include "Game/IW5/Menu/MenuConverterIW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Parsing/Menu/MenuFileReader.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
namespace
|
||||
{
|
||||
class MenuListLoader final : public AssetCreator<AssetMenuList>
|
||||
{
|
||||
public:
|
||||
MenuListLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
: m_memory(memory),
|
||||
m_search_path(searchPath)
|
||||
{
|
||||
}
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||
{
|
||||
std::vector<menuDef_t*> menus;
|
||||
AssetRegistration<AssetMenuList> registration(assetName);
|
||||
|
||||
auto* zoneState = context.GetZoneAssetLoaderState<menu::MenuAssetZoneState>();
|
||||
auto* conversionState = context.GetZoneAssetLoaderState<MenuConversionZoneState>();
|
||||
|
||||
std::deque<std::string> menuLoadQueue;
|
||||
const auto alreadyLoadedMenuListFileMenus = conversionState->m_menus_by_filename.find(assetName);
|
||||
|
||||
if (alreadyLoadedMenuListFileMenus == conversionState->m_menus_by_filename.end())
|
||||
{
|
||||
const auto file = m_search_path.Open(assetName);
|
||||
if (!file.IsOpen())
|
||||
return AssetCreationResult::NoAction();
|
||||
|
||||
const auto menuListResult = ParseMenuFile(*file.m_stream, assetName, zoneState);
|
||||
if (menuListResult)
|
||||
{
|
||||
ProcessParsedResults(assetName, context, menuListResult.get(), zoneState, conversionState, menus, registration);
|
||||
|
||||
for (const auto& menuToLoad : menuListResult->m_menus_to_load)
|
||||
menuLoadQueue.emplace_back(menuToLoad);
|
||||
|
||||
zoneState->AddMenusToLoad(assetName, std::move(menuListResult->m_menus_to_load));
|
||||
}
|
||||
else
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
|
||||
while (!menuLoadQueue.empty())
|
||||
{
|
||||
const auto& menuFileToLoad = menuLoadQueue.front();
|
||||
|
||||
LoadMenuFileFromQueue(menuFileToLoad, context, zoneState, conversionState, menus, registration);
|
||||
|
||||
menuLoadQueue.pop_front();
|
||||
}
|
||||
|
||||
auto* menuListAsset = m_memory.Create<MenuList>();
|
||||
menuListAsset->name = m_memory.Dup(assetName.c_str());
|
||||
registration.SetAsset(menuListAsset);
|
||||
|
||||
CreateMenuListAsset(*menuListAsset, menus);
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
||||
}
|
||||
|
||||
void FinalizeZone(AssetCreationContext& context) override
|
||||
{
|
||||
context.GetZoneAssetLoaderState<MenuConversionZoneState>()->FinalizeSupportingData();
|
||||
}
|
||||
|
||||
private:
|
||||
bool LoadMenuFileFromQueue(const std::string& menuFilePath,
|
||||
AssetCreationContext& context,
|
||||
menu::MenuAssetZoneState* zoneState,
|
||||
MenuConversionZoneState* conversionState,
|
||||
std::vector<menuDef_t*>& menus,
|
||||
AssetRegistration<AssetMenuList>& registration)
|
||||
{
|
||||
const auto alreadyLoadedMenuFile = conversionState->m_menus_by_filename.find(menuFilePath);
|
||||
if (alreadyLoadedMenuFile != conversionState->m_menus_by_filename.end())
|
||||
{
|
||||
std::cout << std::format("Already loaded \"{}\", skipping\n", menuFilePath);
|
||||
for (auto* menu : alreadyLoadedMenuFile->second)
|
||||
{
|
||||
menus.emplace_back(menu->Asset());
|
||||
registration.AddDependency(menu);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const auto file = m_search_path.Open(menuFilePath);
|
||||
if (!file.IsOpen())
|
||||
{
|
||||
std::cerr << std::format("Could not open menu file \"{}\"\n", menuFilePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto menuFileResult = ParseMenuFile(*file.m_stream, menuFilePath, zoneState);
|
||||
if (menuFileResult)
|
||||
{
|
||||
ProcessParsedResults(menuFilePath, context, menuFileResult.get(), zoneState, conversionState, menus, registration);
|
||||
if (!menuFileResult->m_menus_to_load.empty())
|
||||
std::cout << std::format("WARNING: Menu file has menus to load even though it is not a menu list, ignoring: \"{}\"\n", menuFilePath);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
std::cerr << std::format("Could not read menu file \"{}\"\n", menuFilePath);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ProcessParsedResults(const std::string& fileName,
|
||||
AssetCreationContext& context,
|
||||
menu::ParsingResult* parsingResult,
|
||||
menu::MenuAssetZoneState* zoneState,
|
||||
MenuConversionZoneState* conversionState,
|
||||
std::vector<menuDef_t*>& menus,
|
||||
AssetRegistration<AssetMenuList>& registration)
|
||||
{
|
||||
const auto menuCount = parsingResult->m_menus.size();
|
||||
const auto functionCount = parsingResult->m_functions.size();
|
||||
const auto menuLoadCount = parsingResult->m_menus_to_load.size();
|
||||
auto totalItemCount = 0u;
|
||||
for (const auto& menu : parsingResult->m_menus)
|
||||
totalItemCount += menu->m_items.size();
|
||||
|
||||
std::cout << std::format("Successfully read menu file \"{}\" ({} loads, {} menus, {} functions, {} items)\n",
|
||||
fileName,
|
||||
menuLoadCount,
|
||||
menuCount,
|
||||
functionCount,
|
||||
totalItemCount);
|
||||
|
||||
// Add all functions to the zone state to make them available for all menus to be converted
|
||||
for (auto& function : parsingResult->m_functions)
|
||||
zoneState->AddFunction(std::move(function));
|
||||
|
||||
// Prepare a list of all menus of this file
|
||||
std::vector<XAssetInfo<menuDef_t>*> allMenusOfFile;
|
||||
allMenusOfFile.reserve(parsingResult->m_menus.size());
|
||||
|
||||
// Convert all menus and add them as assets
|
||||
for (auto& commonMenu : parsingResult->m_menus)
|
||||
{
|
||||
auto converter = IMenuConverter::Create(ObjLoading::Configuration.MenuNoOptimization, m_search_path, m_memory, context);
|
||||
|
||||
auto* menuAsset = m_memory.Alloc<menuDef_t>();
|
||||
AssetRegistration<AssetMenu> menuRegistration(commonMenu->m_name, menuAsset);
|
||||
|
||||
converter->ConvertMenu(*commonMenu, *menuAsset, menuRegistration);
|
||||
if (menuAsset == nullptr)
|
||||
{
|
||||
std::cerr << std::format("Failed to convert menu file \"{}\"\n", commonMenu->m_name);
|
||||
return false;
|
||||
}
|
||||
|
||||
menus.emplace_back(menuAsset);
|
||||
auto* menuAssetInfo = context.AddAsset(std::move(menuRegistration));
|
||||
|
||||
if (menuAssetInfo)
|
||||
{
|
||||
allMenusOfFile.emplace_back(menuAssetInfo);
|
||||
registration.AddDependency(menuAssetInfo);
|
||||
}
|
||||
|
||||
zoneState->AddMenu(std::move(commonMenu));
|
||||
}
|
||||
|
||||
// Register this file with all loaded menus
|
||||
conversionState->AddLoadedFile(fileName, std::move(allMenusOfFile));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CreateMenuListAsset(MenuList& menuList, const std::vector<menuDef_t*>& menus)
|
||||
{
|
||||
menuList.menuCount = static_cast<int>(menus.size());
|
||||
|
||||
if (menuList.menuCount > 0)
|
||||
{
|
||||
menuList.menus = m_memory.Alloc<menuDef_t*>(menuList.menuCount);
|
||||
for (auto i = 0; i < menuList.menuCount; i++)
|
||||
menuList.menus[i] = menus[i];
|
||||
}
|
||||
else
|
||||
menuList.menus = nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<menu::ParsingResult> ParseMenuFile(std::istream& stream, const std::string& menuFileName, const menu::MenuAssetZoneState* zoneState)
|
||||
{
|
||||
menu::MenuFileReader reader(stream,
|
||||
menuFileName,
|
||||
menu::FeatureLevel::IW4,
|
||||
[this](const std::string& filename, const std::string& sourceFile) -> std::unique_ptr<std::istream>
|
||||
{
|
||||
auto foundFileToInclude = m_search_path.Open(filename);
|
||||
if (!foundFileToInclude.IsOpen() || !foundFileToInclude.m_stream)
|
||||
return nullptr;
|
||||
|
||||
return std::move(foundFileToInclude.m_stream);
|
||||
});
|
||||
|
||||
reader.IncludeZoneState(zoneState);
|
||||
reader.SetPermissiveMode(ObjLoading::Configuration.MenuPermissiveParsing);
|
||||
|
||||
return reader.ReadMenuFile();
|
||||
}
|
||||
|
||||
MemoryManager& m_memory;
|
||||
ISearchPath& m_search_path;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetMenuList>> CreateMenuListLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
{
|
||||
return std::make_unique<MenuListLoader>(memory, searchPath);
|
||||
}
|
||||
} // namespace IW5
|
13
src/ObjLoading/Game/IW5/Menu/LoaderMenuListIW5.h
Normal file
13
src/ObjLoading/Game/IW5/Menu/LoaderMenuListIW5.h
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "Asset/IAssetCreator.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetMenuList>> CreateMenuListLoader(MemoryManager& memory, ISearchPath& searchPath);
|
||||
} // namespace IW5
|
@ -16,18 +16,16 @@
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <format>
|
||||
#include <sstream>
|
||||
|
||||
using namespace IW5;
|
||||
using namespace menu;
|
||||
|
||||
namespace IW5
|
||||
namespace
|
||||
{
|
||||
class MenuConverterImpl : public AbstractMenuConverter
|
||||
class MenuConverter final : public AbstractMenuConverter, public IMenuConverter
|
||||
{
|
||||
MenuConversionZoneState* m_conversion_zone_state;
|
||||
MenuAssetZoneState* m_parsing_zone_state;
|
||||
|
||||
_NODISCARD static rectDef_s ConvertRectDef(const CommonRect& rect)
|
||||
{
|
||||
return rectDef_s{
|
||||
@ -78,26 +76,26 @@ namespace IW5
|
||||
return input;
|
||||
}
|
||||
|
||||
_NODISCARD Material* ConvertMaterial(const std::string& materialName, const CommonMenuDef* menu, const CommonItemDef* item = nullptr) const
|
||||
[[nodiscard]] Material* ConvertMaterial(const std::string& materialName, const CommonMenuDef* menu, const CommonItemDef* item = nullptr) const
|
||||
{
|
||||
if (materialName.empty())
|
||||
return nullptr;
|
||||
|
||||
auto* materialDependency = m_manager->LoadDependency<AssetMaterial>(materialName);
|
||||
auto* materialDependency = m_context.LoadDependency<AssetMaterial>(materialName);
|
||||
if (!materialDependency)
|
||||
throw MenuConversionException("Failed to load material \"" + materialName + "\"", menu, item);
|
||||
throw MenuConversionException(std::format("Failed to load material \"{}\"", materialName), menu, item);
|
||||
|
||||
return materialDependency->Asset();
|
||||
}
|
||||
|
||||
_NODISCARD snd_alias_list_t* ConvertSound(const std::string& soundName, const CommonMenuDef* menu, const CommonItemDef* item = nullptr) const
|
||||
[[nodiscard]] snd_alias_list_t* ConvertSound(const std::string& soundName, const CommonMenuDef* menu, const CommonItemDef* item = nullptr) const
|
||||
{
|
||||
if (soundName.empty())
|
||||
return nullptr;
|
||||
|
||||
auto* soundDependency = m_manager->LoadDependency<AssetSound>(soundName);
|
||||
auto* soundDependency = m_context.LoadDependency<AssetSound>(soundName);
|
||||
if (!soundDependency)
|
||||
throw MenuConversionException("Failed to load sound \"" + soundName + "\"", menu, item);
|
||||
throw MenuConversionException(std::format("Failed to load sound \"{}\"", soundName), menu, item);
|
||||
|
||||
return soundDependency->Asset();
|
||||
}
|
||||
@ -416,7 +414,7 @@ namespace IW5
|
||||
if (!expression)
|
||||
return nullptr;
|
||||
|
||||
auto* statement = m_memory->Create<Statement_s>();
|
||||
auto* statement = m_memory.Alloc<Statement_s>();
|
||||
for (auto& result : statement->persistentState.lastResult)
|
||||
result = Operand{};
|
||||
for (auto& lastExecutionTime : statement->persistentState.lastExecuteTime)
|
||||
@ -426,8 +424,8 @@ namespace IW5
|
||||
std::vector<expressionEntry> expressionEntries;
|
||||
ConvertExpressionEntry(statement, expressionEntries, expression, menu, item);
|
||||
|
||||
auto* outputExpressionEntries = m_memory->Alloc<expressionEntry>(expressionEntries.size());
|
||||
memcpy(outputExpressionEntries, expressionEntries.data(), sizeof(expressionEntry) * expressionEntries.size());
|
||||
auto* outputExpressionEntries = m_memory.Alloc<expressionEntry>(expressionEntries.size());
|
||||
std::memcpy(outputExpressionEntries, expressionEntries.data(), sizeof(expressionEntry) * expressionEntries.size());
|
||||
|
||||
statement->entries = outputExpressionEntries;
|
||||
statement->numEntries = static_cast<int>(expressionEntries.size());
|
||||
@ -435,10 +433,10 @@ namespace IW5
|
||||
return statement;
|
||||
}
|
||||
|
||||
_NODISCARD Statement_s* ConvertOrApplyStatement(float& staticValue,
|
||||
const ISimpleExpression* expression,
|
||||
const CommonMenuDef* menu,
|
||||
const CommonItemDef* item = nullptr) const
|
||||
[[nodiscard]] Statement_s* ConvertOrApplyStatement(float& staticValue,
|
||||
const ISimpleExpression* expression,
|
||||
const CommonMenuDef* menu,
|
||||
const CommonItemDef* item = nullptr) const
|
||||
{
|
||||
if (m_disable_optimizations)
|
||||
return ConvertExpression(expression, menu, item);
|
||||
@ -466,10 +464,10 @@ namespace IW5
|
||||
return ConvertExpression(expression, menu, item);
|
||||
}
|
||||
|
||||
_NODISCARD Statement_s* ConvertOrApplyStatement(const char*& staticValue,
|
||||
const ISimpleExpression* expression,
|
||||
const CommonMenuDef* menu,
|
||||
const CommonItemDef* item = nullptr) const
|
||||
[[nodiscard]] Statement_s* ConvertOrApplyStatement(const char*& staticValue,
|
||||
const ISimpleExpression* expression,
|
||||
const CommonMenuDef* menu,
|
||||
const CommonItemDef* item = nullptr) const
|
||||
{
|
||||
if (m_disable_optimizations)
|
||||
return ConvertExpression(expression, menu, item);
|
||||
@ -483,7 +481,7 @@ namespace IW5
|
||||
switch (value.m_type)
|
||||
{
|
||||
case SimpleExpressionValue::Type::STRING:
|
||||
staticValue = m_memory->Dup(value.m_string_value->c_str());
|
||||
staticValue = m_memory.Dup(value.m_string_value->c_str());
|
||||
break;
|
||||
|
||||
case SimpleExpressionValue::Type::DOUBLE:
|
||||
@ -496,10 +494,10 @@ namespace IW5
|
||||
return ConvertExpression(expression, menu, item);
|
||||
}
|
||||
|
||||
_NODISCARD Statement_s* ConvertOrApplyStatement(Material*& staticValue,
|
||||
const ISimpleExpression* expression,
|
||||
const CommonMenuDef* menu,
|
||||
const CommonItemDef* item = nullptr) const
|
||||
[[nodiscard]] Statement_s* ConvertOrApplyStatement(Material*& staticValue,
|
||||
const ISimpleExpression* expression,
|
||||
const CommonMenuDef* menu,
|
||||
const CommonItemDef* item = nullptr) const
|
||||
{
|
||||
if (m_disable_optimizations)
|
||||
return ConvertExpression(expression, menu, item);
|
||||
@ -526,10 +524,10 @@ namespace IW5
|
||||
return ConvertExpression(expression, menu, item);
|
||||
}
|
||||
|
||||
_NODISCARD Statement_s* ConvertVisibleExpression(windowDef_t* window,
|
||||
const ISimpleExpression* expression,
|
||||
const CommonMenuDef* commonMenu,
|
||||
const CommonItemDef* commonItem = nullptr) const
|
||||
[[nodiscard]] Statement_s* ConvertVisibleExpression(windowDef_t* window,
|
||||
const ISimpleExpression* expression,
|
||||
const CommonMenuDef* commonMenu,
|
||||
const CommonItemDef* commonItem = nullptr) const
|
||||
{
|
||||
if (expression == nullptr)
|
||||
return nullptr;
|
||||
@ -560,7 +558,7 @@ namespace IW5
|
||||
return ConvertExpression(expression, commonMenu, commonItem);
|
||||
}
|
||||
|
||||
_NODISCARD static EventType SetLocalVarTypeToEventType(const SetLocalVarType setLocalVarType)
|
||||
[[nodiscard]] static EventType SetLocalVarTypeToEventType(const SetLocalVarType setLocalVarType)
|
||||
{
|
||||
switch (setLocalVarType)
|
||||
{
|
||||
@ -588,16 +586,16 @@ namespace IW5
|
||||
if (!setLocalVar)
|
||||
return;
|
||||
|
||||
auto* outputHandler = m_memory->Alloc<MenuEventHandler>();
|
||||
auto* outputSetLocalVar = m_memory->Alloc<SetLocalVarData>();
|
||||
auto* outputHandler = m_memory.Alloc<MenuEventHandler>();
|
||||
auto* outputSetLocalVar = m_memory.Alloc<SetLocalVarData>();
|
||||
|
||||
outputHandler->eventType = SetLocalVarTypeToEventType(setLocalVar->m_type);
|
||||
outputHandler->eventData.setLocalVarData = outputSetLocalVar;
|
||||
|
||||
outputSetLocalVar->localVarName = m_memory->Dup(setLocalVar->m_var_name.c_str());
|
||||
outputSetLocalVar->localVarName = m_memory.Dup(setLocalVar->m_var_name.c_str());
|
||||
outputSetLocalVar->expression = ConvertExpression(setLocalVar->m_value.get(), menu, item);
|
||||
|
||||
elements.push_back(outputHandler);
|
||||
elements.emplace_back(outputHandler);
|
||||
}
|
||||
|
||||
void ConvertEventHandlerScript(std::vector<MenuEventHandler*>& elements, const CommonEventHandlerScript* script) const
|
||||
@ -606,11 +604,11 @@ namespace IW5
|
||||
if (!script)
|
||||
return;
|
||||
|
||||
auto* outputHandler = m_memory->Create<MenuEventHandler>();
|
||||
auto* outputHandler = m_memory.Alloc<MenuEventHandler>();
|
||||
outputHandler->eventType = EVENT_UNCONDITIONAL;
|
||||
outputHandler->eventData.unconditionalScript = m_memory->Dup(script->m_script.c_str());
|
||||
outputHandler->eventData.unconditionalScript = m_memory.Dup(script->m_script.c_str());
|
||||
|
||||
elements.push_back(outputHandler);
|
||||
elements.emplace_back(outputHandler);
|
||||
}
|
||||
|
||||
void ConvertEventHandlerCondition(std::vector<MenuEventHandler*>& elements,
|
||||
@ -633,8 +631,8 @@ namespace IW5
|
||||
}
|
||||
else
|
||||
{
|
||||
auto* outputHandler = m_memory->Alloc<MenuEventHandler>();
|
||||
auto* outputCondition = m_memory->Alloc<ConditionalScript>();
|
||||
auto* outputHandler = m_memory.Alloc<MenuEventHandler>();
|
||||
auto* outputCondition = m_memory.Alloc<ConditionalScript>();
|
||||
|
||||
outputHandler->eventType = EVENT_IF;
|
||||
outputHandler->eventData.conditionalScript = outputCondition;
|
||||
@ -646,7 +644,7 @@ namespace IW5
|
||||
|
||||
if (condition->m_else_elements)
|
||||
{
|
||||
auto* outputElseHandler = m_memory->Create<MenuEventHandler>();
|
||||
auto* outputElseHandler = m_memory.Alloc<MenuEventHandler>();
|
||||
outputElseHandler->eventType = EVENT_ELSE;
|
||||
outputElseHandler->eventData.elseScript = ConvertEventHandlerSet(condition->m_else_elements.get(), menu, item);
|
||||
|
||||
@ -689,7 +687,7 @@ namespace IW5
|
||||
ConvertEventHandler(elements, element.get(), menu, item);
|
||||
}
|
||||
|
||||
_NODISCARD MenuEventHandlerSet*
|
||||
[[nodiscard]] MenuEventHandlerSet*
|
||||
ConvertEventHandlerSet(const CommonEventHandlerSet* eventHandlerSet, const CommonMenuDef* menu, const CommonItemDef* item = nullptr) const
|
||||
{
|
||||
if (!eventHandlerSet)
|
||||
@ -701,9 +699,9 @@ namespace IW5
|
||||
if (elements.empty())
|
||||
return nullptr;
|
||||
|
||||
auto* outputSet = m_memory->Alloc<MenuEventHandlerSet>();
|
||||
auto* outputElements = m_memory->Alloc<MenuEventHandler*>(elements.size());
|
||||
memcpy(outputElements, elements.data(), sizeof(void*) * elements.size());
|
||||
auto* outputSet = m_memory.Alloc<MenuEventHandlerSet>();
|
||||
auto* outputElements = m_memory.Alloc<MenuEventHandler*>(elements.size());
|
||||
std::memcpy(outputElements, elements.data(), sizeof(void*) * elements.size());
|
||||
|
||||
outputSet->eventHandlerCount = static_cast<int>(elements.size());
|
||||
outputSet->eventHandlers = outputElements;
|
||||
@ -711,15 +709,15 @@ namespace IW5
|
||||
return outputSet;
|
||||
}
|
||||
|
||||
_NODISCARD ItemKeyHandler* ConvertKeyHandler(const std::multimap<int, std::unique_ptr<CommonEventHandlerSet>>& keyHandlers,
|
||||
const CommonMenuDef* menu,
|
||||
const CommonItemDef* item = nullptr) const
|
||||
[[nodiscard]] ItemKeyHandler* ConvertKeyHandler(const std::multimap<int, std::unique_ptr<CommonEventHandlerSet>>& keyHandlers,
|
||||
const CommonMenuDef* menu,
|
||||
const CommonItemDef* item = nullptr) const
|
||||
{
|
||||
if (keyHandlers.empty())
|
||||
return nullptr;
|
||||
|
||||
const auto keyHandlerCount = keyHandlers.size();
|
||||
auto* output = m_memory->Alloc<ItemKeyHandler>(keyHandlerCount);
|
||||
auto* output = m_memory.Alloc<ItemKeyHandler>(keyHandlerCount);
|
||||
auto currentKeyHandler = keyHandlers.cbegin();
|
||||
for (auto i = 0u; i < keyHandlerCount; i++)
|
||||
{
|
||||
@ -831,7 +829,7 @@ namespace IW5
|
||||
if (floatExpressionCount <= 0)
|
||||
return nullptr;
|
||||
|
||||
auto* floatExpressions = m_memory->Alloc<ItemFloatExpression>(floatExpressionCount);
|
||||
auto* floatExpressions = m_memory.Alloc<ItemFloatExpression>(floatExpressionCount);
|
||||
auto floatExpressionIndex = 0;
|
||||
for (const auto& [expression, expressionIsStatic, target, staticValue, staticValueArraySize, dynamicFlagsToSet] : locations)
|
||||
{
|
||||
@ -848,7 +846,7 @@ namespace IW5
|
||||
return floatExpressions;
|
||||
}
|
||||
|
||||
_NODISCARD const char* CreateEnableDvarString(const std::vector<std::string>& stringElements) const
|
||||
[[nodiscard]] const char* CreateEnableDvarString(const std::vector<std::string>& stringElements) const
|
||||
{
|
||||
std::ostringstream ss;
|
||||
|
||||
@ -857,10 +855,10 @@ namespace IW5
|
||||
ss << "\"" << element << "\" ";
|
||||
}
|
||||
|
||||
return m_memory->Dup(ss.str().c_str());
|
||||
return m_memory.Dup(ss.str().c_str());
|
||||
}
|
||||
|
||||
_NODISCARD const char* ConvertEnableDvar(const CommonItemDef& commonItem, int& dvarFlags) const
|
||||
[[nodiscard]] const char* ConvertEnableDvar(const CommonItemDef& commonItem, int& dvarFlags) const
|
||||
{
|
||||
dvarFlags = 0;
|
||||
|
||||
@ -897,15 +895,15 @@ namespace IW5
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
_NODISCARD listBoxDef_s* ConvertListBoxFeatures(itemDef_s* item,
|
||||
CommonItemFeaturesListBox* commonListBox,
|
||||
const CommonMenuDef& parentMenu,
|
||||
const CommonItemDef& commonItem) const
|
||||
[[nodiscard]] listBoxDef_s* ConvertListBoxFeatures(itemDef_s* item,
|
||||
CommonItemFeaturesListBox* commonListBox,
|
||||
const CommonMenuDef& parentMenu,
|
||||
const CommonItemDef& commonItem) const
|
||||
{
|
||||
if (commonListBox == nullptr)
|
||||
return nullptr;
|
||||
|
||||
auto* listBox = m_memory->Alloc<listBoxDef_s>();
|
||||
auto* listBox = m_memory.Alloc<listBoxDef_s>();
|
||||
listBox->notselectable = commonListBox->m_not_selectable ? 1 : 0;
|
||||
listBox->noScrollBars = commonListBox->m_no_scrollbars ? 1 : 0;
|
||||
listBox->usePaging = commonListBox->m_use_paging ? 1 : 0;
|
||||
@ -935,15 +933,15 @@ namespace IW5
|
||||
return listBox;
|
||||
}
|
||||
|
||||
_NODISCARD editFieldDef_s* ConvertEditFieldFeatures(itemDef_s* item,
|
||||
CommonItemFeaturesEditField* commonEditField,
|
||||
const CommonMenuDef& parentMenu,
|
||||
const CommonItemDef& commonItem) const
|
||||
[[nodiscard]] editFieldDef_s* ConvertEditFieldFeatures(itemDef_s* item,
|
||||
CommonItemFeaturesEditField* commonEditField,
|
||||
const CommonMenuDef& parentMenu,
|
||||
const CommonItemDef& commonItem) const
|
||||
{
|
||||
if (commonEditField == nullptr)
|
||||
return nullptr;
|
||||
|
||||
auto* editField = m_memory->Alloc<editFieldDef_s>();
|
||||
auto* editField = m_memory.Alloc<editFieldDef_s>();
|
||||
editField->stepVal = static_cast<float>(commonEditField->m_def_val);
|
||||
editField->minVal = static_cast<float>(commonEditField->m_min_val);
|
||||
editField->maxVal = static_cast<float>(commonEditField->m_max_val);
|
||||
@ -955,15 +953,15 @@ namespace IW5
|
||||
return editField;
|
||||
}
|
||||
|
||||
_NODISCARD multiDef_s* ConvertMultiValueFeatures(itemDef_s* item,
|
||||
CommonItemFeaturesMultiValue* commonMultiValue,
|
||||
const CommonMenuDef& parentMenu,
|
||||
const CommonItemDef& commonItem) const
|
||||
[[nodiscard]] multiDef_s* ConvertMultiValueFeatures(itemDef_s* item,
|
||||
CommonItemFeaturesMultiValue* commonMultiValue,
|
||||
const CommonMenuDef& parentMenu,
|
||||
const CommonItemDef& commonItem) const
|
||||
{
|
||||
if (commonMultiValue == nullptr)
|
||||
return nullptr;
|
||||
|
||||
auto* multiValue = m_memory->Alloc<multiDef_s>();
|
||||
auto* multiValue = m_memory.Alloc<multiDef_s>();
|
||||
multiValue->count = static_cast<int>(std::min(std::extent_v<decltype(multiDef_s::dvarList)>, commonMultiValue->m_step_names.size()));
|
||||
multiValue->strDef = !commonMultiValue->m_string_values.empty() ? 1 : 0;
|
||||
|
||||
@ -986,15 +984,15 @@ namespace IW5
|
||||
return multiValue;
|
||||
}
|
||||
|
||||
_NODISCARD newsTickerDef_s* ConvertNewsTickerFeatures(itemDef_s* item,
|
||||
CommonItemFeaturesNewsTicker* commonNewsTicker,
|
||||
const CommonMenuDef& parentMenu,
|
||||
const CommonItemDef& commonItem) const
|
||||
[[nodiscard]] newsTickerDef_s* ConvertNewsTickerFeatures(itemDef_s* item,
|
||||
CommonItemFeaturesNewsTicker* commonNewsTicker,
|
||||
const CommonMenuDef& parentMenu,
|
||||
const CommonItemDef& commonItem) const
|
||||
{
|
||||
if (commonNewsTicker == nullptr)
|
||||
return nullptr;
|
||||
|
||||
auto* newsTicker = m_memory->Alloc<newsTickerDef_s>();
|
||||
auto* newsTicker = m_memory.Alloc<newsTickerDef_s>();
|
||||
newsTicker->spacing = commonNewsTicker->m_spacing;
|
||||
newsTicker->speed = commonNewsTicker->m_speed;
|
||||
newsTicker->feedId = commonNewsTicker->m_news_feed_id;
|
||||
@ -1002,9 +1000,9 @@ namespace IW5
|
||||
return newsTicker;
|
||||
}
|
||||
|
||||
_NODISCARD itemDef_s* ConvertItem(const CommonMenuDef& parentMenu, const CommonItemDef& commonItem) const
|
||||
[[nodiscard]] itemDef_s* ConvertItem(const CommonMenuDef& parentMenu, const CommonItemDef& commonItem) const
|
||||
{
|
||||
auto* item = m_memory->Create<itemDef_s>();
|
||||
auto* item = m_memory.Alloc<itemDef_s>();
|
||||
memset(item, 0, sizeof(itemDef_s));
|
||||
|
||||
item->window.name = ConvertString(commonItem.m_name);
|
||||
@ -1094,7 +1092,7 @@ namespace IW5
|
||||
case CommonItemFeatureType::NONE:
|
||||
default:
|
||||
if (item->type == ITEM_TYPE_TEXT_SCROLL)
|
||||
item->typeData.scroll = m_memory->Alloc<textScrollDef_s>();
|
||||
item->typeData.scroll = m_memory.Alloc<textScrollDef_s>();
|
||||
|
||||
break;
|
||||
}
|
||||
@ -1110,7 +1108,7 @@ namespace IW5
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto* items = m_memory->Alloc<itemDef_s*>(commonMenu.m_items.size());
|
||||
auto* items = m_memory.Alloc<itemDef_s*>(commonMenu.m_items.size());
|
||||
for (auto i = 0u; i < commonMenu.m_items.size(); i++)
|
||||
items[i] = ConvertItem(commonMenu, *commonMenu.m_items[i]);
|
||||
|
||||
@ -1120,101 +1118,79 @@ namespace IW5
|
||||
}
|
||||
|
||||
public:
|
||||
MenuConverterImpl(const bool disableOptimizations, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager)
|
||||
: AbstractMenuConverter(disableOptimizations, searchPath, memory, manager),
|
||||
m_conversion_zone_state(manager->GetAssetLoadingContext()->GetZoneAssetLoaderState<MenuConversionZoneState>()),
|
||||
m_parsing_zone_state(manager->GetAssetLoadingContext()->GetZoneAssetLoaderState<MenuAssetZoneState>())
|
||||
MenuConverter(const bool disableOptimizations, ISearchPath& searchPath, MemoryManager& memory, AssetCreationContext& context)
|
||||
: AbstractMenuConverter(disableOptimizations, searchPath, memory, context),
|
||||
m_conversion_zone_state(context.GetZoneAssetLoaderState<MenuConversionZoneState>()),
|
||||
m_parsing_zone_state(context.GetZoneAssetLoaderState<MenuAssetZoneState>())
|
||||
{
|
||||
assert(m_conversion_zone_state);
|
||||
assert(m_parsing_zone_state);
|
||||
}
|
||||
|
||||
_NODISCARD menuDef_t* ConvertMenu(const CommonMenuDef& commonMenu) const
|
||||
void ConvertMenu(const menu::CommonMenuDef& commonMenu, menuDef_t& menu, AssetRegistration<AssetMenu>& registration) override
|
||||
{
|
||||
auto* menu = m_memory->Create<menuDef_t>();
|
||||
auto* menuData = m_memory->Create<menuData_t>();
|
||||
memset(menu, 0, sizeof(menuDef_t));
|
||||
try
|
||||
{
|
||||
auto* menuData = m_memory.Alloc<menuData_t>();
|
||||
|
||||
menu->data = menuData;
|
||||
menu->window.name = m_memory->Dup(commonMenu.m_name.c_str());
|
||||
menuData->fullScreen = commonMenu.m_full_screen;
|
||||
ApplyFlag(menu->window.staticFlags, commonMenu.m_screen_space, WINDOW_FLAG_SCREEN_SPACE);
|
||||
ApplyFlag(menu->window.staticFlags, commonMenu.m_decoration, WINDOW_FLAG_DECORATION);
|
||||
menu->window.rect = ConvertRectDef(commonMenu.m_rect);
|
||||
menu->window.style = commonMenu.m_style;
|
||||
menu->window.border = commonMenu.m_border;
|
||||
menu->window.borderSize = static_cast<float>(commonMenu.m_border_size);
|
||||
ConvertColor(menu->window.backColor, commonMenu.m_back_color);
|
||||
ConvertColor(menu->window.foreColor, commonMenu.m_fore_color);
|
||||
ConvertColor(menu->window.borderColor, commonMenu.m_border_color);
|
||||
ConvertColor(menuData->focusColor, commonMenu.m_focus_color);
|
||||
menu->window.background = ConvertMaterial(commonMenu.m_background, &commonMenu);
|
||||
menu->window.ownerDraw = commonMenu.m_owner_draw;
|
||||
menu->window.ownerDrawFlags = commonMenu.m_owner_draw_flags;
|
||||
ApplyFlag(menu->window.staticFlags, commonMenu.m_out_of_bounds_click, WINDOW_FLAG_OUT_OF_BOUNDS_CLICK);
|
||||
menuData->soundName = ConvertString(commonMenu.m_sound_loop);
|
||||
ApplyFlag(menu->window.staticFlags, commonMenu.m_popup, WINDOW_FLAG_POPUP);
|
||||
menuData->fadeClamp = static_cast<float>(commonMenu.m_fade_clamp);
|
||||
menuData->fadeCycle = commonMenu.m_fade_cycle;
|
||||
menuData->fadeAmount = static_cast<float>(commonMenu.m_fade_amount);
|
||||
menuData->fadeInAmount = static_cast<float>(commonMenu.m_fade_in_amount);
|
||||
menuData->blurRadius = static_cast<float>(commonMenu.m_blur_radius);
|
||||
ApplyFlag(menu->window.staticFlags, commonMenu.m_legacy_split_screen_scale, WINDOW_FLAG_LEGACY_SPLIT_SCREEN_SCALE);
|
||||
ApplyFlag(menu->window.staticFlags, commonMenu.m_hidden_during_scope, WINDOW_FLAG_HIDDEN_DURING_SCOPE);
|
||||
ApplyFlag(menu->window.staticFlags, commonMenu.m_hidden_during_flashbang, WINDOW_FLAG_HIDDEN_DURING_FLASH_BANG);
|
||||
ApplyFlag(menu->window.staticFlags, commonMenu.m_hidden_during_ui, WINDOW_FLAG_HIDDEN_DURING_UI);
|
||||
menuData->allowedBinding = ConvertString(commonMenu.m_allowed_binding);
|
||||
ApplyFlag(menu->window.staticFlags, commonMenu.m_text_only_focus, WINDOW_FLAG_TEXT_ONLY_FOCUS);
|
||||
menuData->visibleExp = ConvertVisibleExpression(&menu->window, commonMenu.m_visible_expression.get(), &commonMenu);
|
||||
menuData->rectXExp = ConvertOrApplyStatement(menu->window.rect.x, commonMenu.m_rect_x_exp.get(), &commonMenu);
|
||||
menuData->rectYExp = ConvertOrApplyStatement(menu->window.rect.y, commonMenu.m_rect_y_exp.get(), &commonMenu);
|
||||
menuData->rectWExp = ConvertOrApplyStatement(menu->window.rect.w, commonMenu.m_rect_w_exp.get(), &commonMenu);
|
||||
menuData->rectHExp = ConvertOrApplyStatement(menu->window.rect.h, commonMenu.m_rect_h_exp.get(), &commonMenu);
|
||||
menuData->openSoundExp = ConvertExpression(commonMenu.m_open_sound_exp.get(), &commonMenu);
|
||||
menuData->closeSoundExp = ConvertExpression(commonMenu.m_close_sound_exp.get(), &commonMenu);
|
||||
menuData->onOpen = ConvertEventHandlerSet(commonMenu.m_on_open.get(), &commonMenu);
|
||||
menuData->onClose = ConvertEventHandlerSet(commonMenu.m_on_close.get(), &commonMenu);
|
||||
menuData->onCloseRequest = ConvertEventHandlerSet(commonMenu.m_on_request_close.get(), &commonMenu);
|
||||
menuData->onESC = ConvertEventHandlerSet(commonMenu.m_on_esc.get(), &commonMenu);
|
||||
menuData->onFocusDueToClose = ConvertEventHandlerSet(commonMenu.m_on_focus_due_to_close.get(), &commonMenu);
|
||||
menuData->onKey = ConvertKeyHandler(commonMenu.m_key_handlers, &commonMenu);
|
||||
menu->items = ConvertMenuItems(commonMenu, menu->itemCount);
|
||||
menuData->expressionData = m_conversion_zone_state->m_supporting_data;
|
||||
|
||||
return menu;
|
||||
menu.data = menuData;
|
||||
menu.window.name = m_memory.Dup(commonMenu.m_name.c_str());
|
||||
menuData->fullScreen = commonMenu.m_full_screen;
|
||||
ApplyFlag(menu.window.staticFlags, commonMenu.m_screen_space, WINDOW_FLAG_SCREEN_SPACE);
|
||||
ApplyFlag(menu.window.staticFlags, commonMenu.m_decoration, WINDOW_FLAG_DECORATION);
|
||||
menu.window.rect = ConvertRectDef(commonMenu.m_rect);
|
||||
menu.window.style = commonMenu.m_style;
|
||||
menu.window.border = commonMenu.m_border;
|
||||
menu.window.borderSize = static_cast<float>(commonMenu.m_border_size);
|
||||
ConvertColor(menu.window.backColor, commonMenu.m_back_color);
|
||||
ConvertColor(menu.window.foreColor, commonMenu.m_fore_color);
|
||||
ConvertColor(menu.window.borderColor, commonMenu.m_border_color);
|
||||
ConvertColor(menuData->focusColor, commonMenu.m_focus_color);
|
||||
menu.window.background = ConvertMaterial(commonMenu.m_background, &commonMenu);
|
||||
menu.window.ownerDraw = commonMenu.m_owner_draw;
|
||||
menu.window.ownerDrawFlags = commonMenu.m_owner_draw_flags;
|
||||
ApplyFlag(menu.window.staticFlags, commonMenu.m_out_of_bounds_click, WINDOW_FLAG_OUT_OF_BOUNDS_CLICK);
|
||||
menuData->soundName = ConvertString(commonMenu.m_sound_loop);
|
||||
ApplyFlag(menu.window.staticFlags, commonMenu.m_popup, WINDOW_FLAG_POPUP);
|
||||
menuData->fadeClamp = static_cast<float>(commonMenu.m_fade_clamp);
|
||||
menuData->fadeCycle = commonMenu.m_fade_cycle;
|
||||
menuData->fadeAmount = static_cast<float>(commonMenu.m_fade_amount);
|
||||
menuData->fadeInAmount = static_cast<float>(commonMenu.m_fade_in_amount);
|
||||
menuData->blurRadius = static_cast<float>(commonMenu.m_blur_radius);
|
||||
ApplyFlag(menu.window.staticFlags, commonMenu.m_legacy_split_screen_scale, WINDOW_FLAG_LEGACY_SPLIT_SCREEN_SCALE);
|
||||
ApplyFlag(menu.window.staticFlags, commonMenu.m_hidden_during_scope, WINDOW_FLAG_HIDDEN_DURING_SCOPE);
|
||||
ApplyFlag(menu.window.staticFlags, commonMenu.m_hidden_during_flashbang, WINDOW_FLAG_HIDDEN_DURING_FLASH_BANG);
|
||||
ApplyFlag(menu.window.staticFlags, commonMenu.m_hidden_during_ui, WINDOW_FLAG_HIDDEN_DURING_UI);
|
||||
menuData->allowedBinding = ConvertString(commonMenu.m_allowed_binding);
|
||||
ApplyFlag(menu.window.staticFlags, commonMenu.m_text_only_focus, WINDOW_FLAG_TEXT_ONLY_FOCUS);
|
||||
menuData->visibleExp = ConvertVisibleExpression(&menu.window, commonMenu.m_visible_expression.get(), &commonMenu);
|
||||
menuData->rectXExp = ConvertOrApplyStatement(menu.window.rect.x, commonMenu.m_rect_x_exp.get(), &commonMenu);
|
||||
menuData->rectYExp = ConvertOrApplyStatement(menu.window.rect.y, commonMenu.m_rect_y_exp.get(), &commonMenu);
|
||||
menuData->rectWExp = ConvertOrApplyStatement(menu.window.rect.w, commonMenu.m_rect_w_exp.get(), &commonMenu);
|
||||
menuData->rectHExp = ConvertOrApplyStatement(menu.window.rect.h, commonMenu.m_rect_h_exp.get(), &commonMenu);
|
||||
menuData->openSoundExp = ConvertExpression(commonMenu.m_open_sound_exp.get(), &commonMenu);
|
||||
menuData->closeSoundExp = ConvertExpression(commonMenu.m_close_sound_exp.get(), &commonMenu);
|
||||
menuData->onOpen = ConvertEventHandlerSet(commonMenu.m_on_open.get(), &commonMenu);
|
||||
menuData->onClose = ConvertEventHandlerSet(commonMenu.m_on_close.get(), &commonMenu);
|
||||
menuData->onCloseRequest = ConvertEventHandlerSet(commonMenu.m_on_request_close.get(), &commonMenu);
|
||||
menuData->onESC = ConvertEventHandlerSet(commonMenu.m_on_esc.get(), &commonMenu);
|
||||
menuData->onFocusDueToClose = ConvertEventHandlerSet(commonMenu.m_on_focus_due_to_close.get(), &commonMenu);
|
||||
menuData->onKey = ConvertKeyHandler(commonMenu.m_key_handlers, &commonMenu);
|
||||
menu.items = ConvertMenuItems(commonMenu, menu.itemCount);
|
||||
menuData->expressionData = m_conversion_zone_state->m_supporting_data;
|
||||
}
|
||||
catch (const MenuConversionException& e)
|
||||
{
|
||||
PrintConversionExceptionDetails(e);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<XAssetInfoGeneric*> m_dependencies;
|
||||
MenuConversionZoneState* m_conversion_zone_state;
|
||||
MenuAssetZoneState* m_parsing_zone_state;
|
||||
};
|
||||
} // namespace IW5
|
||||
} // namespace
|
||||
|
||||
MenuConverter::MenuConverter(const bool disableOptimizations, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager)
|
||||
: m_disable_optimizations(disableOptimizations),
|
||||
m_search_path(searchPath),
|
||||
m_memory(memory),
|
||||
m_manager(manager)
|
||||
std::unique_ptr<IMenuConverter> IMenuConverter::Create(bool disableOptimizations, ISearchPath& searchPath, MemoryManager& memory, AssetCreationContext& context)
|
||||
{
|
||||
}
|
||||
|
||||
std::vector<XAssetInfoGeneric*>& MenuConverter::GetDependencies()
|
||||
{
|
||||
return m_dependencies;
|
||||
}
|
||||
|
||||
menuDef_t* MenuConverter::ConvertMenu(const CommonMenuDef& commonMenu)
|
||||
{
|
||||
MenuConverterImpl impl(m_disable_optimizations, m_search_path, m_memory, m_manager);
|
||||
|
||||
try
|
||||
{
|
||||
auto* result = impl.ConvertMenu(commonMenu);
|
||||
m_dependencies = std::move(impl.m_dependencies);
|
||||
return result;
|
||||
}
|
||||
catch (const MenuConversionException& e)
|
||||
{
|
||||
MenuConverterImpl::PrintConversionExceptionDetails(e);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
return std::make_unique<MenuConverter>(disableOptimizations, searchPath, memory, context);
|
||||
}
|
||||
|
@ -1,26 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
#include "Asset/AssetCreationContext.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "Parsing/Menu/Domain/CommonMenuDef.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class MenuConverter
|
||||
class IMenuConverter
|
||||
{
|
||||
bool m_disable_optimizations;
|
||||
ISearchPath* m_search_path;
|
||||
MemoryManager* m_memory;
|
||||
IAssetLoadingManager* m_manager;
|
||||
std::vector<XAssetInfoGeneric*> m_dependencies;
|
||||
|
||||
public:
|
||||
MenuConverter(bool disableOptimizations, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager);
|
||||
IMenuConverter() = default;
|
||||
virtual ~IMenuConverter() = default;
|
||||
|
||||
std::vector<XAssetInfoGeneric*>& GetDependencies();
|
||||
_NODISCARD menuDef_t* ConvertMenu(const menu::CommonMenuDef& commonMenu);
|
||||
virtual void ConvertMenu(const menu::CommonMenuDef& commonMenu, menuDef_t& menu, AssetRegistration<AssetMenu>& registration) = 0;
|
||||
|
||||
static std::unique_ptr<IMenuConverter> Create(bool disableOptimizations, ISearchPath& searchPath, MemoryManager& memory, AssetCreationContext& context);
|
||||
};
|
||||
} // namespace IW5
|
||||
|
@ -3,8 +3,19 @@
|
||||
#include "Asset/GlobalAssetPoolsLoader.h"
|
||||
#include "Game/IW5/GameIW5.h"
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "Localize/AssetLoaderLocalizeIW5.h"
|
||||
#include "Game/IW5/XModel/LoaderXModelIW5.h"
|
||||
#include "Image/LoaderImageIW5.h"
|
||||
#include "Leaderboard/LoaderLeaderboardIW5.h"
|
||||
#include "Localize/LoaderLocalizeIW5.h"
|
||||
#include "Material/LoaderMaterialIW5.h"
|
||||
#include "Menu/LoaderMenuListIW5.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "RawFile/LoaderRawFileIW5.h"
|
||||
#include "Script/LoaderScriptFileIW5.h"
|
||||
#include "StringTable/LoaderStringTableIW5.h"
|
||||
#include "Weapon/GdtLoaderWeaponIW5.h"
|
||||
#include "Weapon/LoaderAttachmentIW5.h"
|
||||
#include "Weapon/RawLoaderWeaponIW5.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
@ -106,7 +117,7 @@ namespace
|
||||
collection.AddAssetCreator(std::make_unique<GlobalAssetPoolsLoader<AssetAddonMapEnts>>(zone));
|
||||
}
|
||||
|
||||
void ConfigureLoaders(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath)
|
||||
void ConfigureLoaders(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath, IGdtQueryable& gdt)
|
||||
{
|
||||
auto& memory = *zone.GetMemory();
|
||||
|
||||
@ -114,13 +125,13 @@ namespace
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderPhysCollMap>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderXAnim>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderXModelSurfs>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderXModel>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderMaterial>(memory));
|
||||
collection.AddAssetCreator(CreateXModelLoader(memory, searchPath, zone));
|
||||
collection.AddAssetCreator(CreateMaterialLoader(memory, searchPath));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderPixelShader>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderVertexShader>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderVertexDecl>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderTechniqueSet>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderImage>(memory));
|
||||
collection.AddAssetCreator(CreateImageLoader(memory, searchPath));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSound>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSoundCurve>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderLoadedSound>(memory));
|
||||
@ -134,18 +145,19 @@ namespace
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderGfxWorld>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderLightDef>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderFont>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderMenuList>(memory));
|
||||
collection.AddAssetCreator(CreateMenuListLoader(memory, searchPath));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderMenu>(memory));
|
||||
collection.AddAssetCreator(std::make_unique<AssetLoaderLocalize>(memory, searchPath, zone));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderAttachment>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderWeapon>(memory));
|
||||
collection.AddAssetCreator(CreateLocalizeLoader(memory, searchPath, zone));
|
||||
collection.AddAssetCreator(CreateAttachmentLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(CreateRawWeaponLoader(memory, searchPath, zone));
|
||||
collection.AddAssetCreator(CreateGdtWeaponLoader(memory, searchPath, gdt, zone));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderFx>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderImpactFx>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSurfaceFx>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderRawFile>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderScript>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderStringTable>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderLeaderboard>(memory));
|
||||
collection.AddAssetCreator(CreateRawFileLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(CreateScriptLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(CreateStringTableLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(CreateLeaderboardLoader(memory, searchPath));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderStructuredDataDef>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderTracer>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderVehicle>(memory));
|
||||
@ -153,9 +165,9 @@ 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);
|
||||
ConfigureLoaders(collection, zone, searchPath);
|
||||
ConfigureLoaders(collection, zone, searchPath, gdt);
|
||||
ConfigureGlobalAssetPoolsLoaders(collection, zone);
|
||||
}
|
||||
|
@ -12,6 +12,6 @@ namespace IW5
|
||||
void LoadReferencedContainersForZone(ISearchPath& searchPath, 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 IW5
|
||||
|
90
src/ObjLoading/Game/IW5/RawFile/LoaderRawFileIW5.cpp
Normal file
90
src/ObjLoading/Game/IW5/RawFile/LoaderRawFileIW5.cpp
Normal file
@ -0,0 +1,90 @@
|
||||
#include "LoaderRawFileIW5.h"
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <filesystem>
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
#include <zlib.h>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr size_t COMPRESSED_BUFFER_SIZE_PADDING = 64;
|
||||
|
||||
class RawFileLoader final : public AssetCreator<AssetRawFile>
|
||||
{
|
||||
public:
|
||||
RawFileLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
: m_memory(memory),
|
||||
m_search_path(searchPath)
|
||||
{
|
||||
}
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||
{
|
||||
const auto file = m_search_path.Open(assetName);
|
||||
if (!file.IsOpen())
|
||||
return AssetCreationResult::NoAction();
|
||||
|
||||
const auto uncompressedBuffer = std::make_unique<char[]>(static_cast<size_t>(file.m_length));
|
||||
file.m_stream->read(uncompressedBuffer.get(), file.m_length);
|
||||
if (file.m_stream->gcount() != file.m_length)
|
||||
return AssetCreationResult::Failure();
|
||||
|
||||
const auto compressionBufferSize = static_cast<size_t>(file.m_length + COMPRESSED_BUFFER_SIZE_PADDING);
|
||||
auto* compressedBuffer = m_memory.Alloc<char>(compressionBufferSize);
|
||||
|
||||
z_stream_s zs{};
|
||||
|
||||
zs.zalloc = Z_NULL;
|
||||
zs.zfree = Z_NULL;
|
||||
zs.opaque = Z_NULL;
|
||||
zs.avail_in = static_cast<uInt>(file.m_length);
|
||||
zs.avail_out = compressionBufferSize;
|
||||
zs.next_in = reinterpret_cast<const Bytef*>(uncompressedBuffer.get());
|
||||
zs.next_out = reinterpret_cast<Bytef*>(compressedBuffer);
|
||||
|
||||
int ret = deflateInit(&zs, Z_DEFAULT_COMPRESSION);
|
||||
|
||||
if (ret != Z_OK)
|
||||
throw std::runtime_error("Initializing deflate failed");
|
||||
|
||||
ret = deflate(&zs, Z_FINISH);
|
||||
|
||||
if (ret != Z_STREAM_END)
|
||||
{
|
||||
std::cerr << std::format("Deflate failed for loading rawfile \"{}\"\n", assetName);
|
||||
deflateEnd(&zs);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
|
||||
const auto compressedSize = compressionBufferSize - zs.avail_out;
|
||||
|
||||
auto* rawFile = m_memory.Alloc<RawFile>();
|
||||
rawFile->name = m_memory.Dup(assetName.c_str());
|
||||
rawFile->compressedLen = static_cast<int>(compressedSize);
|
||||
rawFile->len = static_cast<int>(file.m_length);
|
||||
rawFile->buffer = static_cast<const char*>(compressedBuffer);
|
||||
|
||||
deflateEnd(&zs);
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset<AssetRawFile>(assetName, rawFile));
|
||||
}
|
||||
|
||||
private:
|
||||
MemoryManager& m_memory;
|
||||
ISearchPath& m_search_path;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetRawFile>> CreateRawFileLoader(MemoryManager& memory, ISearchPath& searchPath)
|
||||
{
|
||||
return std::make_unique<RawFileLoader>(memory, searchPath);
|
||||
}
|
||||
} // namespace IW5
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user