chore(gx): clean up TextBlockCreate

This commit is contained in:
fallenoak 2025-12-14 22:46:41 -06:00
parent 850daf5e66
commit eee9322da9
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
2 changed files with 23 additions and 22 deletions

View File

@ -202,15 +202,16 @@ void TextBlockAddShadow(HTEXTBLOCK string, CImVector color, const C2Vector& offs
GxuFontAddShadow(TextBlockGetStringPtr(string), color, offset); GxuFontAddShadow(TextBlockGetStringPtr(string), color, offset);
} }
HTEXTBLOCK TextBlockCreate(HTEXTFONT font, const char* text, const CImVector& color, const C3Vector& pos, float fontHeight, float blockWidth, float blockHeight, uint32_t flags, float charSpacing, float lineSpacing, float scale) { HTEXTBLOCK TextBlockCreate(HTEXTFONT fontHandle, const char* text, const CImVector& color, const C3Vector& position, float fontHeight, float blockWidth, float blockHeight, uint32_t flags, float charSpacing, float lineSpacing, float scale) {
STORM_ASSERT(font); STORM_VALIDATE_BEGIN;
STORM_ASSERT(text); STORM_VALIDATE(fontHandle);
STORM_VALIDATE(text);
STORM_VALIDATE_END;
auto m = SMemAlloc(sizeof(TEXTBLOCK), __FILE__, __LINE__, 0x0); auto textBlock = STORM_NEW(TEXTBLOCK)();
auto textBlock = new (m) TEXTBLOCK();
C3Vector position = { 0.0f, 0.0f, pos.z }; C3Vector ndcPosition = { 0.0f, 0.0f, position.z };
DDCToNDC(pos.x, pos.y, &position.x, &position.y); DDCToNDC(position.x, position.y, &ndcPosition.x, &ndcPosition.y);
EGxFontHJusts hjust = GxHJ_Center; EGxFontHJusts hjust = GxHJ_Center;
@ -228,28 +229,28 @@ HTEXTBLOCK TextBlockCreate(HTEXTFONT font, const char* text, const CImVector& co
vjust = GxVJ_Bottom; vjust = GxVJ_Bottom;
} }
uint32_t v16 = ConvertStringFlags(flags); uint32_t stringFlags = ConvertStringFlags(flags);
float v15 = DDCToNDCWidth(charSpacing); float ndcCharSpacing = DDCToNDCWidth(charSpacing);
float v20 = DDCToNDCHeight(lineSpacing); float ndcLineSpacing = DDCToNDCHeight(lineSpacing);
float v21 = DDCToNDCHeight(blockHeight); float ndcBlockHeight = DDCToNDCHeight(blockHeight);
float v22 = DDCToNDCWidth(blockWidth); float ndcBlockWidth = DDCToNDCWidth(blockWidth);
float v23 = DDCToNDCHeight(fontHeight); float ndcFontHeight = DDCToNDCHeight(fontHeight);
GxuFontCreateString( GxuFontCreateString(
reinterpret_cast<FONTHASHOBJ*>(font)->font, reinterpret_cast<FONTHASHOBJ*>(fontHandle)->font,
text, text,
v23, ndcFontHeight,
position, ndcPosition,
v22, ndcBlockWidth,
v21, ndcBlockHeight,
v20, ndcLineSpacing,
textBlock->string, textBlock->string,
vjust, vjust,
hjust, hjust,
v16, stringFlags,
color, color,
v15, ndcCharSpacing,
scale scale
); );

View File

@ -51,7 +51,7 @@ uint32_t GetScreenPixelWidth(void);
void TextBlockAddShadow(HTEXTBLOCK, CImVector, const C2Vector&); void TextBlockAddShadow(HTEXTBLOCK, CImVector, const C2Vector&);
HTEXTBLOCK TextBlockCreate(HTEXTFONT, const char*, const CImVector&, const C3Vector&, float, float, float, uint32_t, float, float, float); HTEXTBLOCK TextBlockCreate(HTEXTFONT fontHandle, const char* text, const CImVector& color, const C3Vector& position, float fontHeight, float blockWidth, float blockHeight, uint32_t flags, float charSpacing, float lineSpacing, float scale);
HTEXTFONT TextBlockGenerateFont(const char*, uint32_t, float); HTEXTFONT TextBlockGenerateFont(const char*, uint32_t, float);