iw4x-client/src/Components/Modules/AssetInterfaces/IFont_s.cpp

52 lines
1.2 KiB
C++
Raw Normal View History

2017-02-26 06:57:02 -05:00
#include "STDInclude.hpp"
namespace Assets
{
void IFont_s::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
{
Game::Font_s *asset = header.font;
2018-05-09 08:33:52 -04:00
if (asset->material)
2017-02-26 06:57:02 -05:00
{
2018-05-09 08:33:52 -04:00
builder->loadAsset(Game::ASSET_TYPE_MATERIAL, asset->material);
2017-02-26 06:57:02 -05:00
}
2018-05-09 08:33:52 -04:00
if (asset->glowMaterial)
2017-02-26 06:57:02 -05:00
{
2018-05-09 08:33:52 -04:00
builder->loadAsset(Game::ASSET_TYPE_MATERIAL, asset->glowMaterial);
2017-02-26 06:57:02 -05:00
}
}
void IFont_s::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
{
AssertSize(Game::Font_s, 24);
2018-05-09 08:33:52 -04:00
AssertSize(Game::Glyph, 24);
2017-02-26 06:57:02 -05:00
Utils::Stream* buffer = builder->getBuffer();
Game::Font_s* asset = header.font;
Game::Font_s* dest = buffer->dest<Game::Font_s>();
buffer->save(asset);
buffer->pushBlock(Game::XFILE_BLOCK_VIRTUAL);
2018-05-09 08:33:52 -04:00
if (asset->fontName)
2017-02-26 06:57:02 -05:00
{
2018-05-09 08:33:52 -04:00
buffer->saveString(asset->fontName);
Utils::Stream::ClearPointer(&dest->fontName);
2017-02-26 06:57:02 -05:00
}
2018-05-09 08:33:52 -04:00
dest->material = builder->saveSubAsset(Game::ASSET_TYPE_MATERIAL, asset->material).material;
dest->glowMaterial = builder->saveSubAsset(Game::ASSET_TYPE_MATERIAL, asset->glowMaterial).material;
2017-02-26 06:57:02 -05:00
2018-05-09 08:33:52 -04:00
if (asset->glyphs)
2017-02-26 06:57:02 -05:00
{
buffer->align(Utils::Stream::ALIGN_4);
2018-05-09 08:33:52 -04:00
buffer->saveArray(asset->glyphs, asset->glyphCount);
Utils::Stream::ClearPointer(&dest->glyphs);
2017-02-26 06:57:02 -05:00
}
buffer->popBlock();
}
}