mirror of
https://github.com/whoahq/whoa.git
synced 2026-03-05 15:42:17 +03:00
feat(ui): add CSimpleFrame::SetAttribute
This commit is contained in:
parent
c099226cd2
commit
bdce266205
@ -376,6 +376,29 @@ void CSimpleFrame::RegisterForEvents(int32_t a2) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSimpleFrame::RunOnAttributeChangedScript(const char* name, int32_t luaRef) {
|
||||||
|
if (!this->m_onAttributeChange.luaRef) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto L = FrameScript_GetContext();
|
||||||
|
|
||||||
|
// TODO taint management
|
||||||
|
|
||||||
|
// Attribute name
|
||||||
|
auto nameLower = static_cast<char*>(alloca(SStrLen(name) + 1));
|
||||||
|
SStrCopy(nameLower, name);
|
||||||
|
SStrLower(nameLower);
|
||||||
|
lua_pushstring(L, nameLower);
|
||||||
|
|
||||||
|
// Attribute ref
|
||||||
|
lua_rawgeti(L, LUA_REGISTRYINDEX, luaRef);
|
||||||
|
|
||||||
|
this->RunScript(this->m_onAttributeChange, 2, nullptr);
|
||||||
|
|
||||||
|
// TODO taint management
|
||||||
|
}
|
||||||
|
|
||||||
void CSimpleFrame::RunOnCharScript(const char* chr) {
|
void CSimpleFrame::RunOnCharScript(const char* chr) {
|
||||||
if (this->m_onChar.luaRef) {
|
if (this->m_onChar.luaRef) {
|
||||||
auto L = FrameScript_GetContext();
|
auto L = FrameScript_GetContext();
|
||||||
@ -1329,6 +1352,18 @@ void CSimpleFrame::RemoveFrameRegion(CSimpleRegion* region, uint32_t drawlayer)
|
|||||||
this->NotifyDrawLayerChanged(drawlayer);
|
this->NotifyDrawLayerChanged(drawlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSimpleFrame::SetAttribute(const char* name, int32_t luaRef) {
|
||||||
|
auto attr = this->m_attributes.Ptr(name);
|
||||||
|
|
||||||
|
if (!attr) {
|
||||||
|
attr = this->m_attributes.New(name, 0, 0x0);
|
||||||
|
}
|
||||||
|
|
||||||
|
attr->luaRef = luaRef;
|
||||||
|
|
||||||
|
this->RunOnAttributeChangedScript(name, luaRef);
|
||||||
|
}
|
||||||
|
|
||||||
void CSimpleFrame::SetBackdrop(CBackdropGenerator* backdrop) {
|
void CSimpleFrame::SetBackdrop(CBackdropGenerator* backdrop) {
|
||||||
if (this->m_backdrop) {
|
if (this->m_backdrop) {
|
||||||
delete this->m_backdrop;
|
delete this->m_backdrop;
|
||||||
|
|||||||
@ -146,6 +146,7 @@ class CSimpleFrame : public CScriptRegion {
|
|||||||
void RegisterForEvents(int32_t a2);
|
void RegisterForEvents(int32_t a2);
|
||||||
void RegisterRegion(CSimpleRegion* region);
|
void RegisterRegion(CSimpleRegion* region);
|
||||||
void RemoveFrameRegion(CSimpleRegion* region, uint32_t drawlayer);
|
void RemoveFrameRegion(CSimpleRegion* region, uint32_t drawlayer);
|
||||||
|
void RunOnAttributeChangedScript(const char* name, int32_t luaRef);
|
||||||
void RunOnCharScript(const char* chr);
|
void RunOnCharScript(const char* chr);
|
||||||
void RunOnEnableScript();
|
void RunOnEnableScript();
|
||||||
void RunOnEnterScript(int32_t a2);
|
void RunOnEnterScript(int32_t a2);
|
||||||
@ -159,6 +160,7 @@ class CSimpleFrame : public CScriptRegion {
|
|||||||
void RunOnShowScript();
|
void RunOnShowScript();
|
||||||
void RunOnSizeChangedScript(float width, float height);
|
void RunOnSizeChangedScript(float width, float height);
|
||||||
void RunOnUpdateScript(float elapsedSec);
|
void RunOnUpdateScript(float elapsedSec);
|
||||||
|
void SetAttribute(const char* name, int32_t luaRef);
|
||||||
void SetBackdrop(CBackdropGenerator* backdrop);
|
void SetBackdrop(CBackdropGenerator* backdrop);
|
||||||
void SetBeingScrolled(int32_t a2, int32_t a3);
|
void SetBeingScrolled(int32_t a2, int32_t a3);
|
||||||
void SetFrameAlpha(uint8_t alpha);
|
void SetFrameAlpha(uint8_t alpha);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user