feat(ui): implement CSimpleFrame_SetAttribute

This commit is contained in:
fallenoak 2026-02-03 10:13:08 -06:00
parent c201da76cd
commit 66fd4a6564
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
3 changed files with 37 additions and 1 deletions

View File

@ -95,6 +95,10 @@ void CSimpleFrame::AddFrameRegion(CSimpleRegion* region, uint32_t drawlayer) {
this->NotifyDrawLayerChanged(drawlayer); this->NotifyDrawLayerChanged(drawlayer);
} }
int32_t CSimpleFrame::AttributeChangesAllowed() {
return true;
}
void CSimpleFrame::DisableDrawLayer(uint32_t drawlayer) { void CSimpleFrame::DisableDrawLayer(uint32_t drawlayer) {
this->m_drawenabled[drawlayer] = 0; this->m_drawenabled[drawlayer] = 0;
this->NotifyDrawLayerChanged(drawlayer); this->NotifyDrawLayerChanged(drawlayer);

View File

@ -128,6 +128,7 @@ class CSimpleFrame : public CScriptRegion {
// Member functions // Member functions
CSimpleFrame(CSimpleFrame* parent); CSimpleFrame(CSimpleFrame* parent);
void AddFrameRegion(CSimpleRegion* region, uint32_t drawlayer); void AddFrameRegion(CSimpleRegion* region, uint32_t drawlayer);
int32_t AttributeChangesAllowed();
void DisableDrawLayer(uint32_t drawlayer); void DisableDrawLayer(uint32_t drawlayer);
void DisableEvent(CSimpleEventType eventType); void DisableEvent(CSimpleEventType eventType);
void EnableDrawLayer(uint32_t drawlayer); void EnableDrawLayer(uint32_t drawlayer);

View File

@ -209,7 +209,38 @@ int32_t CSimpleFrame_GetAttribute(lua_State* L) {
} }
int32_t CSimpleFrame_SetAttribute(lua_State* L) { int32_t CSimpleFrame_SetAttribute(lua_State* L) {
WHOA_UNIMPLEMENTED(0); auto type = CSimpleFrame::GetObjectType();
auto frame = static_cast<CSimpleFrame*>(FrameScript_GetObjectThis(L, type));
if (!frame->ProtectedFunctionsAllowed() && !frame->AttributeChangesAllowed()) {
// TODO disallowed logic
return 0;
}
lua_settop(L, 3);
if (!lua_isstring(L, 2) || lua_type(L, 3) == LUA_TNONE) {
luaL_error(L, "Usage: %s:SetAttribute(\"name\", value)", frame->GetDisplayName());
return 0;
}
auto attrName = lua_tostring(L, 2);
int32_t luaRef;
if (frame->GetAttribute(attrName, luaRef)) {
luaL_unref(L, LUA_REGISTRYINDEX, luaRef);
}
// TODO taint management
luaRef = luaL_ref(L, LUA_REGISTRYINDEX);
// TODO taint management
frame->SetAttribute(attrName, luaRef);
return 0;
} }
int32_t CSimpleFrame_GetEffectiveScale(lua_State* L) { int32_t CSimpleFrame_GetEffectiveScale(lua_State* L) {