From a54bdc61feb1764734b8010b80d50982477f3586 Mon Sep 17 00:00:00 2001 From: Qwreey Date: Wed, 12 Apr 2023 00:37:52 +0900 Subject: [PATCH 1/2] feat: linker class (mockup) --- DEV_CHANGELOG.txt | 3 +++ mock/Slot.txt | 22 ++++++++++++++++++++++ src/class.lua | 39 +++++++++++++++++++++++++-------------- src/store.lua | 3 +++ 4 files changed, 53 insertions(+), 14 deletions(-) create mode 100644 mock/Slot.txt diff --git a/DEV_CHANGELOG.txt b/DEV_CHANGELOG.txt index 030981f..6682ab6 100644 --- a/DEV_CHANGELOG.txt +++ b/DEV_CHANGELOG.txt @@ -5,3 +5,6 @@ types 모듈이 삭제되며 init.lua 에 통합됨 이제 extend 에 대해서 Init(self) self 안에 props 기능이 내장되어있음 TODO: slot 기능 구현 +spring 구현 + +TODO: !ChildRemoved 구현 \ No newline at end of file diff --git a/mock/Slot.txt b/mock/Slot.txt new file mode 100644 index 0000000..dfc28d7 --- /dev/null +++ b/mock/Slot.txt @@ -0,0 +1,22 @@ + +Window { + Class.Slot "Content" { + Text { + Text = "wow"; + }; + Text { + Text = "wow"; + }; + Text { + Text = "wow"; + }; + Text { + Text = "wow"; + }; + } + TopbarButton { + [Class.Slot] = "Topbar"; + }; +} +다수가 있을경우 +이런식으로 묶을 수 있다고 하자 diff --git a/src/class.lua b/src/class.lua index a3ff83b..f8a74a9 100644 --- a/src/class.lua +++ b/src/class.lua @@ -110,8 +110,13 @@ function module.init(shared) new.SetProperty = SetProperty local function Link(linker,item,index,indexType) - local target = linker.target - local name = linker.name + -- error("Not implemented") + + local target = linker.lvalue + local name = linker.key + + -- local target = linker.target + -- local name = linker.name if indexType == "number" then -- set -- if rawget(target,name) ~= nil then @@ -140,7 +145,7 @@ function module.init(shared) local indexType = typeof(index) local quadType = valueType == "table" and PcallGetProperty(value,"__type") - if quadType == "quad_linker" then + if indexType == "number" and quadType == "quad_register" then -- linking Link(value,item,index,indexType) elseif indexType == "string" and quadType == "quad_register" then @@ -349,13 +354,13 @@ function module.init(shared) end }) - local function Linker(target,name) - return { - __type = "quad_linker"; - target = target; - name = name; - } - end + -- local function Linker(target,name) + -- return { + -- __type = "quad_linker"; + -- target = target; + -- name = name; + -- } + -- end -- make class function new.Extend() @@ -400,8 +405,12 @@ function module.init(shared) return self end - function this:Default(...) - return this.__prop:Default(...) + -- default function from props + function this:Default(key,value) + if self == this then + error("prop handler not found (this method cannot be used on class)") + end + self.__prop:Default(key,value) end function this:GetPropertyChangedSignal(propertyName) @@ -504,7 +513,6 @@ function module.init(shared) end end end - self = nil end --- link to new @@ -517,7 +525,10 @@ function module.init(shared) if type(name) ~= "string" then error(("Name must be string, but got %s"):format(type(name))) end - return Linker(self,name) + -- return Linker(self,name) + local register = self.__props(name) + register:Link(self) + return register end -- indexer (getter) diff --git a/src/store.lua b/src/store.lua index bf7101c..be9d58f 100644 --- a/src/store.lua +++ b/src/store.lua @@ -283,6 +283,9 @@ function module.init(shared) -- return s return setmetatable({avalue = avalue},{__index = s}) end; + Link = function(s,lvalue) + return setmetatable({avalue = lvalue},{__index = s}) + end; -- return init data CalcWithDefault = function (s,withItem) local with = s.wfunc From b6c4e9a650f30139cfd543b458038adcbd7ba7d2 Mon Sep 17 00:00:00 2001 From: Qwreey Date: Wed, 12 Apr 2023 01:09:03 +0900 Subject: [PATCH 2/2] feat: GetChildren slotName argument --- DEV_CHANGELOG.txt | 7 +++++-- src/class.lua | 18 +++++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/DEV_CHANGELOG.txt b/DEV_CHANGELOG.txt index 6682ab6..e231f77 100644 --- a/DEV_CHANGELOG.txt +++ b/DEV_CHANGELOG.txt @@ -5,6 +5,9 @@ types 모듈이 삭제되며 init.lua 에 통합됨 이제 extend 에 대해서 Init(self) self 안에 props 기능이 내장되어있음 TODO: slot 기능 구현 -spring 구현 -TODO: !ChildRemoved 구현 \ No newline at end of file +TODO: spring 구현 + +TODO: !ChildRemoved 구현 + +TODO: AdvancedTween 을 submodule 로 변경 diff --git a/src/class.lua b/src/class.lua index f8a74a9..1069632 100644 --- a/src/class.lua +++ b/src/class.lua @@ -167,7 +167,8 @@ function module.init(shared) local setValue,tween = value:CalcWithNewValue(item,newValue,key) if tween then if not advancedTween then - return warn "[QUAD] module 'AdvancedTween' needs to be loaded for tween properties but it is not found on 'src.libs'. you should adding that to src.libs directory" + warn "[QUAD] Failed to execute register handler function. (Real Instance was not updated)" + return warn "[QUAD] module 'AdvancedTween' needs to be loaded for tween properties but it is not found on 'src.libs'. you should adding that to src.libs directory.\nPossible reason : Cloned repository without recursive option. => 'git submodule init ; git submodule update' to get submodules" end -- local ended, onStepped -- if tween.Ended then @@ -445,11 +446,18 @@ function module.init(shared) thisSignal:Fire(value) end - function this:GetChildren() - local children = rawget(self,"__child") - if not children then - return {} + function this:GetChildren(slotName) + if slotName then + local slot = rawget(slotName,"__slot") + if not slot then return {} end + local newSlot = {} + for _,v in pairs(slot) do + insert(newSlot,v) + end + return slot end + local children = rawget(self,"__child") + if not children then return {} end local newChildren = {} for _,v in pairs(children) do insert(newChildren,v)