Add dumper and reader for IW4 GfxLightDef

This commit is contained in:
Jan
2022-01-02 18:01:24 +01:00
parent 77b6b7c87a
commit daa7008038
8 changed files with 177 additions and 1 deletions

View File

@ -0,0 +1,36 @@
#include "AssetDumperGfxLightDef.h"
#include <sstream>
using namespace IW4;
std::string AssetDumperGfxLightDef::GetAssetFilename(const std::string& assetName)
{
std::ostringstream ss;
ss << "lights/" << assetName;
return ss.str();
}
bool AssetDumperGfxLightDef::ShouldDump(XAssetInfo<GfxLightDef>* asset)
{
return true;
}
void AssetDumperGfxLightDef::DumpAsset(AssetDumpingContext& context, XAssetInfo<GfxLightDef>* asset)
{
const auto* lightDef = asset->Asset();
const auto assetFile = context.OpenAssetFile(GetAssetFilename(asset->m_name));
if (!assetFile || lightDef->attenuation.image == nullptr || lightDef->attenuation.image->name == nullptr)
return;
auto& stream = *assetFile;
const auto* imageName = lightDef->attenuation.image->name;
if (imageName[0] == ',')
imageName = &imageName[1];
stream << lightDef->attenuation.samplerState << imageName << static_cast<char>(lightDef->lmapLookupStart);
}

View File

@ -0,0 +1,16 @@
#pragma once
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW4/IW4.h"
namespace IW4
{
class AssetDumperGfxLightDef final : public AbstractAssetDumper<GfxLightDef>
{
static std::string GetAssetFilename(const std::string& assetName);
protected:
bool ShouldDump(XAssetInfo<GfxLightDef>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<GfxLightDef>* asset) override;
};
}

View File

@ -6,6 +6,7 @@
#include "AssetDumpers/AssetDumperAddonMapEnts.h"
#include "AssetDumpers/AssetDumperGfxImage.h"
#include "AssetDumpers/AssetDumperGfxLightDef.h"
#include "AssetDumpers/AssetDumperLoadedSound.h"
#include "AssetDumpers/AssetDumperLocalizeEntry.h"
#include "AssetDumpers/AssetDumperMenuDef.h"
@ -56,7 +57,7 @@ bool ZoneDumper::DumpZone(AssetDumpingContext& context) const
// DUMP_ASSET_POOL(AssetDumperMapEnts, m_map_ents, ASSET_TYPE_MAP_ENTS)
// DUMP_ASSET_POOL(AssetDumperFxWorld, m_fx_world, ASSET_TYPE_FXWORLD)
// DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world, ASSET_TYPE_GFXWORLD)
// DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF)
DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF)
// DUMP_ASSET_POOL(AssetDumperFont_s, m_font, ASSET_TYPE_FONT)
DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list, ASSET_TYPE_MENULIST)
DUMP_ASSET_POOL(AssetDumperMenuDef, m_menu_def, ASSET_TYPE_MENU)