From c201da76cd7294eae60769568d3598604be0c12f Mon Sep 17 00:00:00 2001 From: fallenoak Date: Tue, 3 Feb 2026 09:40:46 -0600 Subject: [PATCH] feat(ui): partially implement CSimpleFrame_GetAttribute --- src/ui/simple/CSimpleFrameScript.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/ui/simple/CSimpleFrameScript.cpp b/src/ui/simple/CSimpleFrameScript.cpp index ca9d743..cd2f78f 100644 --- a/src/ui/simple/CSimpleFrameScript.cpp +++ b/src/ui/simple/CSimpleFrameScript.cpp @@ -180,7 +180,32 @@ int32_t CSimpleFrame_CanChangeAttributes(lua_State* L) { } int32_t CSimpleFrame_GetAttribute(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + auto type = CSimpleFrame::GetObjectType(); + auto frame = static_cast(FrameScript_GetObjectThis(L, type)); + + // 3 argument form + if (lua_gettop(L) == 4 && lua_isstring(L, 3)) { + // TODO 3 argument form isn't handled yet + WHOA_UNIMPLEMENTED(0); + } + + // 1 argument form + if (lua_isstring(L, 2)) { + auto attrName = lua_tostring(L, 2); + int32_t luaRef; + + if (frame->GetAttribute(attrName, luaRef)) { + lua_rawgeti(L, LUA_REGISTRYINDEX, luaRef); + } else { + lua_pushnil(L); + } + + return 1; + } + + // Invalid call + luaL_error(L, "Usage: %s:GetAttribute(\"name\")", frame->GetDisplayName()); + return 0; } int32_t CSimpleFrame_SetAttribute(lua_State* L) {