From 54b2cdb67831b6f492b643872f65dafbfeb0c56e Mon Sep 17 00:00:00 2001 From: fallenoak Date: Fri, 7 Nov 2025 15:52:07 -0600 Subject: [PATCH] feat(ui): implement CSimpleButton_SetHighlightFontObject --- src/ui/CSimpleButtonScript.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/ui/CSimpleButtonScript.cpp b/src/ui/CSimpleButtonScript.cpp index 9ce8f99..7f4687e 100644 --- a/src/ui/CSimpleButtonScript.cpp +++ b/src/ui/CSimpleButtonScript.cpp @@ -159,7 +159,28 @@ int32_t CSimpleButton_GetDisabledFontObject(lua_State* L) { } int32_t CSimpleButton_SetHighlightFontObject(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + auto type = CSimpleButton::GetObjectType(); + auto button = static_cast(FrameScript_GetObjectThis(L, type)); + + CSimpleFont* font = nullptr; + + if (lua_type(L, 2) == LUA_TSTRING) { + auto fontName = lua_tostring(L, 2); + font = CSimpleFont::GetFont(fontName, 0); + } else if (lua_type(L, 2) == LUA_TTABLE) { + lua_rawgeti(L, 2, 0); + font = static_cast(lua_touserdata(L, -1)); + lua_settop(L, -2); + } + + if (!button || !font || !font->IsA(CSimpleFont::GetObjectType())) { + return luaL_error(L, "Usage: %s:SetHighlightFontObject(\"fontname\")", button->GetDisplayName()); + } + + button->m_highlightFont = font; + button->UpdateTextState(button->m_state); + + return 0; } int32_t CSimpleButton_GetHighlightFontObject(lua_State* L) {