diff --git a/src/Components/Modules/AssetHandler.cpp b/src/Components/Modules/AssetHandler.cpp index a9159f11..b6b6625a 100644 --- a/src/Components/Modules/AssetHandler.cpp +++ b/src/Components/Modules/AssetHandler.cpp @@ -425,6 +425,7 @@ namespace Components // Register asset interfaces if (ZoneBuilder::IsEnabled()) { + AssetHandler::RegisterInterface(new Assets::IFont_s()); AssetHandler::RegisterInterface(new Assets::IXModel()); AssetHandler::RegisterInterface(new Assets::IFxWorld()); AssetHandler::RegisterInterface(new Assets::IMapEnts()); diff --git a/src/Components/Modules/AssetHandler.hpp b/src/Components/Modules/AssetHandler.hpp index 8b6b7980..8ba38f9f 100644 --- a/src/Components/Modules/AssetHandler.hpp +++ b/src/Components/Modules/AssetHandler.hpp @@ -74,6 +74,7 @@ namespace Components }; } +#include "AssetInterfaces/IFont_s.hpp" #include "AssetInterfaces/IXModel.hpp" #include "AssetInterfaces/IFxWorld.hpp" #include "AssetInterfaces/IMapEnts.hpp" diff --git a/src/Components/Modules/AssetInterfaces/IFont_s.cpp b/src/Components/Modules/AssetInterfaces/IFont_s.cpp new file mode 100644 index 00000000..5a8a318c --- /dev/null +++ b/src/Components/Modules/AssetInterfaces/IFont_s.cpp @@ -0,0 +1,51 @@ +#include "STDInclude.hpp" + +namespace Assets +{ + void IFont_s::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) + { + Game::Font_s *asset = header.font; + + if (asset->image) + { + builder->loadAsset(Game::ASSET_TYPE_MATERIAL, asset->image); + } + + if (asset->glowImage) + { + builder->loadAsset(Game::ASSET_TYPE_MATERIAL, asset->glowImage); + } + } + + void IFont_s::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) + { + AssertSize(Game::Font_s, 24); + AssertSize(Game::FontEntry, 24); + + Utils::Stream* buffer = builder->getBuffer(); + Game::Font_s* asset = header.font; + Game::Font_s* dest = buffer->dest(); + + buffer->save(asset); + + buffer->pushBlock(Game::XFILE_BLOCK_VIRTUAL); + + if (asset->name) + { + buffer->saveString(asset->name); + Utils::Stream::ClearPointer(&dest->name); + } + + dest->image = builder->saveSubAsset(Game::ASSET_TYPE_MATERIAL, asset->image).material; + dest->glowImage = builder->saveSubAsset(Game::ASSET_TYPE_MATERIAL, asset->glowImage).material; + + if (asset->characters) + { + buffer->align(Utils::Stream::ALIGN_4); + buffer->saveArray(asset->characters, asset->entries); + Utils::Stream::ClearPointer(&dest->characters); + } + + buffer->popBlock(); + } +} diff --git a/src/Components/Modules/AssetInterfaces/IFont_s.hpp b/src/Components/Modules/AssetInterfaces/IFont_s.hpp new file mode 100644 index 00000000..3d9edda2 --- /dev/null +++ b/src/Components/Modules/AssetInterfaces/IFont_s.hpp @@ -0,0 +1,14 @@ +#pragma once + +namespace Assets +{ + class IFont_s : public Components::AssetHandler::IAsset + { + public: + virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_FONT; }; + + virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + // virtual void load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder) override; + }; +}