From c0afcc2a22cefb6588571e171449b1889c3270a4 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Thu, 17 Mar 2016 19:22:19 -0700 Subject: [PATCH] CRasterFont fixes --- Editor/ProjectResourceFactory.cpp | 2 ++ Runtime/GuiSys/CRasterFont.cpp | 10 ++++++---- Runtime/GuiSys/CRasterFont.hpp | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Editor/ProjectResourceFactory.cpp b/Editor/ProjectResourceFactory.cpp index 768ea2c4f..909e1d440 100644 --- a/Editor/ProjectResourceFactory.cpp +++ b/Editor/ProjectResourceFactory.cpp @@ -6,6 +6,7 @@ #include "Runtime/Particle/CElectricDescription.hpp" #include "Runtime/Particle/CSwooshDescription.hpp" #include "Runtime/GuiSys/CGuiFrame.hpp" +#include "Runtime/GuiSys/CRasterFont.hpp" #include "Runtime/Graphics/CModel.hpp" #include "Runtime/Graphics/CTexture.hpp" @@ -17,6 +18,7 @@ ProjectResourceFactory::ProjectResourceFactory() m_factoryMgr.AddFactory(FOURCC('TXTR'), urde::FTextureFactory); m_factoryMgr.AddFactory(FOURCC('PART'), urde::FParticleFactory); m_factoryMgr.AddFactory(FOURCC('FRME'), urde::RGuiFrameFactoryInGame); + m_factoryMgr.AddFactory(FOURCC('FONT'), urde::FRasterFontFactory); } void ProjectResourceFactory::BuildObjectMap(const hecl::Database::Project::ProjectDataSpec &spec) diff --git a/Runtime/GuiSys/CRasterFont.cpp b/Runtime/GuiSys/CRasterFont.cpp index cbcf2be20..7c0d0aeaf 100644 --- a/Runtime/GuiSys/CRasterFont.cpp +++ b/Runtime/GuiSys/CRasterFont.cpp @@ -4,7 +4,8 @@ namespace urde { CRasterFont::CRasterFont(urde::CInputStream& in, urde::IObjectStore& store) { - u32 magic = in.readUint32Big(); + u32 magic; + in.readBytesToBuf(&magic, 4); if (magic != SBIG('FONT')) return; @@ -27,8 +28,8 @@ CRasterFont::CRasterFont(urde::CInputStream& in, urde::IObjectStore& store) u32 tmp4 = in.readUint32Big(); std::string name= in.readString(); u32 txtrId = in.readUint32Big(); - x80_texture = store.GetObj({'TXTR', txtrId}); x30_fontInfo = CFontInfo(tmp1, tmp2, tmp3, tmp4, name.c_str()); + x80_texture = store.GetObj({'TXTR', txtrId}); u32 mode = in.readUint32Big(); /* TODO: Make an enum */ if (mode == 1) @@ -52,7 +53,7 @@ CRasterFont::CRasterFont(urde::CInputStream& in, urde::IObjectStore& store) s32 cellWidth = in.readInt32Big(); s32 cellHeight = in.readInt32Big(); s32 baseline = in.readInt32Big(); - s32 kernStart = in.readUint32(); + s32 kernStart = in.readInt32Big(); xc_glyphs[i] = std::make_pair(chr, CGlyph(a, b, c, startU, startV, endU, endV, cellWidth, cellHeight, baseline, kernStart)); } @@ -192,7 +193,8 @@ void CRasterFont::GetSize(const CDrawStringOptions& opts, int& width, int& heigh std::unique_ptr FRasterFontFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms) { - return TToken::GetIObjObjectFor(std::make_unique(in, *(reinterpret_cast(vparms.GetObj())))); + return TToken::GetIObjObjectFor( + std::make_unique(in, *static_cast*>(vparms.GetObj())->GetParam())); } } diff --git a/Runtime/GuiSys/CRasterFont.hpp b/Runtime/GuiSys/CRasterFont.hpp index f41723d53..cba6b8a93 100644 --- a/Runtime/GuiSys/CRasterFont.hpp +++ b/Runtime/GuiSys/CRasterFont.hpp @@ -88,7 +88,7 @@ class CFontInfo bool x1_ = false; s32 x4_ = 0; s32 x8_fontSize = 0; - char* xc_name = 0; + char xc_name[40]; public: CFontInfo() = default; @@ -109,7 +109,7 @@ class CRasterFont s32 x28_lineMargin = 0; s32 x2c_mode = 0; CFontInfo x30_fontInfo; - TToken x80_texture; + TLockedToken x80_texture; bool x88_ = false; s32 x8c_baseline; s32 x90_lineMargin = 0;