No look lua support wheeeeeeeeeee

This commit is contained in:
Antonio Martinez 2024-09-16 05:17:01 -07:00 committed by AJ Martinez
parent 1c87d358fb
commit 2546fc8351
3 changed files with 26 additions and 0 deletions

View file

@ -964,6 +964,21 @@ static int libd_stringWidth(lua_State *L)
return 1;
}
static int libd_parseText(lua_State *L)
{
HUDONLY
const char *rawText = luaL_checkstring(L, 1);
if (!rawText)
return luaL_error(L, "no string provided to v.parseText");
char *newText = V_ParseText(rawText);
lua_pushstring(gL, newText);
Z_Free(newText);
return 1;
}
static int libd_getColormap(lua_State *L)
{
INT32 skinnum = TC_DEFAULT;
@ -1162,6 +1177,7 @@ static luaL_Reg lib_draw[] = {
// misc
{"stringWidth", libd_stringWidth},
{"titleCardStringWidth", libd_titleCardStringWidth},
{"parseText", libd_parseText},
// m_random
{"RandomFixed",libd_RandomFixed},
{"RandomByte",libd_RandomByte},

View file

@ -3700,3 +3700,10 @@ void VID_DisplaySoftwareScreen()
// Post-process blit to the 'default' framebuffer
hw_state->blit_postimg_screens->draw(*rhi, ctx);
}
char *V_ParseText(const char *rawText)
{
using srb2::Draw;
return Z_StrDup(srb2::Draw::TextElement().parse(rawText).string().c_str());
}

View file

@ -442,6 +442,9 @@ void VID_BlitLinearScreen(const UINT8 *srcptr, UINT8 *destptr, INT32 width, INT3
*/
void VID_DisplaySoftwareScreen(void);
char *V_ParseText(const char *rawText); // Launder srb2::draw::TextElement.parse() through C code!
#ifdef __cplusplus
} // extern "C"
#endif