feat: reformat error messages, update atween

This commit is contained in:
Qwreey 2023-01-01 21:45:05 +09:00
parent 3318270c3d
commit 458477d7c8
6 changed files with 143 additions and 113 deletions

View file

@ -1,5 +1,5 @@
{ {
"name": "Plugin", "name": "Quad",
"tree": { "tree": {
"$properties": { "$properties": {
"Name": "Quad" "Name": "Quad"

View file

@ -66,7 +66,7 @@ function module.init(shared)
local isImage = (ClassName == "ImageLabel" or ClassName == "ImageButton"); local isImage = (ClassName == "ImageLabel" or ClassName == "ImageButton");
if (index == "RoundSize" or index == "roundSize") and isImage then if (index == "RoundSize" or index == "roundSize") and isImage then
if not round then if not round then
error("module 'round' needs to be loaded for set image round size but it is not found on 'src.libs'. you should adding that to src.libs directory"); error("[QUAD] module 'round' needs to be loaded for set image round size but it is not found on 'src.libs'. you should adding that to src.libs directory");
end end
round.setRound(item,value); round.setRound(item,value);
elseif index == "UiRoundSize" or index == "uiRoundSize" or index == "UIRoundSize" then elseif index == "UiRoundSize" or index == "uiRoundSize" or index == "UIRoundSize" then
@ -135,7 +135,7 @@ function module.init(shared)
end end
if not item then -- if cannot make new object, ignore this call if not item then -- if cannot make new object, ignore this call
local str = tostring(ClassName); local str = tostring(ClassName);
print(("fail to make item '%s', did you forget to checking the class '%s' is exist?"):format(str,str)); warn(("[Quad] fail to make item '%s', did you forget to checking the class '%s' is exist?"):format(str,str));
end end
-- set property and adding child and binding functions -- set property and adding child and binding functions
@ -190,7 +190,7 @@ function module.init(shared)
end end
if tween then if tween then
if not advancedTween then if not advancedTween then
return warn "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"; 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";
end end
local ended, onStepped; local ended, onStepped;
if tween.Ended then if tween.Ended then

View file

@ -142,7 +142,7 @@ module.LerpProperties = LerpProperties
--Data.Properties.Position = UDim2.new(1,0,1,0) 처럼 하면 Position 속성의 목표를 1,0,1,0 으로 지정 --Data.Properties.Position = UDim2.new(1,0,1,0) 처럼 하면 Position 속성의 목표를 1,0,1,0 으로 지정
function module.RunTween(Item,Data,Properties,Ended,OnStepped,Setter,Getter,_) function module.RunTween(Item,Data,Properties,Ended,OnStepped,Setter,Getter,_)
-- remove self -- remove self
if Item == module then Item = Data; Data = Properties; Properties = Ended; Ended = OnStepped; OnStepped = Setter; Setter = Getter; Getter = _; end if Item == module then warn "AdvancedTween:RunTween() is deprecated, You can use AdvancedTween.RunTween() instead"; Item = Data; Data = Properties; Properties = Ended; Ended = OnStepped; OnStepped = Setter; Setter = Getter; Getter = _; end
-- 시간 저장 -- 시간 저장
local Time = Data.Time or 1 local Time = Data.Time or 1
@ -291,26 +291,50 @@ function module.RunTween(Item,Data,Properties,Ended,OnStepped,Setter,Getter,_)
-- 스캐줄에 등록 -- 스캐줄에 등록
insert(BindedFunctions,Step) insert(BindedFunctions,Step)
FunctionTargetItem[Step] = Item FunctionTargetItem[Step] = Item
return Step
end end
-- 여러개의 개체를 트윈시킴 -- 여러개의 개체를 트윈시킴
function module.RunTweens(Items,Data,Properties,Ended,OnStepped,Setter,Getter,_) function module.RunTweens(Items,Data,Properties,Ended,OnStepped,Setter,Getter,_)
-- remove self -- remove self
if Items == module then Items = Data; Data = Properties; Properties = Ended; Ended = OnStepped; OnStepped = Setter; Setter = Getter; Getter = _; end if Items == module then warn "AdvancedTween:RunTweens() is deprecated, You can use AdvancedTween.RunTweens() instead"; Items = Data; Data = Properties; Properties = Ended; Ended = OnStepped; OnStepped = Setter; Setter = Getter; Getter = _; end
for _,Item in pairs(Items) do for _,Item in pairs(Items) do
module.RunTween(Item,Data,Properties,Ended,OnStepped,Setter,Getter) module.RunTween(Item,Data,Properties,Ended,OnStepped,Setter,Getter)
end end
end end
-- 트윈 멈추기 -- 트윈 멈추기
function module.StopTween(Item,_) function module.StopTween(ItemOrStep,_)
if Item == module then Item = _ end if ItemOrStep == module then warn "AdvancedTween:StopTween() is deprecated, You can use AdvancedTween.StopTween() instead"; ItemOrStep = _ end
module.PlayIndex[Item] = nil if type(ItemOrStep) == "function" then
local pos = find(BindedFunctions,ItemOrStep)
if not pos then
warn(("tween %s was not found from AdvancedTween BindedFunctions. ignored call StopTween"):format(tostring(ItemOrStep)))
return
end
remove(BindedFunctions,pos)
return
end
module.PlayIndex[ItemOrStep] = nil
end
function module.StopPropertyTween(Item,PropertyName,_)
if Item == module then warn "AdvancedTween:StopTween() is deprecated, You can use AdvancedTween.StopTween() instead"; Item = _ end
local ItemPlayIndex = module.PlayIndex[Item]
if not ItemPlayIndex then return end
if type(PropertyName) == "table" then
for _,name in pairs(PropertyName) do
ItemPlayIndex[name] = (ItemPlayIndex[name] or 0) + 1
end
else
ItemPlayIndex[PropertyName] = (ItemPlayIndex[PropertyName] or 0) + 1
end
end end
-- 해당 개체가 트윈중인지 반환 -- 해당 개체가 트윈중인지 반환
function module.IsTweening(Item,_) function module.IsTweening(Item,_)
if Item == module then Item = _ end if Item == module then warn "AdvancedTween:IsTweening() is deprecated, You can use AdvancedTween.IsTweening() instead"; Item = _ end
if module.PlayIndex[Item] == nil then if module.PlayIndex[Item] == nil then
return false return false
@ -326,7 +350,7 @@ end
-- 해당 개체의 해당 프로퍼티가 트윈중인지 반환 -- 해당 개체의 해당 프로퍼티가 트윈중인지 반환
function module.IsPropertyTweening(Item,PropertyName,_) function module.IsPropertyTweening(Item,PropertyName,_)
if Item == module then Item = _ end if Item == module then warn "AdvancedTween:IsPropertyTweening() is deprecated, You can use AdvancedTween.IsPropertyTweening() instead"; Item = _ end
if module.PlayIndex[Item] == nil then if module.PlayIndex[Item] == nil then
return false return false
@ -359,4 +383,8 @@ script.Destroying:Connect(function()
Stepped.UnbindAll() Stepped.UnbindAll()
end) end)
function module.Destroy()
Stepped.UnbindAll()
end
return module return module

View file

@ -107,7 +107,9 @@ function module.init(shared)
tween = function (s,value) tween = function (s,value)
return setmetatable({tvalue = value},{__index = s}); return setmetatable({tvalue = value},{__index = s});
end; end;
---@deprecated
from = function (s,value) from = function (s,value)
warn "[QUAD] register:from() is deprecated. You can use register:add(t:table|function) instead"
return setmetatable({fvalue = value},{__index = s}); return setmetatable({fvalue = value},{__index = s});
end; end;
add = function (s,value) add = function (s,value)